| 1 |
// ===================================================================
|
| 2 |
// Author: Matt Kruse <matt@mattkruse.com>
|
| 3 |
// WWW: http://www.mattkruse.com/
|
| 4 |
//
|
| 5 |
// NOTICE: You may use this code for any purpose, commercial or
|
| 6 |
// private, without any further permission from the author. You may
|
| 7 |
// remove this notice from your final code if you wish, however it is
|
| 8 |
// appreciated by the author if at least my web site address is kept.
|
| 9 |
//
|
| 10 |
// You may *NOT* re-distribute this code in any way except through its
|
| 11 |
// use. That means, you can include it in your product, or your web
|
| 12 |
// site, or any other form where the code is actually being used. You
|
| 13 |
// may not put the plain javascript up on your site for download or
|
| 14 |
// include it in your javascript libraries for download.
|
| 15 |
// If you wish to share this code with others, please just point them
|
| 16 |
// to the URL instead.
|
| 17 |
// Please DO NOT link directly to my .js files from your site. Copy
|
| 18 |
// the files to your server and use them there. Thank you.
|
| 19 |
// ===================================================================
|
| 20 |
|
| 21 |
/* SOURCE FILE: AnchorPosition.js */
|
| 22 |
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
|
| 23 |
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
|
| 24 |
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
|
| 25 |
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
|
| 26 |
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
|
| 27 |
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}
|
| 28 |
/* SOURCE FILE: PopupWindow.js */
|
| 29 |
|
| 30 |
/*
|
| 31 |
PopupWindow.js
|
| 32 |
Author: Matt Kruse
|
| 33 |
Last modified: 02/16/04
|
| 34 |
|
| 35 |
DESCRIPTION: This object allows you to easily and quickly popup a window
|
| 36 |
in a certain place. The window can either be a DIV or a separate browser
|
| 37 |
window.
|
| 38 |
|
| 39 |
COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
|
| 40 |
positioning errors - usually with Window positioning - occur on the
|
| 41 |
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup
|
| 42 |
window with <STYLE> tags may cause errors.
|
| 43 |
|
| 44 |
USAGE:
|
| 45 |
// Create an object for a WINDOW popup
|
| 46 |
var win = new PopupWindow();
|
| 47 |
|
| 48 |
// Create an object for a DIV window using the DIV named 'mydiv'
|
| 49 |
var win = new PopupWindow('mydiv');
|
| 50 |
|
| 51 |
// Set the window to automatically hide itself when the user clicks
|
| 52 |
// anywhere else on the page except the popup
|
| 53 |
win.autoHide();
|
| 54 |
|
| 55 |
// Show the window relative to the anchor name passed in
|
| 56 |
win.showPopup(anchorname);
|
| 57 |
|
| 58 |
// Hide the popup
|
| 59 |
win.hidePopup();
|
| 60 |
|
| 61 |
// Set the size of the popup window (only applies to WINDOW popups
|
| 62 |
win.setSize(width,height);
|
| 63 |
|
| 64 |
// Populate the contents of the popup window that will be shown. If you
|
| 65 |
// change the contents while it is displayed, you will need to refresh()
|
| 66 |
win.populate(string);
|
| 67 |
|
| 68 |
// set the URL of the window, rather than populating its contents
|
| 69 |
// manually
|
| 70 |
win.setUrl("http://www.site.com/");
|
| 71 |
|
| 72 |
// Refresh the contents of the popup
|
| 73 |
win.refresh();
|
| 74 |
|
| 75 |
// Specify how many pixels to the right of the anchor the popup will appear
|
| 76 |
win.offsetX = 50;
|
| 77 |
|
| 78 |
// Specify how many pixels below the anchor the popup will appear
|
| 79 |
win.offsetY = 100;
|
| 80 |
|
| 81 |
NOTES:
|
| 82 |
1) Requires the functions in AnchorPosition.js
|
| 83 |
|
| 84 |
2) Your anchor tag MUST contain both NAME and ID attributes which are the
|
| 85 |
same. For example:
|
| 86 |
<A NAME="test" ID="test"> </A>
|
| 87 |
|
| 88 |
3) There must be at least a space between <A> </A> for IE5.5 to see the
|
| 89 |
anchor tag correctly. Do not do <A></A> with no space.
|
| 90 |
|
| 91 |
4) When a PopupWindow object is created, a handler for 'onmouseup' is
|
| 92 |
attached to any event handler you may have already defined. Do NOT define
|
| 93 |
an event handler for 'onmouseup' after you define a PopupWindow object or
|
| 94 |
the autoHide() will not work correctly.
|
| 95 |
*/
|
| 96 |
|
| 97 |
// Set the position of the popup window based on the anchor
|
| 98 |
function PopupWindow_getXYPosition(anchorname) {
|
| 99 |
var coordinates;
|
| 100 |
if (this.type == "WINDOW") {
|
| 101 |
coordinates = getAnchorWindowPosition(anchorname);
|
| 102 |
}
|
| 103 |
else {
|
| 104 |
coordinates = getAnchorPosition(anchorname);
|
| 105 |
}
|
| 106 |
this.x = coordinates.x;
|
| 107 |
this.y = coordinates.y;
|
| 108 |
}
|
| 109 |
// Set width/height of DIV/popup window
|
| 110 |
function PopupWindow_setSize(width,height) {
|
| 111 |
this.width = width;
|
| 112 |
this.height = height;
|
| 113 |
}
|
| 114 |
// Fill the window with contents
|
| 115 |
function PopupWindow_populate(contents) {
|
| 116 |
this.contents = contents;
|
| 117 |
this.populated = false;
|
| 118 |
}
|
| 119 |
// Set the URL to go to
|
| 120 |
function PopupWindow_setUrl(url) {
|
| 121 |
this.url = url;
|
| 122 |
}
|
| 123 |
// Set the window popup properties
|
| 124 |
function PopupWindow_setWindowProperties(props) {
|
| 125 |
this.windowProperties = props;
|
| 126 |
}
|
| 127 |
// Refresh the displayed contents of the popup
|
| 128 |
function PopupWindow_refresh() {
|
| 129 |
if (this.divName != null) {
|
| 130 |
// refresh the DIV object
|
| 131 |
if (this.use_gebi) {
|
| 132 |
document.getElementById(this.divName).innerHTML = this.contents;
|
| 133 |
}
|
| 134 |
else if (this.use_css) {
|
| 135 |
document.all[this.divName].innerHTML = this.contents;
|
| 136 |
}
|
| 137 |
else if (this.use_layers) {
|
| 138 |
var d = document.layers[this.divName];
|
| 139 |
d.document.open();
|
| 140 |
d.document.writeln(this.contents);
|
| 141 |
d.document.close();
|
| 142 |
}
|
| 143 |
}
|
| 144 |
else {
|
| 145 |
if (this.popupWindow != null && !this.popupWindow.closed) {
|
| 146 |
if (this.url!="") {
|
| 147 |
this.popupWindow.location.href=this.url;
|
| 148 |
}
|
| 149 |
else {
|
| 150 |
this.popupWindow.document.open();
|
| 151 |
this.popupWindow.document.writeln(this.contents);
|
| 152 |
this.popupWindow.document.close();
|
| 153 |
}
|
| 154 |
this.popupWindow.focus();
|
| 155 |
}
|
| 156 |
}
|
| 157 |
}
|
| 158 |
// Position and show the popup, relative to an anchor object
|
| 159 |
function PopupWindow_showPopup(anchorname) {
|
| 160 |
this.getXYPosition(anchorname);
|
| 161 |
this.x += this.offsetX;
|
| 162 |
this.y += this.offsetY;
|
| 163 |
if (!this.populated && (this.contents != "")) {
|
| 164 |
this.populated = true;
|
| 165 |
this.refresh();
|
| 166 |
}
|
| 167 |
if (this.divName != null) {
|
| 168 |
// Show the DIV object
|
| 169 |
if (this.use_gebi) {
|
| 170 |
document.getElementById(this.divName).style.left = this.x + "px";
|
| 171 |
document.getElementById(this.divName).style.top = this.y + 'px';
|
| 172 |
document.getElementById(this.divName).style.visibility = "visible";
|
| 173 |
}
|
| 174 |
else if (this.use_css) {
|
| 175 |
document.all[this.divName].style.left = this.x + 'px';
|
| 176 |
document.all[this.divName].style.top = this.y + 'px';
|
| 177 |
document.all[this.divName].style.visibility = "visible";
|
| 178 |
}
|
| 179 |
else if (this.use_layers) {
|
| 180 |
document.layers[this.divName].left = this.x + 'px';
|
| 181 |
document.layers[this.divName].top = this.y + 'px';
|
| 182 |
document.layers[this.divName].visibility = "visible";
|
| 183 |
}
|
| 184 |
}
|
| 185 |
else {
|
| 186 |
if (this.popupWindow == null || this.popupWindow.closed) {
|
| 187 |
// If the popup window will go off-screen, move it so it doesn't
|
| 188 |
if (this.x<0) { this.x=0; }
|
| 189 |
if (this.y<0) { this.y=0; }
|
| 190 |
if (screen && screen.availHeight) {
|
| 191 |
if ((this.y + this.height) > screen.availHeight) {
|
| 192 |
this.y = screen.availHeight - this.height;
|
| 193 |
}
|
| 194 |
}
|
| 195 |
if (screen && screen.availWidth) {
|
| 196 |
if ((this.x + this.width) > screen.availWidth) {
|
| 197 |
this.x = screen.availWidth - this.width;
|
| 198 |
}
|
| 199 |
}
|
| 200 |
var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
|
| 201 |
this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
|
| 202 |
}
|
| 203 |
this.refresh();
|
| 204 |
}
|
| 205 |
}
|
| 206 |
// Hide the popup
|
| 207 |
function PopupWindow_hidePopup() {
|
| 208 |
if (this.divName != null) {
|
| 209 |
if (this.use_gebi) {
|
| 210 |
document.getElementById(this.divName).style.visibility = "hidden";
|
| 211 |
}
|
| 212 |
else if (this.use_css) {
|
| 213 |
document.all[this.divName].style.visibility = "hidden";
|
| 214 |
}
|
| 215 |
else if (this.use_layers) {
|
| 216 |
document.layers[this.divName].visibility = "hidden";
|
| 217 |
}
|
| 218 |
}
|
| 219 |
else {
|
| 220 |
if (this.popupWindow && !this.popupWindow.closed) {
|
| 221 |
this.popupWindow.close();
|
| 222 |
this.popupWindow = null;
|
| 223 |
}
|
| 224 |
}
|
| 225 |
}
|
| 226 |
// Pass an event and return whether or not it was the popup DIV that was clicked
|
| 227 |
function PopupWindow_isClicked(e) {
|
| 228 |
if (this.divName != null) {
|
| 229 |
if (this.use_layers) {
|
| 230 |
var clickX = e.pageX;
|
| 231 |
var clickY = e.pageY;
|
| 232 |
var t = document.layers[this.divName];
|
| 233 |
if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
|
| 234 |
return true;
|
| 235 |
}
|
| 236 |
else { return false; }
|
| 237 |
}
|
| 238 |
else if (document.all) { // Need to hard-code this to trap IE for error-handling
|
| 239 |
var t = window.event.srcElement;
|
| 240 |
while (t.parentElement != null) {
|
| 241 |
if (t.id==this.divName) {
|
| 242 |
return true;
|
| 243 |
}
|
| 244 |
t = t.parentElement;
|
| 245 |
}
|
| 246 |
return false;
|
| 247 |
}
|
| 248 |
else if (this.use_gebi && e) {
|
| 249 |
var t = e.originalTarget;
|
| 250 |
while (t.parentNode != null) {
|
| 251 |
if (t.id==this.divName) {
|
| 252 |
return true;
|
| 253 |
}
|
| 254 |
t = t.parentNode;
|
| 255 |
}
|
| 256 |
return false;
|
| 257 |
}
|
| 258 |
return false;
|
| 259 |
}
|
| 260 |
return false;
|
| 261 |
}
|
| 262 |
|
| 263 |
// Check an onMouseDown event to see if we should hide
|
| 264 |
function PopupWindow_hideIfNotClicked(e) {
|
| 265 |
if (this.autoHideEnabled && !this.isClicked(e)) {
|
| 266 |
this.hidePopup();
|
| 267 |
}
|
| 268 |
}
|
| 269 |
// Call this to make the DIV disable automatically when mouse is clicked outside it
|
| 270 |
function PopupWindow_autoHide() {
|
| 271 |
this.autoHideEnabled = true;
|
| 272 |
}
|
| 273 |
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
|
| 274 |
function PopupWindow_hidePopupWindows(e) {
|
| 275 |
for (var i=0; i<popupWindowObjects.length; i++) {
|
| 276 |
if (popupWindowObjects[i] != null) {
|
| 277 |
var p = popupWindowObjects[i];
|
| 278 |
p.hideIfNotClicked(e);
|
| 279 |
}
|
| 280 |
}
|
| 281 |
}
|
| 282 |
// Run this immediately to attach the event listener
|
| 283 |
function PopupWindow_attachListener() {
|
| 284 |
if (document.layers) {
|
| 285 |
document.captureEvents(Event.MOUSEUP);
|
| 286 |
}
|
| 287 |
window.popupWindowOldEventListener = document.onmouseup;
|
| 288 |
if (window.popupWindowOldEventListener != null) {
|
| 289 |
document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
|
| 290 |
}
|
| 291 |
else {
|
| 292 |
document.onmouseup = PopupWindow_hidePopupWindows;
|
| 293 |
}
|
| 294 |
}
|
| 295 |
// CONSTRUCTOR for the PopupWindow object
|
| 296 |
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
|
| 297 |
function PopupWindow() {
|
| 298 |
if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
|
| 299 |
if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
|
| 300 |
if (!window.listenerAttached) {
|
| 301 |
window.listenerAttached = true;
|
| 302 |
PopupWindow_attachListener();
|
| 303 |
}
|
| 304 |
this.index = popupWindowIndex++;
|
| 305 |
popupWindowObjects[this.index] = this;
|
| 306 |
this.divName = null;
|
| 307 |
this.popupWindow = null;
|
| 308 |
this.width=0;
|
| 309 |
this.height=0;
|
| 310 |
this.populated = false;
|
| 311 |
this.visible = false;
|
| 312 |
this.autoHideEnabled = false;
|
| 313 |
|
| 314 |
this.contents = "";
|
| 315 |
this.url="";
|
| 316 |
this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
|
| 317 |
if (arguments.length>0) {
|
| 318 |
this.type="DIV";
|
| 319 |
this.divName = arguments[0];
|
| 320 |
}
|
| 321 |
else {
|
| 322 |
this.type="WINDOW";
|
| 323 |
}
|
| 324 |
this.use_gebi = false;
|
| 325 |
this.use_css = false;
|
| 326 |
this.use_layers = false;
|
| 327 |
if (document.getElementById) { this.use_gebi = true; }
|
| 328 |
else if (document.all) { this.use_css = true; }
|
| 329 |
else if (document.layers) { this.use_layers = true; }
|
| 330 |
else { this.type = "WINDOW"; }
|
| 331 |
this.offsetX = 0;
|
| 332 |
this.offsetY = 0;
|
| 333 |
// Method mappings
|
| 334 |
this.getXYPosition = PopupWindow_getXYPosition;
|
| 335 |
this.populate = PopupWindow_populate;
|
| 336 |
this.setUrl = PopupWindow_setUrl;
|
| 337 |
this.setWindowProperties = PopupWindow_setWindowProperties;
|
| 338 |
this.refresh = PopupWindow_refresh;
|
| 339 |
this.showPopup = PopupWindow_showPopup;
|
| 340 |
this.hidePopup = PopupWindow_hidePopup;
|
| 341 |
this.setSize = PopupWindow_setSize;
|
| 342 |
this.isClicked = PopupWindow_isClicked;
|
| 343 |
this.autoHide = PopupWindow_autoHide;
|
| 344 |
this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
|
| 345 |
}
|
| 346 |
/* SOURCE FILE: ColorPicker2.js */
|
| 347 |
|
| 348 |
/*
|
| 349 |
Last modified: 02/24/2003
|
| 350 |
|
| 351 |
DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB
|
| 352 |
form. It uses a color "swatch" to display the standard 216-color web-safe
|
| 353 |
palette. The user can then click on a color to select it.
|
| 354 |
|
| 355 |
COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js.
|
| 356 |
Only the latest DHTML-capable browsers will show the color and hex values
|
| 357 |
at the bottom as your mouse goes over them.
|
| 358 |
|
| 359 |
USAGE:
|
| 360 |
// Create a new ColorPicker object using DHTML popup
|
| 361 |
var cp = new ColorPicker();
|
| 362 |
|
| 363 |
// Create a new ColorPicker object using Window Popup
|
| 364 |
var cp = new ColorPicker('window');
|
| 365 |
|
| 366 |
// Add a link in your page to trigger the popup. For example:
|
| 367 |
<A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A>
|
| 368 |
|
| 369 |
// Or use the built-in "select" function to do the dirty work for you:
|
| 370 |
<A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A>
|
| 371 |
|
| 372 |
// If using DHTML popup, write out the required DIV tag near the bottom
|
| 373 |
// of your page.
|
| 374 |
<SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
|
| 375 |
|
| 376 |
// Write the 'pickColor' function that will be called when the user clicks
|
| 377 |
// a color and do something with the value. This is only required if you
|
| 378 |
// want to do something other than simply populate a form field, which is
|
| 379 |
// what the 'select' function will give you.
|
| 380 |
function pickColor(color) {
|
| 381 |
field.value = color;
|
| 382 |
}
|
| 383 |
|
| 384 |
NOTES:
|
| 385 |
1) Requires the functions in AnchorPosition.js and PopupWindow.js
|
| 386 |
|
| 387 |
2) Your anchor tag MUST contain both NAME and ID attributes which are the
|
| 388 |
same. For example:
|
| 389 |
<A NAME="test" ID="test"> </A>
|
| 390 |
|
| 391 |
3) There must be at least a space between <A> </A> for IE5.5 to see the
|
| 392 |
anchor tag correctly. Do not do <A></A> with no space.
|
| 393 |
|
| 394 |
4) When a ColorPicker object is created, a handler for 'onmouseup' is
|
| 395 |
attached to any event handler you may have already defined. Do NOT define
|
| 396 |
an event handler for 'onmouseup' after you define a ColorPicker object or
|
| 397 |
the color picker will not hide itself correctly.
|
| 398 |
*/
|
| 399 |
ColorPicker_targetInput = null;
|
| 400 |
function ColorPicker_writeDiv() {
|
| 401 |
document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
|
| 402 |
}
|
| 403 |
|
| 404 |
function ColorPicker_show(anchorname) {
|
| 405 |
this.showPopup(anchorname);
|
| 406 |
}
|
| 407 |
|
| 408 |
function ColorPicker_pickColor(color,obj) {
|
| 409 |
obj.hidePopup();
|
| 410 |
pickColor(color);
|
| 411 |
}
|
| 412 |
|
| 413 |
// A Default "pickColor" function to accept the color passed back from popup.
|
| 414 |
// User can over-ride this with their own function.
|
| 415 |
function pickColor(color) {
|
| 416 |
if (ColorPicker_targetInput==null) {
|
| 417 |
alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");
|
| 418 |
return;
|
| 419 |
}
|
| 420 |
ColorPicker_targetInput.value = color;
|
| 421 |
if (ColorPicker_targetInput.id == 'edit-textlinkads-link-color') {
|
| 422 |
update_link_color(color);
|
| 423 |
}
|
| 424 |
else if (ColorPicker_targetInput.id == 'edit-textlinkads-bg-color') {
|
| 425 |
update_bg_color(color);
|
| 426 |
}
|
| 427 |
else if (ColorPicker_targetInput.id == 'edit-textlinkads-border-color') {
|
| 428 |
update_border_color(color);
|
| 429 |
}
|
| 430 |
}
|
| 431 |
|
| 432 |
// This function is the easiest way to popup the window, select a color, and
|
| 433 |
// have the value populate a form field, which is what most people want to do.
|
| 434 |
function ColorPicker_select(inputobj, linkname) {
|
| 435 |
if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") {
|
| 436 |
alert("colorpicker.select: Input object passed is not a valid form input object");
|
| 437 |
window.ColorPicker_targetInput=null;
|
| 438 |
return;
|
| 439 |
}
|
| 440 |
window.ColorPicker_targetInput = inputobj;
|
| 441 |
this.show(linkname);
|
| 442 |
}
|
| 443 |
|
| 444 |
// This function runs when you move your mouse over a color block, if you have a newer browser
|
| 445 |
function ColorPicker_highlightColor(c) {
|
| 446 |
var thedoc = (arguments.length>1)?arguments[1]:window.document;
|
| 447 |
var d = thedoc.getElementById("colorPickerSelectedColor");
|
| 448 |
d.style.backgroundColor = c;
|
| 449 |
d = thedoc.getElementById("colorPickerSelectedColorValue");
|
| 450 |
d.innerHTML = c;
|
| 451 |
}
|
| 452 |
|
| 453 |
function ColorPicker() {
|
| 454 |
var windowMode = false;
|
| 455 |
// Create a new PopupWindow object
|
| 456 |
if (arguments.length==0) {
|
| 457 |
var divname = "colorPickerDiv";
|
| 458 |
}
|
| 459 |
else if (arguments[0] == "window") {
|
| 460 |
var divname = '';
|
| 461 |
windowMode = true;
|
| 462 |
}
|
| 463 |
else {
|
| 464 |
var divname = arguments[0];
|
| 465 |
}
|
| 466 |
|
| 467 |
if (divname != "") {
|
| 468 |
var cp = new PopupWindow(divname);
|
| 469 |
}
|
| 470 |
else {
|
| 471 |
var cp = new PopupWindow();
|
| 472 |
cp.setSize(225,250);
|
| 473 |
}
|
| 474 |
|
| 475 |
// Object variables
|
| 476 |
cp.currentValue = "#FFFFFF";
|
| 477 |
|
| 478 |
// Method Mappings
|
| 479 |
cp.writeDiv = ColorPicker_writeDiv;
|
| 480 |
cp.highlightColor = ColorPicker_highlightColor;
|
| 481 |
cp.show = ColorPicker_show;
|
| 482 |
cp.select = ColorPicker_select;
|
| 483 |
|
| 484 |
// Code to populate color picker window
|
| 485 |
var colors = new Array("#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099","#3300CC",
|
| 486 |
"#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099",
|
| 487 |
"#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066",
|
| 488 |
"#FF0099","#FF00CC","#FF00FF","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333",
|
| 489 |
"#333366","#333399","#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300",
|
| 490 |
"#993333","#993366","#993399","#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF",
|
| 491 |
"#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#006600","#006633","#006666","#006699","#0066CC",
|
| 492 |
"#0066FF","#336600","#336633","#336666","#336699","#3366CC","#3366FF","#666600","#666633","#666666","#666699",
|
| 493 |
"#6666CC","#6666FF","#996600","#996633","#996666","#996699","#9966CC","#9966FF","#CC6600","#CC6633","#CC6666",
|
| 494 |
"#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699","#FF66CC","#FF66FF","#009900","#009933",
|
| 495 |
"#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999","#3399CC","#3399FF","#669900",
|
| 496 |
"#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999","#9999CC","#9999FF",
|
| 497 |
"#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999","#FF99CC",
|
| 498 |
"#FF99FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99",
|
| 499 |
"#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66",
|
| 500 |
"#99CC99","#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33",
|
| 501 |
"#FFCC66","#FFCC99","#FFCCCC","#FFCCFF","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00",
|
| 502 |
"#33FF33","#33FF66","#33FF99","#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF",
|
| 503 |
"#99FF00","#99FF33","#99FF66","#99FF99","#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC",
|
| 504 |
"#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99","#FFFFCC","#FFFFFF");
|
| 505 |
var total = colors.length;
|
| 506 |
var width = 18;
|
| 507 |
var cp_contents = "";
|
| 508 |
var windowRef = (windowMode)?"window.opener.":"";
|
| 509 |
if (windowMode) {
|
| 510 |
cp_contents += "<HTML><HEAD><TITLE>Select Color</TITLE></HEAD>";
|
| 511 |
cp_contents += "<BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0><CENTER>";
|
| 512 |
}
|
| 513 |
cp_contents += "<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=0>";
|
| 514 |
var use_highlight = (document.getElementById || document.all)?true:false;
|
| 515 |
for (var i=0; i<total; i++) {
|
| 516 |
if ((i % width) == 0) { cp_contents += "<TR>"; }
|
| 517 |
if (use_highlight) { var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"'; }
|
| 518 |
else { mo = ""; }
|
| 519 |
cp_contents += '<TD BGCOLOR="'+colors[i]+'"><FONT SIZE="-3"><A HREF="#" onClick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+' STYLE="text-decoration:none;"> </A></FONT></TD>';
|
| 520 |
if ( ((i+1)>=total) || (((i+1) % width) == 0)) {
|
| 521 |
cp_contents += "</TR>";
|
| 522 |
}
|
| 523 |
}
|
| 524 |
// If the browser supports dynamically changing TD cells, add the fancy stuff
|
| 525 |
if (document.getElementById) {
|
| 526 |
var width1 = Math.floor(width/2);
|
| 527 |
var width2 = width = width1;
|
| 528 |
cp_contents += "<TR><TD COLSPAN='"+width1+"' BGCOLOR='#ffffff' ID='colorPickerSelectedColor'> </TD><TD COLSPAN='"+width2+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>";
|
| 529 |
}
|
| 530 |
cp_contents += "</TABLE>";
|
| 531 |
if (windowMode) {
|
| 532 |
cp_contents += "</CENTER></BODY></HTML>";
|
| 533 |
}
|
| 534 |
// end populate code
|
| 535 |
|
| 536 |
// Write the contents to the popup object
|
| 537 |
cp.populate(cp_contents+"\n");
|
| 538 |
// Move the table down a bit so you can see it
|
| 539 |
cp.offsetY = 25;
|
| 540 |
cp.autoHide();
|
| 541 |
return cp;
|
| 542 |
}
|