/[drupal]/contributions/modules/field_spotter/field_spotter.js
ViewVC logotype

Contents of /contributions/modules/field_spotter/field_spotter.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Jun 13 07:42:21 2007 UTC (2 years, 5 months ago) by unconed
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
File MIME type: text/javascript
Adding Field Spotter module. A simple JS tool to help you identify fields in forms (and other forms api structures in the future). (Drupal 6)
1 String.prototype.text2html = function () {
2 return this.replace('&', '&')
3 .replace('<', '&lt;')
4 .replace('"', '&quot;')
5 .replace(/^\s+/g, '')
6 .replace(/\s+$/g, '')
7 .replace('\n', '<br />');
8 };
9
10 if (Drupal.jsEnabled) {
11 $(document).ready(function () {
12 var enabled = 0;
13 var toggle = function () {
14 enabled = 1 - enabled;
15 $('input', this).attr('checked', enabled ? 'checked' : '');
16 };
17 $('<div id="field-spotter-toggle"><input type="checkbox" />Field spotter</div>')
18 .appendTo($('body'))
19 .click(toggle);
20 $('span.field-spotter').each(function () {
21 var text = '&lt;?php print drupal_render($'+ $(this).attr('formkey').text2html() +'); ?&gt;';
22 var label = $('<span style="display: none" class="field-label field-tip">'+ text +'</span>').prependTo(this);
23
24 $(this)
25 .mouseover(function () { if (enabled) { $(label).show(); } })
26 .mouseout(function () { if (enabled) { $(label).hide(); } });
27 });
28 });
29 }

  ViewVC Help
Powered by ViewVC 1.1.2