diff --git a/js/halfstyle.js b/js/halfstyle.js
index 2bad267..08353d7 100644
--- a/js/halfstyle.js
+++ b/js/halfstyle.js
@@ -3,29 +3,31 @@
* Copyright 2014 Arbel Hakopian
* Licensed under MIT (https://github.com/arbelh/HalfStyle/blob/master/license.md)
*/
-jQuery(function($) {
- var halfstyle_text, halfstyle_chars, $halfstyle_el, halfstyle_i, halfstyle_output, halfstyle_style;
+(function () {
+ var nodes = document.querySelectorAll('.textToHalfStyle');
- // Iterate over all class occurrences
- $('.textToHalfStyle').each(function(idx, halfstyle_el) {
- $halfstyle_el = $(halfstyle_el);
- halfstyle_style = $halfstyle_el.data('halfstyle');
- halfstyle_text = $halfstyle_el.text();
- halfstyle_chars = halfstyle_text.split('');
+ Array.prototype.forEach.call(nodes, function (node, index) {
+ var halfStyle = node.getAttribute('data-halfstyle');
+ var text = node.innerText || node.textContent;
+ var chars = text.split('');
+ var styles = [
+ 'position: absolute !important',
+ 'clip: rect(1px 1px 1px 1px)',
+ 'clip: rect(1px, 1px, 1px, 1px)'
+ ].join(';');
- // Set the screen-reader text
- $halfstyle_el.html('' + halfstyle_text + '');
+ var output = '' + text + '';
- // Reset output for appending
- halfstyle_output = '';
+ for (var i = 0; i < chars.length; i++) {
+ var attributes = [
+ 'aria-hidden="true"',
+ 'class="halfStyle ' + halfStyle + '"',
+ 'data-content="' + chars[i] + '"'
+ ].join(' ');
- // Iterate over all chars in the text
- for (halfstyle_i = 0; halfstyle_i < halfstyle_chars.length; halfstyle_i++) {
- // Create a styled element for each character and append to container
- halfstyle_output += '' + halfstyle_chars[halfstyle_i] + '';
+ output += '' + chars[i] + '';
}
-
- // Write to DOM only once
- $halfstyle_el.append(halfstyle_output);
+
+ node.innerHTML = output;
});
-});
\ No newline at end of file
+}());