Changeset 979
- Timestamp:
- 03/20/08 12:37:41 (5 years ago)
- Files:
-
- 1 modified
-
trunk/modules/ColorPicker/ColorPicker.js (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/ColorPicker/ColorPicker.js
r936 r979 90 90 function ColorPicker() 91 91 { 92 // dummy function for Xinha plugin api, note the different names92 // dummy function for Xinha plugin api, note the different names 93 93 } 94 if (window.opener && window.opener.Xinha) 95 { // this prevents that the Xinha.colorPicker object of the opening window is replaced by the one loaded in the popup 96 var openerColorPicker = window.opener.Xinha.colorPicker; 97 Xinha._addEvent(window,'unload', function() {Xinha.colorPicker = openerColorPicker;}); 98 } 94 try { 95 if (window.opener && window.opener.Xinha) 96 { // this prevents that the Xinha.colorPicker object of the opening window is replaced by the one loaded in the popup 97 var openerColorPicker = window.opener.Xinha.colorPicker; 98 Xinha._addEvent(window,'unload', function() {Xinha.colorPicker = openerColorPicker;}); 99 } 100 } catch(e) {} 99 101 //the actual function is below 100 102 Xinha.colorPicker = function (params) … … 105 107 Xinha.colorPicker.loadColors(); 106 108 } 107 108 this.is_ie_6 = (Xinha.is_ie && Xinha.ie_version < 7);109 110 this.is_ie_6 = (Xinha.is_ie && Xinha.ie_version < 7); 109 111 var picker = this; 110 112 var enablepick = false; … … 128 130 this.table.onmouseup = function() 129 131 { 130 enablepick = false;131 enablevalue = false;132 enablepick = false; 133 enablevalue = false; 132 134 }; 133 135 this.tbody = document.createElement('tbody'); … … 197 199 this.chosenColor.onchange = function() 198 200 { 199 if(/#[0-9a-f]{6,6}/i.test(this.value))200 {201 picker.backSample.style.backgroundColor = this.value;201 if(/#[0-9a-f]{6,6}/i.test(this.value)) 202 { 203 picker.backSample.style.backgroundColor = this.value; 202 204 picker.foreSample.style.color = this.value; 203 }205 } 204 206 }; 205 207 … … 353 355 { 354 356 this.chosenColor.value = initcolor; 355 this.backSample.style.backgroundColor = initcolor;357 this.backSample.style.backgroundColor = initcolor; 356 358 this.foreSample.style.color = initcolor; 357 359 } … … 385 387 else 386 388 { 387 this.table.style.top = 0;389 this.table.style.top = 0; 388 390 } 389 391 } … … 401 403 else 402 404 { 403 this.table.style.left = 0;405 this.table.style.left = 0; 404 406 } 405 407 } … … 410 412 // IE6 ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 411 413 if (this.is_ie_6) 412 {414 { 413 415 this.iframe.style.top = this.table.style.top; 414 416 this.iframe.style.left = this.table.style.left; … … 422 424 picker.foreSample.style.color = cell.colorCode; 423 425 if((cell.hue >= 195 && cell.saturation > 0.5) || 424 (cell.hue === 0 && cell.saturation === 0 && cell.value < 0.5) ||425 (cell.hue !== 0 && picker.value < 0.75))426 (cell.hue === 0 && cell.saturation === 0 && cell.value < 0.5) || 427 (cell.hue !== 0 && picker.value < 0.75)) 426 428 { 427 429 cell.style.borderColor = '#fff'; … … 445 447 else 446 448 { 447 cell.style.borderColor = '#000';449 cell.style.borderColor = '#000'; 448 450 } 449 451 valuerow = cell.thisrow; … … 456 458 function unpickCell(row,col) 457 459 { 458 picker.saved_cells[row][col].style.borderColor = picker.saved_cells[row][col].colorCode;460 picker.saved_cells[row][col].style.borderColor = picker.saved_cells[row][col].colorCode; 459 461 } 460 462 … … 510 512 { 511 513 enablepick = true; 512 // unpickCell(pickrow,pickcol);514 // unpickCell(pickrow,pickcol); 513 515 picker.saved_cells[pickrow][pickcol].style.borderColor = picker.saved_cells[pickrow][pickcol].colorCode; 514 516 pickCell(this); … … 516 518 td.onmouseover = function() 517 519 { 518 if(enablepick)519 {520 pickCell(this);521 }520 if(enablepick) 521 { 522 pickCell(this); 523 } 522 524 }; 523 525 td.onmouseout = function() 524 526 { 525 if(enablepick)526 {527 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode;527 if(enablepick) 528 { 529 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; 528 530 this.style.borderColor = this.colorCode; 529 }531 } 530 532 }; 531 533 td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; … … 566 568 { 567 569 enablevalue = true; 568 // unpickCell(valuerow,valuecol);570 // unpickCell(valuerow,valuecol); 569 571 picker.saved_cells[valuerow][valuecol].style.borderColor = picker.saved_cells[valuerow][valuecol].colorCode; 570 572 picker.value = this.hsv_value; … … 643 645 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; 644 646 this.style.borderColor = this.colorCode; 645 }647 } 646 648 }; 647 649 td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; … … 786 788 this.foreSample.style.color = pickcell.colorCode; 787 789 if((pickcell.hue >= 195 && pickcell.saturation > 0.5) || 788 (pickcell.hue === 0 && pickcell.saturation === 0 && pickcell.value < 0.5) ||789 (pickcell.hue !== 0 && picker.value < 0.75))790 (pickcell.hue === 0 && pickcell.saturation === 0 && pickcell.value < 0.5) || 791 (pickcell.hue !== 0 && picker.value < 0.75)) 790 792 { 791 793 pickcell.style.borderColor = '#fff'; … … 793 795 else 794 796 { 795 pickcell.style.borderColor = '#000';797 pickcell.style.borderColor = '#000'; 796 798 } 797 799 } … … 892 894 { 893 895 var colPicker = new Xinha.colorPicker(pickerConfig); 894 colPicker.open("",chooser, input.value );896 colPicker.open("",chooser, input.value ); 895 897 } 896 898 Xinha.freeLater(this,"chooser");
