Changeset 404
- Timestamp:
- 10/27/05 08:28:55 (8 years ago)
- Location:
- branches/new-dialogs
- Files:
-
- 6 added
- 7 modified
-
dialogs (added)
-
dialogs/insert-image.html (added)
-
dialogs/insert-link.html (added)
-
dialogs/insert-table.html (added)
-
examples/full_example-menu.html (modified) (1 diff)
-
examples/full_example.js (modified) (1 diff)
-
floating-dialog.js (added)
-
htmlarea.css (modified) (1 diff)
-
htmlarea.js (modified) (15 diffs)
-
inline-dialog.js (modified) (5 diffs)
-
plugins/Linker/linker.js (modified) (13 diffs)
-
plugins/SuperClean/super-clean.js (modified) (10 diffs)
-
popup-dialog.js (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/new-dialogs/examples/full_example-menu.html
r367 r404 63 63 </select> 64 64 </label> 65 <label> 66 Dialogs: 67 <select name="popupType"> 68 <option value="inline">inline</option> 69 <option value="floating">floating</option> 70 <option value="popup">popup</option> 71 </select> 72 </label> 65 73 </fieldset> 66 74 -
branches/new-dialogs/examples/full_example.js
r359 r404 107 107 xinha_config.Filters = ["Word", "Paragraph"] 108 108 } 109 110 config.popupType = f.popupType.value; 109 111 110 112 return config; -
branches/new-dialogs/htmlarea.css
r379 r404 172 172 .dialog legend { font-weight: bold; } 173 173 .dialog fieldset table { margin: 2px 0px; } 174 175 .dialog div.insertlink { } 176 .dialog div.insertlink div { margin-top: 5px; } 177 .dialog div.insertlink label { width: 97px; display: block; float: left; text-align: right; margin-top: 3px; margin-right: 3px; } 178 .dialog div.insertlink input { width: 200px; } 179 .dialog div.insertlink div.buttons input { width: 90px; } 180 181 .dialog div.insertimage { } 182 .dialog div.insertimage div { margin-top: 5px; } 183 .dialog div.insertimage label { width: 97px; display: block; float: left; text-align: right; margin-top: 3px; margin-right: 3px; } 184 .dialog div.insertimage input { width: 200px; } 185 .dialog div.insertimage fieldset { width: 40%; float: left; } 186 .dialog div.insertimage fieldset label { width: 70px; } 187 .dialog div.insertimage fieldset input { width: 50px; } 188 .dialog div.insertimage fieldset select { width: 90px; } 189 .dialog div.insertimage div.buttons input { width: 90px; } 174 190 175 191 .popupwin { -
branches/new-dialogs/htmlarea.js
r402 r404 151 151 HTMLArea.freeLater(panels[i], 'div'); 152 152 } 153 154 this.dialogs = { }; 155 156 var toolbarDlgs = { "createlink" : HTMLArea.InsertLinkDialog, 157 "insertimage" : HTMLArea.InsertImageDialog, 158 "inserttable" : HTMLArea.InsertTableDialog } 159 for (var i = 0; i < this.config.toolbar.length; i++) 160 { 161 if(this.config.toolbar[i].length) 162 { 163 for (var j = 0; j < this.config.toolbar[i].length; j++) 164 { 165 if(toolbarDlgs[this.config.toolbar[i][j]]) { 166 this.addDialog(this.config.toolbar[i][j], toolbarDlgs[this.config.toolbar[i][j]]); 167 } 168 } 169 } 170 else 171 { 172 if(toolbarDlgs[this.config.toolbar[i]]) { 173 this.addDialog(this.config.toolbar[i], toolbarDlgs[this.config.toolbar[i]]); 174 } 175 } 176 } 177 153 178 HTMLArea.freeLater(this, '_textArea'); 154 179 } … … 297 322 298 323 this.flowToolbars = true; 324 325 // Type of the popup-dialogs 326 // avaliable: popup, inline, floating 327 this.popupType = 'inline'; 299 328 300 329 /** CUSTOMIZING THE TOOLBAR … … 698 727 } 699 728 } 729 } 730 }; 731 732 HTMLArea.prototype.addDialog = function(name, dialog) 733 { 734 this.dialogs[name] = dialog; 735 }; 736 737 HTMLArea.prototype.removeDialog = function(name) 738 { 739 if(this.dialogs[name]) { 740 this.dialogs[name] = null; 700 741 } 701 742 }; … … 1189 1230 { 1190 1231 HTMLArea._loadback 1191 (_editor_url + 'inline-dialog.js', function() { editor.generate(); } );1232 (_editor_url + this.config.popupType + '-dialog.js', function() { editor.generate(); } ); 1192 1233 return false; 1193 1234 } … … 1917 1958 doc.write(html); 1918 1959 doc.close(); 1960 1961 // load dialogs 1962 for(var i in editor.dialogs) 1963 { 1964 if(editor.dialogs[i]) { 1965 editor.dialogs[i] = new editor.dialogs[i](editor); 1966 } 1967 } 1968 1919 1969 1920 1970 this.setEditorEvents(); … … 3294 3344 return; 3295 3345 } 3296 outparam = { 3297 f_href : '', 3298 f_title : '', 3299 f_target : '', 3300 f_usetarget : editor.config.makeLinkShowsTarget 3346 inputs = { 3347 href : '', 3348 title : '', 3349 target : '' 3301 3350 }; 3302 3351 } else 3303 outparam = { 3304 f_href : HTMLArea.is_ie ? editor.stripBaseURL(link.href) : link.getAttribute("href"), 3305 f_title : link.title, 3306 f_target : link.target, 3307 f_usetarget : editor.config.makeLinkShowsTarget 3352 inputs = { 3353 href : HTMLArea.is_ie ? editor.stripBaseURL(link.href) : link.getAttribute("href"), 3354 title : link.title, 3355 target : link.target 3308 3356 }; 3309 this._popupDialog(editor.config.URIs["link"], function(param) { 3310 if (!param) 3311 return false; 3312 var a = link; 3313 if (!a) try { 3314 editor._doc.execCommand("createlink", false, param.f_href); 3315 a = editor.getParentElement(); 3316 var sel = editor._getSelection(); 3317 var range = editor._createRange(sel); 3318 if (!HTMLArea.is_ie) { 3319 a = range.startContainer; 3320 if (!/^a$/i.test(a.tagName)) { 3321 a = a.nextSibling; 3322 if (a == null) 3323 a = range.startContainer.parentNode; 3324 } 3325 } 3326 } catch(e) {} 3327 else { 3328 var href = param.f_href.trim(); 3329 editor.selectNodeContents(a); 3330 if (href == "") { 3331 editor._doc.execCommand("unlink", false, null); 3332 editor.updateToolbar(); 3333 return false; 3334 } 3335 else { 3336 a.href = href; 3337 } 3338 } 3339 if (!(a && /^a$/i.test(a.tagName))) 3340 return false; 3341 a.target = param.f_target.trim(); 3342 a.title = param.f_title.trim(); 3343 editor.selectNodeContents(a); 3344 editor.updateToolbar(); 3345 }, outparam); 3357 3358 // If we are not editing a link, then we need to insert links now using execCommand 3359 // because for some reason IE is losing the selection between now and when doOK is 3360 // complete. I guess because we are defocusing the iframe when we click stuff in the 3361 // linker dialog. 3362 3363 this.a = link; // Why doesn't a get into the closure below, but if I set it as a property then it's fine? 3364 3365 var doOK = function() 3366 { 3367 var a = editor.a; 3368 3369 var values = editor.dialogs.createlink.hide(); 3370 3371 var atr = 3372 { 3373 href: '', 3374 target:'', 3375 title:'' 3376 } 3377 3378 if(values.href) 3379 { 3380 atr.href = values.href; 3381 atr.target = values.target; 3382 } 3383 3384 if(a && a.tagName.toLowerCase() == 'a') 3385 { 3386 if(!atr.href) 3387 { 3388 if(confirm(editor.dialogs.createlink._lc('Are you sure you wish to remove this link?'))) 3389 { 3390 var p = a.parentNode; 3391 while(a.hasChildNodes()) 3392 { 3393 p.insertBefore(a.removeChild(a.childNodes[0]), a); 3394 } 3395 p.removeChild(a); 3396 } 3397 } 3398 // Update the link 3399 for(var i in atr) 3400 { 3401 a.setAttribute(i, atr[i]); 3402 } 3403 } 3404 else 3405 { 3406 if(!atr.href) return true; 3407 3408 // Insert a link, we let the browser do this, we figure it knows best 3409 var tmp = HTMLArea.uniq('http://www.example.com/Link'); 3410 editor._doc.execCommand('createlink', false, tmp); 3411 3412 // Fix them up 3413 var anchors = editor._doc.getElementsByTagName('a'); 3414 for(var i = 0; i < anchors.length; i++) 3415 { 3416 var a = anchors[i]; 3417 if(a.href == tmp) 3418 { 3419 // Found one. 3420 for(var i in atr) 3421 { 3422 a.setAttribute(i, atr[i]); 3423 } 3424 } 3425 } 3426 } 3427 } 3428 this.dialogs.createlink.show(inputs, {'ok': doOK} ); 3346 3429 }; 3347 3430 … … 3365 3448 f_horiz : image.hspace 3366 3449 }; 3367 this._popupDialog(editor.config.URIs["insert_image"], function(param) { 3368 if (!param) { // user must have pressed Cancel 3369 return false; 3370 } 3450 3451 this.image = image; // Why doesn't a get into the closure below, but if I set it as a property then it's fine? 3452 3453 var doOK = function() 3454 { 3371 3455 var img = image; 3456 3457 var param = editor.dialogs.insertimage.hide(); 3458 3372 3459 if (!img) { 3373 3460 var sel = editor._getSelection(); 3374 3461 var range = editor._createRange(sel); 3375 editor._doc.execCommand("insertimage", false, param. f_url);3462 editor._doc.execCommand("insertimage", false, param.url); 3376 3463 if (HTMLArea.is_ie) { 3377 3464 img = range.parentElement(); … … 3388 3475 } 3389 3476 } else { 3390 img.src = param. f_url;3477 img.src = param.url; 3391 3478 } 3392 3479 … … 3394 3481 var value = param[field]; 3395 3482 switch (field) { 3396 case "f_alt" : img.alt = value; break; 3397 case "f_border" : img.border = parseInt(value || "0"); break; 3398 case "f_align" : img.align = value; break; 3399 case "f_vert" : img.vspace = parseInt(value || "0"); break; 3400 case "f_horiz" : img.hspace = parseInt(value || "0"); break; 3401 } 3402 } 3403 }, outparam); 3483 case "alt" : img.alt = value; break; 3484 case "border" : img.border = parseInt(value || "0"); break; 3485 case "align" : img.align = value; break; 3486 case "vert" : img.vspace = parseInt(value || "0"); break; 3487 case "horiz" : img.hspace = parseInt(value || "0"); break; 3488 } 3489 } 3490 } 3491 this.dialogs.insertimage.show(outparam, { 'ok': doOK }); 3492 3404 3493 }; 3405 3494 … … 3409 3498 var range = this._createRange(sel); 3410 3499 var editor = this; // for nested functions 3411 this._popupDialog(editor.config.URIs["insert_table"], function(param) { 3412 if (!param) { // user must have pressed Cancel 3413 return false; 3414 } 3500 3501 var doOK = function() 3502 { 3415 3503 var doc = editor._doc; 3416 3504 // create the table element … … 3418 3506 // assign the given arguments 3419 3507 3508 var param = editor.dialogs.inserttable.hide(); 3509 3420 3510 for (var field in param) { 3421 3511 var value = param[field]; … … 3424 3514 } 3425 3515 switch (field) { 3426 case " f_width" : table.style.width = value + param["f_unit"]; break;3427 case " f_align" : table.align = value; break;3428 case " f_border" : table.border = parseInt(value); break;3429 case " f_spacing" : table.cellSpacing = parseInt(value); break;3430 case " f_padding" : table.cellPadding = parseInt(value); break;3516 case "width" : table.style.width = value + param["unit"]; break; 3517 case "align" : table.align = value; break; 3518 case "border" : table.border = parseInt(value); break; 3519 case "spacing" : table.cellSpacing = parseInt(value); break; 3520 case "padding" : table.cellPadding = parseInt(value); break; 3431 3521 } 3432 3522 } 3433 3523 var cellwidth = 0; 3434 if (param.f _fixed)3435 cellwidth = Math.floor(100 / parseInt(param. f_cols));3524 if (param.fixed) 3525 cellwidth = Math.floor(100 / parseInt(param.cols)); 3436 3526 var tbody = doc.createElement("tbody"); 3437 3527 table.appendChild(tbody); 3438 for (var i = 0; i < param[" f_rows"]; ++i) {3528 for (var i = 0; i < param["rows"]; ++i) { 3439 3529 var tr = doc.createElement("tr"); 3440 3530 tbody.appendChild(tr); 3441 for (var j = 0; j < param[" f_cols"]; ++j) {3531 for (var j = 0; j < param["cols"]; ++j) { 3442 3532 var td = doc.createElement("td"); 3443 3533 if (cellwidth) … … 3454 3544 editor.insertNodeAtSelection(table); 3455 3545 } 3456 return true; 3457 }, null); 3546 }; 3547 3548 this.dialogs.inserttable.show(null, { 'ok': doOK }); 3458 3549 }; 3459 3550 … … 3515 3606 this._doc.execCommand(cmdID, UI, param); 3516 3607 break; 3517 case "inserttable": this._insertTable(); break; 3518 case "insertimage": this._insertImage(); break; 3608 case "inserttable": 3609 this._insertTable(); 3610 return false; //don't updateToolbar 3611 case "insertimage": 3612 this._insertImage(); 3613 return false; //don't updateToolbar 3519 3614 case "about" : this._popupDialog(editor.config.URIs["about"], null, this); break; 3520 3615 case "showhelp" : this._popupDialog(editor.config.URIs["help"], null, this); break; … … 5578 5673 }; 5579 5674 5675 5676 HTMLArea.InsertImageDialog = function(editor) 5677 { 5678 this.editor = editor; 5679 this.ready = false; 5680 this.html = false; 5681 this.dialog = false; 5682 5683 this._prepeareDialog(); 5684 } 5685 5686 HTMLArea.InsertImageDialog.prototype._prepeareDialog = function() 5687 { 5688 var editor = this.editor; 5689 var lDialog = this; 5690 5691 if(this.html == false) 5692 { 5693 HTMLArea._getback(_editor_url + 'dialogs/insert-image.html', function(txt) { lDialog.html = txt; lDialog._prepeareDialog(); }); 5694 return; 5695 } 5696 var html = this.html; 5697 5698 var dialog = this.dialog = new HTMLArea.Dialog(editor, this.html, 'HTMLArea', {width: 400, height: 400}); 5699 5700 this.ready = true; 5701 } 5702 5703 HTMLArea.InsertImageDialog.prototype._lc = HTMLArea.prototype._lc; 5704 5705 HTMLArea.InsertImageDialog.prototype.show = function(inputs, param) 5706 { 5707 var lDialog = this; 5708 if(!this.ready) 5709 { 5710 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 5711 return; 5712 } 5713 5714 //set refence so we can use it in init 5715 this.dialog.iDialog = this; 5716 5717 this.dialog.show(inputs, param, this.init); 5718 }; 5719 5720 HTMLArea.InsertImageDialog.prototype.init = function(inputs, param, dialog) 5721 { 5722 var iDialog = dialog.iDialog; 5723 5724 // Connect the OK and Cancel buttons 5725 if(param.ok) 5726 { 5727 dialog.getElementById('ok').onclick = param.ok; 5728 } 5729 else 5730 { 5731 dialog.getElementById('ok').onclick = function() {iDialog.hide();}; 5732 } 5733 5734 if(param.cancel) 5735 { 5736 dialog.getElementById('cancel').onclick = param.cancel; 5737 } 5738 else 5739 { 5740 dialog.getElementById('cancel').onclick = function() { iDialog.hide()}; 5741 } 5742 5743 // Init the sizes 5744 dialog.onresize(); 5745 }; 5746 5747 HTMLArea.InsertImageDialog.prototype.hide = function() 5748 { 5749 this.editor.enableToolbar(); 5750 return this.dialog.hide(); 5751 }; 5752 5753 5754 HTMLArea.InsertLinkDialog = function(editor) 5755 { 5756 this.editor = editor; 5757 this.ready = false; 5758 this.html = false; 5759 this.dialog = false; 5760 5761 this._prepeareDialog(); 5762 } 5763 5764 HTMLArea.InsertLinkDialog.prototype._prepeareDialog = function() 5765 { 5766 var editor = this.editor; 5767 var lDialog = this; 5768 5769 if(this.html == false) 5770 { 5771 HTMLArea._getback(_editor_url + 'dialogs/insert-link.html', function(txt) { lDialog.html = txt; lDialog._prepeareDialog(); }); 5772 return; 5773 } 5774 var html = this.html; 5775 5776 var dialog = this.dialog = new HTMLArea.Dialog(editor, this.html, 'HTMLArea', {width: 400, height: 200}); 5777 5778 this.ready = true; 5779 } 5780 5781 HTMLArea.InsertLinkDialog.prototype._lc = HTMLArea.prototype._lc; 5782 5783 HTMLArea.InsertLinkDialog.prototype.show = function(inputs, param) 5784 { 5785 if(!this.ready) 5786 { 5787 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 5788 return; 5789 } 5790 5791 //set refence so we can use it in init 5792 this.dialog.lDialog = this; 5793 5794 this.dialog.show(inputs, param, this.init); 5795 }; 5796 5797 HTMLArea.InsertLinkDialog.prototype.init = function(inputs, param, dialog) 5798 { 5799 var lDialog = dialog.lDialog; 5800 5801 if(param.ok) 5802 { 5803 dialog.getElementById('ok').onclick = param.ok; 5804 } 5805 else 5806 { 5807 dialog.getElementById('ok').onclick = function() {lDialog.hide();}; 5808 } 5809 5810 if(param.cancel) 5811 { 5812 dialog.getElementById('cancel').onclick = param.cancel; 5813 } 5814 else 5815 { 5816 dialog.getElementById('cancel').onclick = function() { lDialog.hide()}; 5817 } 5818 5819 if(!dialog.editor.config.makeLinkShowsTarget) 5820 { 5821 dialog.getElementById('f_target').style.display = 'none'; 5822 } 5823 5824 // Init the sizes 5825 dialog.onresize(); 5826 5827 }; 5828 5829 HTMLArea.InsertLinkDialog.prototype.hide = function() 5830 { 5831 return this.dialog.hide(); 5832 } 5833 5834 5835 HTMLArea.InsertTableDialog = function(editor) 5836 { 5837 this.editor = editor; 5838 this.ready = false; 5839 this.html = false; 5840 this.dialog = false; 5841 5842 this._prepeareDialog(); 5843 } 5844 5845 HTMLArea.InsertTableDialog.prototype._prepeareDialog = function() 5846 { 5847 var editor = this.editor; 5848 var lDialog = this; 5849 5850 if(this.html == false) 5851 { 5852 HTMLArea._getback(_editor_url + 'dialogs/insert-table.html', function(txt) { lDialog.html = txt; lDialog._prepeareDialog(); }); 5853 return; 5854 } 5855 var html = this.html; 5856 5857 var dialog = this.dialog = new HTMLArea.Dialog(editor, this.html, 'HTMLArea', {width: 400, height: 200}); 5858 5859 this.ready = true; 5860 } 5861 5862 HTMLArea.InsertTableDialog.prototype._lc = HTMLArea.prototype._lc; 5863 5864 HTMLArea.InsertTableDialog.prototype.show = function(inputs, param) 5865 { 5866 var lDialog = this; 5867 if(!this.ready) 5868 { 5869 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 5870 return; 5871 } 5872 5873 //set refence so we can use it in init 5874 this.dialog.tDialog = this; 5875 5876 this.dialog.show(inputs, param, this.init); 5877 }; 5878 5879 HTMLArea.InsertTableDialog.prototype.init = function(inputs, param, dialog) 5880 { 5881 var tDialog = dialog.tDialog; 5882 5883 // Connect the OK and Cancel buttons 5884 if(param.ok) 5885 { 5886 dialog.getElementById('ok').onclick = param.ok; 5887 } 5888 else 5889 { 5890 dialog.getElementById('ok').onclick = function() {tDialog.hide();}; 5891 } 5892 5893 if(param.cancel) 5894 { 5895 dialog.getElementById('cancel').onclick = param.cancel; 5896 } 5897 else 5898 { 5899 dialog.getElementById('cancel').onclick = function() { tDialog.hide()}; 5900 } 5901 5902 // Init the sizes 5903 dialog.onresize(); 5904 } 5905 5906 HTMLArea.InsertTableDialog.prototype.hide = function() 5907 { 5908 return this.dialog.hide(); 5909 } 5910 5580 5911 HTMLArea.init(); 5581 5912 HTMLArea.addDom0Event(window,'unload',HTMLArea.collectGarbageForIE); -
branches/new-dialogs/inline-dialog.js
r376 r404 68 68 dialog.rootElem.style.width = dialog.width = dialog.editor._framework.ed_cell.offsetWidth + 'px'; 69 69 dialog.rootElem.style.height = dialog.height = dialog.editor._framework.ed_cell.offsetHeight + 'px'; 70 dialog.onresize( );70 dialog.onresize(e, args); 71 71 } 72 72 ); … … 78 78 }; 79 79 80 HTMLArea.Dialog.prototype.show = function(values )80 HTMLArea.Dialog.prototype.show = function(values, param, initFunction) 81 81 { 82 82 // We need to preserve the selection for IE … … 84 84 { 85 85 this._lastRange = this.editor._createRange(this.editor._getSelection()); 86 } 87 88 if(initFunction) 89 { 90 initFunction(values, param, this); 86 91 } 87 92 … … 95 100 this.editor._iframe.style.visibility = 'hidden'; 96 101 this.rootElem.style.display = ''; 102 103 this.editor.disableToolbar(); 97 104 }; 98 105 … … 326 333 return this.document.getElementsByName(this.id[name] ? this.id[name] : name); 327 334 }; 335 336 HTMLArea.Dialog.prototype.getFieldNameByName = function(name) 337 { 338 return(this.id[name] ? this.id[name] : name); 339 }; 340 341 HTMLArea.Dialog.prototype.loadStylesheet = function(href) 342 { 343 HTMLArea.loadStyle(href); 344 }; 345 346 HTMLArea.Dialog.prototype.loadScript = function(href, callback) 347 { 348 HTMLArea._loadback(href, callback); 349 350 }; -
branches/new-dialogs/plugins/Linker/linker.js
r376 r404 12 12 }; 13 13 14 HTMLArea.loadStyle('dTree/dtree.css', 'Linker');15 16 14 HTMLArea.Config.prototype.Linker = 17 15 { … … 24 22 { 25 23 this.editor = editor; 26 this.lConfig = editor.config.Linker;27 24 28 25 var linker = this; … … 42 39 // See if we can find 'createlink' 43 40 editor.config.addToolbarElement("createlink", "createlink", 0); 41 42 editor.removeDialog("createlink"); 43 editor.addDialog("linker", Linker.Dialog); 44 44 } 45 45 … … 150 150 var a = linker.a; 151 151 152 var values = linker. _dialog.hide();152 var values = linker.editor.dialogs.linker.hide(); 153 153 var atr = 154 154 { … … 201 201 if(!atr.href) 202 202 { 203 if(confirm(linker._ dialog._lc('Are you sure you wish to remove this link?')))203 if(confirm(linker._lc('Are you sure you wish to remove this link?'))) 204 204 { 205 205 var p = a.parentNode; … … 256 256 } 257 257 258 this. _dialog.show(inputs, doOK);258 this.editor.dialogs.linker.show(inputs, {'ok': doOK}); 259 259 260 260 }; … … 280 280 }; 281 281 282 Linker.prototype.onGenerate = function()283 {284 this._dialog = new Linker.Dialog(this);285 };286 282 // Inline Dialog for Linker 287 283 … … 289 285 290 286 291 Linker.Dialog = function ( linker)287 Linker.Dialog = function (editor) 292 288 { 293 289 var lDialog = this; 294 290 this.Dialog_nxtid = 0; 295 this. linker = linker;291 this.editor = editor; 296 292 this.id = { }; // This will be filled below with a replace, nifty 297 293 … … 309 305 { 310 306 var lDialog = this; 311 var linker = this.linker;307 var editor = this.editor; 312 308 313 309 // We load some stuff up int he background, recalling this function 314 310 // when they have loaded. This is to keep the editor responsive while 315 311 // we prepare the dialog. 316 if(typeof dTree == 'undefined')317 {318 HTMLArea._loadback(_editor_url + 'plugins/Linker/dTree/dtree.js',319 function() {lDialog._prepareDialog(); }320 );321 return;322 }323 312 324 313 if(this.files == false) 325 314 { 326 if( linker.lConfig.backend)327 { 328 //get files from backend329 HTMLArea._getback(linker.lConfig.backend,315 if(editor.config.Linker.backend) 316 { 317 //get files from backend 318 HTMLArea._getback(editor.config.Linker.backend, 330 319 function(txt) { 331 320 try { … … 335 324 } 336 325 lDialog._prepareDialog(); }); 337 } 338 else if(linker.lConfig.files != null) 339 { 340 //get files from plugin-config 341 lDialog.files = linker.lConfig.files; 342 lDialog._prepareDialog(); 343 } 344 return; 345 } 346 var files = this.files; 326 return; 327 } 328 else if(editor.config.Linker.files != null) 329 { 330 //get files from plugin-config 331 lDialog.files = editor.config.Linker.files; 332 } 333 } 347 334 348 335 if(this.html == false) … … 351 338 return; 352 339 } 353 var html = this.html; 354 355 // Now we have everything we need, so we can build the dialog. 356 var dialog = this.dialog = new HTMLArea.Dialog(linker.editor, this.html, 'Linker'); 357 var dTreeName = HTMLArea.uniq('dTree_'); 358 359 this.dTree = new dTree(dTreeName, _editor_url + 'plugins/Linker/dTree/'); 360 eval(dTreeName + ' = this.dTree'); 361 362 this.dTree.add(this.Dialog_nxtid++, -1, document.location.host, null, document.location.host); 363 this.makeNodes(files, 0); 364 365 // Put it in 366 var ddTree = this.dialog.getElementById('dTree'); 367 //ddTree.innerHTML = this.dTree.toString(); 368 ddTree.innerHTML = ''; 369 ddTree.style.position = 'absolute'; 370 ddTree.style.left = 1 + 'px'; 371 ddTree.style.top = 0 + 'px'; 372 ddTree.style.overflow = 'auto'; 373 this.ddTree = ddTree; 374 this.dTree._linker_premade = this.dTree.toString(); 375 376 var options = this.dialog.getElementById('options'); 340 if(this.dialog == false) 341 { 342 // Now we have everything we need, so we can build the dialog. 343 this.dialog = new HTMLArea.Dialog(editor, this.html, 'Linker'); 344 this.dialog.loadStylesheet(_editor_url + 'plugins/Linker/dTree/dtree.css'); 345 this.dialog.loadScript(_editor_url + 'plugins/Linker/dTree/dtree.js', function() {lDialog._prepareDialog(); }); 346 } 347 348 349 var dialog = this.dialog; 350 // Hookup the resizer 351 this.dialog.onresize = function() 352 { 353 var options = dialog.getElementById('options'); 354 var ddTree = dialog.getElementById('dTree'); 355 options.style.height = ddTree.style.height = (parseInt(dialog.height) - dialog.getElementById('h1').offsetHeight) + 'px'; 356 ddTree.style.width = (parseInt(dialog.width) - 322 ) + 'px'; 357 } 358 359 this.ready = true; 360 }; 361 362 Linker.Dialog.prototype.makeNodes = function(files, parent) 363 { 364 for(var i = 0; i < files.length; i++) 365 { 366 if(typeof files[i] == 'string') 367 { 368 this.dTree.add(Linker.nxtid++, parent, 369 files[i].replace(/^.*\//, ''), 370 'javascript:document.getElementsByName(\'' + this.dialog.getFieldNameByName('href') + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i]) + '\');document.getElementsByName(\'' + this.dialog.getFieldNameByName('type') + '\')[0].click();document.getElementsByName(\'' + this.dialog.getFieldNameByName('href') + '\')[0].focus();void(0);', 371 files[i]); 372 } 373 else if(files[i].length) 374 { 375 var id = this.Dialog_nxtid++; 376 this.dTree.add(id, parent, files[i][0].replace(/^.*\//, ''), null, files[i][0]); 377 this.makeNodes(files[i][1], id); 378 } 379 else if(typeof files[i] == 'object') 380 { 381 if(files[i].children) { 382 var id = this.Dialog_nxtid++; 383 } else { 384 var id = Linker.nxtid++; 385 } 386 387 if(files[i].title) var title = files[i].title; 388 else if(files[i].url) var title = files[i].url.replace(/^.*\//, ''); 389 else var title = "no title defined"; 390 if(files[i].url) var link = 'javascript:document.getElementsByName(\'' + this.dialog.getFieldNameByName('href') + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i].url) + '\');document.getElementsByName(\'' + this.dialog.getFieldNameByName('type') + '\')[0].click();document.getElementsByName(\'' + this.dialog.getFieldNameByName('href') + '\')[0].focus();void(0);'; 391 else var link = ''; 392 393 this.dTree.add(id, parent, title, link, title); 394 if(files[i].children) { 395 this.makeNodes(files[i].children, id); 396 } 397 } 398 } 399 }; 400 401 Linker.Dialog.prototype._lc = Linker.prototype._lc; 402 403 Linker.Dialog.prototype.show = function(inputs, param) 404 { 405 if(!this.ready) 406 { 407 var lDialog = this; 408 window.setTimeout(function() {lDialog.show(inputs,param);},100); 409 return; 410 } 411 412 //set refence so we can use it in init 413 this.dialog.lDialog = this; 414 415 this.dialog.show(inputs, param, this.init); 416 }; 417 418 Linker.Dialog.prototype.init = function(inputs, param, dialog) 419 { 420 var lDialog = dialog.lDialog; 421 422 if(!lDialog.dTree) 423 { 424 var dTreeName = HTMLArea.uniq('dTree_'); 425 lDialog.dTree = new dTree(dTreeName, _editor_url + 'plugins/Linker/dTree/'); 426 eval(dTreeName + ' = this.dTree'); 427 428 lDialog.dTree.add(lDialog.Dialog_nxtid++, -1, document.location.host, null, document.location.host); 429 lDialog.makeNodes(lDialog.files, 0); 430 } 431 432 var ddTree = dialog.getElementById('dTree'); 433 if(ddTree.innerHTML == '(the dTree goes in here)') 434 { 435 // Put it in 436 ddTree.innerHTML = lDialog.dTree.toString(); 437 ddTree.style.position = 'absolute'; 438 ddTree.style.left = 1 + 'px'; 439 ddTree.style.top = 0 + 'px'; 440 ddTree.style.overflow = 'auto'; 441 } 442 443 var options = dialog.getElementById('options'); 377 444 options.style.position = 'absolute'; 378 445 options.style.top = 0 + 'px'; … … 381 448 options.style.overflow = 'auto'; 382 449 383 // Hookup the resizer384 this.dialog.onresize = function()385 {386 options.style.height = ddTree.style.height = (parseInt(dialog.height) - dialog.getElementById('h1').offsetHeight) + 'px';387 ddTree.style.width = (parseInt(dialog.width) - 322 ) + 'px';388 }389 390 this.ready = true;391 };392 393 Linker.Dialog.prototype.makeNodes = function(files, parent)394 {395 for(var i = 0; i < files.length; i++)396 {397 if(typeof files[i] == 'string')398 {399 this.dTree.add(Linker.nxtid++, parent,400 files[i].replace(/^.*\//, ''),401 'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i]) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);',402 files[i]);403 }404 else if(files[i].length)405 {406 var id = this.Dialog_nxtid++;407 this.dTree.add(id, parent, files[i][0].replace(/^.*\//, ''), null, files[i][0]);408 this.makeNodes(files[i][1], id);409 }410 else if(typeof files[i] == 'object')411 {412 if(files[i].children) {413 var id = this.Dialog_nxtid++;414 } else {415 var id = Linker.nxtid++;416 }417 418 if(files[i].title) var title = files[i].title;419 else if(files[i].url) var title = files[i].url.replace(/^.*\//, '');420 else var title = "no title defined";421 if(files[i].url) var link = 'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i].url) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);';422 else var link = '';423 424 this.dTree.add(id, parent, title, link, title);425 if(files[i].children) {426 this.makeNodes(files[i].children, id);427 }428 }429 }430 };431 432 Linker.Dialog.prototype._lc = Linker.prototype._lc;433 434 Linker.Dialog.prototype.show = function(inputs, ok, cancel)435 {436 if(!this.ready)437 {438 var lDialog = this;439 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100);440 return;441 }442 443 if(this.ddTree.innerHTML == '')444 {445 this.ddTree.innerHTML = this.dTree._linker_premade;446 }447 448 450 if(inputs.type=='url') 449 451 { 450 this.dialog.getElementById('urltable').style.display = '';451 this.dialog.getElementById('mailtable').style.display = 'none';452 this.dialog.getElementById('anchortable').style.display = 'none';452 dialog.getElementById('urltable').style.display = ''; 453 dialog.getElementById('mailtable').style.display = 'none'; 454 dialog.getElementById('anchortable').style.display = 'none'; 453 455 } 454 456 else if(inputs.type=='anchor') 455 457 { 456 this.dialog.getElementById('urltable').style.display = 'none';457 this.dialog.getElementById('mailtable').style.display = 'none';458 this.dialog.getElementById('anchortable').style.display = '';458 dialog.getElementById('urltable').style.display = 'none'; 459 dialog.getElementById('mailtable').style.display = 'none'; 460 dialog.getElementById('anchortable').style.display = ''; 459 461 } 460 462 else 461 463 { 462 this.dialog.getElementById('urltable').style.display = 'none';463 this.dialog.getElementById('mailtable').style.display = '';464 this.dialog.getElementById('anchortable').style.display = 'none';464 dialog.getElementById('urltable').style.display = 'none'; 465 dialog.getElementById('mailtable').style.display = ''; 466 dialog.getElementById('anchortable').style.display = 'none'; 465 467 } 466 468 467 469 if(inputs.target=='popup') 468 470 { 469 this.dialog.getElementById('popuptable').style.display = '';471 dialog.getElementById('popuptable').style.display = ''; 470 472 } 471 473 else 472 474 { 473 this.dialog.getElementById('popuptable').style.display = 'none';474 } 475 476 var anchor = this.dialog.getElementById('anchor');475 dialog.getElementById('popuptable').style.display = 'none'; 476 } 477 478 var anchor = dialog.getElementById('anchor'); 477 479 for(var i=0;i<anchor.childNodes.length;i++) { 478 480 anchor.removeChild(anchor.childNodes[i]); 479 481 } 480 482 481 var html = this.linker.editor.getHTML();483 var html = lDialog.editor.getHTML(); 482 484 var anchors = new Array(); 483 485 … … 511 513 //if no anchors found completely hide Anchor-Link 512 514 if(anchor.childNodes.length==0) { 513 this.dialog.getElementById('anchorfieldset').style.display = "none";515 dialog.getElementById('anchorfieldset').style.display = "none"; 514 516 } 515 517 516 518 517 519 // Connect the OK and Cancel buttons 518 var dialog = this.dialog; 519 var lDialog = this; 520 if(ok) 521 { 522 this.dialog.getElementById('ok').onclick = ok; 520 if(param.ok) 521 { 522 dialog.getElementById('ok').onclick = param.ok; 523 523 } 524 524 else 525 525 { 526 this.dialog.getElementById('ok').onclick = function() {lDialog.hide();};527 } 528 529 if( cancel)530 { 531 this.dialog.getElementById('cancel').onclick =cancel;526 dialog.getElementById('ok').onclick = function() {lDialog.hide();}; 527 } 528 529 if(param.cancel) 530 { 531 dialog.getElementById('cancel').onclick = param.cancel; 532 532 } 533 533 else 534 534 { 535 this.dialog.getElementById('cancel').onclick = function() { lDialog.hide()}; 536 } 537 538 // Show the dialog 539 this.linker.editor.disableToolbar(['fullscreen','linker']); 540 541 this.dialog.show(inputs); 535 dialog.getElementById('cancel').onclick = function() { lDialog.hide()}; 536 } 542 537 543 538 // Init the sizes 544 this.dialog.onresize();539 dialog.onresize(); 545 540 }; 546 541 547 542 Linker.Dialog.prototype.hide = function() 548 543 { 549 this.linker.editor.enableToolbar();550 544 return this.dialog.hide(); 551 545 }; -
branches/new-dialogs/plugins/SuperClean/super-clean.js
r376 r404 9 9 // See if we can find 'killword' and replace it with superclean 10 10 editor.config.addToolbarElement("superclean", "killword", 0); 11 12 if(editor.config.SuperClean.show_dialog) 13 { 14 editor.addDialog("superclean", SuperClean.Dialog); 15 } 16 11 17 } 12 18 … … 37 43 var doOK = function() 38 44 { 39 var opts = superclean._dialog.hide();40 45 var editor = superclean.editor; 46 var opts = editor.dialogs.superclean.hide(); 47 41 48 42 49 if(opts.word_clean) editor._wordClean(); … … 68 75 { 69 76 var inputs = {}; 70 this. _dialog.show(inputs, doOK);77 this.editor.dialogs.superclean.show(inputs, doOK); 71 78 } 72 79 else … … 159 166 SuperClean.prototype.onGenerate = function() 160 167 { 161 if(this.editor.config.SuperClean.show_dialog && !this._dialog)162 {163 this._dialog = new SuperClean.Dialog(this);164 }165 168 if(this.editor.config.tidy_handler) 166 169 { … … 192 195 193 196 194 SuperClean.Dialog = function ( SuperClean)197 SuperClean.Dialog = function (editor) 195 198 { 196 199 var lDialog = this; 197 200 this.Dialog_nxtid = 0; 198 this. SuperClean = SuperClean;201 this.editor = editor; 199 202 this.id = { }; // This will be filled below with a replace, nifty 200 203 … … 212 215 { 213 216 var lDialog = this; 214 var SuperClean = this.SuperClean;217 var editor = this.editor; 215 218 216 219 if(this.html == false) … … 221 224 222 225 var htmlFilters = ""; 223 for(var filter in this.SuperClean.editor.config.SuperClean.filters)226 for(var filter in editor.config.SuperClean.filters) 224 227 { 225 228 htmlFilters += " <div>\n"; 226 229 htmlFilters += " <input type=\"checkbox\" name=\"["+filter+"]\" id=\"["+filter+"]\" checked />\n"; 227 htmlFilters += " <label for=\"["+filter+"]\">"+ this.SuperClean.editor.config.SuperClean.filters[filter]+"</label>\n";230 htmlFilters += " <label for=\"["+filter+"]\">"+editor.config.SuperClean.filters[filter]+"</label>\n"; 228 231 htmlFilters += " </div>\n"; 229 232 } … … 233 236 234 237 // Now we have everything we need, so we can build the dialog. 235 var dialog = this.dialog = new HTMLArea.Dialog( SuperClean.editor, this.html, 'SuperClean');238 var dialog = this.dialog = new HTMLArea.Dialog(editor, this.html, 'SuperClean'); 236 239 237 240 this.ready = true; … … 271 274 272 275 // Show the dialog 273 this. SuperClean.editor.disableToolbar(['fullscreen','SuperClean']);276 this.editor.disableToolbar(['fullscreen','SuperClean']); 274 277 275 278 this.dialog.show(inputs); … … 281 284 SuperClean.Dialog.prototype.hide = function() 282 285 { 283 this. SuperClean.editor.enableToolbar();286 this.editor.enableToolbar(); 284 287 return this.dialog.hide(); 285 288 };
