Changeset 382347
- Timestamp:
- 05/08/2011 08:10:13 AM (15 years ago)
- Location:
- prompty/trunk
- Files:
-
- 4 edited
-
prompty.js (modified) (8 diffs)
-
prompty.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
test.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
prompty/trunk/prompty.js
r381971 r382347 18 18 19 19 var prompty = {}; 20 prompty.str = null;21 20 prompty.target = null; 22 21 prompty.data = null; 23 prompty.prompts = ['% ', '# ', '> ' ];22 prompty.prompts = ['% ', '# ', '> ', '$ ']; 24 23 prompty.speed = 100; 24 prompty.buttonIdPrefix = '_promtpy:'; 25 25 prompty.buttons = []; 26 prompty.contents = []; 27 prompty.isIE = navigator.appName == 'Microsoft Internet Explorer'; 26 28 27 29 prompty.style = {}; … … 30 32 prompty.style.color = '#999999'; 31 33 prompty.style.backgroundColor = '#ffffff'; 32 prompty.style.font = '8pt courier, helvetica,arial,sans-serif';34 prompty.style.font = '8pt courier,sans-serif'; 33 35 prompty.style.innerHTML = '>Play'; 34 35 36 36 37 prompty.setup = function() … … 39 40 for (var i=0; i<elems.length; i++) 40 41 { 41 if ( /prompty/.test(elems[i].className))42 if (/prompty/.test(elems[i].className)) 42 43 { 43 // elems[i].onclick = function()44 // {45 // prompty.hideButtons();46 // prompty.start(this);47 // };48 44 var pos = prompty.getPosition(elems[i]); 49 var label = document.createElement('div'); 50 label.style.position = 'absolute'; 51 label.style.top = pos.y + 'px'; 52 label.style.left = pos.x + 'px'; 53 label.style.padding = prompty.style.padding; 54 label.style.border = prompty.style.border; 55 label.style.color = prompty.style.color; 56 label.style.backgroundColor = prompty.style.backgroundColor; 57 label.style.cursor = 'pointer'; 58 label.style.font = prompty.style.font; 59 label.innerHTML = prompty.style.innerHTML; 60 label.onclick = function() 45 var button = document.createElement('div'); 46 button.style.position = 'absolute'; 47 button.style.top = pos.y + 'px'; 48 button.style.left = pos.x + 'px'; 49 button.style.padding = prompty.style.padding; 50 button.style.border = prompty.style.border; 51 button.style.color = prompty.style.color; 52 button.style.backgroundColor = prompty.style.backgroundColor; 53 button.style.cursor = 'pointer'; 54 button.style.font = prompty.style.font; 55 button.innerHTML = prompty.style.innerHTML; 56 button.id = prompty.buttonIdPrefix + i; 57 button.onclick = function() 61 58 { 62 59 prompty.hideButtons(); 63 prompty.start(this .nextSibling);60 prompty.start(this); 64 61 }; 65 elems[i].parentNode.insertBefore(label, elems[i]); 66 prompty.buttons.push(label); 62 elems[i].parentNode.insertBefore(button, elems[i]); 63 // store all the button elements for show/hide buttons. 64 prompty.buttons.push(button); 65 // store all the pre tag text contents. 66 prompty.contents.push(elems[i].textContent ? elems[i].textContent : elems[i].innerText); 67 67 } 68 68 } … … 83 83 prompty.start = function(elem) 84 84 { 85 prompty.str = elem.textContent;86 prompty.target = elem ;87 prompty.target.innerHTML = ''; 88 prompty.data = prompty.parse(prompty. str);85 var idx = elem.id.replace(prompty.buttonIdPrefix, ''); 86 prompty.target = elem.nextSibling; // target pre tag 87 prompty.target.innerHTML = ''; // clear the pre tag contents 88 prompty.data = prompty.parse(prompty.contents[idx]); 89 89 prompty.render(); 90 90 } … … 92 92 prompty.parse = function(str) 93 93 { 94 var lines = str.split('\n'); // line feed letter itself will be removed here. 94 var lfstr = prompty.isIE ? '<br/>' : '\n'; 95 var lines = str.split('\n'); 95 96 var data = []; 96 97 … … 98 99 { 99 100 var p = prompty.isPrompt(lines[i]); 100 var lf = (i==lines.length - 1) ? '' : '\n'; 101 if (p==null) 102 { 103 data.push(lines[i] + lf); 104 } 105 else 101 var lf = (i==lines.length - 1 && !prompty.isIE ) ? '' : lfstr; 102 if (p) 106 103 { 107 104 data.push(p); … … 110 107 data = data.concat(chars); 111 108 data.push(lf); 109 } 110 else 111 { 112 data.push(lines[i] + lf); 112 113 } 113 114 } … … 137 138 prompty.getPosition = function (elem) 138 139 { 139 var left = top = 0;140 var left = 0, top = 0; 140 141 if (elem.offsetParent) 141 142 { -
prompty/trunk/prompty.php
r381994 r382347 4 4 Plugin URI: http://wordpress.org/extend/plugins/prompty/ 5 5 Description: This plugin adds the prompt-like effect on the pre tag contents in your post. 6 Version: 1. 06 Version: 1.1 7 7 Author: Kei Saito 8 8 Author URI: … … 64 64 // as prompt lines, you can modify the line like following. 65 65 // 66 // prompty.prompts = ['% ', '# ', '> ', ' SQL> '];66 // prompty.prompts = ['% ', '# ', '> ', '$ ', 'SQL> ']; 67 67 // 68 prompty.prompts = ['% ', '# ', '> ' ];68 prompty.prompts = ['% ', '# ', '> ', '$ ' ]; 69 69 70 70 // You can change the speed here. … … 83 83 prompty.style.color = '#999999'; 84 84 prompty.style.backgroundColor = '#ffffff'; 85 prompty.style.font = '8pt courier, helvetica,arial,sans-serif';85 prompty.style.font = '8pt courier,sans-serif'; 86 86 prompty.style.innerHTML = '>Play'; 87 87 -
prompty/trunk/readme.txt
r381995 r382347 5 5 Requires at least: 2.7.0 6 6 Tested up to: 3.1.2 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 9 9 This plugin adds the prompt-like effect on the pre tag contents in your post. … … 48 48 Please edit the `prompty.php` with the plugin editor for all the customizations. 49 49 50 = Buttons are not positioned/aligned correctly = 51 I see some small alignment issues especially on IE. 52 Those are known issues and I will fix in later release. 53 50 54 == Screenshots == 51 55 … … 54 58 55 59 == Changelog == 60 = 1.1 = 61 * Fixed IE issues. 62 56 63 = 1.0 = 57 64 * Initinal version. 58 65 59 66 == Upgrade Notice == 60 No upgrade notice here since no previous versions.61 67 -
prompty/trunk/test.html
r381971 r382347 22 22 [scott@server1] % pwd 23 23 /home/paul/dev 24 25 24 26 25 27 </pre>
Note: See TracChangeset
for help on using the changeset viewer.