Sha256: 021aeb6ee8a929d7e214aa55212c4125d553c02c449ec6ea2cd90491f34d86d6

Contents?: true

Size: 691 Bytes

Versions: 5

Compression:

Stored size: 691 Bytes

Contents

/*!
 *  Highlight areas of text
 *  Copyright 2012, Swirrl IT Limited
 *  All rights reserved
 */

jQuery.fn.selectText = function(){
    var doc = document;
    var element = this[0];
    if (doc.body.createTextRange) {
        var range = document.body.createTextRange();
        range.moveToElementText(element);
        range.select();
    } else if (window.getSelection) {
        var selection = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(element);
        selection.removeAllRanges();
        selection.addRange(range);
    }
};

$(function(){
    $('.click-to-select').click(function(){
      $(this).selectText();
    });
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
publish_my_data-1.0.4 app/assets/javascripts/publish_my_data/select_text.js
publish_my_data-1.0.3 app/assets/javascripts/publish_my_data/select_text.js
publish_my_data-1.0.2 app/assets/javascripts/publish_my_data/select_text.js
publish_my_data-1.0.1 app/assets/javascripts/publish_my_data/select_text.js
publish_my_data-1.0.0 app/assets/javascripts/publish_my_data/select_text.js