Plugin Directory

Changeset 382347


Ignore:
Timestamp:
05/08/2011 08:10:13 AM (15 years ago)
Author:
kei51
Message:

Fixed issues on IE browsers.

Location:
prompty/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • prompty/trunk/prompty.js

    r381971 r382347  
    1818
    1919var prompty = {};
    20 prompty.str = null;
    2120prompty.target = null;
    2221prompty.data = null;
    23 prompty.prompts = ['% ', '# ', '> '];
     22prompty.prompts = ['% ', '# ', '> ', '$ '];
    2423prompty.speed = 100;
     24prompty.buttonIdPrefix = '_promtpy:';
    2525prompty.buttons = [];
     26prompty.contents = [];
     27prompty.isIE = navigator.appName == 'Microsoft Internet Explorer';
    2628
    2729prompty.style = {};
     
    3032prompty.style.color = '#999999';
    3133prompty.style.backgroundColor = '#ffffff';
    32 prompty.style.font = '8pt courier,helvetica,arial,sans-serif';
     34prompty.style.font = '8pt courier,sans-serif';
    3335prompty.style.innerHTML = '>Play';
    34 
    3536
    3637prompty.setup = function()
     
    3940  for (var i=0; i<elems.length; i++)
    4041  {
    41     if ( /prompty/.test(elems[i].className))
     42    if (/prompty/.test(elems[i].className))
    4243    {
    43 //      elems[i].onclick = function()
    44 //      {
    45 //        prompty.hideButtons();
    46 //        prompty.start(this);
    47 //      };
    4844      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()
    6158      {
    6259        prompty.hideButtons();
    63         prompty.start(this.nextSibling);
     60        prompty.start(this);
    6461      };
    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);
    6767    }
    6868  }
     
    8383prompty.start = function(elem)
    8484{
    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]);
    8989  prompty.render();
    9090}
     
    9292prompty.parse = function(str)
    9393{
    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');
    9596  var data = [];
    9697 
     
    9899  {   
    99100    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)
    106103    {
    107104      data.push(p);
     
    110107      data = data.concat(chars);
    111108      data.push(lf);
     109    }
     110    else
     111    {
     112      data.push(lines[i] + lf);
    112113    }
    113114  }
     
    137138prompty.getPosition = function (elem)
    138139{
    139   var left = top = 0;
     140  var left = 0, top = 0;
    140141  if (elem.offsetParent)
    141142  {
  • prompty/trunk/prompty.php

    r381994 r382347  
    44Plugin URI: http://wordpress.org/extend/plugins/prompty/
    55Description: This plugin adds the prompt-like effect on the pre tag contents in your post.
    6 Version: 1.0
     6Version: 1.1
    77Author: Kei Saito
    88Author URI:
     
    6464    //  as prompt lines, you can modify the line like following.
    6565  //
    66   //  prompty.prompts = ['% ', '# ', '> ', 'SQL> '];
     66  //  prompty.prompts = ['% ', '# ', '> ', '$ ', 'SQL> '];
    6767  //
    68   prompty.prompts = ['% ', '# ', '> ' ];
     68  prompty.prompts = ['% ', '# ', '> ', '$ ' ];
    6969
    7070    //  You can change the speed here.
     
    8383  prompty.style.color = '#999999';
    8484  prompty.style.backgroundColor = '#ffffff';
    85   prompty.style.font = '8pt courier,helvetica,arial,sans-serif';
     85  prompty.style.font = '8pt courier,sans-serif';
    8686  prompty.style.innerHTML = '&gt;Play';
    8787
  • prompty/trunk/readme.txt

    r381995 r382347  
    55Requires at least: 2.7.0
    66Tested up to: 3.1.2
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88
    99This plugin adds the prompt-like effect on the pre tag contents in your post.
     
    4848Please edit the `prompty.php` with the plugin editor for all the customizations.
    4949
     50= Buttons are not positioned/aligned correctly =
     51I see some small alignment issues especially on IE.
     52Those are known issues and I will fix in later release.
     53
    5054== Screenshots ==
    5155
     
    5458
    5559== Changelog ==
     60= 1.1 =
     61* Fixed IE issues.
     62
    5663= 1.0 =
    5764* Initinal version.
    5865
    5966== Upgrade Notice ==
    60 No upgrade notice here since no previous versions.
    6167
  • prompty/trunk/test.html

    r381971 r382347  
    2222[scott@server1] % pwd
    2323/home/paul/dev
     24
     25
    2426
    2527</pre>
Note: See TracChangeset for help on using the changeset viewer.