Changeset 558
- Timestamp:
- 08/25/06 13:45:41 (7 years ago)
- Location:
- branches/mokhet
- Files:
-
- 4 modified
-
htmlarea.js (modified) (20 diffs)
-
plugins/ListType/list-type.js (modified) (3 diffs)
-
popups/color_picker.js (modified) (8 diffs)
-
popups/popup.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/mokhet/htmlarea.js
r551 r558 367 367 this.showLoading = false; 368 368 369 // size of color picker cells 370 this.colorPickerCellsize = '6px'; 371 // granularity of color picker cells (number per column/row) 372 this.colorPickerGranularity = 18; 373 // position of color picker from toolbar button 374 this.colorPickerPosition = 'bottom,right'; 375 369 376 /** CUSTOMIZING THE TOOLBAR 370 377 * ------------------------- … … 889 896 var tb_row = null; 890 897 var tb_objects = {}; 891 // wrong case name. Should be this._toolBarObjects according to the comment 5 lines above898 // [mokhet] wrong case name. Should be this._toolBarObjects according to the comment 5 lines above 892 899 this._toolbarObjects = tb_objects; 893 900 … … 1128 1135 }; 1129 1136 1130 // editor.freeLater(obj);1131 1137 editor.freeLater(obj, ['element', 'state']); 1132 1133 1138 tb_objects[txt] = obj; 1134 1139 break; … … 1159 1164 }; 1160 1165 // editor.freeLater(el); 1161 // editor.freeLater(obj);1162 1166 editor.freeLater(obj, ['element', 'cmd', 'state', 'imgel', 'swapImage']); 1163 1167 … … 1169 1173 1170 1174 // handlers to emulate nice flat toolbar buttons 1171 function el_onmouseout() 1172 { 1173 if ( obj.enabled ) 1174 { 1175 //HTMLArea._removeClass(el, "buttonHover"); 1176 HTMLArea._removeClass(el, "buttonActive"); 1177 if ( obj.active ) 1175 editor.addEvent( 1176 el, 1177 "mouseout", 1178 function() 1179 { 1180 if ( obj.enabled ) 1178 1181 { 1179 HTMLArea._addClass(el, "buttonPressed"); 1182 //HTMLArea._removeClass(el, "buttonHover"); 1183 HTMLArea._removeClass(el, "buttonActive"); 1184 if ( obj.active ) 1185 { 1186 HTMLArea._addClass(el, "buttonPressed"); 1187 } 1180 1188 } 1181 1189 } 1182 } 1183 function el_onmousedown(ev) 1184 { 1185 if ( obj.enabled ) 1186 { 1187 HTMLArea._addClass(el, "buttonActive"); 1188 HTMLArea._removeClass(el, "buttonPressed"); 1189 } 1190 HTMLArea.Events.stop(ev); 1191 } 1190 ); 1191 1192 editor.addEvent( 1193 el, 1194 "mousedown", 1195 function(ev) 1196 { 1197 if ( obj.enabled ) 1198 { 1199 HTMLArea._addClass(el, "buttonActive"); 1200 HTMLArea._removeClass(el, "buttonPressed"); 1201 } 1202 HTMLArea.Events.stop(ev); 1203 } 1204 ); 1205 1192 1206 // when clicked, do the following: 1193 function el_onclick(ev) 1194 { 1195 if ( obj.enabled ) 1196 { 1197 HTMLArea._removeClass(el, "buttonActive"); 1198 //HTMLArea._removeClass(el, "buttonHover"); 1199 if ( HTMLArea.is_gecko ) 1207 editor.addEvent( 1208 el, 1209 "click", 1210 function(ev) 1211 { 1212 if ( obj.enabled ) 1200 1213 { 1201 editor.activateEditor(); 1214 HTMLArea._removeClass(el, "buttonActive"); 1215 //HTMLArea._removeClass(el, "buttonHover"); 1216 if ( HTMLArea.is_gecko ) 1217 { 1218 editor.activateEditor(); 1219 } 1220 obj.cmd(editor, obj.name, obj); 1202 1221 } 1203 obj.cmd(editor, obj.name, obj); 1204 } 1205 HTMLArea.Events.stop(ev); 1206 } 1207 editor.addEvent(el, 'mouseout', el_onmouseout); 1208 editor.addEvent(el, 'mousedown', el_onmousedown); 1209 editor.addEvent(el, 'click', el_onclick); 1222 HTMLArea.Events.stop(ev); 1223 } 1224 ); 1210 1225 1211 1226 var i_contain = HTMLArea.makeBtnImg(btn[1]); … … 1433 1448 } 1434 1449 1450 if ( typeof colorPicker == 'undefined' ) 1451 { 1452 HTMLArea._loadback(_editor_url + 'popups/color_picker.js', this.generate, this ); 1453 return false; 1454 } 1455 1435 1456 if ( _editor_skin !== "" ) 1436 1457 { … … 1608 1629 1609 1630 // update the original form.submit() function. See ticket #823 1631 // disabled until a proper fix for IE is found 1632 /* 1610 1633 if ( !textarea.form.xinha_submit ) 1611 1634 { … … 1628 1651 }; 1629 1652 } 1630 1631 // this variable should already be saved when the editor was generating1653 */ 1654 // [mokhet] this variable should already be saved when the editor was generating 1632 1655 var initialTAContent = textarea.value; 1633 1656 1634 1657 // onreset revert the HTMLArea content to the textarea content 1635 function form_onreset() 1636 { 1637 editor.setHTML(editor.inwardHtml(initialTAContent)); 1638 editor.updateToolbar(); 1639 return true; 1640 } 1641 editor.prependDom0Event(textarea.form, 'reset', form_onreset); 1658 editor.prependDom0Event( 1659 textarea.form, 1660 'reset', 1661 function() 1662 { 1663 editor.setHTML(editor.inwardHtml(initialTAContent)); 1664 editor.updateToolbar(); 1665 return true; 1666 } 1667 ); 1642 1668 } 1643 1669 1644 1670 // add a handler for the "back/forward" case -- on body.unload we save 1645 1671 // the HTML content into the original textarea. 1646 function backforward() 1647 { 1648 textarea.value = editor.outwardHtml(editor.getHTML()); 1649 return true; 1650 } 1651 editor.prependDom0Event(window, 'unload', backforward); 1672 editor.prependDom0Event( 1673 window, 1674 'unload', 1675 function() 1676 { 1677 textarea.value = editor.outwardHtml(editor.getHTML()); 1678 return true; 1679 } 1680 ); 1652 1681 1653 1682 // Hide textarea … … 1659 1688 // Add an event to initialize the iframe once loaded. 1660 1689 editor._iframeLoadDone = false; 1661 function iframe_onload() 1662 { 1663 if ( !editor._iframeLoadDone ) 1664 { 1665 editor._iframeLoadDone = true; 1666 editor.initIframe(); 1667 } 1668 return true; 1669 } 1670 editor.addEvent(iframe, 'load', iframe_onload); 1690 editor.addEvent( 1691 iframe, 1692 'load', 1693 function() 1694 { 1695 if ( !editor._iframeLoadDone ) 1696 { 1697 editor._iframeLoadDone = true; 1698 editor.initIframe(); 1699 } 1700 return true; 1701 } 1702 ); 1671 1703 1672 1704 return true; … … 2367 2399 var doc = editor._doc; 2368 2400 // if we have multiple editors some bug in Mozilla makes some lose editing ability 2369 editor.addEvent(doc, 'mousedown', editor.activateEditor, false, editor); 2401 editor.addEvent( 2402 doc, 2403 "mousedown", 2404 function() 2405 { 2406 editor.activateEditor(); 2407 return true; 2408 } 2409 ); 2370 2410 2371 2411 // intercept some events; for updating the toolbar & keyboard handlers … … 3090 3130 for ( var ka = 0; ka < attrs.length; ++ka ) 3091 3131 { 3092 // eval ???? why not using the following line instead ?3132 // [mokhet] eval ???? why not using the following line instead ? 3093 3133 // if ( !ancestors[k][attrs[ka]] ) 3094 3134 if ( !eval("ancestors[k]." + attrs[ka]) ) … … 3667 3707 }; 3668 3708 3669 // Why is this is still in the trunk ?3709 // [mokhet] move to deprecated.js ticket #829 3670 3710 // there's no reference to it anywhere else even in plugins 3671 3711 HTMLArea.prototype._formatBlock = function(block_format) … … 3766 3806 } 3767 3807 } 3768 3808 return true; 3769 3809 }; 3770 3810 … … 4247 4287 { 4248 4288 var editor = this; // for nested functions 4289 var btn = editor._toolbarObjects[cmdID].element; 4249 4290 if ( cmdID == 'hilitecolor' ) 4250 4291 { … … 4262 4303 } 4263 4304 } 4264 this._popupDialog( 4265 editor.config.URIs.select_color, 4266 function(color) 4267 { 4268 // selection not canceled 4269 if ( color ) 4270 { 4271 editor._doc.execCommand(cmdID, false, "#" + color); 4272 } 4273 }, 4274 HTMLArea._colorToRgb(this._doc.queryCommandValue(cmdID))); 4305 var cback = function(color) { editor._doc.execCommand(cmdID, false, color); }; 4306 if ( HTMLArea.is_ie ) 4307 { 4308 var range = editor._createRange(editor._getSelection()); 4309 cback = function(color) 4310 { 4311 range.select(); 4312 editor._doc.execCommand(cmdID, false, color); 4313 }; 4314 } 4315 var picker = new colorPicker({cellsize:editor.config.colorPickerCellsize,callback:cback,granularity:editor.config.colorPickerGranularity}); 4316 picker.open(editor.config.colorPickerPosition, btn); 4275 4317 }; 4276 4318 … … 5297 5339 5298 5340 // FIXME!!! this should return false for IE < 5.5 5341 // @todo : this should check for objects existence and NOT on useragent strings 5299 5342 HTMLArea.checkSupportedBrowser = function() 5300 5343 { … … 5388 5431 } 5389 5432 }; 5433 5434 /** 5435 * Remove the notifier for the couple ev / fn 5436 * @param {string} ev EventNotifier type to remove 5437 * @param {object} fn Function to remove 5438 * @return {boolean} true if the removing was successfull 5439 * @public 5440 */ 5441 HTMLArea.prototype.notifyRemove = function(ev, fn) 5442 { 5443 if ( this._notifyListeners[ev] ) 5444 { 5445 var index = this._notifyListeners[ev].indexOf(fn); 5446 if ( index != -1 ) 5447 { 5448 this._notifyListeners[ev].splice(index, 1); 5449 return true; 5450 } 5451 } 5452 return false; 5453 }; 5454 5390 5455 5391 5456 /* … … 6607 6672 if ( returnValue ) 6608 6673 { 6609 this.notifyOn('dispose', function() { HTMLArea.Events.remove(element, type, handler, scope); }); 6674 function notifier() { HTMLArea.Events.remove(element, type, handler, scope); } 6675 function notifierRemove() 6676 { 6677 // call the notifier to actually remove the listener 6678 notifier(); 6679 // remove the notifiers 6680 this.notifyRemove('dispose', notifier); 6681 this.notifyRemove('remove_event_autodisposer', notifierRemove); 6682 } 6683 this.notifyOn('dispose', notifier); 6684 this.notifyOn('remove_event_autodisposer', notifierRemove); 6610 6685 } 6611 6686 return returnValue; … … 6632 6707 { 6633 6708 return this.addEvent(element, type, handler, 'prepend', scope, arbitraryObj); 6709 }; 6710 6711 /** 6712 * Remove an event listener and remove the associated dispose notifier 6713 * @see HTMLArea.Events.remove, @see HTMLArea.prototype.addEvent 6714 * @public 6715 */ 6716 HTMLArea.prototype.removeEvent = function(element, type, handler, scope) 6717 { 6718 this.notifyOf('remove_event_autodisposer'); 6634 6719 }; 6635 6720 … … 7224 7309 /* 7225 7310 --------------------------------------------------------------------------- 7226 COMPATIBILITY ALIAS7311 EVENT COMPATIBILITY ALIAS 7227 7312 --------------------------------------------------------------------------- 7228 7313 */ -
branches/mokhet/plugins/ListType/list-type.js
r430 r558 37 37 { 38 38 editor._ListType = editor.addPanel( 'right' ); 39 HTMLArea.freeLater( editor, '_ListType' );39 editor.freeLater( editor, '_ListType' ); 40 40 HTMLArea.addClass( editor._ListType, 'ListType' ); 41 41 // hurm, ok it's pretty to use the background color for the whole panel, … … 46 46 function(e,args) 47 47 { 48 if ( args.mode == 'text' ) editor.hidePanel( editor._ListType );48 if ( args.mode == 'text' ) { editor.hidePanel( editor._ListType ); } 49 49 } 50 50 ); … … 130 130 ListType.prototype.onUpdateToolbar = function() 131 131 { 132 if ( this.editor.config.ListType.mode == 'toolbar' ) return ;132 if ( this.editor.config.ListType.mode == 'toolbar' ) { return ; } 133 133 var parent = this.editor.getParentElement(); 134 while ( parent && !/^[o|u]l$/i.test( parent.tagName ) ) 134 while ( parent && parent.tagName && !/^[o|u]l$/i.test( parent.tagName ) ) 135 { 135 136 parent = parent.parentNode; 136 if (parent && /^[o|u]l$/i.test( parent.tagName ) ) 137 } 138 if (parent && parent.tagName && /^[o|u]l$/i.test( parent.tagName ) ) 137 139 { 138 140 this.showPanel( parent ); 139 141 } 140 else if ( this.editor._ListType.style.display != 'none')142 else if ( this.editor._ListType.style.display != 'none' ) 141 143 { 142 144 this.editor.hidePanel( this.editor._ListType ); -
branches/mokhet/popups/color_picker.js
r376 r558 75 75 function colorPicker(params) 76 76 { 77 // if the savedColors is empty, try to read the savedColors from cookie 78 if ( colorPicker.savedColors.length == 0 ) 79 { 80 colorPicker.loadColors(); 81 } 77 82 var picker = this; 78 83 this.callback = params.callback?params.callback:function(color){alert('You picked ' + color )}; 79 84 85 this.websafe = params.websafe?params.websafe:false; 80 86 this.cellsize = params.cellsize?params.cellsize:'10px'; 81 87 this.side = params.granularity?params.granularity:18; … … 289 295 this.table.style.left = (left - (this.table.offsetWidth - element.offsetWidth)) + 'px'; 290 296 } 297 // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 298 /*@cc_on 299 this.iframe.style.top = this.table.style.top; 300 this.iframe.style.left = this.table.style.left; 301 @*/ 291 302 }; 292 303 … … 339 350 } 340 351 } 341 td.onclick = function() { picker.callback(this.colorCode); picker.close(); }352 td.onclick = function() { colorPicker.remember(this.colorCode); picker.callback(this.colorCode); picker.close(); } 342 353 td.appendChild(document.createTextNode(' ')); 343 354 td.style.cursor = 'pointer'; … … 414 425 } 415 426 } 416 td.onclick = function() { picker.callback(this.colorCode); picker.close(); }427 td.onclick = function() { colorPicker.remember(this.colorCode); picker.callback(this.colorCode); picker.close(); } 417 428 td.appendChild(document.createTextNode(' ')); 418 429 td.style.cursor = 'pointer'; … … 430 441 td.style.padding = '3px'; 431 442 443 if ( this.websafe ) 444 { 432 445 var div = document.createElement('div'); 433 446 var label = document.createElement('label'); … … 440 453 div.appendChild(label); 441 454 td.appendChild(div); 455 } 442 456 443 457 var div = document.createElement('div'); … … 467 481 td.appendChild(sampleTable); 468 482 483 var savedColors = document.createElement('div'); 484 savedColors.style.clear = 'both'; 485 486 function createSavedColors(color) 487 { 488 var is_ie = false; 489 /*@cc_on is_ie = true; @*/ 490 var div = document.createElement('div'); 491 div.style.width = '13px'; 492 div.style.height = '13px'; 493 div.style.margin = '1px'; 494 div.style.border = '1px solid black'; 495 div.style.cursor = 'pointer'; 496 div.style.backgroundColor = color; 497 div.style[ is_ie ? 'styleFloat' : 'cssFloat'] = 'left'; 498 div.onclick = function() { picker.callback(color); picker.close(); }; 499 div.onmouseover = function() 500 { 501 picker.chosenColor.value = color; 502 picker.backSample.style.backgroundColor = color; 503 picker.foreSample.style.color = color; 504 }; 505 savedColors.appendChild(div); 506 } 507 for ( var savedCols = 0; savedCols < colorPicker.savedColors.length; savedCols++ ) 508 { 509 createSavedColors(colorPicker.savedColors[savedCols]); 510 } 511 td.appendChild(savedColors); 469 512 470 513 this.tbody.appendChild(tr); 471 514 document.body.appendChild(this.table); 472 515 // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 516 /*@cc_on 517 if ( !this.iframe ) 518 { 519 this.iframe = document.createElement('iframe'); 520 this.iframe.style.zIndex = 999; 521 this.table.style.zIndex = 1000; 522 this.iframe.style.position = 'absolute'; 523 this.iframe.style.width = this.table.offsetWidth; 524 this.iframe.style.height = this.table.offsetHeight; 525 this.iframe.border = 0; 526 this.iframe.frameBorder = 0; 527 this.iframe.frameSpacing = 0; 528 this.iframe.marginWidth = 0; 529 this.iframe.marginHeight = 0; 530 this.iframe.hspace = 0; 531 this.iframe.vspace = 0; 532 document.body.appendChild(this.iframe); 533 } 534 this.iframe.style.display = ''; 535 @*/ 473 536 } 474 537 else … … 496 559 { 497 560 this.table.style.display = 'none'; 561 // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 562 /*@cc_on 563 if ( this.iframe ) { this.iframe.style.display = 'none'; } 564 @*/ 498 565 }; 499 500 566 } 567 568 // array of the saved colors 569 colorPicker.savedColors = []; 570 571 // add the color to the savedColors 572 colorPicker.remember = function(color) 573 { 574 // check if this color is known 575 for ( var i = colorPicker.savedColors.length; i--; ) 576 { 577 if ( colorPicker.savedColors[i] == color ) 578 { 579 return false; 580 } 581 } 582 // insert the new color 583 colorPicker.savedColors.splice(0, 0, color); 584 // limit elements 585 colorPicker.savedColors = colorPicker.savedColors.slice(0, 21); 586 //[mokhet] probably some more parameters to send to the cookie definition 587 // like domain, secure and such, especially with https connection i presume 588 // save the cookie 589 var expdate = new Date(); 590 expdate.setMonth(expdate.getMonth() + 1); 591 592 document.cookie = 'XinhaColorPicker=' + escape (colorPicker.savedColors.join('-')) + ';expires=' + expdate.toGMTString(); 593 return true; 594 }; 595 596 // try to read the colors from the cookie 597 colorPicker.loadColors = function() 598 { 599 var index = document.cookie.indexOf('XinhaColorPicker'); 600 if ( index != -1 ) 601 { 602 var begin = (document.cookie.indexOf('=', index) + 1); 603 var end = document.cookie.indexOf(';', index); 604 if ( end == -1 ) { end = document.cookie.length; } 605 colorPicker.savedColors = unescape(document.cookie.substring(begin, end)).split('-'); 606 } 607 }; -
branches/mokhet/popups/popup.js
r504 r558 11 11 // 12 12 // $Id$ 13 HTMLArea = window.opener.HTMLArea;13 var HTMLArea = window.opener.HTMLArea; 14 14 15 15 function getAbsolutePos(el) {
