Sha256: 8d8a6d4399e0c76a9890303f386b0dd1228badb6fe386808cb7ffdfe7b5a990c

Contents?: true

Size: 848 Bytes

Versions: 9

Compression:

Stored size: 848 Bytes

Contents

// Underline text in elements. Especially useful for accesskeys.
// Written by Daniel Mendler
(function($) {
    "use strict";

    $.extend($.fn, {
	// Underline text
	underlineText: function(str) {
	    this.each(function() {
		var elem = $(this), text, i;
		if (elem.children().size() === 0) {
		    text = elem.text();
		    i = text.toLowerCase().indexOf(str.toLowerCase());
		    if (i >= 0) {
			elem.html(text.substr(0, i) + '<span style="text-decoration: underline">' +
			          text.substr(i, str.length) + '</span>' + text.substr(i+str.length));
		    }
		} else {
		    elem.children().underlineText(str);
		}
	    });
	},
	// Underline access key
	underlineAccessKey: function() {
	    this.each(function() {
		var key = $(this).attr('accesskey');
		if (key) {
		    $(this).underlineText(key);
		}
	    });
	}
    });
})(jQuery);

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
olelo-0.9.15 static/script/16-olelo.underliner.js
olelo-0.9.14 static/script/16-olelo.underliner.js
olelo-0.9.13 static/script/16-olelo.underliner.js
olelo-0.9.12 static/script/16-olelo.underliner.js
olelo-0.9.11 static/script/16-olelo.underliner.js
olelo-0.9.10 static/script/16-olelo.underliner.js
olelo-0.9.9 static/script/16-olelo.underliner.js
olelo-0.9.8 static/script/16-olelo.underliner.js
olelo-0.9.7 static/script/16-olelo.underliner.js