2014-10-06 20:23:59 +02:00
|
|
|
define(["jquery"], function ($) {
|
|
|
|
$.fn.hasScrollBar = function() {
|
|
|
|
if (!$.contains(document, this.get(0))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(this.parent().height() < this.get(0).scrollHeight) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-07 22:18:44 +02:00
|
|
|
return false;
|
2014-10-06 20:23:59 +02:00
|
|
|
};
|
2014-10-13 21:15:25 +02:00
|
|
|
|
|
|
|
$.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;
|
|
|
|
};
|
2014-10-13 22:02:55 +02:00
|
|
|
|
|
|
|
var utils = {
|
|
|
|
// Translation machinery
|
|
|
|
// ---------------------
|
|
|
|
__: $.proxy(function (str) {
|
|
|
|
// Translation factory
|
|
|
|
if (this.i18n === undefined) {
|
|
|
|
this.i18n = locales.en;
|
|
|
|
}
|
|
|
|
var t = this.i18n.translate(str);
|
|
|
|
if (arguments.length>1) {
|
|
|
|
return t.fetch.apply(t, [].slice.call(arguments,1));
|
|
|
|
} else {
|
|
|
|
return t.fetch();
|
|
|
|
}
|
|
|
|
}, this),
|
|
|
|
|
|
|
|
___: function (str) {
|
|
|
|
/* XXX: This is part of a hack to get gettext to scan strings to be
|
|
|
|
* translated. Strings we cannot send to the function above because
|
|
|
|
* they require variable interpolation and we don't yet have the
|
|
|
|
* variables at scan time.
|
|
|
|
*
|
|
|
|
* See actionInfoMessages
|
|
|
|
*/
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return utils;
|
2014-10-06 20:23:59 +02:00
|
|
|
});
|