Changeset 1097
- Timestamp:
- 10/20/08 15:53:08 (5 years ago)
- Location:
- trunk/plugins/Linker
- Files:
-
- 2 modified
-
dialog.html (modified) (4 diffs)
-
pluginMethods.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/Linker/dialog.html
r1078 r1097 4 4 <div id="[options]" > 5 5 <fieldset> 6 <legend><label><input type="radio" name="[type]" id="[type]" value="url" checked="checked" onclick=" 7 document.getElementById('[urltable]').style.display=this.checked?'':'none'; 8 document.getElementById('[mailtable]').style.display=this.checked?'none':''; 9 document.getElementById('[anchortable]').style.display=this.checked?'none':''; 10 " /> <l10n>URL Link</l10n></label></legend> 6 <legend><label><input type="radio" name="[type]" id="[type_url]" value="url" checked="checked" /> 7 <l10n>URL Link</l10n> 8 </label></legend> 11 9 <table id="[urltable]" width="100%"> 12 10 <tr> 13 11 <th><label for="[href]"><l10n>URL:</l10n> </label></th> 14 <td><input type="text" name="[href]" style="width:100%" value="http://www.example.com/" onfocus="if (this.value == 'http://www.example.com/') this.value = '';" /></td>12 <td><input type="text" name="[href]" id="[href]" style="width:100%" value="http://www.example.com/" onfocus="if (this.value == 'http://www.example.com/') this.value = '';" /></td> 15 13 </tr> 16 <tr style="vertical-align: top;" >14 <tr style="vertical-align: top;" id="[target_options]"> 17 15 <th><l10n>Target:</l10n></th> 18 16 <td> 19 <div ><label><input type="radio" name="[target]" value="" onclick="document.getElementById('[popuptable]').style.display='none';" checked="checked" /> <l10n>Ordinary Link</l10n></label></div>20 <div ><label><input type="radio" name="[target]" value="_top" onclick="document.getElementById('[popuptable]').style.display='none';"/> <l10n>Same Window (jump out of frames)</l10n></label></div>21 <div ><label><input type="radio" name="[target]" value="_blank" onclick="document.getElementById('[popuptable]').style.display='none';"/> <l10n>New Window</l10n> </label></div>22 <div >23 <label><input type="radio" name="[target]" value="popup" onclick="document.getElementById('[popuptable]').style.display='';" /> <l10n>Popup Window</l10n> </label>17 <div id="[noTarget]"><label><input type="radio" name="[target]" id="[noTargetRadio]" value="" /> <l10n>Ordinary Link</l10n></label></div> 18 <div id="[sameWindow]"><label><input type="radio" name="[target]" id="[sameWindowRadio]" value="_top" /> <l10n>Same Window (jump out of frames)</l10n></label></div> 19 <div id="[newWindow]"><label><input type="radio" name="[target]" id="[newWindowRadio]" value="_blank" /> <l10n>New Window</l10n> </label></div> 20 <div id="[popupWindow]"> 21 <label><input type="radio" name="[target]" id="[popupWindowRadio]" value="popup" /> <l10n>Popup Window</l10n> </label> 24 22 <div style="padding-left:10px"> 25 23 <table id="[popuptable]"> … … 61 59 </fieldset> 62 60 <fieldset id="[mailtofieldset]"> 63 <legend><label><input type="radio" name="[type]" value="mailto" onclick=" 64 document.getElementById('[mailtable]').style.display=this.checked?'':'none'; 65 document.getElementById('[urltable]').style.display=this.checked?'none':''; 66 document.getElementById('[anchortable]').style.display=this.checked?'none':''; 67 "/> <l10n>Email Link</l10n></label></legend> 61 <legend><label><input type="radio" name="[type]" id="[type_mailto]" value="mailto"/> 62 <l10n>Email Link</l10n> 63 </label></legend> 68 64 <table id="[mailtable]" width="100%"> 69 65 <tr> 70 66 <th><label for="[to]"><l10n>Email Address:</l10n> </label></th> 71 <td><input type="text" name="[to]" style="width:100%" value="alice@example.com" onfocus="if (this.value == 'alice@example.com') this.value = '';" /></td>67 <td><input type="text" name="[to]" id="[to]" style="width:100%" value="alice@example.com" onfocus="if (this.value == 'alice@example.com') this.value = '';" /></td> 72 68 </tr> 73 69 <tr> … … 83 79 84 80 <fieldset id="[anchorfieldset]"> 85 <legend><label><input type="radio" name="[type]" value="anchor" onclick=" 86 document.getElementById('[urltable]').style.display=this.checked?'none':''; 87 document.getElementById('[mailtable]').style.display=this.checked?'none':''; 88 document.getElementById('[anchortable]').style.display=this.checked?'':'none'; 89 "/> <l10n>Anchor-Link</l10n></label></legend> 81 <legend><label><input type="radio" name="[type]" id="[type_anchor]" value="anchor"/> 82 <l10n>Anchor-Link</l10n> 83 </label></legend> 90 84 <table id="[anchortable]" width="100%"> 91 85 <tr> … … 101 95 <div style="text-align:right"> 102 96 <input type="button" id="[ok]" value="_(OK)" /> 103 <input type="button" id="[clear]" value="_(Remove Link)" onclick="this.form['[href]'].value='';this.form['[to]'].value='';document.getElementById('[ok]').click();"/>97 <input type="button" id="[clear]" value="_(Remove Link)" /> 104 98 <input type="button" id="[cancel]" value="_(Cancel)" /> 105 99 </div> 106 100 </div> 107 101 </div> 102 103 -
trunk/plugins/Linker/pluginMethods.js
r1078 r1097 269 269 var files = this.linker.files; 270 270 271 var html = Linker.html;272 273 271 // Now we have everything we need, so we can build the dialog. 274 272 var dialog = this.dialog = new Xinha.Dialog(linker.editor, Linker.html, 'Linker',{width:600,height:400}); … … 325 323 lDialog.ddTree.style.width = w + 'px'; 326 324 } 325 326 // Set the onclick handlers for the link type radio buttons 327 self = this; 328 this.dialog.getElementById('type_url').onclick = function() { 329 self.showOptionsForType('url'); 330 }; 331 this.dialog.getElementById('type_mailto').onclick = function() { 332 self.showOptionsForType('mailto'); 333 }; 334 this.dialog.getElementById('type_anchor').onclick = function() { 335 self.showOptionsForType('anchor'); 336 }; 337 338 var hidePopupOptions = function() { 339 self.showOptionsForTarget('none') 340 }; 341 this.dialog.getElementById('noTargetRadio').onclick = hidePopupOptions; 342 this.dialog.getElementById('sameWindowRadio').onclick = hidePopupOptions; 343 this.dialog.getElementById('newWindowRadio').onclick = hidePopupOptions; 344 this.dialog.getElementById('popupWindowRadio').onclick = function() { 345 self.showOptionsForTarget('popup'); 346 }; 347 327 348 this.ready = true; 328 349 ddTree = null; … … 386 407 } 387 408 388 if(inputs.type=='url') 389 { 390 this.dialog.getElementById('urltable').style.display = ''; 391 this.dialog.getElementById('mailtable').style.display = 'none'; 392 this.dialog.getElementById('anchortable').style.display = 'none'; 393 } 394 else if(inputs.type=='anchor') 395 { 396 this.dialog.getElementById('urltable').style.display = 'none'; 397 this.dialog.getElementById('mailtable').style.display = 'none'; 398 this.dialog.getElementById('anchortable').style.display = ''; 399 } 400 else 401 { 402 this.dialog.getElementById('urltable').style.display = 'none'; 403 this.dialog.getElementById('mailtable').style.display = ''; 404 this.dialog.getElementById('anchortable').style.display = 'none'; 405 } 406 407 if(inputs.target=='popup') 408 { 409 this.dialog.getElementById('popuptable').style.display = ''; 410 } 411 else 412 { 413 this.dialog.getElementById('popuptable').style.display = 'none'; 414 } 409 this.showOptionsForType(inputs.type); 410 this.showOptionsForTarget(inputs.target); 415 411 416 412 var anchor = this.dialog.getElementById('anchor'); … … 467 463 } 468 464 469 465 // Disable link targets (all targets available by default) 466 var disabledTargets = this.linker.lConfig.disableTargetTypes; 467 if (typeof disabledTargets == 'undefined') 468 { 469 disabledTargets = []; 470 } 471 else if (typeof disabledTargets == 'string') 472 { 473 disabledTargets = [disabledTargets]; 474 } 475 for (var i=0; i<disabledTargets.length; i++) 476 { 477 this.dialog.getElementById(disabledTargets[i]).style.display = "none"; 478 } 479 if (disabledTargets.length == 3) // only one target option is visible 480 { 481 if (disabledTargets.contains('popupWindow')) 482 { 483 // There's no need to show anything, so hide the entire div 484 this.dialog.getElementById('target_options').style.display = "none"; 485 } 486 else 487 { 488 // Only popups are allowed, hide the radio button 489 this.dialog.getElementById('popupWindowRadio').style.display = "none"; 490 this.showOptionsForTarget('popup'); 491 } 492 } 493 494 var enabledTargets = new Array(); 495 if (!disabledTargets.contains('noTarget')) 496 { 497 enabledTargets.push('noTargetRadio'); 498 } 499 if (!disabledTargets.contains('sameWindow')) 500 { 501 enabledTargets.push('sameWindowRadio'); 502 } 503 if (!disabledTargets.contains('newWindow')) 504 { 505 enabledTargets.push('newWindowRadio'); 506 } 507 if (!disabledTargets.contains('popupWindow')) 508 { 509 enabledTargets.push('popupWindowRadio'); 510 } 511 470 512 // if we're not editing an existing link, hide the remove link button 471 513 if (inputs.href == 'http://www.example.com/' && inputs.to == 'alice@example.com') { 472 514 this.dialog.getElementById('clear').style.display = "none"; 473 515 } 474 else { 475 this.dialog.getElementById('clear').style.display = ""; 516 else { // 517 var clearBtn = this.dialog.getElementById('clear'); 518 clearBtn.style.display = ""; 519 if (ok) 520 { 521 clearBtn.onclick = function() { lDialog.removeLink(ok); }; 522 } 476 523 } 477 524 // Connect the OK and Cancel buttons … … 501 548 this.dialog.show(inputs); 502 549 550 // If we set the default radio button *before* we call dialog.show() 551 // it doesn' work... 552 var targetSelected = false; 553 for (var i=0; i<enabledTargets.length; i++) 554 { 555 console.log(this.dialog.getElementById(enabledTargets[i])); 556 console.log("is checked: " + this.dialog.getElementById(enabledTargets[i]).checked); 557 if (this.dialog.getElementById(enabledTargets[i]).checked == true) 558 { 559 targetSelected = true; 560 break; 561 } 562 } 563 // If no target is selected, select the first one by default 564 if (!targetSelected && enabledTargets.length > 0) 565 { 566 this.dialog.getElementById(enabledTargets[0]).checked = true; 567 } 568 503 569 // Init the sizes 504 570 this.dialog.onresize(); … … 510 576 return this.dialog.hide(); 511 577 }; 578 579 Linker.Dialog.prototype.removeLink = function(applyFunc) 580 { 581 this.dialog.getElementById('href').value = ""; 582 this.dialog.getElementById('to').value = ""; 583 584 return applyFunc(); 585 }; 586 587 Linker.Dialog.prototype.showOptionsForType = function(type) 588 { 589 var urlOptions = this.dialog.getElementById('urltable'); 590 var mailtoOptions = this.dialog.getElementById('mailtable'); 591 var anchorOptions = this.dialog.getElementById('anchortable'); 592 593 if (type == 'anchor') 594 { 595 anchorOptions.style.display = ''; 596 urlOptions.style.display = 'none'; 597 mailtoOptions.style.display = 'none'; 598 } 599 else if (type == 'mailto') 600 { 601 mailtoOptions.style.display = ''; 602 urlOptions.style.display = 'none'; 603 anchorOptions.style.display = 'none'; 604 } 605 else 606 { 607 urlOptions.style.display = ''; 608 mailtoOptions.style.display = 'none'; 609 anchorOptions.style.display = 'none'; 610 } 611 }; 612 613 Linker.Dialog.prototype.showOptionsForTarget = function(target) 614 { 615 var popupOptions = this.dialog.getElementById('popuptable'); 616 popupOptions.style.display = target == 'popup' ? '' : 'none'; 617 };
