1234567891011121314151617181920212223242526272829 |
- define(["jquery"], function ($) {
- $.fn.hasScrollBar = function() {
- if (!$.contains(document, this.get(0))) {
- return false;
- }
- if(this.parent().height() < this.get(0).scrollHeight) {
- return true;
- }
- return false;
- };
- $.fn.addHyperlinks = function () {
- if (this.length > 0) {
- this.each(function (i, obj) {
- var x = $(obj).html();
- var list = x.match(/\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<]{2,200}\b/g );
- if (list) {
- for (i=0; i<list.length; i++) {
- var prot = list[i].indexOf('http://') === 0 || list[i].indexOf('https://') === 0 ? '' : 'http://';
- var escaped_url = encodeURI(decodeURI(list[i])).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
- x = x.replace(list[i], "<a target='_blank' href='" + prot + escaped_url + "'>"+ list[i] + "</a>" );
- }
- }
- $(obj).html(x);
- });
- }
- return this;
- };
- });
|