Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

link.html 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  7. <script type="text/javascript" src="../internal.js"></script>
  8. <style type="text/css">
  9. *{margin:0;padding:0;color: #838383;}
  10. table{font-size: 12px;margin: 13px 23px 0px;line-height: 30px}
  11. tr{height:50px}
  12. tr.tr-txt{height: 40px;}
  13. td{width: 170px}
  14. .txt{width:290px;height:30px;line-height:21px;border:1px solid #d7d7d7;margin-left: 4px;border-radius: 5px;}
  15. </style>
  16. </head>
  17. <body>
  18. <table>
  19. <tr>
  20. <td><label for="text"> <var id="lang_input_text"></var></label></td>
  21. <td><input class="txt" id="text" type="text" disabled="true"/></td>
  22. </tr>
  23. <tr>
  24. <td><label for="href"> <var id="lang_input_url"></var></label></td>
  25. <td><input class="txt" id="href" type="text" /></td>
  26. </tr>
  27. <tr>
  28. <td><label for="title"> <var id="lang_input_title"></var></label></td>
  29. <td><input class="txt" id="title" type="text"/></td>
  30. </tr>
  31. <tr class="tr-txt">
  32. <td colspan="2">
  33. <label for="target"><var id="lang_input_target"></var></label>
  34. <input id="target" type="checkbox"/>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td colspan="2" id="msg"></td>
  39. </tr>
  40. </table>
  41. <script type="text/javascript">
  42. editor.setOpt('allowLinkProtocols', ['http:', 'https:', '#', '/', 'ftp:', 'mailto:', 'tel:']);
  43. var allowLinkProtocols = editor.getOpt('allowLinkProtocols');
  44. var range = editor.selection.getRange(),
  45. link = range.collapsed ? editor.queryCommandValue( "link" ) : editor.selection.getStart(),
  46. url,
  47. text = $G('text'),
  48. rangeLink = domUtils.findParentByTagName(range.getCommonAncestor(),'a',true),
  49. orgText;
  50. link = domUtils.findParentByTagName( link, "a", true );
  51. if(link){
  52. url = utils.html(link.getAttribute( '_href' ) || link.getAttribute( 'href', 2 ));
  53. if(rangeLink === link && !link.getElementsByTagName('img').length){
  54. text.removeAttribute('disabled');
  55. orgText = text.value = link[browser.ie ? 'innerText':'textContent'];
  56. }else{
  57. text.setAttribute('disabled','true');
  58. text.value = lang.validLink;
  59. }
  60. }else{
  61. if(range.collapsed){
  62. text.removeAttribute('disabled');
  63. text.value = '';
  64. }else{
  65. text.setAttribute('disabled','true');
  66. text.value = lang.validLink;
  67. }
  68. }
  69. $G("title").value = url ? link.title : "";
  70. $G("href").value = url ? url: '';
  71. $G("target").checked = url && link.target == "_blank" ? true : false;
  72. $focus($G("href"));
  73. function handleDialogOk(){
  74. var href =$G('href').value.replace(/^\s+|\s+$/g, '');
  75. if(href){
  76. if(!hrefStartWith(href, allowLinkProtocols)) {
  77. href = "http://" + href;
  78. }
  79. var obj = {
  80. 'href' : href,
  81. 'target' : $G("target").checked ? "_blank" : '_self',
  82. 'title' : $G("title").value.replace(/^\s+|\s+$/g, ''),
  83. '_href':href
  84. };
  85. //修改链接内容的情况太特殊了,所以先做到这里了
  86. //todo:情况多的时候,做到command里
  87. if(orgText && text.value != orgText){
  88. link[browser.ie ? 'innerText' : 'textContent'] = obj.textValue = text.value;
  89. range.selectNode(link).select()
  90. }
  91. if(range.collapsed){
  92. obj.textValue = text.value;
  93. }
  94. editor.execCommand('link',utils.clearEmptyAttrs(obj) );
  95. dialog.close();
  96. }
  97. }
  98. dialog.onok = handleDialogOk;
  99. $G('href').onkeydown = $G('title').onkeydown = function(evt){
  100. evt = evt || window.event;
  101. if (evt.keyCode == 13) {
  102. handleDialogOk();
  103. return false;
  104. }
  105. };
  106. $G('href').onblur = function(){
  107. if(!hrefStartWith(this.value, allowLinkProtocols)){
  108. $G("msg").innerHTML = "<span style='color: red'>"+lang.httpPrompt+"</span>";
  109. }else{
  110. $G("msg").innerHTML = "";
  111. }
  112. };
  113. function hrefStartWith(href,arr){
  114. href = href.replace(/^\s+|\s+$/g, '');
  115. for(var i=0,ai;ai=arr[i++];){
  116. if(href.indexOf(ai)==0){
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. </script>
  123. </body>
  124. </html>