All Downloads are FREE. Search and download functionalities are using the official Maven repository.

portal.default.redbox.javascript-widgets.widgets.js Maven / Gradle / Ivy

There is a newer version: 1.10.2
Show newest version

var widgets={forms:[], globalObject:this};


(function($){
  var formClassName = "widget-form";

  if(!$.fn.dataset){     // if dataset function not defined
      $.fn.dataset=function(name, value){return this.attr("data-"+name, value);};
  }
  if(!$.fn.getDatasets){
      $.fn.getDatasets=function(ff){
          var atts, d={}, item, name, value;
          if(this[0]){
            atts=this[0].attributes;
            for(var i=0,l=atts.length; ia+b")(3, 2)   or fn("$1+$2")(3, 2)
      var re=/^([\w$,\s]+)-\>/, re2=/;|}/;
      var a, b;
      if(re.test(s)){
          b=s.replace(re, function(_, a1){a=a1;return "";});
          if(!re2.test(b)) b = "return " + b;
      } else {
          a = "$1,$2,$3,$4";
          b=s;
      }
      return new Function(a, b);
  }
  _fn = fn;

  var _idNum=1;
  function getIdNum(){
      return _idNum++;
  }
  gId = getIdNum;

  function trim(s){
    return $.trim(s);
    return s.replace(/^\s+|\s+$/g, "")
  }

  function keys(d, f){
    var keys=[], k;
    for(k in d){
        if(!f || f(k)){
            keys.push(k);
        }
    }
    return keys;
  }
  function values(d){
      var values=[], k;
      for(k in d){values.push(d[k]);}
      return values;
  }

  function getById(id){
    var e=document.getElementById(id);
    if(e){
        return $(e);
    }else{
        return $("#_doesNotExist_.-_");
    }
  }

  function reduce(c, func, i){
    if(!i)i=0;
    $.each(c, function(k, v){
      i = func(v, i);
    });
    return i;
  }

  function any(c, func){
    var flag=false;
    $.each(c, function(k, v){
      if(func(v)) flag=true;
    });
    return flag;
  }

  function isFunction(func){
      return typeof(func)==="function";
  }

  function callIfFunction(func, a, b, c){
      if(typeof(func)==="function"){
          try{ func(a, b, c); }catch(e){}
      }
  }

  function messageBox(msg){
      var msgBox=messageBox.msgBox;
      if(!msgBox){  // setup
          var div, i;
          msgBox = $("