12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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;
- };
- 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;
- });
|