Advertisement
Guest User

wp-tooltip quick-fix

a guest
Sep 17th, 2011
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Insert a Tooltip</title>
  5. <?php $wproot = dirname(dirname(dirname(dirname(dirname($_SERVER['PHP_SELF']))))); ?><br />
  6. <!--<style type='text/css' src='/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css'></style> --bn-->
  7. <style type='text/css' src='<?php echo $wproot; ?>/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css'></style>
  8. <style type='text/css'>
  9. body { background: #f1f1f1; }
  10. #button-dialog { }
  11. #button-dialog div { padding: 10px 0; }
  12. #button-dialog label { display: block; margin: 0 8px 8px 0; color: #333; }
  13. #button-dialog input[type=text] { display: block; padding: 3px 5px; width: 80%; }
  14. #button-dialog input[type=submit] { padding: 5px; }
  15. </style>
  16.  
  17. <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js'></script>
  18. <!--<script type='text/javascript' src='/wp-includes/js/tinymce/tiny_mce_popup.js'></script> --bn-->
  19. <script type='text/javascript' src='<?php echo $wproot; ?>/wp-includes/js/tinymce/tiny_mce_popup.js'></script>
  20.  
  21. <script type="text/javascript">
  22. jQuery(document).ready(function() {
  23. jQuery('form').submit(function(e) {
  24. ButtonDialog.insert(ButtonDialog.local_ed)
  25.  
  26. e.preventDefault();
  27. });
  28.  
  29. var ButtonDialog = {
  30. local_ed : 'ed',
  31. init : function(ed) {
  32. ButtonDialog.local_ed = ed;
  33. tinyMCEPopup.resizeToInnerSize();
  34. },
  35. insert : function insertButton(ed) {
  36. // Try and remove existing style / blockquote
  37. tinyMCEPopup.execCommand('mceRemoveNode', false, null);
  38.  
  39. // set up variables to contain our input values
  40. var content = jQuery('input[name=tooltip]').val();
  41. var text = jQuery('input[name=text]').val();
  42. var url = jQuery('input[name=url]').val();
  43.  
  44. var output = '';
  45.  
  46. // setup the output of our shortcode
  47. output = '[tooltip ';
  48. output += 'content="' + content + '" ';
  49. output += 'url="' + url + '" ';
  50.  
  51. // check to see if the TEXT field is blank
  52. if(text) {
  53. output += ']'+ text + '[/tooltip]';
  54. }
  55. // if it is blank, use the selected text, if present
  56. else {
  57. output += ']'+ButtonDialog.local_ed.selection.getContent() + '[/tooltip]';
  58. }
  59. tinyMCEPopup.execCommand('mceReplaceContent', false, output);
  60.  
  61. // Return
  62. tinyMCEPopup.close();
  63.  
  64. return false
  65. }
  66. };
  67. tinyMCEPopup.onInit.add(ButtonDialog.init, ButtonDialog);
  68. });
  69. </script>
  70. </head>
  71. <body>
  72. <?php // echo $wproot = dirname(dirname(dirname(dirname(dirname($_SERVER['PHP_SELF']))))); ?><br />
  73. <div id="button-dialog">
  74. <!-- <form action="/" method="get" accept-charset="utf-8"> --bn-->
  75. <form action="<?php echo $wproot; ?>" method="get" accept-charset="utf-8">
  76. <div>
  77. <label for="tooltip">Tooltip Content</label>
  78. <input type="text" name="tooltip" value="" id="tooltip" />
  79. </div>
  80.  
  81. <div>
  82. <label for="text">Text (Leave blank if text is selected)</label>
  83. <input type="text" name="text" value="" id="text" />
  84. </div>
  85.  
  86. <div>
  87. <label for="url">URL (Optional)</label>
  88. <input type="text" name="url" value="" id="url" />
  89. </div>
  90.  
  91. <div>
  92. <input type='submit' value='Add a Tooltip' />
  93. </div>
  94. </form>
  95. </div>
  96. </body>
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement