| 1 |
String.prototype.text2html = function () {
|
| 2 |
return this.replace('&', '&')
|
| 3 |
.replace('<', '<')
|
| 4 |
.replace('"', '"')
|
| 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 = '<?php print drupal_render($'+ $(this).attr('formkey').text2html() +'); ?>';
|
| 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 |
}
|