alecpl
2011-07-05 9d195d6e82c3be4e543a47ef8ff1e9fe54bd0939
program/js/common.js
@@ -55,16 +55,13 @@
  this.ie7 = (this.dom && this.appver.indexOf('MSIE 7')>0);
  this.ie6 = (this.dom && !this.ie8 && !this.ie7 && this.appver.indexOf('MSIE 6')>0);
  this.mz = (this.dom && this.ver >= 5);  // (this.dom && this.product=='Gecko')
  this.ns = ((this.ver < 5 && this.name == 'Netscape') || (this.ver >= 5 && this.vendor.indexOf('Netscape') >= 0));
  this.ns6 = (this.ns && parseInt(this.vendver) == 6);  // (this.mz && this.ns) ? true : false;
  this.ns7 = (this.ns && parseInt(this.vendver) == 7);  // this.agent.indexOf('Netscape/7')>0);
  this.chrome = (this.agent_lc.indexOf('chrome') > 0);
  this.safari = (!this.chrome && (this.agent_lc.indexOf('safari') > 0 || this.agent_lc.indexOf('applewebkit') > 0));
  this.mz = (this.dom && !this.ie && !this.ns && !this.chrome && !this.safari && this.agent.indexOf('Mozilla') >= 0);
  this.konq   = (this.agent_lc.indexOf('konqueror') > 0);
  this.iphone = (this.safari && this.agent_lc.indexOf('iphone') > 0);
  this.ipad = (this.safari && this.agent_lc.indexOf('ipad') > 0);
  this.opera = window.opera ? true : false;
  if (this.opera && window.RegExp)
@@ -81,7 +78,7 @@
    this.vendver = (/khtml\/([0-9\.]+)/.test(this.agent_lc)) ? parseFloat(RegExp.$1) : 0;
  // get real language out of safari's user agent
  if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/.test(this.agent_lc)))
  if (this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/.test(this.agent_lc)))
    this.lang = RegExp.$1;
  this.dhtml = ((this.ie4 && this.win) || this.ie5 || this.ie6 || this.ns4 || this.mz);
@@ -129,10 +126,6 @@
      classname += ' iphone';
    else if (this.ipad)
      classname += ' ipad';
    else if (this.ns6)
      classname += ' netscape6';
    else if (this.ns7)
      classname += ' netscape7';
    if (document.documentElement)
      document.documentElement.className += classname;
@@ -354,9 +347,14 @@
          break;
      }
    }
    if (ret)
      delete ret.event;
  }
  this._event_exec = false;
  delete e.event;
  return ret;
}
@@ -385,21 +383,17 @@
      parent = arg.parent,
      obj = document.createElement('DIV');
    with (obj) {
      id = this.name;
      with (style) {
       position = 'absolute';
        visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden';
        left = l+'px';
        top = t+'px';
        if (w)
         width = w.toString().match(/\%$/) ? w : w+'px';
        if (h)
         height = h.toString().match(/\%$/) ? h : h+'px';
        if (z)
          zIndex = z;
     }
    }
    obj.id = this.name;
    obj.style.position = 'absolute';
    obj.style.visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden';
    obj.style.left = l+'px';
    obj.style.top = t+'px';
    if (w)
     obj.style.width = w.toString().match(/\%$/) ? w : w+'px';
    if (h)
     obj.style.height = h.toString().match(/\%$/) ? h : h+'px';
    if (z)
      obj.style.zIndex = z;
    if (parent)
      parent.appendChild(obj);
@@ -493,11 +487,27 @@
      // So, e-mail address should be validated also on server side after idn_to_ascii() use
      //domain_literal = '\\x5b('+dtext+'|'+quoted_pair+')*\\x5d',
      //sub_domain = '('+atom+'|'+domain_literal+')',
      domain = '([^@\\x2e]+\\x2e)+[a-z]{2,}',
      // allow punycode/unicode top-level domain
      domain = '([^@\\x2e]+\\x2e)+([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,})',
      // ICANN e-mail test (http://idn.icann.org/E-mail_test)
      icann_domains = [
        '\\u0645\\u062b\\u0627\\u0644\\x2e\\u0625\\u062e\\u062a\\u0628\\u0627\\u0631',
        '\\u4f8b\\u5b50\\x2e\\u6d4b\\u8bd5',
        '\\u4f8b\\u5b50\\x2e\\u6e2c\\u8a66',
        '\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1\\x2e\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae',
        '\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923\\x2e\\u092a\\u0930\\u0940\\u0915\\u094d\\u0937\\u093e',
        '\\u4f8b\\u3048\\x2e\\u30c6\\u30b9\\u30c8',
        '\\uc2e4\\ub840\\x2e\\ud14c\\uc2a4\\ud2b8',
        '\\u0645\\u062b\\u0627\\u0644\\x2e\\u0622\\u0632\\u0645\\u0627\\u06cc\\u0634\u06cc',
        '\\u043f\\u0440\\u0438\\u043c\\u0435\\u0440\\x2e\\u0438\\u0441\\u043f\\u044b\\u0442\\u0430\\u043d\\u0438\\u0435',
        '\\u0b89\\u0ba4\\u0bbe\\u0bb0\\u0ba3\\u0bae\\u0bcd\\x2e\\u0baa\\u0bb0\\u0bbf\\u0b9f\\u0bcd\\u0b9a\\u0bc8',
        '\\u05d1\\u05f2\\u05b7\\u05e9\\u05e4\\u05bc\\u05d9\\u05dc\\x2e\\u05d8\\u05e2\\u05e1\\u05d8'
      ],
      icann_addr = 'mailtest\\x40('+icann_domains.join('|')+')',
      word = '('+atom+'|'+quoted_string+')',
      delim = '[,;\s\n]',
      local_part = word+'(\\x2e'+word+')*',
      addr_spec = local_part+'\\x40'+domain,
      addr_spec = '(('+local_part+'\\x40'+domain+')|('+icann_addr+'))',
      reg1 = inline ? new RegExp('(^|<|'+delim+')'+addr_spec+'($|>|'+delim+')', 'i') : new RegExp('^'+addr_spec+'$', 'i');
    return reg1.test(input) ? true : false;
@@ -566,8 +576,8 @@
// determine whether the mouse is over the given object or not
function rcube_mouse_is_over(ev, obj)
{
  var mouse = rcube_event.get_mouse_pos(ev);
  var pos = $(obj).offset();
  var mouse = rcube_event.get_mouse_pos(ev),
    pos = $(obj).offset();
  return ((mouse.x >= pos.left) && (mouse.x < (pos.left + obj.offsetWidth)) &&
    (mouse.y >= pos.top) && (mouse.y < (pos.top + obj.offsetHeight)));
@@ -587,18 +597,23 @@
function getCookie(name)
{
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  var dc = document.cookie,
    prefix = name + "=",
    begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    if (begin != 0)
      return null;
  }
  else
  else {
    begin += 2;  
  }
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
};
@@ -618,7 +633,7 @@
      else
        msg += '\n--------------------------------------\n';
      // Konqueror doesn't allows to just change value of hidden element
      // Konqueror doesn't allow to just change the value of hidden element
      if (bw.konq) {
        box.innerText += msg;
        box.value = box.innerText;
@@ -637,9 +652,6 @@
var bw = new roundcube_browser();
bw.set_html_class();
if (!window.console)
  console = new rcube_console();
// Add escape() method to RegExp object