You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.min.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Roundcube common js library
  3. *
  4. * This file is part of the Roundcube Webmail client
  5. *
  6. * @licstart The following is the entire license notice for the
  7. * JavaScript code in this file.
  8. *
  9. * Copyright (c) 2005-2014, The Roundcube Dev Team
  10. *
  11. * The JavaScript code in this page is free software: you can
  12. * redistribute it and/or modify it under the terms of the GNU
  13. * General Public License (GNU GPL) as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option)
  15. * any later version. The code is distributed WITHOUT ANY WARRANTY;
  16. * without even the implied warranty of MERCHANTABILITY or FITNESS
  17. * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  18. *
  19. * As additional permission under GNU GPL version 3 section 7, you
  20. * may distribute non-source (e.g., minimized or compacted) forms of
  21. * that code without the copy of the GNU GPL normally required by
  22. * section 4, provided you include this license notice and a URL
  23. * through which recipients can access the Corresponding Source.
  24. *
  25. * @licend The above is the entire license notice
  26. * for the JavaScript code in this file.
  27. */
  28. var CONTROL_KEY=1,SHIFT_KEY=2,CONTROL_SHIFT_KEY=3;
  29. function roundcube_browser(){var a=navigator;this.agent=a.userAgent;this.agent_lc=a.userAgent.toLowerCase();this.name=a.appName;this.vendor=a.vendor?a.vendor:"";this.vendver=a.vendorSub?parseFloat(a.vendorSub):0;this.product=a.product?a.product:"";this.platform=String(a.platform).toLowerCase();this.lang=a.language?a.language.substring(0,2):a.browserLanguage?a.browserLanguage.substring(0,2):a.systemLanguage?a.systemLanguage.substring(0,2):"en";this.win=0<=this.platform.indexOf("win");this.mac=0<=this.platform.indexOf("mac");
  30. this.linux=0<=this.platform.indexOf("linux");this.unix=0<=this.platform.indexOf("unix");this.dom=document.getElementById?!0:!1;this.dom2=document.addEventListener&&document.removeEventListener;this.webkit=0<this.agent_lc.indexOf("applewebkit");(this.ie=document.all&&!window.opera||this.win&&0<this.agent_lc.indexOf("trident/"))?(this.ie7=0<a.appVersion.indexOf("MSIE 7"),this.ie8=0<a.appVersion.indexOf("MSIE 8"),this.ie9=0<a.appVersion.indexOf("MSIE 9")):window.opera?(this.opera=!0,this.vendver=opera.version()):
  31. (this.chrome=0<this.agent_lc.indexOf("chrome"),this.opera=this.webkit&&0<this.agent.indexOf(" OPR/"),this.safari=!this.chrome&&!this.opera&&(this.webkit||0<this.agent_lc.indexOf("safari")),this.konq=0<this.agent_lc.indexOf("konqueror"),this.mz=this.dom&&!this.chrome&&!this.safari&&!this.konq&&!this.opera&&0<=this.agent.indexOf("Mozilla"),this.iphone=this.safari&&(0<this.agent_lc.indexOf("iphone")||0<this.agent_lc.indexOf("ipod")),this.ipad=this.safari&&0<this.agent_lc.indexOf("ipad"));this.vendver||
  32. (this.vendver=/(opera|opr|khtml|chrome|safari|applewebkit|msie)(\s|\/)([0-9\.]+)/.test(this.agent_lc)?parseFloat(RegExp.$3):0,this.vendver||(this.vendver=/rv:([0-9\.]+)/.test(this.agent)?parseFloat(RegExp.$1):0));this.safari&&/;\s+([a-z]{2})-[a-z]{2}\)/.test(this.agent_lc)&&(this.lang=RegExp.$1);this.tablet=/ipad|android|xoom|sch-i800|playbook|tablet|kindle/i.test(this.agent_lc);this.touch=(this.mobile=/iphone|ipod|blackberry|iemobile|opera mini|opera mobi|mobile/i.test(this.agent_lc))||this.tablet;
  33. this.cookies=a.cookieEnabled;this.xmlhttp_test=function(){var a=new Function("try{var o=new ActiveXObject('Microsoft.XMLHTTP');return true;}catch(err){return false;}");return this.xmlhttp=window.XMLHttpRequest||"ActiveXObject"in window&&a()};this.set_html_class=function(){var a=" js";this.ie?a+=" ie ie"+parseInt(this.vendver):this.opera?a+=" opera":this.konq?a+=" konqueror":this.safari?a+=" chrome":this.chrome?a+=" chrome":this.mz&&(a+=" mozilla");this.iphone?a+=" iphone":this.ipad?a+=" ipad":this.webkit&&
  34. (a+=" webkit");this.mobile&&(a+=" mobile");this.tablet&&(a+=" tablet");document.documentElement&&(document.documentElement.className+=a)}}
  35. var rcube_event={get_target:function(a){return(a=a||window.event)&&a.target?a.target:a.srcElement},get_keycode:function(a){return(a=a||window.event)&&a.keyCode?a.keyCode:a&&a.which?a.which:0},get_button:function(a){return(a=a||window.event)&&void 0!==a.button?a.button:a&&a.which?a.which:0},get_modifier:function(a){var c=0;a=a||window.event;bw.mac&&a?c+=(a.metaKey&&CONTROL_KEY)+(a.shiftKey&&SHIFT_KEY):a&&(c+=(a.ctrlKey&&CONTROL_KEY)+(a.shiftKey&&SHIFT_KEY));return c},get_mouse_pos:function(a){a||(a=
  36. window.event);var c=a.pageX?a.pageX:a.clientX,b=a.pageY?a.pageY:a.clientY;document.body&&document.all&&(c+=document.body.scrollLeft,b+=document.body.scrollTop);a._offset&&(c+=a._offset.left,b+=a._offset.top);return{x:c,y:b}},add_listener:function(a){if(a.object&&a.method){a.element||(a.element=document);a.object._rc_events||(a.object._rc_events={});var c=a.event+"*"+a.method;a.object._rc_events[c]||(a.object._rc_events[c]=function(c){return a.object[a.method](c)});a.element.addEventListener?a.element.addEventListener(a.event,
  37. a.object._rc_events[c],!1):a.element.attachEvent?(a.element.detachEvent("on"+a.event,a.object._rc_events[c]),a.element.attachEvent("on"+a.event,a.object._rc_events[c])):a.element["on"+a.event]=a.object._rc_events[c]}},remove_listener:function(a){a.element||(a.element=document);var c=a.event+"*"+a.method;a.object&&a.object._rc_events&&a.object._rc_events[c]&&(a.element.removeEventListener?a.element.removeEventListener(a.event,a.object._rc_events[c],!1):a.element.detachEvent?a.element.detachEvent("on"+
  38. a.event,a.object._rc_events[c]):a.element["on"+a.event]=null)},cancel:function(a){a=a?a:window.event;a.preventDefault?a.preventDefault():a.returnValue=!1;a.stopPropagation&&a.stopPropagation();a.cancelBubble=!0;return!1},is_keyboard:function(a){return a&&(void 0!==a.pointerType&&"mouse"!==a.pointerType||a.mozInputSource&&a.mozInputSource==a.MOZ_SOURCE_KEYBOARD||0===a.offsetX&&0===a.offsetY||!a.pageX&&0>=(a.pageY||0)&&!a.clientX&&0>=(a.clientY||0)||bw.ie&&rcube_event._last_keyboard_event&&rcube_event._last_keyboard_event.target==
  39. a.target)},keyboard_only:function(a){return rcube_event.is_keyboard(a)?!0:rcube_event.cancel(a)},touchevent:function(a){return{pageX:a.pageX,pageY:a.pageY,offsetX:a.pageX-a.target.offsetLeft,offsetY:a.pageY-a.target.offsetTop,target:a.target,istouch:!0}}};function rcube_event_engine(){this._events={}}
  40. rcube_event_engine.prototype={addEventListener:function(a,c,b){this._events||(this._events={});this._events[a]||(this._events[a]=[]);this._events[a].push({func:c,obj:b?b:window});return this},removeEventListener:function(a,c,b){void 0===b&&(b=window);for(var d,e=0;this._events&&this._events[a]&&e<this._events[a].length;e++)(d=this._events[a][e])&&d.func==c&&d.obj==b&&(this._events[a][e]=null)},triggerEvent:function(a,c){var b,d;void 0===c?c=this:"object"===typeof c&&(c.event=a);this._event_exec||
  41. (this._event_exec={});if(this._events&&this._events[a]&&!this._event_exec[a]){this._event_exec[a]=!0;for(var e=0;e<this._events[a].length;e++)if(d=this._events[a][e])if("function"===typeof d.func?b=d.func.call?d.func.call(d.obj,c):d.func(c):"function"===typeof d.obj[d.func]&&(b=d.obj[d.func](c)),void 0!==b&&!b)break;if(b&&b.event)try{delete b.event}catch(k){$(b).removeAttr("event")}}delete this._event_exec[a];if(c.event)try{delete c.event}catch(f){$(c).removeAttr("event")}return b}};
  42. function rcube_check_email(a,c){return a&&window.RegExp?(c?RegExp("(^|<|[,;\\s\\n])((([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40(((\\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}\\])|(\\[IPv6:[0-9a-f:.]+\\]))|(([^@\\x2e]+\\x2e)+([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))))|(mailtest\\x40(\\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)))($|>|[,;\\s\\n])",
  43. "i"):RegExp("^((([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40(((\\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}\\])|(\\[IPv6:[0-9a-f:.]+\\]))|(([^@\\x2e]+\\x2e)+([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))))|(mailtest\\x40(\\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)))$",
  44. "i")).test(a)?!0:!1:!1}function rcube_clone_object(a){var c={},b;for(b in a)c[b]=a[b]&&"object"===typeof a[b]?rcube_clone_object(a[b]):a[b];return c}function urlencode(a){return window.encodeURIComponent?encodeURIComponent(a).replace("*","%2A"):escape(a).replace("+","%2B").replace("*","%2A").replace("/","%2F").replace("@","%40")}
  45. function rcube_find_object(a,c){var b,d;c||(c=document);if(c.getElementById&&(d=c.getElementById(a)))return d;!d&&c.getElementsByName&&(b=c.getElementsByName(a))&&(d=b[0]);!d&&c.all&&(d=c.all[a]);!d&&c.images.length&&(d=c.images[a]);if(!d&&c.forms.length)for(b=0;b<c.forms.length;b++)c.forms[b].name==a?d=c.forms[b]:c.forms[b].elements[a]&&(d=c.forms[b].elements[a]);if(!d&&c.layers)for(c.layers[a]&&(d=c.layers[a]),b=0;!d&&b<c.layers.length;b++)d=rcube_find_object(a,c.layers[b].document);return d}
  46. function rcube_mouse_is_over(a,c){var b=rcube_event.get_mouse_pos(a),d=$(c).offset();return b.x>=d.left&&b.x<d.left+c.offsetWidth&&b.y>=d.top&&b.y<d.top+c.offsetHeight}function setCookie(a,c,b,d,e,k){a=a+"="+escape(c)+(b?"; expires="+b.toGMTString():"")+(d?"; path="+d:"")+(e?"; domain="+e:"")+(k?"; secure":"");document.cookie=a}
  47. function getCookie(a){var c=document.cookie;a+="=";var b=c.indexOf("; "+a);if(-1==b){if(b=c.indexOf(a),0!=b)return null}else b+=2;var d=c.indexOf(";",b);-1==d&&(d=c.length);return unescape(c.substring(b+a.length,d))}roundcube_browser.prototype.set_cookie=setCookie;roundcube_browser.prototype.get_cookie=getCookie;var bw=new roundcube_browser;bw.set_html_class();RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};
  48. Date.prototype.getStdTimezoneOffset=function(){for(var a=12,c=new Date(null,a,1),b=c.getTimezoneOffset();--a;)if(c.setUTCMonth(a),b!=c.getTimezoneOffset())return Math.max(b,c.getTimezoneOffset());return b};String.prototype.startsWith||(String.prototype.startsWith=function(a,c){return this.slice(c||0,a.length)===a});jQuery.last=function(a){return a&&a.length?a[a.length-1]:void 0};
  49. jQuery.fn.placeholder=function(a){return this.each(function(){var c=!1,b=$(this);this.title=a;if("placeholder"in this)b.attr("placeholder",a);else{this._placeholder=a;b.blur(function(c){""==$.trim(b.val())&&b.val(a);b.triggerHandler("change")}).focus(function(c){$.trim(b.val())==a&&b.val("");b.triggerHandler("change")}).change(function(c){c=b.val()==a;b[c?"addClass":"removeClass"]("placeholder").attr("spellcheck",c)});try{c=this==document.activeElement}catch(d){}c||b.blur()}})};
  50. rcube_parse_query=function(a){if(!a)return{};var c={},b,d,e=/([^&=]+)=?([^&]*)/g,k=/\+/g;for(a=a.replace(/\?/,"");b=e.exec(a);)d=decodeURIComponent(b[1].replace(k," ")),b=decodeURIComponent(b[2].replace(k," ")),"[]"===d.substring(d.length-2)?(d=d.substring(0,d.length-2),(c[d]||(c[d]=[])).push(b)):c[d]=b;return c};
  51. var Base64=function(){var a=function(a){for(var b=0,d="",e=c2=c3=0;b<a.length;)e=a.charCodeAt(b),128>e?(d+=String.fromCharCode(e),b++):191<e&&224>e?(c2=a.charCodeAt(b+1),d+=String.fromCharCode((e&31)<<6|c2&63),b+=2):(c2=a.charCodeAt(b+1),c3=a.charCodeAt(b+2),d+=String.fromCharCode((e&15)<<12|(c2&63)<<6|c3&63),b+=3);return d};return{encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?b+=String.fromCharCode(e):(127<e&&2048>e?b+=String.fromCharCode(e>>
  52. 6|192):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128)),b+=String.fromCharCode(e&63|128))}a=b;if("function"===typeof window.btoa)try{return btoa(a)}catch(k){}for(var f,l,m,h=0,g="",n=a.length;h<n;)f=a.charCodeAt(h++),b=a.charCodeAt(h++),d=a.charCodeAt(h++),e=f>>2,f=(f&3)<<4|b>>4,l=(b&15)<<2|d>>6,m=d&63,isNaN(b)?l=m=64:isNaN(d)&&(m=64),g=g+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+
  53. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(m);return g},decode:function(c){if("function"===typeof window.atob)try{return a(atob(c))}catch(b){}var d,e,k,f,l,m,h=0,g="";c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(m=c.length;h<m;)d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(h++)),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(h++)),
  54. f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(h++)),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(h++)),d=d<<2|e>>4,e=(e&15)<<4|f>>2,k=(f&3)<<6|l,g+=String.fromCharCode(d),64!=f&&(g+=String.fromCharCode(e)),64!=l&&(g+=String.fromCharCode(k));return a(g)}}}();