bplist00_WebMainResource_WebSubframeArchives_WebSubresources _WebResourceMIMEType_WebResourceTextEncodingName_WebResourceFrameName^WebResourceURL_WebResourceDataYtext/htmlUUTF-8_webkitendfullscreen_5https://www.dropbox.com/sh/1kvxn62rknkb9nd/Sd9Nm6VvjfO Dropbox - eResponder marketing materials
eResponder marketing materials
Flag for copyright
 _3-->_https://marketing.dropbox.com/sh/%3Atkey/%3Asecure_hash/%2Apath?owner=1&viewer_signed_in=False#http://www.securusgps.com/gpsaas/persinfocenter/pershome.aspxO&
 _A/-->_khttps://4727608.fls.doubleclick.net/activityi;src=4727608;type=invmedia;cat=7ltetgda;ord=7434030938893.557?O"(-26:>BFJNRW\afkpuz  !_WebResourceResponse_application/javascript_https://bat.bing.com/bat.jsO#bplist00opX$versionX$objectsY$archiverT$top##)*0123OPQRSTUVWXYZ[\]^_`abcdehijU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1  "!$%&'(WNS.base[NS.relative_https://bat.bing.com/bat.js+,-.Z$classnameX$classesUNSURL-/XNSObject#Aîem456BNWNS.keysZNS.objects789:;<=>?@A CDEFGHIJKLMVServerZSet-Cookie\Content-Type]Last-ModifiedTVaryTEtag]Accept-RangesTDate_Content-Encoding^Content-Length_Access-Control-Allow-Origin_Microsoft-IIS/8.0_MUID=0CF543E1E6A660372C374497E2A66399; domain=.bing.com; expires=Sat, 25-Mar-2017 03:04:02 GMT; path=/;, MR=0; domain=bat.bing.com; expires=Tue, 22-Sep-2015 03:04:02 GMT; path=/;_application/javascript_Wed, 14 Jan 2015 10:13:24 GMT_Accept-Encoding_"0fafcbae22fd01:0"Ubytes_Thu, 26 Mar 2015 03:04:01 GMTTgzipT2542Q*+,fg\NSDictionaryf/_application/javascript+,kl_NSHTTPURLResponsemn/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverqr_WebResourceResponse#-27]c~"%.79;BJUacegikmoqsuw%9'9NTty~sOfunction UET(o){this.stringExists=function(n){return n&&n.length>0},this.domain="bat.bing.com",this.secondaryDomain="bat.r.msn.com",this.URLLENGTHLIMIT=2048,this.pageLoadEvt="pageLoad",this.customEvt="custom",o.Ver=o.Ver!==undefined&&(o.Ver==="1"||o.Ver===1)?1:2,this.supportsCORS=this.supportsXDR=!1,this.validKeyNames={ec:1,el:1,ev:1,ea:1},this.validCustomEventKeyNames={ec:1,el:1,ev:1,ea:1,gv:1},this.invalidKeyException="Invalid data: Key Name: ",this.invalidEventException="Invalid event type: Event Type: ",this.evq=o.q||[],delete o.q,this.evqDispatch=!1,this.pageLoadDispatch=!1,window.XMLHttpRequest!==undefined&&"withCredentials"in new XMLHttpRequest&&(this.supportsCORS=!0),typeof XDomainRequest!="undefined"&&(this.supportsXDR=!0),this.push=function(){var n=arguments;n.length===1&&(n[0]===this.pageLoadEvt?this.evt(this.pageLoadEvt):this.evt(this.customEvt,n[0]))},this.dispatchq=function(){this.evqDispatch=!0;for(var n=0;nt.name?1:n.name9999999)throw n+" cannot be greater than 9999999";return r},this.validateDataObject=function(n,t){var r,i;if(!n)throw this.invalidEventException+"undefined event.";if(n!==this.pageLoadEvt&&n!==this.customEvt)throw this.invalidEventException+n;if(!t)throw"undefined data object passed to validate";if(typeof t!="object")return;r=this.validKeyNames,n!==this.pageLoadEvt&&(r=this.validCustomEventKeyNames);for(i in t)if(!r[i])throw this.invalidKeyException+i;t.hasOwnProperty("ev")>0&&(t.ev=this.validateValue("ev",t.ev,!0)),t.hasOwnProperty("gv")>0&&(t.gv=this.validateValue("gv",t.gv,!1))},this.evt=function(n,t){var i,r;if(n===this.pageLoadEvt&&this.pageLoadDispatch===!0)return;t=t||{};if(t instanceof Array)if(t.length>0)t=t[0];else return;if(typeof t!="object")return;this.validateDataObject(n,t);if(n===this.customEvt){i=[];for(r in t)i.push(r);if(i.length===0)return}this.invisibleDiv||this.createInvisibleDiv(document.body),t.evt=n,window.self!=window.top&&(t.ifm=1),n===this.pageLoadEvt&&(t=this.addPageData(t),this.fireBeacon(t,!0),this.pageLoadDispatch=!0),this.fireBeacon(t),t.abf=!0,n===this.pageLoadEvt&&this.evqDispatch===!1&&this.dispatchq()},this.createIframe=function(n){return this.invisibleFrame=this.createInvisibleElement(n,"iframe"),this.invisibleFrame.src="",this.invisibleFrame.name=this.invisibleFrame.id,this.invisibleFrame.id},this.clone=function(n,t){t===undefined&&(t={});for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t},this.combine=function(n,t){var i=this.clone(n);return i=this.clone(t,i)},this.addHiddenFields=function(n,t,i,r){var e="",u,f;r&&(e=r+".");for(u in n)n.hasOwnProperty(u)&&(typeof n[u]=="object"?this.addHiddenFields(n[u],t,i,e+u):(f=i.createElement("input"),f.setAttribute("type","hidden"),f.setAttribute("name",e+u),f.setAttribute("value",n[u]),t.appendChild(f)))},this.fireBeacon=function(n,t){var u=this.urlPrefix,f=this.postURL;t&&(u=this.secondUrlPrefix,f=this.secondPostURL);var i=this.combine(o,n),e=this.stringifyToRequest(i),r=this.removeTrailingAmp(u+e);r.length>this.URLLENGTHLIMIT?this.supportsCORS||this.supportsXDR?this.fireBeaconCORS(i,f):this.fireBeaconForm(i):this.fireBeaconImg(r)},this.createCORSRequest=function(n,t){var i=null;return this.supportsCORS?(i=new XMLHttpRequest,i.withCredentials=!0,i.open(n,t,!0),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded")):this.supportsXDR&&(i=new XDomainRequest,i.open(n,t)),i},this.fireBeaconCORS=function(n,t){var i=this.createCORSRequest("post",t);i.send(this.removeTrailingAmp(this.stringifyToRequest(n)))},this.createForm=function(n){var t=document.createElement("form");return t.method="post",t.action=this.postURL,t.target=this.invisibleFrame.name,n.fp="1",this.addHiddenFields(n,t,document),t},this.fireBeaconForm=function(n){var i=document.getElementById(this.createIframe(document.body)),t;i.onload=function(){document.body.removeChild(i)},t=this.createForm(n,i.name),document.body.appendChild(t),t.submit(),document.body.removeChild(t)}} #$%&'_application/javascriptUutf-8_https://api.demandbase.com/api/v2/ip.json?key=cd79a9f82c976038cd27dd4fc100b577&referrer=http%3A%2F%2Fwww.securusgps.com%2Fgpsaas%2Fpersinfocenter%2Fpershome.aspx&page=http%3A%2F%2Fwww.securusgps.com%2Fgpsaas%2Fpersinfocenter%2Fpershome.aspx&page_title=&callback=Demandbase.IP._callbackObplist00opX$versionX$objectsY$archiverT$top##)*0123OPQRSTUVWXYZ[\]^_`abcdehijU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1  "!$%&'(WNS.base[NS.relative_https://api.demandbase.com/api/v2/ip.json?key=cd79a9f82c976038cd27dd4fc100b577&referrer=http%3A%2F%2Fwww.securusgps.com%2Fgpsaas%2Fpersinfocenter%2Fpershome.aspx&page=http%3A%2F%2Fwww.securusgps.com%2Fgpsaas%2Fpersinfocenter%2Fpershome.aspx&page_title=&callback=Demandbase.IP._callback+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî.4456BNWNS.keysZNS.objects789:;<=>?@A CDEFGHIJKLMVServer\Content-TypeVPragma]Cache-Control[Api-VersionTVaryTDate_Content-Encoding^Content-LengthWExpiresZConnectionUnginx_$application/javascript;charset=utf-8Xno-cache_.no-cache, no-store, max-age=0, must-revalidateRv2_Accept-Encoding_Thu, 26 Mar 2015 03:02:51 GMTTgzipS231_Wed, 25 Mar 2015 03:02:51 GMTZkeep-alive+,fg\NSDictionaryf/_application/javascript+,kl_NSHTTPURLResponsemn/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverqr_WebResourceResponse#-27]c~ %(1:<>EMXdfhjlnprtvxz?Hy|,0DRdg}sODemandbase.IP._callback({"registry_city":null,"registry_state":null,"registry_zip_code":null,"registry_area_code":null,"registry_country":"United States","registry_country_code":"US","registry_latitude":38.0,"registry_longitude":-97.0,"isp":true,"information_level":"Basic","audience":"Residential","audience_segment":"","ip":"138.229.181.49","registry_dma_code":null,"registry_country_code3":"USA"}) )*+,_text/javascript_https://d.adroll.com/pixel/U7C3RGPYVFBRPNTVQLPXAB/56766LR465ARRDJLPT63JW?pv=45933741773.47868&cookie=U7C3RGPYVFBRPNTVQLPXAB%3A1%7C56766LR465ARRDJLPT63JW%3A1%7CD33PO2KM7ZEHNI2NW5CGWR%3A1&keyw=&adroll_external_data=OPbplist00X$versionX$objectsY$archiverT$top0#)*0123]^_`abcdefghijklmnopqrstuvwxyz{|}~U$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 -/.$%&'(WNS.base[NS.relative_bhttps://s.adroll.com/pixel/U7C3RGPYVFBRPNTVQLPXAB/56766LR465ARRDJLPT63JW/D33PO2KM7ZEHNI2NW5CGWR.js+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî\456I\WNS.keysZNS.objects789:;<=>?@ABCDEFGH JKLMNOPQKSTUVWXYZ[ !"#$%&'()*+,\Content-Type_Access-Control-Allow-OriginZx-amz-id-2]Last-Modified_Content-EncodingVServer_access-control-allow-methods_access-control-max-age_access-control-allow-headers]Cache-ControlTDate_x-amz-request-id_ access-control-allow-credentials^Content-LengthZConnectionTEtagTVary]Accept-Ranges_text/javascriptQ*_@0D2pw1YY+gqVqvRblZ+lt5AtKIONO2+SjwZ4y9L8oeSq7bxZrLGaFYQa6wkmO9+N_Tue, 24 Mar 2015 19:25:57 GMTTgzipXAmazonS3SGETS600_max-age=300, must-revalidate_Thu, 26 Mar 2015 03:04:02 GMT_417191B40454BD49UfalseS836Zkeep-alive_""0f7925dfefc4e889cb21984e177577d3"_Accept-EncodingUbytes+,\NSDictionary/ k_text/javascript+,_NSHTTPURLResponse/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverь_WebResourceResponse#-27jpW\gpvy   *HSat{*5:?M_a,26Afx~O k(function () { var scheme = (("https:" == document.location.protocol) ? "https" : "http"); var adnxs_domain = 'secure.adnxs.com'; var aol_domain = 'secure.leadback.advertising.com'; var rule = ["*", "*"]; if (scheme=='http') { adnxs_domain = 'ib.adnxs.com'; aol_domain = 'leadback.advertising.com';} var el = document.createElement("div"); el.style["width"] = "1px"; el.style["height"] = "1px"; el.style["display"] = "inline"; var content = unescape('%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/r/out%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/b/out%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/x/out%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/l/out%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/o/out%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20alt%3d%22%22%20style%3d%22display%3anone%22%20src%3d%22https%3a//www.facebook.com/tr%3fid%3d1521600591411484%26cd%5bsegment_eid%5d%3dD33PO2KM7ZEHNI2NW5CGWR%26ev%3dNoScript%22%20/%3e%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//googleads.g.doubleclick.net/pagead/viewthroughconversion/933633792/%3flabel%3dS_G-CNDRuRAQgL6YvQM%26amp%3bguid%3dON%26amp%3bscript%3d0%26amp%3bord%3d%5bord%5d%22/%3e%0a%3cimg%20height%3d%221%22%20width%3d%221%22%20style%3d%22border-style%3anone%3b%22%20alt%3d%22%22%20src%3d%22%5bprotocol%5d%3a//d.adroll.com/cm/g/out%3fgoogle_nid%3dadroll4%22/%3e%0a%3cimg%20src%3d%22%5bprotocol%5d%3a//%5badnxs_domain%5d/seg%3fadd%3d1503989%26t%3d2%22%20width%3d%221%22%20height%3d%221%22/%3e%0a'); try { } catch(e) {} var r = Math.random()*10000000000000000; content = content.replace(/\[ord\]/gi, r); content = content.replace(/\[protocol\]/gi, scheme); content = content.replace(/\[adnxs_domain\]/gi, adnxs_domain); content = content.replace(/\[aol_domain\]/gi, aol_domain); content = __adroll.replace_external_data(content); el.innerHTML = content; __adroll._head().appendChild(el); if (typeof __adroll.set_pixel_cookie != 'undefined') {__adroll.set_pixel_cookie(adroll_adv_id, adroll_pix_id, "D33PO2KM7ZEHNI2NW5CGWR");} }());  ./01Yimage/gif_https://d.adroll.com/cm/r/outOvbplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_https://d.adroll.com/cm/r/out+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî=]456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=ea29c33bda05f05e4d9d552aa54e4a05; Version=1; Expires=Tue, 24-Mar-2020 03:04:01 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|"+468?GR\^`bdfhjlnxz|~hr{/3GUgjjO#GIF87a,Q; .345_https://d.adroll.com/cm/b/outOvbplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_https://d.adroll.com/cm/b/out+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=9bee9a76d38200d43775522b88c5a55c; Version=1; Expires=Tue, 24-Mar-2020 03:04:01 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|"+468?GR\^`bdfhjlnxz|~hr{/3GUgjjO#GIF87a,Q; .789_https://d.adroll.com/cm/x/outOvbplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_https://d.adroll.com/cm/x/out+,-.Z$classnameX$classesUNSURL-/XNSObject#AîXh456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=47cd62317f74b7e6831d31d2511eb2d0; Version=1; Expires=Tue, 24-Mar-2020 03:04:02 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|"+468?GR\^`bdfhjlnxz|~hr{/3GUgjjO#GIF87a,Q; .;<=_https://d.adroll.com/cm/l/outOvbplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_https://d.adroll.com/cm/l/out+,-.Z$classnameX$classesUNSURL-/XNSObject#Aîn456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=7b8b4475540587b7d899ddf5ed74eb36; Version=1; Expires=Tue, 24-Mar-2020 03:04:02 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|"+468?GR\^`bdfhjlnxz|~hr{/3GUgjjO#GIF87a,Q; .?@A_https://d.adroll.com/cm/o/outOvbplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_https://d.adroll.com/cm/o/out+,-.Z$classnameX$classesUNSURL-/XNSObject#Aîz456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=a6f2806b44169cae9cca455b5b737802; Version=1; Expires=Tue, 24-Mar-2020 03:04:01 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|"+468?GR\^`bdfhjlnxz|~hr{/3GUgjjO#GIF87a,Q; .CDE_bhttps://www.facebook.com/tr?id=1521600591411484&cd[segment_eid]=D33PO2KM7ZEHNI2NW5CGWR&ev=NoScriptObplist00noX$versionX$objectsY$archiverT$top"#)*0123OPQRSTUVWXYZ[\]^_`abcdehiU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1  !$%&'(WNS.base[NS.relative_fhttps://www.facebook.com/tr?id=1521600591411484&cd%5Bsegment_eid%5D=D33PO2KM7ZEHNI2NW5CGWR&ev=NoScript+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî=456BNWNS.keysZNS.objects789:;<=>?@A CEFGHIJKLM_x-content-type-options\Content-TypeVPragma_Strict-Transport-SecurityTVaryTDate_Content-EncodingZx-fb-debug_x-xss-protection]Cache-ControlWExpiresWnosniffYimage/gifVpublic_max-age=15552000; preload_Accept-Encoding_Wed, 25 Mar 2015 20:04:02 PDTTgzip_XxaTgY0U2E1+vzThgMVWW6amA/BJubS3wjaAcZEaUmBpgHZUheTSxBedycVd2m6cLI+rRWWBCS3+GbPc1a2nddw==Q0_public, max-age=0_Wed, 25 Mar 2015 20:04:02 PDT+,fg\NSDictionaryf/++,jk_NSHTTPURLResponselm/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverpq_WebResourceResponse#-27\b}MR]flox .38KViwFH\|rO+GIF89a!,D; .GHI_https://googleads.g.doubleclick.net/pagead/viewthroughconversion/933633792/?label=S_G-CNDRuRAQgL6YvQM&guid=ON&script=0&ord=3656363324262202Obplist00jkX$versionX$objectsY$archiverT$top #)*0123MNOPQRSTUVWXYZ[\]^_`adeU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_ehttps://www.google.com/ads/user-lists/933633792/?label=S_G-CNDRuRAQgL6YvQM&script=0&random=1781955105+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî456ALWNS.keysZNS.objects789:;<=>?@ BDEFGHIJK_x-content-type-options\Content-TypeVServerVPragmaTDate_x-xss-protection_alternate-protocol^Content-LengthWExpires]Cache-ControlWnosniffYimage/gif^adclick_serverXno-cache_Thu, 26 Mar 2015 03:04:02 GMT]1; mode=block^443:quic,p=0.5R42_Fri, 01 Jan 1990 00:00:00 GMT_#no-cache, no-store, must-revalidate+,bc\NSDictionaryb/*+,fg_NSHTTPURLResponsehi/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverlm_WebResourceResponse#-27Z`{~JOZcilu~ (=LTbjt$').BFZhz}nO*GIF89a!,D; .KLM_0https://d.adroll.com/cm/g/out?google_nid=adroll4Obplist00fgX$versionX$objectsY$archiverT$top#)*0123KLMNOPQRSTUVWXYZ[\]`aU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_0https://d.adroll.com/cm/g/out?google_nid=adroll4+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî>456@JWNS.keysZNS.objects789:;<=>? ABDEFGHIVServerZSet-Cookie\Content-TypeVPragmaSP3PTDate^Content-Length]Cache-ControlZConnection[nginx/1.6.2_v__adroll=f53f15ec8a0b0f0dfff03d7eddf924ba; Version=1; Expires=Tue, 24-Mar-2020 03:04:01 GMT; Max-Age=157680000; Path=/Yimage/gifXno-cache_-CP="NON DSP COR CURa PSA PSD OUR BUS NAV STA"_Thu, 26 Mar 2015 03:04:02 GMTR35_#no-store, no-cache, must-revalidateZkeep-alive+,^_\NSDictionary^/#+,bc_NSHTTPURLResponsede/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverhi_WebResourceResponse#-27X^y|#,25>GIKRZeoqsuwy{}{$').BFZhz}jO#GIF87a,Q; .OPQ_,https://secure.adnxs.com/seg?add=1503989&t=2O[bplist00jkX$versionX$objectsY$archiverT$top #)*0123MNOPQRSTUVWXYZ[\]^_`adeU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 $%&'(WNS.base[NS.relative_,https://secure.adnxs.com/seg?add=1503989&t=2+,-.Z$classnameX$classesUNSURL-/XNSObject#Aîtۜ456ALWNS.keysZNS.objects789:;<=>?@ BDEFGHIJKVPragma\Content-TypeZSet-Cookie]Cache-ControlSP3PTDate_X-XSS-Protection^Content-LengthWExpiresZConnectionXno-cacheYimage/gif_uuid2=1918384025097156297; path=/; expires=Wed, 24-Jun-2015 03:04:02 GMT; domain=.adnxs.com; HttpOnly, sess=1; path=/; expires=Fri, 27-Mar-2015 03:04:02 GMT; domain=.adnxs.com; HttpOnly, anj=dTM7k!M4/CTNQ'e>eVSMG)[*If^/e2ch['@=f_OH7J%EaN+JZJv_mD>==oE>I'<5SPB`wI3xm.em02AR6snVWka1phr5Jj$(sj1$U:=kMgc6fWZ5$XAmwof^^AYq'^uIas77dK>48q5aj50gO3+M*e9lBEYN)a8IIkQZfXb^LXy6Hs__xBb[M[xoq(9gXJwB=FF):OvH+6ng=_/05gA0BG+^+uqI6P=jynRd'*V@@%JU/ldsrt@[_cCI3G7x'2RLkdti$ckm.pBmMF<-$A?'9>K=v49C`?@ABC EFGHIJKLMNOPQ !"#\Content-Type_alternate-protocol_Content-EncodingVServer_x-xss-protectionWExpiresSAge]Cache-ControlTDate^Content-Length_x-content-type-optionsTVary]Last-Modified_text/javascript^443:quic,p=0.5TgzipTsffe]1; mode=block_Thu, 26 Mar 2015 03:29:47 GMTT2053_public, max-age=3600_Thu, 26 Mar 2015 02:29:47 GMTS852Wnosniff_Accept-Encoding_Thu, 06 Nov 2014 23:19:05 GMT+,no\NSDictionaryn/!_text/javascript+,st_NSHTTPURLResponseuv/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiveryz_WebResourceResponse#-27ag!&1:@CLUWY`hs .3B[`n!AFSVYkp{O!(function(){var e=window,h=document,k="replace";var m=function(a,c,d,b,g){c=encodeURIComponent(c)[k](/\(/g,"%28")[k](/\)/g,"%29");a=a+"="+c+"; path="+(d||"/")+"; ";g&&(a+="expires="+(new Date((new Date).getTime()+g)).toGMTString()+"; ");b&&"none"!=b&&(a+="domain="+b+";");b=h.cookie;h.cookie=a;return b!=h.cookie},p=function(a){var c=h.body;try{c.addEventListener?c.addEventListener("click",a,!1):c.attachEvent&&c.attachEvent("onclick",a)}catch(d){}};var q=function(a,c,d,b){this.get=function(){for(var b=void 0,c=[],d=h.cookie.split(";"),l=new RegExp("^\\s*"+a+"=\\s*(.*?)\\s*$"),f=0;f?@A CDEFGHIJKLMVServer\Content-TypeVPragma]Last-ModifiedZSet-CookieWExpiresTDate_Transfer-EncodingSP3P]Cache-ControlZConnectionUnginx_text/javascript; charset=UTF-8Xno-cache_Tue, 24 Mar 2015 03:04:01 GMT_^evo5=wlzsmwqqvdskh%7CMn8OQYD0p4sEDT6%2BqYi7aKvNovQ8SFI7paiEEU%2FqZAhaIbI3U921t9iCA2OGwzhYJ9FPWghKoOcaOzXmEAcAGeYjTH8B7OGJPAbZ0r%2BYlqUqovLH6%2B1JviCz5KGftVEv7ZduW8gUUbZey%2B4a0YiAn5ChuavAwPSc2VCnFiqyo7R%2BNQExAhqIP0lFuHd%2BLibaveKfRgRhDeTKUf%2BYFb6J3Sufb31SFdStbq%2BeibIHiFBoqCdYQ2WP%2Bg6Ml0IB1b%2F8D%2FnDBbP7M3RX1oTmKo6jvnFJVcj9ZvKIc97gpgzPxjicXSIDxdQYp0VVgo0qZR%2BzDL9zW79wLC0ROLFQiHVdT3LMqaiDkSoPXz4VAALCCMPgoE8VRkmQqNmfXLwboaYFPq58H3qTSm4WGnZszL7PyAT5g3ecao5Rkf9TO0O4IoAE%2FALxTjX74G46ZRcHags%2BJevlPxWG%2BQ%2BJq4v5bnwyL7f7bFtx1Z3NJpCQnTJdvOs7fhSvXLfuzCidPjTftFJiPv%2FlvonhOeRwMRl2tSpareCqxbudnUrIRnuC1auvh22rqxiS%2FAqYJpMZHQtboxmxHOmijCE7mqjuZMIDDRdiI5AzwkRfb2H11NtmDK1RggZu61VQijB7vdxtNgwNe1j6PtQjuT1%2BhDnhrwNfRdFx8g5JDQOGDZg4AoS7mdqOA89eeY9LvpLfnZMQSPGgd9qPtSy5PqC%2FNmsFgvZDav9QFw%3D%3D; expires=Fri, 25-Sep-2015 03:04:01 GMT; path=/; domain=.netmng.com_Tue, 24 Mar 2015 03:04:01 GMT_Thu, 26 Mar 2015 03:04:01 GMTXIdentity_Dpolicyref="/w3c/p3p.xml", CP="NOI DSP COR DEVa PSAa OUR BUS COM NAV"_>no-store, no-cache, must-revalidate, post-check=0, pre-check=0Zkeep-alive+,fg\NSDictionaryf/_text/javascript+,jk_NSHTTPURLResponselm/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverpq_WebResourceResponse#-27\b}fkv'2:?SWepv"Bbk%*>BVdvyrO@ var nm_mt_rand = '137827053'; var nm_tag_uri = 'https://'; var nm_query_str = 'aid=3808&siclientid=&ref=http%3A%2F%2Fwww.securusgps.com%2Fgpsaas%2Fpersinfocenter%2Fpershome.aspx'; if (document.getElementById && document.createElement && document.body) { var i=document.createElement('IFRAME'); var axel = Math.random() + ''; var a = axel * 10000000000000; i.src='//4727608.fls.doubleclick.net/activityi;src=4727608;type=invmedia;cat=7ltetgda;ord=' + a + '?'; i.width=1; i.height=1; i.frameBorder=0; document.body.appendChild(i); }  ]^_`_text/javascript_.https://scripts.demandbase.com/phXI6yS7.min.jsObplist00stX$versionX$objectsY$archiverT$top%#)*0123QRSTUVWXYZ[\]^_`abcdefghilmnU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 "$#$%&'(WNS.base[NS.relative_.https://scripts.demandbase.com/phXI6yS7.min.js+,-.Z$classnameX$classesUNSURL-/XNSObject#Aî5B456CPWNS.keysZNS.objects789:;<=>?@AB DEFGHIJKLMNO !\Content-Type]Last-Modified[X-Amz-Cf-IdSAgeSViaVServerTDate^Content-LengthZConnection]Accept-RangesTEtagWX-Cache_text/javascript_Wed, 04 Mar 2015 22:18:55 GMT_88-mSpfqRDgK9tb5_9ilJzI0UvOO1ZZZ0qzvxNadhBqG0-GS28kVUVg==U21570_@1.1 82a5ddf78f0308b7bb785072568f2da0.cloudfront.net (CloudFront)XAmazonS3_Tue, 24 Mar 2015 21:04:25 GMTU14192Zkeep-aliveUbytes_""e3632ae86ec999f55a2207d79c664a34"_Hit from cloudfront+,jk\NSDictionaryj/7p_text/javascript+,op_NSHTTPURLResponseqr/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiveruv_WebResourceResponse#-27_e(17:CLNPW_jwy{} &8X AW\ilowO7pvar Demandbase=window.Demandbase||{},Demandbase=window.Demandbase||{};Demandbase.Config={clientId:"phXI6yS7",nonCompanyDefault:null,nonWatchDefault:null,getDomain:null,conditions:null,segments:null,ads:{key:"cd79a9f82c976038cd27dd4fc100b577",pixels:{ad:"1420577520",rt:"1420577553",cn:null}},analytics:{key:null,fieldMap:null},isFormPage:null,forms:{key:null,companyID:null,emailID:null},content:{key:null,mods:null}};"use strict"; "undefined"===typeof window.console&&(window.console={log:function(){},debug:function(){}});"undefined"===typeof window.localStorage&&(window.localStorage={getItem:function(){},setItem:function(){}});"undefined"===typeof JSON&&(JSON={stringify:function(){},parse:function(){}});Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){var c=this.length>>>0,d=Number(b)||0,d=0>d?Math.ceil(d):Math.floor(d);for(0>d&&(d+=c);d?@AB DEFGHIJKLMNO !\Content-TypeZX-FB-Debug_Content-Encoding[Content-MD5WExpires_Timing-Allow-Origin]Cache-ControlTDate^Content-LengthZConnectionTEtagTVary_'application/x-javascript; charset=utf-8_XZHTdAMYYcPvfb+za1aDXA88YheGE8bwbmuUamQVhEjmXXwv9FKaM/5yQdP6Yz6MQE5WH0VqAnLEcmvNf+H7faw==Tgzip_kicVDl6JDyKKEwHBqroErw==_Thu, 26 Mar 2015 03:24:01 GMTQ*_public, max-age=1200_Thu, 26 Mar 2015 03:04:01 GMTT1562Zkeep-alive_""448b95cf9203c44ef702a459f92c46bd"_Accept-Encoding+,jk\NSDictionaryj/ _application/x-javascript+,op_NSHTTPURLResponseqr/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiveruv_WebResourceResponse#-27_e$-36?HJLS[fsuwy{})49>h<ALq  w"O /*1427337480,,JIT Construction: v1660812,en_US*/ /** * Copyright Facebook Inc. * * Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ try {(function(a,b,c,d){var e=a._fbq||(a._fbq=[]);if(e.push!==Array.prototype.push)return;var f=/^\d+$/,g='https://www.facebook.com/tr/',h={},i=[],j=c.href,k=b.referrer,l=a.top!==a;function m(v){var w=[];for(var x=0,y=v.length;x':'iframe',ba=b.createElement(aa);ba.src='javascript:false';ba.id=x;ba.name=x;y.appendChild(ba);n(ba,function(){for(var ca=0,da=w.length;ca0;};function p(v,w,x){var y=[];y.push(['id',v]);y.push(['ev',w]);y.push(['dl',j]);y.push(['rl',k]);y.push(['if',l]);y.push(['ts',new Date().valueOf()]);if(x&&typeof x==='object')for(var z in x)if(x.hasOwnProperty(z)){var aa=x[z],ba=(aa===null)?'null':typeof aa;if(ba in {number:1,string:1,boolean:1}){y.push(['cd['+encodeURIComponent(z)+']',aa]);}else if(ba==='object'){aa=(typeof JSON==='undefined')?String(aa):JSON.stringify(aa);y.push(['cd['+encodeURIComponent(z)+']',aa]);}}var ca=m(y);if(1024>(g+'?'+ca).length){var da=new Image();da.src=g+'?'+ca;}else o(g,y);}var q=function(v){if(Object.prototype.toString.call(v)!=='[object Array]')return false;var w=v.shift();if(!w)return false;var x=h[w];if(typeof x!=='function')return false;if(a._fbds){var y=a._fbds.pixelId;if(f.test(y)){i.push(y);delete a._fbds.pixelId;}}return x.apply(h,v);};for(var r=0,s=e.length;r?@ABC EFGHIJKLMNOPQ !"#\Content-Type]Last-Modified[X-Amz-Cf-IdSAgeSViaVServer]Cache-ControlTDate^Content-LengthZConnection]Accept-RangesTEtagWX-Cache_application/javascript_Mon, 23 Mar 2015 16:11:25 GMT_8iaRroYLOz9wYVTHDWj8UeIp0hQijLyfZmYDDst_zO82FUKeBAOcPXA==U53828_@1.1 ee8b5e6013d73b1439e0c010462ded31.cloudfront.net (CloudFront)XAmazonS3]max-age=86400_Tue, 24 Mar 2015 12:06:53 GMTU23730Zkeep-aliveUbytes_""530780a17af4e8fb66b50ee85c9e19f0"_Hit from cloudfront+,no\NSDictionaryn/\_application/javascript+,st_NSHTTPURLResponseuv/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiveryz_WebResourceResponse#-27ag'069BKMOV^iwy{},19Rr -3>Di{O\(function(){var TagSettings; TagSettings=function(){function e(a){var b;this.context=a;this.data={};this.cookie_manager=new CookieManager(this.context);this._set_window_options();this._set_cookie_options();a=this.data.custom_group_id;b=this.data.custom_user_id;if(a!=null&&b!=null)this.data.custom_tracking_id=""+a+"="+b;this.data.protocol=this.context.win.location.protocol;this.data.page_url=this.context.win.location.href;this.data.hostname=this.context.win.location.hostname;this.data.referrer=this.context.doc.referrer;this.data.loaded_in_iframe= window.self!==this.context.win.top?true:false}e.options={partner_id:"_bizo_data_partner_id",custom_channel_id:"_bizo_data_partner_channel_id",custom_group_id:"_bizo_data_partner_custom_group_id",custom_user_id:"_bizo_data_partner_custom_user_id",zoom_info_id:"_bizo_data_zi_person_id",title:"_bizo_data_partner_title",domain:"_bizo_data_partner_domain",company:"_bizo_data_partner_company",gender:"_bizo_data_partner_gender",location:"_bizo_data_partner_location",education:"_bizo_data_partner_education", email:"_bizo_data_partner_email",raw_data:"_bizo_data_partner_raw_data",raw_data_overwrite:"_bizo_data_partner_raw_data_overwrite",encrypted_data:"_bizo_data_partner_encrypted_data",partner_data:"_bizo_data_partner_data",sic_codes:"_bizo_data_partner_sics",employee_range:"_bizo_data_partner_employee_range",default_keywords:"_bizo_ad_default_keywords",order_id:"_bizo_order_id",async_target:"_bizo_data_async_target",use_iframe:"_bizo_data_use_iframe",use_callback:"_bizo_data_partner_use_callback",test_url:"_bizo_data_test_base_url"}; e.cookie_options={bizo_id:"_bizo_bzid",bizographics:"BizographicData",checksum:"_bizo_cksm"};e.prototype._set_window_options=function(){return this._set_options(e.options,function(a){return function(b){return a.context.win[b]}}(this))};e.prototype._set_cookie_options=function(){return this._set_options(e.cookie_options,function(a){return function(b){return a.cookie_manager.get(b)}}(this))};e.prototype._set_option=function(a,b){var c,d;c=ArrayUtil.is_array;return c(b)?this.data[a]=function(){var f, g,h;h=[];f=0;for(g=b.length;f0};return e}();var SiteCodes; SiteCodes=function(){function e(){}e.generate=function(a,b,c){var d,f,g,h,i,j;if(c==null)c=void 0;d=c;b=c!=null&&c.length>0?d.replace(/http:\/\//,""):b;b=b.split(".");h=[];d=b.length;if(d>1){c=i=0;for(j=b.length;id)return true;return false};return a}();var BaseLogger,ConsoleLogger,ErrorLog,LocalLogger,PixelLogger,__slice=[].slice,__hasProp={}.hasOwnProperty,__extends=function(e,a){function b(){this.constructor=e}for(var c in a)if(__hasProp.call(a,c))e[c]=a[c];b.prototype=a.prototype;e.prototype=new b;e.__super__=a.prototype;return e}; ErrorLog=function(){function e(){}e.log=function(){var a,b,c,d,f,g,h;a=arguments[0];b=arguments[1];d=3<=arguments.length?__slice.call(arguments,2):[];h=[];f=0;for(g=d.length;f";return c};e.prototype.to_element=function(){var a,b,c,d;b=this.doc.createElement(this.type);d=this.attributes;for(a in d){c=d[a];this.set_property(b,a,c)}return b};e.prototype.set_invisible= function(){var a;if((a=this.attributes).style==null)a.style={};return this.attributes.style.display="none"};e.prototype.set_property=function(a,b,c){return(!this._is_object(c)?this._set_single_property:this._set_multiple_properties)(a,b,c)};e.prototype._get_style_string=function(a){var b,c,d;c="";for(b in a){d=a[b];c+=""+b+": "+d+"; "}return c};e.prototype._is_object=function(a){return typeof a==="object"};e.prototype._set_single_property=function(a,b,c){return a[b]=c};e.prototype._set_multiple_properties= function(a,b,c){var d,f,g;g=[];for(d in c){f=c[d];g.push(a[b][d]=f)}return g};return e}();var HashUtil;HashUtil=function(){function e(){}e.clone=function(a){return this.merge(a,{})};e.merge=function(a,b){var c;for(c in a)if(a.hasOwnProperty(c)&&b[c]==null)b[c]=a[c];return b};e.merge_copy=function(a,b){return this.merge(a,this.clone(b))};return e}();var CookieManager; CookieManager=function(){function e(a){this.context=a;this.one_day=864E5}e.prototype.get=function(a){var b,c,d,f,g;g=this.context.doc.cookie.split("; ");d=0;for(f=g.length;d0?b.substring(0,Math.min(b.length,c)):b;return this.params[a]=b}};e.prototype.add_all=function(a,b){var c,d,f,g,h;h=[];c=f=0;for(g=b.length;f=d;f=1<=d?++h:--h)i.push("0");return i}());return g};b=function(d,f){if(f==null)f=8;return""+c(f-d.length).join("")+d};e={};e.to_crc32=function(d){var f,g,h,i;if(!(d!=null&& d.length>0))return"";g=0;g=~g;f=h=0;for(i=d.length;h>>8}g=~g;if(g<0)g=4294967295+g+1;return g};e.to_crc32_string=function(d){return b(e.to_crc32(d).toString(16).toUpperCase())};e.generate_checksum=function(d){var f,g,h;f=[];for(g in d){h=d[g];f.push(""+g+"="+h)}return e.to_crc32_string(f.sort().join("&"))};return e}();var PartnerTags; PartnerTags=function(){function e(){}e.fire_partners=function(a,b,c,d,f){var g,h,i,j;if(!(a!=null&&a.length&&a.length>0))return null;j=[];h=0;for(i=a.length;h0)d=f(b);f=d.length;h=[];if(f>1){b=i=0;for(j=d.length;i?@ABCD FGHIJKLMNOPQRS !"#$%\Content-TypeSp3p_Content-Disposition_alternate-protocol_Content-EncodingVServer_x-xss-protectionWExpiresSAge]Cache-ControlTDate^Content-Length_x-content-type-optionsTEtag_text/javascript; charset=UTF-8_mpolicyref="https://www.googleadservices.com/pagead/p3p.xml", CP="NOI DEV PSA PSD IVA IVD OTP OUR OTR IND OTC"_attachment; filename="f.txt"^443:quic,p=0.5TgzipTcafe]1; mode=block_Thu, 26 Mar 2015 04:28:50 GMTU81311_public, max-age=86400_Wed, 25 Mar 2015 04:28:50 GMTT2955Wnosniff_5399909606642304841+,rs\NSDictionaryr/_text/javascript+,wx_NSHTTPURLResponseyz/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiver}~_WebResourceResponse#-27ci).9BHKT]_ahp{")<DHV[j8GLQ_ #';I[^tvO(function(){var f=this,k=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var e=Object.prototype.toString.call(a);if("[object Window]"==e)return"object";if("[object Array]"==e||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==e||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; else if("function"==b&&"undefined"==typeof a.call)return"object";return b};var l=function(a){l[" "](a);return a};l[" "]=function(){};var m=function(a,b){for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&b.call(void 0,a[e],e,a)};var n=window;var p;a:{var u=f.navigator;if(u){var y=u.userAgent;if(y){p=y;break a}}p=""}var z=function(a){return-1!=p.indexOf(a)};var A=z("Opera")||z("OPR"),C=z("Edge")||z("Trident")||z("MSIE"),D=z("Gecko")&&!(-1!=p.toLowerCase().indexOf("webkit")&&!z("Edge"))&&!(z("Trident")||z("MSIE"))&&!z("Edge"),E=-1!=p.toLowerCase().indexOf("webkit")&&!z("Edge"),F=function(){var a=p;if(D)return/rv\:([^\);]+)(\)|;)/.exec(a);if(C&&z("Edge"))return/Edge\/([\d\.]+)/.exec(a);if(C)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(E)return/WebKit\/(\S+)/.exec(a)}; (function(){if(A&&f.opera){var a=f.opera.version;return"function"==k(a)?a():a}var a="",b=F();b&&(a=b?b[1]:"");return C&&!z("Edge")&&(b=(b=f.document)?b.documentMode:void 0,b>parseFloat(a))?String(b):a})();var G=function(a){this.b=[];this.a={};for(var b=0,e=arguments.length;bMath.random())){var v= Math.random();if(0>v){try{var J=new Uint16Array(1);window.crypto.getRandomValues(J);v=J[0]/65536}catch(ca){v=Math.random()}r=B[Math.floor(v*B.length)];break c}}r=null}r&&""!=r&&q.a.hasOwnProperty(2)&&(q.a[2]=r)}}h=!0}if(h){h="/?";"landing"==a.google_conversion_type&&(h="/extclk?");var K;K=W(e)+"//"+(a.google_remarketing_only?"googleads.g.doubleclick.net":a.google_conversion_domain||"www.googleadservices.com")+"/pagead/"+[a.google_remarketing_only?"viewthroughconversion/":"conversion/",N(a.google_conversion_id), h,"random=",N(a.google_conversion_time)].join("");var ba=d?{visible:1,hidden:2,prerender:3,preview:4}[d.webkitVisibilityState||d.mozVisibilityState||d.visibilityState||""]||0:"0",w;b:{var L=a.google_conversion_language;if(null!=L){var t=L.toString();if(2==t.length){w=P("hl",t);break b}if(5==t.length){w=P("hl",t.substring(0,2))+P("gl",t.substring(3,5));break b}}w=""}b=[P("cv",a.google_conversion_js_version),P("fst",a.google_conversion_first_time),P("num",a.google_conversion_snippets),P("fmt",a.google_conversion_format), P("value",a.google_conversion_value),P("currency_code",a.google_conversion_currency),P("label",a.google_conversion_label),P("oid",a.google_conversion_order_id),P("bg",a.google_conversion_color),w,P("guid","ON"),P("disvt",a.google_disable_viewthrough),P("is_call",a.google_is_call),P("eid",I().join()),T(a),U(e,c,a.google_conversion_date),R(a),V(e,d,a.google_conversion_page_url),a.google_remarketing_for_search&&!a.google_conversion_domain?"&srr=n":"",P("vis",ba)].join("");Z(a,K+b,!0);if(a.google_remarketing_for_search&& !a.google_conversion_domain){var x;x=W(e)+"//www.google.com/ads/user-lists/"+[N(a.google_conversion_id),"/?random=",Math.floor(1E9*Math.random())].join("");x+=[P("label",a.google_conversion_label),P("fmt","3"),V(e,d,a.google_conversion_page_url)].join("");Z(a,x,!1)}g=!0}}catch(da){}b=g}else b=!1;return b};})();  qrst_text/javascript_#https://s.adroll.com/j/roundtrip.jsObplist00X$versionX$objectsY$archiverT$top0#)*0123]^_`abcdefghijklmnopqrstuvwxyz{|}~U$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 -/.$%&'(WNS.base[NS.relative_#https://s.adroll.com/j/roundtrip.js+,-.Z$classnameX$classesUNSURL-/XNSObject#Aîc456I\WNS.keysZNS.objects789:;<=>?@ABCDEFGH JKLMNOPQKSTUVWXYZ[ !"#$%&'()*+,\Content-Type_Access-Control-Allow-OriginZx-amz-id-2]Last-Modified_Content-EncodingVServer_access-control-allow-methods_access-control-max-age_access-control-allow-headers]Cache-ControlTDate_x-amz-request-id_ access-control-allow-credentials^Content-LengthZConnectionTEtagTVary]Accept-Ranges_text/javascriptQ*_@1NY6DlgB7OLjPuoaHitw4S+yxwMNqi3wP1K7fe5sgCXtjs4geWx339Jjx5LBZtvr_Wed, 18 Feb 2015 22:18:41 GMTTgzipXAmazonS3SGETS600_max-age=300, must-revalidate_Thu, 26 Mar 2015 03:04:01 GMT_504BAED4C8C10F27UfalseT4805Zkeep-alive_""d9de225f37d7aac3b2ee0af4ae2b99b6"_Accept-EncodingUbytes+,\NSDictionary/6_text/javascript+,_NSHTTPURLResponse/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiverь_WebResourceResponse#-27jp(17:CLNPW_j "5<[t "e(:@ERUXjoO6(function(b){b.__adroll=b.__adroll||{exp:5E4,eexp:720,pv:1E11*Math.random(),__adc:"__ar_v4",_nad:0,_lce:null,_broken:!1,_loaded:!1,_url:2E3,_r:{},_kwl:300,_logs:[],_secure:function(){return"https:"===this._protocol()},_head:function(){return(b.document.getElementsByTagName("head")||[null])[0]||(b.document.getElementsByTagName("body")||[null])[0]||b.document.getElementsByTagName("script")[0].parentNode},_protocol:function(){return b.document.location.protocol},_native:function(){try{return"http"!== this._protocol().slice(0,4)}catch(a){return!0}},_srv:function(a){return(this._native()?"https:":"")+"//d.adroll.com"+("undefined"===typeof a?"":a)},_cdn:function(a){a="undefined"===typeof a?"":a;return this._secure()?"https://s.adroll.com"+a:"http://a.adroll.com"+a},log:function(a){this._logs.push(a)},read_log:function(a){return this._logs.join(a?"\n":"
\n")},cookieEnabled:function(a){if(b.adroll_ext_network||b.adroll_optout||this._broken)return!1;if(2<=this._nad||a)return this._lce;this.set("_te_", "1");return"1"===this.get("_te_")?(this.del("_te_"),0d.indexOf(a+"=")?d=null:(a=d.indexOf(a+"=")+a.length+1,c=d.indexOf(";",a),-1===c&&(c=d.length),d=d.substring(a, c),d=""===d?null:b.unescape(d));return d},set:function(a,d,c){var e;!c||"number"!==typeof c?c="":(e=new Date,e.setTime(e.getTime()+36E5*c),c=e.toGMTString(),c="; expires="+c);e="; domain="+b.location.hostname;d=b.escape(d);b.document.cookie=a+"="+d+c+"; path=/"+e},del:function(a){this.set(a,"",-8760)},generate_link:function(){return""},get_base_url:function(a,d,c,e,f,g){a=a+"/"+d+"/"+c+(e?"/"+e:"")+(f?"/"+f:"");var j="";this.cookieEnabled(!1)?(j=b.escape(this.get_eids()),a+="?pv="+this.pv+"&cookie="+ j):a+="?no-cookies=1&pv="+this.pv;g&&(a+="&"+g.join("&"));if(a.length>this._url){this.del(this.__adc);if(a.length-j.length>this._url)return"#";this.log("Url was too big, shrinking it");return this.get_url(d,c,e,f,g)}this.log("Generated url: "+a);return a},get_url:function(a,d,c,b,f){var g=!c?this._srv("/r"):this._srv("/c");return this.get_base_url(g,a,d,c,b,f)},get_eids:function(){if(b.adroll_ext_network||b.adroll_optout)return"";try{for(var a=this.get(this.__adc),d=a?a.split("|"):"",a=[],c=d.length- 1;0<=c;c--)if(d[c]){var e=d[c].split(":");a.push([e[0],e[2]].join(":"))}return a.join("|")}catch(f){return this.del(this.__adc),""}},get_date:function(a){var d=new Date;a&&d.setTime(d.getTime()+36E5*a);a=""+d.getUTCFullYear();var b=d.getUTCMonth(),b=10<=b?b:"0"+b,d=d.getUTCDate();return[a,b,10<=d?d:"0"+d].join("")},normalize_url:function(a){return a.toLowerCase()},check_cookie:function(a,d){if(b.adroll_ext_network||b.adroll_optout)return"";for(var c=a.split("|"),e=c.length-1;0<=e;e--)if(c[e]){var f= c[e].split(":");d===f[0]&&(f[2]=""+(parseInt(f[2])+1),c[e]=f.join(":"))}return c.join("|")},handle:function(a){var b=this.get(this.__adc)||"";-1!==b.indexOf(a)?this.set(this.__adc,this.check_cookie(b,a),this.exp):(a=[b,[a,this.get_date(this.eexp),"1"].join(":")].join("|"),this.set(this.__adc,a,this.exp))},expire_old:function(){if(!b.adroll_ext_network&&!b.adroll_optout){for(var a=this.get_date(),d=this.get(this.__adc),d=d?d.split("|"):[""],c=[],e=d.length-1;0<=e;e--)d[e]&&d[e].split(":")[1]>a&&c.push(d[e]); this.set(this.__adc,c.join("|"),this.exp)}},render_win_notification:function(a){if(a.adroll_cpm_macro&&a.adroll_win_notif){var d=new b.Image,c=this._secure()?"https://":"http://";d.src=c+a.adroll_win_notif+a.adroll_cpm_macro;d.setAttribute("width","1");d.setAttribute("height","1");d.setAttribute("border","0");this._head().appendChild(d)}},render_ad_code:function(a,d,c,e){e="undefined"===typeof e?null:e;if("undefined"===typeof this._r[d]||e){var f=["width="+b.adroll_width,"height="+b.adroll_height, "x=0","y=0"];if(c)this.log("Rendering test ad "+c+" in space "+d),f.push("test_ad="+c),a=this.get_url(a,d,null,"ad",f);else if(e){this.log("Rendering adgroup "+e);c=this.macro_values();var g=this.macro_url_params(c,!1,!1,!1,!1);f.push(g);this.render_win_notification(c);a=this.get_url(a,d,e,null,f)}else this.log("Rendering ad space "+d),a=this.get_url(a,d,null,"ad",f);this.expire_old();b.document.write(' */ var dispatches = [ /** Dispatched when runtime is connected and file-picker is ready to be used. @event ready @param {Object} event */ 'ready', /** Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked. Check [corresponding documentation entry](#method_refresh) for more info. @event refresh @param {Object} event */ /** Dispatched when selection of files in the dialog is complete. @event change @param {Object} event */ 'change', 'cancel', // TODO: might be useful /** Dispatched when mouse cursor enters file-picker area. Can be used to style element accordingly. @event mouseenter @param {Object} event */ 'mouseenter', /** Dispatched when mouse cursor leaves file-picker area. Can be used to style element accordingly. @event mouseleave @param {Object} event */ 'mouseleave', /** Dispatched when functional mouse button is pressed on top of file-picker area. @event mousedown @param {Object} event */ 'mousedown', /** Dispatched when functional mouse button is released on top of file-picker area. @event mouseup @param {Object} event */ 'mouseup' ]; function FileInput(options) { var self = this, container, browseButton, defaults; // if flat argument passed it should be browse_button id if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) { options = { browse_button : options }; } // this will help us to find proper default container browseButton = Dom.get(options.browse_button); if (!browseButton) { // browse button is required throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); } // figure out the options defaults = { accept: [{ title: I18n.translate('All Files'), extensions: '*' }], name: 'file', multiple: false, required_caps: false, container: browseButton.parentNode || document.body }; options = Basic.extend({}, defaults, options); // convert to object representation if (typeof(options.required_caps) === 'string') { options.required_caps = Runtime.parseCaps(options.required_caps); } // normalize accept option (could be list of mime types or array of title/extensions pairs) if (typeof(options.accept) === 'string') { options.accept = Mime.mimes2extList(options.accept); } container = Dom.get(options.container); // make sure we have container if (!container) { container = document.body; } // make container relative, if it's not if (Dom.getStyle(container, 'position') === 'static') { container.style.position = 'relative'; } container = browseButton = null; // IE RuntimeClient.call(self); Basic.extend(self, { /** Unique id of the component @property uid @protected @readOnly @type {String} @default UID */ uid: Basic.guid('uid_'), /** Unique id of the connected runtime, if any. @property ruid @protected @type {String} */ ruid: null, /** Array of selected mOxie.File objects @property files @type {Array} @default null */ files: null, /** Initializes the file-picker, connects it to runtime and dispatches event ready when done. @method init */ init: function() { self.convertEventPropsToHandlers(dispatches); self.bind('RuntimeInit', function(e, runtime) { self.ruid = runtime.uid; self.bind("Ready", function() { self.trigger("Refresh"); }, 999); self.bind("Change", function() { var files = runtime.exec.call(self, 'FileInput', 'getFiles'); self.files = []; Basic.each(files, function(file) { // ignore empty files (IE10 for example hangs if you try to send them via XHR) if (file.size === 0) { return true; } self.files.push(new File(self.ruid, file)); }); }, 999); // re-position and resize shim container self.bind('Refresh', function() { var pos, size, browseButton, shimContainer; browseButton = Dom.get(options.browse_button); shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist if (browseButton) { pos = Dom.getPos(browseButton, Dom.get(options.container)); size = Dom.getSize(browseButton); if (shimContainer) { Basic.extend(shimContainer.style, { top : pos.y + 'px', left : pos.x + 'px', width : size.w + 'px', height : size.h + 'px' }); } } shimContainer = browseButton = null; }); runtime.exec.call(self, 'FileInput', 'init', options); }); // runtime needs: options.required_features, options.runtime_order and options.container self.connectRuntime(Basic.extend({}, options, { required_caps: { select_file: true } })); }, /** Disables file-picker element, so that it doesn't react to mouse clicks. @method disable @param {Boolean} [state=true] Disable component if - true, enable if - false */ disable: function(state) { var runtime = this.getRuntime(); if (runtime) { runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state); } }, /** Reposition and resize dialog trigger to match the position and size of browse_button element. @method refresh */ refresh: function() { self.trigger("Refresh"); }, /** Destroy component. @method destroy */ destroy: function() { var runtime = this.getRuntime(); if (runtime) { runtime.exec.call(this, 'FileInput', 'destroy'); this.disconnectRuntime(); } if (Basic.typeOf(this.files) === 'array') { // no sense in leaving associated files behind Basic.each(this.files, function(file) { file.destroy(); }); } this.files = null; } }); } FileInput.prototype = EventTarget.instance; return FileInput; }); // Included from: src/javascript/file/FileDrop.js /** * FileDrop.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/file/FileDrop', [ 'moxie/core/I18n', 'moxie/core/utils/Dom', 'moxie/core/Exceptions', 'moxie/core/utils/Basic', 'moxie/file/File', 'moxie/runtime/RuntimeClient', 'moxie/core/EventTarget', 'moxie/core/utils/Mime' ], function(I18n, Dom, x, Basic, File, RuntimeClient, EventTarget, Mime) { /** Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through _XMLHttpRequest_. @example
Drop files here

@class FileDrop @constructor @extends EventTarget @uses RuntimeClient @param {Object|String} options If options has typeof string, argument is considered as options.drop_zone @param {String|DOMElement} options.drop_zone DOM Element to turn into a drop zone @param {Array} [options.accept] Array of mime types to accept. By default accepts all @param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support */ var dispatches = [ /** Dispatched when runtime is connected and drop zone is ready to accept files. @event ready @param {Object} event */ 'ready', /** Dispatched when dragging cursor enters the drop zone. @event dragenter @param {Object} event */ 'dragenter', /** Dispatched when dragging cursor leaves the drop zone. @event dragleave @param {Object} event */ 'dragleave', /** Dispatched when file is dropped onto the drop zone. @event drop @param {Object} event */ 'drop', /** Dispatched if error occurs. @event error @param {Object} event */ 'error' ]; function FileDrop(options) { var self = this, defaults; // if flat argument passed it should be drop_zone id if (typeof(options) === 'string') { options = { drop_zone : options }; } // figure out the options defaults = { accept: [{ title: I18n.translate('All Files'), extensions: '*' }], required_caps: { drag_and_drop: true } }; options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults; // this will help us to find proper default container options.container = Dom.get(options.drop_zone) || document.body; // make container relative, if it is not if (Dom.getStyle(options.container, 'position') === 'static') { options.container.style.position = 'relative'; } // normalize accept option (could be list of mime types or array of title/extensions pairs) if (typeof(options.accept) === 'string') { options.accept = Mime.mimes2extList(options.accept); } RuntimeClient.call(self); Basic.extend(self, { uid: Basic.guid('uid_'), ruid: null, files: null, init: function() { self.convertEventPropsToHandlers(dispatches); self.bind('RuntimeInit', function(e, runtime) { self.ruid = runtime.uid; self.bind("Drop", function() { var files = runtime.exec.call(self, 'FileDrop', 'getFiles'); self.files = []; Basic.each(files, function(file) { self.files.push(new File(self.ruid, file)); }); }, 999); runtime.exec.call(self, 'FileDrop', 'init', options); self.dispatchEvent('ready'); }); // runtime needs: options.required_features, options.runtime_order and options.container self.connectRuntime(options); // throws RuntimeError }, destroy: function() { var runtime = this.getRuntime(); if (runtime) { runtime.exec.call(this, 'FileDrop', 'destroy'); this.disconnectRuntime(); } this.files = null; } }); } FileDrop.prototype = EventTarget.instance; return FileDrop; }); // Included from: src/javascript/runtime/RuntimeTarget.js /** * RuntimeTarget.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/runtime/RuntimeTarget', [ 'moxie/core/utils/Basic', 'moxie/runtime/RuntimeClient', "moxie/core/EventTarget" ], function(Basic, RuntimeClient, EventTarget) { /** Instance of this class can be used as a target for the events dispatched by shims, when allowing them onto components is for either reason inappropriate @class RuntimeTarget @constructor @protected @extends EventTarget */ function RuntimeTarget() { this.uid = Basic.guid('uid_'); RuntimeClient.call(this); this.destroy = function() { this.disconnectRuntime(); this.unbindAll(); }; } RuntimeTarget.prototype = EventTarget.instance; return RuntimeTarget; }); // Included from: src/javascript/file/FileReader.js /** * FileReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/file/FileReader', [ 'moxie/core/utils/Basic', 'moxie/core/utils/Encode', 'moxie/core/Exceptions', 'moxie/core/EventTarget', 'moxie/file/Blob', 'moxie/file/File', 'moxie/runtime/RuntimeTarget' ], function(Basic, Encode, x, EventTarget, Blob, File, RuntimeTarget) { /** Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader) interface. Where possible uses native FileReader, where - not falls back to shims. @class FileReader @constructor FileReader @extends EventTarget @uses RuntimeClient */ var dispatches = [ /** Dispatched when the read starts. @event loadstart @param {Object} event */ 'loadstart', /** Dispatched while reading (and decoding) blob, and reporting partial Blob data (progess.loaded/progress.total). @event progress @param {Object} event */ 'progress', /** Dispatched when the read has successfully completed. @event load @param {Object} event */ 'load', /** Dispatched when the read has been aborted. For instance, by invoking the abort() method. @event abort @param {Object} event */ 'abort', /** Dispatched when the read has failed. @event error @param {Object} event */ 'error', /** Dispatched when the request has completed (either in success or failure). @event loadend @param {Object} event */ 'loadend' ]; function FileReader() { var self = this, _fr; Basic.extend(this, { /** UID of the component instance. @property uid @type {String} */ uid: Basic.guid('uid_'), /** Contains current state of FileReader object. Can take values of FileReader.EMPTY, FileReader.LOADING and FileReader.DONE. @property readyState @type {Number} @default FileReader.EMPTY */ readyState: FileReader.EMPTY, /** Result of the successful read operation. @property result @type {String} */ result: null, /** Stores the error of failed asynchronous read operation. @property error @type {DOMError} */ error: null, /** Initiates reading of File/Blob object contents to binary string. @method readAsBinaryString @param {Blob|File} blob Object to preload */ readAsBinaryString: function(blob) { _read.call(this, 'readAsBinaryString', blob); }, /** Initiates reading of File/Blob object contents to dataURL string. @method readAsDataURL @param {Blob|File} blob Object to preload */ readAsDataURL: function(blob) { _read.call(this, 'readAsDataURL', blob); }, /** Initiates reading of File/Blob object contents to string. @method readAsText @param {Blob|File} blob Object to preload */ readAsText: function(blob) { _read.call(this, 'readAsText', blob); }, /** Aborts preloading process. @method abort */ abort: function() { this.result = null; if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) { return; } else if (this.readyState === FileReader.LOADING) { this.readyState = FileReader.DONE; } if (_fr) { _fr.getRuntime().exec.call(this, 'FileReader', 'abort'); } this.trigger('abort'); this.trigger('loadend'); }, /** Destroy component and release resources. @method destroy */ destroy: function() { this.abort(); if (_fr) { _fr.getRuntime().exec.call(this, 'FileReader', 'destroy'); _fr.disconnectRuntime(); } self = _fr = null; } }); function _read(op, blob) { _fr = new RuntimeTarget(); function error(err) { self.readyState = FileReader.DONE; self.error = err; self.trigger('error'); loadEnd(); } function loadEnd() { _fr.destroy(); _fr = null; self.trigger('loadend'); } function exec(runtime) { _fr.bind('Error', function(e, err) { error(err); }); _fr.bind('Progress', function(e) { self.result = runtime.exec.call(_fr, 'FileReader', 'getResult'); self.trigger(e); }); _fr.bind('Load', function(e) { self.readyState = FileReader.DONE; self.result = runtime.exec.call(_fr, 'FileReader', 'getResult'); self.trigger(e); loadEnd(); }); runtime.exec.call(_fr, 'FileReader', 'read', op, blob); } this.convertEventPropsToHandlers(dispatches); if (this.readyState === FileReader.LOADING) { return error(new x.DOMException(x.DOMException.INVALID_STATE_ERR)); } this.readyState = FileReader.LOADING; this.trigger('loadstart'); // if source is o.Blob/o.File if (blob instanceof Blob) { if (blob.isDetached()) { var src = blob.getSource(); switch (op) { case 'readAsText': case 'readAsBinaryString': this.result = src; break; case 'readAsDataURL': this.result = 'data:' + blob.type + ';base64,' + Encode.btoa(src); break; } this.readyState = FileReader.DONE; this.trigger('load'); loadEnd(); } else { exec(_fr.connectRuntime(blob.ruid)); } } else { error(new x.DOMException(x.DOMException.NOT_FOUND_ERR)); } } } /** Initial FileReader state @property EMPTY @type {Number} @final @static @default 0 */ FileReader.EMPTY = 0; /** FileReader switches to this state when it is preloading the source @property LOADING @type {Number} @final @static @default 1 */ FileReader.LOADING = 1; /** Preloading is complete, this is a final state @property DONE @type {Number} @final @static @default 2 */ FileReader.DONE = 2; FileReader.prototype = EventTarget.instance; return FileReader; }); // Included from: src/javascript/core/utils/Url.js /** * Url.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/core/utils/Url', [], function() { /** Parse url into separate components and fill in absent parts with parts from current url, based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js @method parseUrl @for Utils @static @param {String} str Url to parse (defaults to empty string if undefined) @return {Object} Hash containing extracted uri components */ var parseUrl = function(str) { var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment'] , i = key.length , ports = { http: 80, https: 443 } , uri = {} , regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/ , m = regex.exec(str || '') // default to empty string if undefined ; while (i--) { if (m[i]) { uri[key[i]] = m[i]; } } if (/^[^\/]/.test(uri.path) && !uri.scheme) { // when url is relative, we need to figure out the path ourselves var path = document.location.pathname; // if path ends with a filename, strip it if (!/(\/|\/[^\.]+)$/.test(path)) { path = path.replace(/[^\/]+$/, ''); } uri.host = document.location.hostname; uri.path = path + (uri.path || ''); // site may reside at domain.com or domain.com/subdir } if (!uri.scheme) { uri.scheme = document.location.protocol.replace(/:$/, ''); } if (!uri.host) { uri.host = document.location.hostname; } if (!uri.port) { uri.port = document.location.port || ports[uri.scheme] || 80; } uri.port = parseInt(uri.port, 10); if (!uri.path) { uri.path = "/"; } delete uri.source; return uri; }; /** Resolve url - among other things will turn relative url to absolute @method resolveUrl @static @param {String} url Either absolute or relative @return {String} Resolved, absolute url */ var resolveUrl = function(url) { var ports = { // we ignore default ports http: 80, https: 443 } , urlp = parseUrl(url) ; return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : ''); }; /** Check if specified url has the same origin as the current document @method hasSameOrigin @param {String|Object} url @return {Boolean} */ var hasSameOrigin = function(url) { function origin(url) { return [url.scheme, url.host, url.port].join('/'); } if (typeof url === 'string') { url = parseUrl(url); } return origin(parseUrl()) === origin(url); }; return { parseUrl: parseUrl, resolveUrl: resolveUrl, hasSameOrigin: hasSameOrigin }; }); // Included from: src/javascript/file/FileReaderSync.js /** * FileReaderSync.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/file/FileReaderSync', [ 'moxie/core/utils/Basic', 'moxie/runtime/RuntimeClient', 'moxie/core/utils/Encode' ], function(Basic, RuntimeClient, Encode) { /** Synchronous FileReader implementation. Something like this is available in WebWorkers environment, here it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be, but probably < 1mb). Not meant to be used directly by user. @class FileReaderSync @private @constructor */ return function() { RuntimeClient.call(this); Basic.extend(this, { uid: Basic.guid('uid_'), readAsBinaryString: function(blob) { return _read.call(this, 'readAsBinaryString', blob); }, readAsDataURL: function(blob) { return _read.call(this, 'readAsDataURL', blob); }, /*readAsArrayBuffer: function(blob) { return _read.call(this, 'readAsArrayBuffer', blob); },*/ readAsText: function(blob) { return _read.call(this, 'readAsText', blob); } }); function _read(op, blob) { if (blob.isDetached()) { var src = blob.getSource(); switch (op) { case 'readAsBinaryString': return src; case 'readAsDataURL': return 'data:' + blob.type + ';base64,' + Encode.btoa(src); case 'readAsText': var txt = ''; for (var i = 0, length = src.length; i < length; i++) { txt += String.fromCharCode(src[i]); } return txt; } } else { var result = this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob); this.disconnectRuntime(); return result; } } }; }); // Included from: src/javascript/xhr/FormData.js /** * FormData.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define("moxie/xhr/FormData", [ "moxie/core/Exceptions", "moxie/core/utils/Basic", "moxie/file/Blob" ], function(x, Basic, Blob) { /** FormData @class FormData @constructor */ function FormData() { var _blobField, _fields = {}, _name = ""; Basic.extend(this, { /** Append another key-value pair to the FormData object @method append @param {String} name Name for the new field @param {String|Blob|Array|Object} value Value for the field */ append: function(name, value) { var self = this, valueType = Basic.typeOf(value); if (value instanceof Blob) { if (_blobField) { delete _fields[_blobField]; } _blobField = name; _fields[name] = [value]; // unfortunately we can only send single Blob in one FormData } else if ('array' === valueType) { name += '[]'; Basic.each(value, function(value) { self.append.call(self, name, value); }); } else if ('object' === valueType) { Basic.each(value, function(value, key) { self.append.call(self, name + '[' + key + ']', value); }); } else { value = value.toString(); // according to specs value might be either Blob or String if (!_fields[name]) { _fields[name] = []; } _fields[name].push(value); } }, /** Checks if FormData contains Blob. @method hasBlob @return {Boolean} */ hasBlob: function() { return !!_blobField; }, /** Retrieves blob. @method getBlob @return {Object} Either Blob if found or null */ getBlob: function() { return _fields[_blobField] && _fields[_blobField][0] || null; }, /** Retrieves blob field name. @method getBlobName @return {String} Either Blob field name or null */ getBlobName: function() { return _blobField || null; }, /** Loop over the fields in FormData and invoke the callback for each of them. @method each @param {Function} cb Callback to call for each field */ each: function(cb) { Basic.each(_fields, function(value, name) { Basic.each(value, function(value) { cb(value, name); }); }); }, destroy: function() { _blobField = null; _name = ""; _fields = {}; } }); } return FormData; }); // Included from: src/javascript/xhr/XMLHttpRequest.js /** * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define("moxie/xhr/XMLHttpRequest", [ "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/core/EventTarget", "moxie/core/utils/Encode", "moxie/core/utils/Url", "moxie/runtime/Runtime", "moxie/runtime/RuntimeTarget", "moxie/file/Blob", "moxie/file/FileReaderSync", "moxie/xhr/FormData", "moxie/core/utils/Env", "moxie/core/utils/Mime" ], function(Basic, x, EventTarget, Encode, Url, Runtime, RuntimeTarget, Blob, FileReaderSync, FormData, Env, Mime) { var httpCode = { 100: 'Continue', 101: 'Switching Protocols', 102: 'Processing', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 207: 'Multi-Status', 226: 'IM Used', 300: 'Multiple Choices', 301: 'Moved Permanently', 302: 'Found', 303: 'See Other', 304: 'Not Modified', 305: 'Use Proxy', 306: 'Reserved', 307: 'Temporary Redirect', 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Request Entity Too Large', 414: 'Request-URI Too Long', 415: 'Unsupported Media Type', 416: 'Requested Range Not Satisfiable', 417: 'Expectation Failed', 422: 'Unprocessable Entity', 423: 'Locked', 424: 'Failed Dependency', 426: 'Upgrade Required', 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 506: 'Variant Also Negotiates', 507: 'Insufficient Storage', 510: 'Not Extended' }; function XMLHttpRequestUpload() { this.uid = Basic.guid('uid_'); } XMLHttpRequestUpload.prototype = EventTarget.instance; /** Implementation of XMLHttpRequest @class XMLHttpRequest @constructor @uses RuntimeClient @extends EventTarget */ var dispatches = ['loadstart', 'progress', 'abort', 'error', 'load', 'timeout', 'loadend']; // & readystatechange (for historical reasons) var NATIVE = 1, RUNTIME = 2; function XMLHttpRequest() { var self = this, // this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible props = { /** The amount of milliseconds a request can take before being terminated. Initially zero. Zero means there is no timeout. @property timeout @type Number @default 0 */ timeout: 0, /** Current state, can take following values: UNSENT (numeric value 0) The object has been constructed. OPENED (numeric value 1) The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method. HEADERS_RECEIVED (numeric value 2) All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available. LOADING (numeric value 3) The response entity body is being received. DONE (numeric value 4) @property readyState @type Number @default 0 (UNSENT) */ readyState: XMLHttpRequest.UNSENT, /** True when user credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false. @property withCredentials @type Boolean @default false */ withCredentials: false, /** Returns the HTTP status code. @property status @type Number @default 0 */ status: 0, /** Returns the HTTP status text. @property statusText @type String */ statusText: "", /** Returns the response type. Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text". @property responseType @type String */ responseType: "", /** Returns the document response entity body. Throws an "InvalidStateError" exception if responseType is not the empty string or "document". @property responseXML @type Document */ responseXML: null, /** Returns the text response entity body. Throws an "InvalidStateError" exception if responseType is not the empty string or "text". @property responseText @type String */ responseText: null, /** Returns the response entity body (http://www.w3.org/TR/XMLHttpRequest/#response-entity-body). Can become: ArrayBuffer, Blob, Document, JSON, Text @property response @type Mixed */ response: null }, _async = true, _url, _method, _headers = {}, _user, _password, _encoding = null, _mimeType = null, // flags _sync_flag = false, _send_flag = false, _upload_events_flag = false, _upload_complete_flag = false, _error_flag = false, _same_origin_flag = false, // times _start_time, _timeoutset_time, _finalMime = null, _finalCharset = null, _options = {}, _xhr, _responseHeaders = '', _responseHeadersBag ; Basic.extend(this, props, { /** Unique id of the component @property uid @type String */ uid: Basic.guid('uid_'), /** Target for Upload events @property upload @type XMLHttpRequestUpload */ upload: new XMLHttpRequestUpload(), /** Sets the request method, request URL, synchronous flag, request username, and request password. Throws a "SyntaxError" exception if one of the following is true: method is not a valid HTTP method. url cannot be resolved. url contains the "user:password" format in the userinfo production. Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK. Throws an "InvalidAccessError" exception if one of the following is true: Either user or password is passed as argument and the origin of url does not match the XMLHttpRequest origin. There is an associated XMLHttpRequest document and either the timeout attribute is not zero, the withCredentials attribute is true, or the responseType attribute is not the empty string. @method open @param {String} method HTTP method to use on request @param {String} url URL to request @param {Boolean} [async=true] If false request will be done in synchronous manner. Asynchronous by default. @param {String} [user] Username to use in HTTP authentication process on server-side @param {String} [password] Password to use in HTTP authentication process on server-side */ open: function(method, url, async, user, password) { var urlp; // first two arguments are required if (!method || !url) { throw new x.DOMException(x.DOMException.SYNTAX_ERR); } // 2 - check if any code point in method is higher than U+00FF or after deflating method it does not match the method if (/[\u0100-\uffff]/.test(method) || Encode.utf8_encode(method) !== method) { throw new x.DOMException(x.DOMException.SYNTAX_ERR); } // 3 if (!!~Basic.inArray(method.toUpperCase(), ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'TRACE', 'TRACK'])) { _method = method.toUpperCase(); } // 4 - allowing these methods poses a security risk if (!!~Basic.inArray(_method, ['CONNECT', 'TRACE', 'TRACK'])) { throw new x.DOMException(x.DOMException.SECURITY_ERR); } // 5 url = Encode.utf8_encode(url); // 6 - Resolve url relative to the XMLHttpRequest base URL. If the algorithm returns an error, throw a "SyntaxError". urlp = Url.parseUrl(url); _same_origin_flag = Url.hasSameOrigin(urlp); // 7 - manually build up absolute url _url = Url.resolveUrl(url); // 9-10, 12-13 if ((user || password) && !_same_origin_flag) { throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); } _user = user || urlp.user; _password = password || urlp.pass; // 11 _async = async || true; if (_async === false && (_p('timeout') || _p('withCredentials') || _p('responseType') !== "")) { throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); } // 14 - terminate abort() // 15 - terminate send() // 18 _sync_flag = !_async; _send_flag = false; _headers = {}; _reset.call(this); // 19 _p('readyState', XMLHttpRequest.OPENED); // 20 this.convertEventPropsToHandlers(['readystatechange']); // unify event handlers this.dispatchEvent('readystatechange'); }, /** Appends an header to the list of author request headers, or if header is already in the list of author request headers, combines its value with value. Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set. Throws a "SyntaxError" exception if header is not a valid HTTP header field name or if value is not a valid HTTP header field value. @method setRequestHeader @param {String} header @param {String|Number} value */ setRequestHeader: function(header, value) { var uaHeaders = [ // these headers are controlled by the user agent "accept-charset", "accept-encoding", "access-control-request-headers", "access-control-request-method", "connection", "content-length", "cookie", "cookie2", "content-transfer-encoding", "date", "expect", "host", "keep-alive", "origin", "referer", "te", "trailer", "transfer-encoding", "upgrade", "user-agent", "via" ]; // 1-2 if (_p('readyState') !== XMLHttpRequest.OPENED || _send_flag) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 3 if (/[\u0100-\uffff]/.test(header) || Encode.utf8_encode(header) !== header) { throw new x.DOMException(x.DOMException.SYNTAX_ERR); } // 4 /* this step is seemingly bypassed in browsers, probably to allow various unicode characters in header values if (/[\u0100-\uffff]/.test(value) || Encode.utf8_encode(value) !== value) { throw new x.DOMException(x.DOMException.SYNTAX_ERR); }*/ header = Basic.trim(header).toLowerCase(); // setting of proxy-* and sec-* headers is prohibited by spec if (!!~Basic.inArray(header, uaHeaders) || /^(proxy\-|sec\-)/.test(header)) { return false; } // camelize // browsers lowercase header names (at least for custom ones) // header = header.replace(/\b\w/g, function($1) { return $1.toUpperCase(); }); if (!_headers[header]) { _headers[header] = value; } else { // http://tools.ietf.org/html/rfc2616#section-4.2 (last paragraph) _headers[header] += ', ' + value; } return true; }, /** Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2. @method getAllResponseHeaders @return {String} reponse headers or empty string */ getAllResponseHeaders: function() { return _responseHeaders || ''; }, /** Returns the header field value from the response of which the field name matches header, unless the field name is Set-Cookie or Set-Cookie2. @method getResponseHeader @param {String} header @return {String} value(s) for the specified header or null */ getResponseHeader: function(header) { header = header.toLowerCase(); if (_error_flag || !!~Basic.inArray(header, ['set-cookie', 'set-cookie2'])) { return null; } if (_responseHeaders && _responseHeaders !== '') { // if we didn't parse response headers until now, do it and keep for later if (!_responseHeadersBag) { _responseHeadersBag = {}; Basic.each(_responseHeaders.split(/\r\n/), function(line) { var pair = line.split(/:\s+/); if (pair.length === 2) { // last line might be empty, omit pair[0] = Basic.trim(pair[0]); // just in case _responseHeadersBag[pair[0].toLowerCase()] = { // simply to retain header name in original form header: pair[0], value: Basic.trim(pair[1]) }; } }); } if (_responseHeadersBag.hasOwnProperty(header)) { return _responseHeadersBag[header].header + ': ' + _responseHeadersBag[header].value; } } return null; }, /** Sets the Content-Type header for the response to mime. Throws an "InvalidStateError" exception if the state is LOADING or DONE. Throws a "SyntaxError" exception if mime is not a valid media type. @method overrideMimeType @param String mime Mime type to set */ overrideMimeType: function(mime) { var matches, charset; // 1 if (!!~Basic.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 2 mime = Basic.trim(mime.toLowerCase()); if (/;/.test(mime) && (matches = mime.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))) { mime = matches[1]; if (matches[2]) { charset = matches[2]; } } if (!Mime.mimes[mime]) { throw new x.DOMException(x.DOMException.SYNTAX_ERR); } // 3-4 _finalMime = mime; _finalCharset = charset; }, /** Initiates the request. The optional argument provides the request entity body. The argument is ignored if request method is GET or HEAD. Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set. @method send @param {Blob|Document|String|FormData} [data] Request entity body @param {Object} [options] Set of requirements and pre-requisities for runtime initialization */ send: function(data, options) { if (Basic.typeOf(options) === 'string') { _options = { ruid: options }; } else if (!options) { _options = {}; } else { _options = options; } this.convertEventPropsToHandlers(dispatches); this.upload.convertEventPropsToHandlers(dispatches); // 1-2 if (this.readyState !== XMLHttpRequest.OPENED || _send_flag) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 3 // sending Blob if (data instanceof Blob) { _options.ruid = data.ruid; _mimeType = data.type || 'application/octet-stream'; } // FormData else if (data instanceof FormData) { if (data.hasBlob()) { var blob = data.getBlob(); _options.ruid = blob.ruid; _mimeType = blob.type || 'application/octet-stream'; } } // DOMString else if (typeof data === 'string') { _encoding = 'UTF-8'; _mimeType = 'text/plain;charset=UTF-8'; // data should be converted to Unicode and encoded as UTF-8 data = Encode.utf8_encode(data); } // if withCredentials not set, but requested, set it automatically if (!this.withCredentials) { this.withCredentials = (_options.required_caps && _options.required_caps.send_browser_cookies) && !_same_origin_flag; } // 4 - storage mutex // 5 _upload_events_flag = (!_sync_flag && this.upload.hasEventListener()); // DSAP // 6 _error_flag = false; // 7 _upload_complete_flag = !data; // 8 - Asynchronous steps if (!_sync_flag) { // 8.1 _send_flag = true; // 8.2 // this.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr // 8.3 if (!_upload_complete_flag) { // this.upload.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr } } // 8.5 - Return the send() method call, but continue running the steps in this algorithm. _doXHR.call(this, data); }, /** Cancels any network activity. @method abort */ abort: function() { _error_flag = true; _sync_flag = false; if (!~Basic.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED, XMLHttpRequest.DONE])) { _p('readyState', XMLHttpRequest.DONE); _send_flag = false; if (_xhr) { _xhr.getRuntime().exec.call(_xhr, 'XMLHttpRequest', 'abort', _upload_complete_flag); } else { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } _upload_complete_flag = true; } else { _p('readyState', XMLHttpRequest.UNSENT); } }, destroy: function() { if (_xhr) { if (Basic.typeOf(_xhr.destroy) === 'function') { _xhr.destroy(); } _xhr = null; } this.unbindAll(); if (this.upload) { this.upload.unbindAll(); this.upload = null; } } }); /* this is nice, but maybe too lengthy // if supported by JS version, set getters/setters for specific properties o.defineProperty(this, 'readyState', { configurable: false, get: function() { return _p('readyState'); } }); o.defineProperty(this, 'timeout', { configurable: false, get: function() { return _p('timeout'); }, set: function(value) { if (_sync_flag) { throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); } // timeout still should be measured relative to the start time of request _timeoutset_time = (new Date).getTime(); _p('timeout', value); } }); // the withCredentials attribute has no effect when fetching same-origin resources o.defineProperty(this, 'withCredentials', { configurable: false, get: function() { return _p('withCredentials'); }, set: function(value) { // 1-2 if (!~o.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED]) || _send_flag) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 3-4 if (_anonymous_flag || _sync_flag) { throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); } // 5 _p('withCredentials', value); } }); o.defineProperty(this, 'status', { configurable: false, get: function() { return _p('status'); } }); o.defineProperty(this, 'statusText', { configurable: false, get: function() { return _p('statusText'); } }); o.defineProperty(this, 'responseType', { configurable: false, get: function() { return _p('responseType'); }, set: function(value) { // 1 if (!!~o.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 2 if (_sync_flag) { throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR); } // 3 _p('responseType', value.toLowerCase()); } }); o.defineProperty(this, 'responseText', { configurable: false, get: function() { // 1 if (!~o.inArray(_p('responseType'), ['', 'text'])) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 2-3 if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } return _p('responseText'); } }); o.defineProperty(this, 'responseXML', { configurable: false, get: function() { // 1 if (!~o.inArray(_p('responseType'), ['', 'document'])) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // 2-3 if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } return _p('responseXML'); } }); o.defineProperty(this, 'response', { configurable: false, get: function() { if (!!~o.inArray(_p('responseType'), ['', 'text'])) { if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) { return ''; } } if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) { return null; } return _p('response'); } }); */ function _p(prop, value) { if (!props.hasOwnProperty(prop)) { return; } if (arguments.length === 1) { // get return Env.can('define_property') ? props[prop] : self[prop]; } else { // set if (Env.can('define_property')) { props[prop] = value; } else { self[prop] = value; } } } /* function _toASCII(str, AllowUnassigned, UseSTD3ASCIIRules) { // TODO: http://tools.ietf.org/html/rfc3490#section-4.1 return str.toLowerCase(); } */ function _doXHR(data) { var self = this; _start_time = new Date().getTime(); _xhr = new RuntimeTarget(); function loadEnd() { _xhr.destroy(); _xhr = null; self.dispatchEvent('loadend'); self = null; } function exec(runtime) { _xhr.bind('LoadStart', function(e) { _p('readyState', XMLHttpRequest.LOADING); self.dispatchEvent('readystatechange'); self.dispatchEvent(e); if (_upload_events_flag) { self.upload.dispatchEvent(e); } }); _xhr.bind('Progress', function(e) { if (_p('readyState') !== XMLHttpRequest.LOADING) { _p('readyState', XMLHttpRequest.LOADING); // LoadStart unreliable (in Flash for example) self.dispatchEvent('readystatechange'); } self.dispatchEvent(e); }); _xhr.bind('UploadProgress', function(e) { if (_upload_events_flag) { self.upload.dispatchEvent({ type: 'progress', lengthComputable: false, total: e.total, loaded: e.loaded }); } }); _xhr.bind('Load', function(e) { _p('readyState', XMLHttpRequest.DONE); _p('status', Number(runtime.exec.call(_xhr, 'XMLHttpRequest', 'getStatus') || 0)); _p('statusText', httpCode[_p('status')] || ""); _p('response', runtime.exec.call(_xhr, 'XMLHttpRequest', 'getResponse', _p('responseType'))); if (!!~Basic.inArray(_p('responseType'), ['text', ''])) { _p('responseText', _p('response')); } else if (_p('responseType') === 'document') { _p('responseXML', _p('response')); } _responseHeaders = runtime.exec.call(_xhr, 'XMLHttpRequest', 'getAllResponseHeaders'); self.dispatchEvent('readystatechange'); if (_p('status') > 0) { // status 0 usually means that server is unreachable if (_upload_events_flag) { self.upload.dispatchEvent(e); } self.dispatchEvent(e); } else { _error_flag = true; self.dispatchEvent('error'); } loadEnd(); }); _xhr.bind('Abort', function(e) { self.dispatchEvent(e); loadEnd(); }); _xhr.bind('Error', function(e) { _error_flag = true; _p('readyState', XMLHttpRequest.DONE); self.dispatchEvent('readystatechange'); _upload_complete_flag = true; self.dispatchEvent(e); loadEnd(); }); runtime.exec.call(_xhr, 'XMLHttpRequest', 'send', { url: _url, method: _method, async: _async, user: _user, password: _password, headers: _headers, mimeType: _mimeType, encoding: _encoding, responseType: self.responseType, withCredentials: self.withCredentials, options: _options }, data); } // clarify our requirements if (typeof(_options.required_caps) === 'string') { _options.required_caps = Runtime.parseCaps(_options.required_caps); } _options.required_caps = Basic.extend({}, _options.required_caps, { return_response_type: self.responseType }); if (data instanceof FormData) { _options.required_caps.send_multipart = true; } if (!_same_origin_flag) { _options.required_caps.do_cors = true; } if (_options.ruid) { // we do not need to wait if we can connect directly exec(_xhr.connectRuntime(_options)); } else { _xhr.bind('RuntimeInit', function(e, runtime) { exec(runtime); }); _xhr.bind('RuntimeError', function(e, err) { self.dispatchEvent('RuntimeError', err); }); _xhr.connectRuntime(_options); } } function _reset() { _p('responseText', ""); _p('responseXML', null); _p('response', null); _p('status', 0); _p('statusText', ""); _start_time = _timeoutset_time = null; } } XMLHttpRequest.UNSENT = 0; XMLHttpRequest.OPENED = 1; XMLHttpRequest.HEADERS_RECEIVED = 2; XMLHttpRequest.LOADING = 3; XMLHttpRequest.DONE = 4; XMLHttpRequest.prototype = EventTarget.instance; return XMLHttpRequest; }); // Included from: src/javascript/runtime/Transporter.js /** * Transporter.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define("moxie/runtime/Transporter", [ "moxie/core/utils/Basic", "moxie/core/utils/Encode", "moxie/runtime/RuntimeClient", "moxie/core/EventTarget" ], function(Basic, Encode, RuntimeClient, EventTarget) { function Transporter() { var mod, _runtime, _data, _size, _pos, _chunk_size; RuntimeClient.call(this); Basic.extend(this, { uid: Basic.guid('uid_'), state: Transporter.IDLE, result: null, transport: function(data, type, options) { var self = this; options = Basic.extend({ chunk_size: 204798 }, options); // should divide by three, base64 requires this if ((mod = options.chunk_size % 3)) { options.chunk_size += 3 - mod; } _chunk_size = options.chunk_size; _reset.call(this); _data = data; _size = data.length; if (Basic.typeOf(options) === 'string' || options.ruid) { _run.call(self, type, this.connectRuntime(options)); } else { // we require this to run only once var cb = function(e, runtime) { self.unbind("RuntimeInit", cb); _run.call(self, type, runtime); }; this.bind("RuntimeInit", cb); this.connectRuntime(options); } }, abort: function() { var self = this; self.state = Transporter.IDLE; if (_runtime) { _runtime.exec.call(self, 'Transporter', 'clear'); self.trigger("TransportingAborted"); } _reset.call(self); }, destroy: function() { this.unbindAll(); _runtime = null; this.disconnectRuntime(); _reset.call(this); } }); function _reset() { _size = _pos = 0; _data = this.result = null; } function _run(type, runtime) { var self = this; _runtime = runtime; //self.unbind("RuntimeInit"); self.bind("TransportingProgress", function(e) { _pos = e.loaded; if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) { _transport.call(self); } }, 999); self.bind("TransportingComplete", function() { _pos = _size; self.state = Transporter.DONE; _data = null; // clean a bit self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || ''); }, 999); self.state = Transporter.BUSY; self.trigger("TransportingStarted"); _transport.call(self); } function _transport() { var self = this, chunk, bytesLeft = _size - _pos; if (_chunk_size > bytesLeft) { _chunk_size = bytesLeft; } chunk = Encode.btoa(_data.substr(_pos, _chunk_size)); _runtime.exec.call(self, 'Transporter', 'receive', chunk, _size); } } Transporter.IDLE = 0; Transporter.BUSY = 1; Transporter.DONE = 2; Transporter.prototype = EventTarget.instance; return Transporter; }); // Included from: src/javascript/core/JSON.js /** * JSON.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*jshint smarttabs:true */ define("moxie/core/JSON", [], function() { /** Parse string into the JSON object in a safe way @credits Douglas Crockford: https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js @method parse @static @protected @param {Object} obj Object to add property to @param {String} prop Property name @param {Object} desc Set of key-value pairs defining descriptor for the property */ return !!window.JSON && JSON.parse || (function() { "use strict"; // This is a function that can parse a JSON text, producing a JavaScript // data structure. It is a simple, recursive descent parser. It does not use // eval or regular expressions, so it can be used as a model for implementing // a JSON parser in other languages. // We are defining the function inside of another function to avoid // creating global variables. var at, // The index of the current character ch, // The current character escapee = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' }, text, error = function (m) { // Call error when something is wrong. throw { name: 'SyntaxError', message: m, at: at, text: text }; }, next = function (c) { // If a c parameter is provided, verify that it matches the current character. if (c && c !== ch) { error("Expected '" + c + "' instead of '" + ch + "'"); } // Get the next character. When there are no more characters, // return the empty string. ch = text.charAt(at); at += 1; return ch; }, number = function () { // Parse a number value. var number, string = ''; if (ch === '-') { string = '-'; next('-'); } while (ch >= '0' && ch <= '9') { string += ch; next(); } if (ch === '.') { string += '.'; while (next() && ch >= '0' && ch <= '9') { string += ch; } } if (ch === 'e' || ch === 'E') { string += ch; next(); if (ch === '-' || ch === '+') { string += ch; next(); } while (ch >= '0' && ch <= '9') { string += ch; next(); } } number = +string; if (!isFinite(number)) { error("Bad number"); } else { return number; } }, string = function () { // Parse a string value. var hex, i, string = '', uffff; // When parsing for string values, we must look for " and \ characters. if (ch === '"') { while (next()) { if (ch === '"') { next(); return string; } else if (ch === '\\') { next(); if (ch === 'u') { uffff = 0; for (i = 0; i < 4; i += 1) { hex = parseInt(next(), 16); if (!isFinite(hex)) { break; } uffff = uffff * 16 + hex; } string += String.fromCharCode(uffff); } else if (typeof escapee[ch] === 'string') { string += escapee[ch]; } else { break; } } else { string += ch; } } } error("Bad string"); }, white = function () { // Skip whitespace. while (ch && ch <= ' ') { next(); } }, word = function () { // true, false, or null. switch (ch) { case 't': next('t'); next('r'); next('u'); next('e'); return true; case 'f': next('f'); next('a'); next('l'); next('s'); next('e'); return false; case 'n': next('n'); next('u'); next('l'); next('l'); return null; } error("Unexpected '" + ch + "'"); }, value, // Place holder for the value function. array = function () { // Parse an array value. var array = []; if (ch === '[') { next('['); white(); if (ch === ']') { next(']'); return array; // empty array } while (ch) { array.push(value()); white(); if (ch === ']') { next(']'); return array; } next(','); white(); } } error("Bad array"); }, object = function () { // Parse an object value. var key, object = {}; if (ch === '{') { next('{'); white(); if (ch === '}') { next('}'); return object; // empty object } while (ch) { key = string(); white(); next(':'); if (Object.hasOwnProperty.call(object, key)) { error('Duplicate key "' + key + '"'); } object[key] = value(); white(); if (ch === '}') { next('}'); return object; } next(','); white(); } } error("Bad object"); }; value = function () { // Parse a JSON value. It could be an object, an array, a string, a number, // or a word. white(); switch (ch) { case '{': return object(); case '[': return array(); case '"': return string(); case '-': return number(); default: return ch >= '0' && ch <= '9' ? number() : word(); } }; // Return the json_parse function. It will have access to all of the above // functions and variables. return function (source, reviver) { var result; text = source; at = 0; ch = ' '; result = value(); white(); if (ch) { error("Syntax error"); } // If there is a reviver function, we recursively walk the new structure, // passing each name/value pair to the reviver function for possible // transformation, starting with a temporary root object that holds the result // in an empty key. If there is not a reviver function, we simply return the // result. return typeof reviver === 'function' ? (function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.prototype.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); }({'': result}, '')) : result; }; }()); }); // Included from: src/javascript/image/Image.js /** * Image.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define("moxie/image/Image", [ "moxie/core/utils/Basic", "moxie/core/utils/Dom", "moxie/core/Exceptions", "moxie/file/FileReaderSync", "moxie/xhr/XMLHttpRequest", "moxie/runtime/Runtime", "moxie/runtime/RuntimeClient", "moxie/runtime/Transporter", "moxie/core/utils/Env", "moxie/core/EventTarget", "moxie/file/Blob", "moxie/file/File", "moxie/core/utils/Encode", "moxie/core/JSON" ], function(Basic, Dom, x, FileReaderSync, XMLHttpRequest, Runtime, RuntimeClient, Transporter, Env, EventTarget, Blob, File, Encode, parseJSON) { /** Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data. @class Image @constructor @extends EventTarget */ var dispatches = [ 'progress', /** Dispatched when loading is complete. @event load @param {Object} event */ 'load', 'error', /** Dispatched when resize operation is complete. @event resize @param {Object} event */ 'resize', /** Dispatched when visual representation of the image is successfully embedded into the corresponsing container. @event embedded @param {Object} event */ 'embedded' ]; function Image() { RuntimeClient.call(this); Basic.extend(this, { /** Unique id of the component @property uid @type {String} */ uid: Basic.guid('uid_'), /** Unique id of the connected runtime, if any. @property ruid @type {String} */ ruid: null, /** Name of the file, that was used to create an image, if available. If not equals to empty string. @property name @type {String} @default "" */ name: "", /** Size of the image in bytes. Actual value is set only after image is preloaded. @property size @type {Number} @default 0 */ size: 0, /** Width of the image. Actual value is set only after image is preloaded. @property width @type {Number} @default 0 */ width: 0, /** Height of the image. Actual value is set only after image is preloaded. @property height @type {Number} @default 0 */ height: 0, /** Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded. @property type @type {String} @default "" */ type: "", /** Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded. @property meta @type {Object} @default {} */ meta: {}, /** Alias for load method, that takes another mOxie.Image object as a source (see load). @method clone @param {Image} src Source for the image @param {Boolean} [exact=false] Whether to activate in-depth clone mode */ clone: function() { this.load.apply(this, arguments); }, /** Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File, native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL, Image will be downloaded from remote destination and loaded in memory. @example var img = new mOxie.Image(); img.onload = function() { var blob = img.getAsBlob(); var formData = new mOxie.FormData(); formData.append('file', blob); var xhr = new mOxie.XMLHttpRequest(); xhr.onload = function() { // upload complete }; xhr.open('post', 'upload.php'); xhr.send(formData); }; img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg) @method load @param {Image|Blob|File|String} src Source for the image @param {Boolean|Object} [mixed] */ load: function() { // this is here because to bind properly we need an uid first, which is created above this.bind('Load Resize', function() { _updateInfo.call(this); }, 999); this.convertEventPropsToHandlers(dispatches); _load.apply(this, arguments); }, /** Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions. @method downsize @param {Number} width Resulting width @param {Number} [height=width] Resulting height (optional, if not supplied will default to width) @param {Boolean} [crop=false] Whether to crop the image to exact dimensions @param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) */ downsize: function(width, height, crop, preserveHeaders) { try { if (!this.size) { // only preloaded image objects can be used as source throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } // no way to reliably intercept the crash due to high resolution, so we simply avoid it if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) { throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); } if (!width && !height || Basic.typeOf(crop) === 'undefined') { crop = false; } width = width || this.width; height = height || this.height; preserveHeaders = (Basic.typeOf(preserveHeaders) === 'undefined' ? true : !!preserveHeaders); this.getRuntime().exec.call(this, 'Image', 'downsize', width, height, crop, preserveHeaders); } catch(ex) { // for now simply trigger error event this.trigger('error', ex); } }, /** Alias for downsize(width, height, true). (see downsize) @method crop @param {Number} width Resulting width @param {Number} [height=width] Resulting height (optional, if not supplied will default to width) @param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize) */ crop: function(width, height, preserveHeaders) { this.downsize(width, height, true, preserveHeaders); }, getAsCanvas: function() { if (!Env.can('create_canvas')) { throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); } var runtime = this.connectRuntime(this.ruid); return runtime.exec.call(this, 'Image', 'getAsCanvas'); }, /** Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR). @method getAsBlob @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png @param {Number} [quality=90] Applicable only together with mime type image/jpeg @return {Blob} Image as Blob */ getAsBlob: function(type, quality) { if (!this.size) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } if (!type) { type = 'image/jpeg'; } if (type === 'image/jpeg' && !quality) { quality = 90; } return this.getRuntime().exec.call(this, 'Image', 'getAsBlob', type, quality); }, /** Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR). @method getAsDataURL @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png @param {Number} [quality=90] Applicable only together with mime type image/jpeg @return {String} Image as dataURL string */ getAsDataURL: function(type, quality) { if (!this.size) { throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } return this.getRuntime().exec.call(this, 'Image', 'getAsDataURL', type, quality); }, /** Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR). @method getAsBinaryString @param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png @param {Number} [quality=90] Applicable only together with mime type image/jpeg @return {String} Image as binary string */ getAsBinaryString: function(type, quality) { var dataUrl = this.getAsDataURL(type, quality); return Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)); }, /** Embeds the image, or better to say, it's visual representation into the specified node. Depending on the runtime in use, might be a canvas, or image (actual ) element or shim object (Flash or SilverLight - very rare, used for legacy browsers that do not have canvas or proper dataURI support). @method embed @param {DOMElement} el DOM element to insert the image object into @param {Object} options Set of key/value pairs controlling the mime type, dimensions and cropping factor of resulting representation */ embed: function(el) { var self = this , imgCopy , type, quality, crop , options = arguments[1] || {} , width = this.width , height = this.height , runtime // this has to be outside of all the closures to contain proper runtime ; function onResize() { // if possible, embed a canvas element directly if (Env.can('create_canvas')) { var canvas = imgCopy.getAsCanvas(); if (canvas) { el.appendChild(canvas); canvas = null; imgCopy.destroy(); self.trigger('embedded'); return; } } var dataUrl = imgCopy.getAsDataURL(type, quality); if (!dataUrl) { throw new x.ImageError(x.ImageError.WRONG_FORMAT); } if (Env.can('use_data_uri_of', dataUrl.length)) { el.innerHTML = ''; imgCopy.destroy(); self.trigger('embedded'); } else { var tr = new Transporter(); tr.bind("TransportingComplete", function() { runtime = self.connectRuntime(this.result.ruid); self.bind("Embedded", function() { // position and size properly Basic.extend(runtime.getShimContainer().style, { //position: 'relative', top: '0px', left: '0px', width: imgCopy.width + 'px', height: imgCopy.height + 'px' }); // some shims (Flash/SilverLight) reinitialize, if parent element is hidden, reordered or it's // position type changes (in Gecko), but since we basically need this only in IEs 6/7 and // sometimes 8 and they do not have this problem, we can comment this for now /*tr.bind("RuntimeInit", function(e, runtime) { tr.destroy(); runtime.destroy(); onResize.call(self); // re-feed our image data });*/ runtime = null; }, 999); runtime.exec.call(self, "ImageView", "display", this.result.uid, width, height); imgCopy.destroy(); }); tr.transport(Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)), type, Basic.extend({}, options, { required_caps: { display_media: true }, runtime_order: 'flash,silverlight', container: el })); } } try { if (!(el = Dom.get(el))) { throw new x.DOMException(x.DOMException.INVALID_NODE_TYPE_ERR); } if (!this.size) { // only preloaded image objects can be used as source throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) { throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR); } type = options.type || this.type || 'image/jpeg'; quality = options.quality || 90; crop = Basic.typeOf(options.crop) !== 'undefined' ? options.crop : false; // figure out dimensions for the thumb if (options.width) { width = options.width; height = options.height || width; } else { // if container element has > 0 dimensions, take them var dimensions = Dom.getSize(el); if (dimensions.w && dimensions.h) { // both should be > 0 width = dimensions.w; height = dimensions.h; } } imgCopy = new Image(); imgCopy.bind("Resize", function() { onResize.call(self); }); imgCopy.bind("Load", function() { imgCopy.downsize(width, height, crop, false); }); imgCopy.clone(this, false); return imgCopy; } catch(ex) { // for now simply trigger error event this.trigger('error', ex); } }, /** Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object. @method destroy */ destroy: function() { if (this.ruid) { this.getRuntime().exec.call(this, 'Image', 'destroy'); this.disconnectRuntime(); } this.unbindAll(); } }); function _updateInfo(info) { if (!info) { info = this.getRuntime().exec.call(this, 'Image', 'getInfo'); } if (info) { if (Basic.typeOf(info.meta) === 'string') { // might be a JSON string try { this.meta = parseJSON(info.meta); } catch(ex) {} } else { this.meta = info.meta; } } Basic.extend(this, { // info object might be non-enumerable (as returned from SilverLight for example) size: parseInt(info.size, 10), width: parseInt(info.width, 10), height: parseInt(info.height, 10), type: info.type }); // update file name, only if empty if (this.name === '') { this.name = info.name; } } function _load(src) { var srcType = Basic.typeOf(src); try { // if source is Image if (src instanceof Image) { if (!src.size) { // only preloaded image objects can be used as source throw new x.DOMException(x.DOMException.INVALID_STATE_ERR); } _loadFromImage.apply(this, arguments); } // if source is o.Blob/o.File else if (src instanceof Blob) { if (!~Basic.inArray(src.type, ['image/jpeg', 'image/png'])) { throw new x.ImageError(x.ImageError.WRONG_FORMAT); } _loadFromBlob.apply(this, arguments); } // if native blob/file else if (Basic.inArray(srcType, ['blob', 'file']) !== -1) { _load.call(this, new File(null, src), arguments[1]); } // if String else if (srcType === 'string') { // if dataUrl String if (/^data:[^;]*;base64,/.test(src)) { _load.call(this, new Blob(null, { data: src }), arguments[1]); } // else assume Url, either relative or absolute else { _loadFromUrl.apply(this, arguments); } } // if source seems to be an img node else if (srcType === 'node' && src.nodeName.toLowerCase() === 'img') { _load.call(this, src.src, arguments[1]); } else { throw new x.DOMException(x.DOMException.TYPE_MISMATCH_ERR); } } catch(ex) { // for now simply trigger error event this.trigger('error', ex); } } function _loadFromImage(img, exact) { var runtime = this.connectRuntime(img.ruid); this.ruid = runtime.uid; runtime.exec.call(this, 'Image', 'loadFromImage', img, (Basic.typeOf(exact) === 'undefined' ? true : exact)); } function _loadFromBlob(blob, options) { var self = this; self.name = blob.name || ''; function exec(runtime) { self.ruid = runtime.uid; runtime.exec.call(self, 'Image', 'loadFromBlob', blob); } if (blob.isDetached()) { this.bind('RuntimeInit', function(e, runtime) { exec(runtime); }); // convert to object representation if (options && typeof(options.required_caps) === 'string') { options.required_caps = Runtime.parseCaps(options.required_caps); } this.connectRuntime(Basic.extend({ required_caps: { access_image_binary: true, resize_image: true } }, options)); } else { exec(this.connectRuntime(blob.ruid)); } } function _loadFromUrl(url, options) { var self = this, xhr; xhr = new XMLHttpRequest(); xhr.open('get', url); xhr.responseType = 'blob'; xhr.onprogress = function(e) { self.trigger(e); }; xhr.onload = function() { _loadFromBlob.call(self, xhr.response, true); }; xhr.onerror = function(e) { self.trigger(e); }; xhr.onloadend = function() { xhr.destroy(); }; xhr.bind('RuntimeError', function(e, err) { self.trigger('RuntimeError', err); }); xhr.send(null, options); } } // virtual world will crash on you if image has a resolution higher than this: Image.MAX_RESIZE_WIDTH = 6500; Image.MAX_RESIZE_HEIGHT = 6500; Image.prototype = EventTarget.instance; return Image; }); // Included from: src/javascript/runtime/html5/Runtime.js /** * Runtime.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global File:true */ /** Defines constructor for HTML5 runtime. @class moxie/runtime/html5/Runtime @private */ define("moxie/runtime/html5/Runtime", [ "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/runtime/Runtime", "moxie/core/utils/Env" ], function(Basic, x, Runtime, Env) { var type = "html5", extensions = {}; function Html5Runtime(options) { var I = this , Test = Runtime.capTest , True = Runtime.capTrue ; var caps = Basic.extend({ access_binary: Test(window.FileReader || window.File && window.File.getAsDataURL), access_image_binary: function() { return I.can('access_binary') && !!extensions.Image; }, display_media: Test(Env.can('create_canvas') || Env.can('use_data_uri_over32kb')), do_cors: Test(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()), drag_and_drop: Test(function() { // this comes directly from Modernizr: http://www.modernizr.com/ var div = document.createElement('div'); // IE has support for drag and drop since version 5, but doesn't support dropping files from desktop return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && (Env.browser !== 'IE' || Env.version > 9); }()), filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10); }()), return_response_headers: True, return_response_type: function(responseType) { if (responseType === 'json') { return true; // we can fake this one even if it's not supported } else { return Env.can('return_response_type', responseType); } }, return_status_code: True, report_upload_progress: Test(window.XMLHttpRequest && new XMLHttpRequest().upload), resize_image: function() { return I.can('access_binary') && Env.can('create_canvas'); }, select_file: function() { return Env.can('use_fileinput') && window.File; }, select_folder: function() { return I.can('select_file') && Env.browser === 'Chrome' && Env.version >= 21; }, select_multiple: function() { return I.can('select_file') && !(Env.browser === 'Safari' && Env.OS === 'Windows'); }, send_binary_string: Test(window.XMLHttpRequest && (new XMLHttpRequest().sendAsBinary || (window.Uint8Array && window.ArrayBuffer))), send_custom_headers: Test(window.XMLHttpRequest), send_multipart: function() { return !!(window.XMLHttpRequest && new XMLHttpRequest().upload && window.FormData) || I.can('send_binary_string'); }, slice_blob: Test(window.File && (File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice)), stream_upload: function(){ return I.can('slice_blob') && I.can('send_multipart'); }, summon_file_dialog: Test(function() { // yeah... some dirty sniffing here... return (Env.browser === 'Firefox' && Env.version >= 4) || (Env.browser === 'Opera' && Env.version >= 12) || (Env.browser === 'IE' && Env.version >= 10) || !!~Basic.inArray(Env.browser, ['Chrome', 'Safari']); }()), upload_filesize: True }, arguments[2] ); Runtime.call(this, options, (arguments[1] || type), caps); Basic.extend(this, { init : function() { this.trigger("Init"); }, destroy: (function(destroy) { // extend default destroy method return function() { destroy.call(I); destroy = I = null; }; }(this.destroy)) }); Basic.extend(this.getShim(), extensions); } Runtime.addConstructor(type, Html5Runtime); return extensions; }); // Included from: src/javascript/runtime/html5/file/Blob.js /** * Blob.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/file/Blob @private */ define("moxie/runtime/html5/file/Blob", [ "moxie/runtime/html5/Runtime", "moxie/file/Blob" ], function(extensions, Blob) { function HTML5Blob() { function w3cBlobSlice(blob, start, end) { var blobSlice; if (window.File.prototype.slice) { try { blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception return blob.slice(start, end); } catch (e) { // depricated slice method return blob.slice(start, end - start); } // slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672 } else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) { return blobSlice.call(blob, start, end); } else { return null; // or throw some exception } } this.slice = function() { return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments)); }; } return (extensions.Blob = HTML5Blob); }); // Included from: src/javascript/core/utils/Events.js /** * Events.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ define('moxie/core/utils/Events', [ 'moxie/core/utils/Basic' ], function(Basic) { var eventhash = {}, uid = 'moxie_' + Basic.guid(); // IE W3C like event funcs function preventDefault() { this.returnValue = false; } function stopPropagation() { this.cancelBubble = true; } /** Adds an event handler to the specified object and store reference to the handler in objects internal Plupload registry (@see removeEvent). @method addEvent @for Utils @static @param {Object} obj DOM element like object to add handler to. @param {String} name Name to add event listener to. @param {Function} callback Function to call when event occurs. @param {String} [key] that might be used to add specifity to the event record. */ var addEvent = function(obj, name, callback, key) { var func, events; name = name.toLowerCase(); // Add event listener if (obj.addEventListener) { func = callback; obj.addEventListener(name, func, false); } else if (obj.attachEvent) { func = function() { var evt = window.event; if (!evt.target) { evt.target = evt.srcElement; } evt.preventDefault = preventDefault; evt.stopPropagation = stopPropagation; callback(evt); }; obj.attachEvent('on' + name, func); } // Log event handler to objects internal mOxie registry if (!obj[uid]) { obj[uid] = Basic.guid(); } if (!eventhash.hasOwnProperty(obj[uid])) { eventhash[obj[uid]] = {}; } events = eventhash[obj[uid]]; if (!events.hasOwnProperty(name)) { events[name] = []; } events[name].push({ func: func, orig: callback, // store original callback for IE key: key }); }; /** Remove event handler from the specified object. If third argument (callback) is not specified remove all events with the specified name. @method removeEvent @static @param {Object} obj DOM element to remove event listener(s) from. @param {String} name Name of event listener to remove. @param {Function|String} [callback] might be a callback or unique key to match. */ var removeEvent = function(obj, name, callback) { var type, undef; name = name.toLowerCase(); if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) { type = eventhash[obj[uid]][name]; } else { return; } for (var i = type.length - 1; i >= 0; i--) { // undefined or not, key should match if (type[i].orig === callback || type[i].key === callback) { if (obj.removeEventListener) { obj.removeEventListener(name, type[i].func, false); } else if (obj.detachEvent) { obj.detachEvent('on'+name, type[i].func); } type[i].orig = null; type[i].func = null; type.splice(i, 1); // If callback was passed we are done here, otherwise proceed if (callback !== undef) { break; } } } // If event array got empty, remove it if (!type.length) { delete eventhash[obj[uid]][name]; } // If mOxie registry has become empty, remove it if (Basic.isEmptyObj(eventhash[obj[uid]])) { delete eventhash[obj[uid]]; // IE doesn't let you remove DOM object property with - delete try { delete obj[uid]; } catch(e) { obj[uid] = undef; } } }; /** Remove all kind of events from the specified object @method removeAllEvents @static @param {Object} obj DOM element to remove event listeners from. @param {String} [key] unique key to match, when removing events. */ var removeAllEvents = function(obj, key) { if (!obj || !obj[uid]) { return; } Basic.each(eventhash[obj[uid]], function(events, name) { removeEvent(obj, name, key); }); }; return { addEvent: addEvent, removeEvent: removeEvent, removeAllEvents: removeAllEvents }; }); // Included from: src/javascript/runtime/html5/file/FileInput.js /** * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/file/FileInput @private */ define("moxie/runtime/html5/file/FileInput", [ "moxie/runtime/html5/Runtime", "moxie/core/utils/Basic", "moxie/core/utils/Dom", "moxie/core/utils/Events", "moxie/core/utils/Mime", "moxie/core/utils/Env" ], function(extensions, Basic, Dom, Events, Mime, Env) { function FileInput() { var _files = [], _options; Basic.extend(this, { init: function(options) { var comp = this, I = comp.getRuntime(), input, shimContainer, mimes, browseButton, zIndex, top; _options = options; _files = []; // figure out accept string mimes = _options.accept.mimes || Mime.extList2mimes(_options.accept, I.can('filter_by_extension')); shimContainer = I.getShimContainer(); shimContainer.innerHTML = ''; input = Dom.get(I.uid); // prepare file input to be placed underneath the browse_button element Basic.extend(input.style, { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }); browseButton = Dom.get(_options.browse_button); // Route click event to the input[type=file] element for browsers that support such behavior if (I.can('summon_file_dialog')) { if (Dom.getStyle(browseButton, 'position') === 'static') { browseButton.style.position = 'relative'; } zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1; browseButton.style.zIndex = zIndex; shimContainer.style.zIndex = zIndex - 1; Events.addEvent(browseButton, 'click', function(e) { var input = Dom.get(I.uid); if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file] input.click(); } e.preventDefault(); }, comp.uid); } /* Since we have to place input[type=file] on top of the browse_button for some browsers, browse_button loses interactivity, so we restore it here */ top = I.can('summon_file_dialog') ? browseButton : shimContainer; Events.addEvent(top, 'mouseover', function() { comp.trigger('mouseenter'); }, comp.uid); Events.addEvent(top, 'mouseout', function() { comp.trigger('mouseleave'); }, comp.uid); Events.addEvent(top, 'mousedown', function() { comp.trigger('mousedown'); }, comp.uid); Events.addEvent(Dom.get(_options.container), 'mouseup', function() { comp.trigger('mouseup'); }, comp.uid); input.onchange = function onChange() { // there should be only one handler for this _files = []; if (_options.directory) { // folders are represented by dots, filter them out (Chrome 11+) Basic.each(this.files, function(file) { if (file.name !== ".") { // if it doesn't looks like a folder _files.push(file); } }); } else { _files = [].slice.call(this.files); } // clearing the value enables the user to select the same file again if they want to if (Env.browser !== 'IE') { this.value = ''; } else { // in IE input[type="file"] is read-only so the only way to reset it is to re-insert it var clone = this.cloneNode(true); this.parentNode.replaceChild(clone, this); clone.onchange = onChange; } comp.trigger('change'); }; // ready event is perfectly asynchronous comp.trigger({ type: 'ready', async: true }); shimContainer = null; }, getFiles: function() { return _files; }, disable: function(state) { var I = this.getRuntime(), input; if ((input = Dom.get(I.uid))) { input.disabled = !!state; } }, destroy: function() { var I = this.getRuntime(), shimContainer = I.getShimContainer(); Events.removeAllEvents(shimContainer, this.uid); Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid); if (shimContainer) { shimContainer.innerHTML = ''; } _files = _options = null; } }); } return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/html5/file/FileDrop.js /** * FileDrop.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/file/FileDrop @private */ define("moxie/runtime/html5/file/FileDrop", [ "moxie/runtime/html5/Runtime", "moxie/core/utils/Basic", "moxie/core/utils/Dom", "moxie/core/utils/Events", "moxie/core/utils/Mime" ], function(extensions, Basic, Dom, Events, Mime) { function FileDrop() { var _files = [], _allowedExts = [], _options; Basic.extend(this, { init: function(options) { var comp = this, dropZone; _options = options; _allowedExts = _extractExts(_options.accept); dropZone = _options.container; Events.addEvent(dropZone, 'dragover', function(e) { e.preventDefault(); e.stopPropagation(); e.dataTransfer.dropEffect = 'copy'; }, comp.uid); Events.addEvent(dropZone, 'drop', function(e) { e.preventDefault(); e.stopPropagation(); _files = []; // Chrome 21+ accepts folders via Drag'n'Drop if (e.dataTransfer.items && e.dataTransfer.items[0].webkitGetAsEntry) { var entries = []; Basic.each(e.dataTransfer.items, function(item) { entries.push(item.webkitGetAsEntry()); }); _readEntries(entries, function() { comp.trigger("drop"); }); } else { Basic.each(e.dataTransfer.files, function(file) { if (_isAcceptable(file)) { _files.push(file); } }); comp.trigger("drop"); } }, comp.uid); Events.addEvent(dropZone, 'dragenter', function(e) { e.preventDefault(); e.stopPropagation(); comp.trigger("dragenter"); }, comp.uid); Events.addEvent(dropZone, 'dragleave', function(e) { e.preventDefault(); e.stopPropagation(); comp.trigger("dragleave"); }, comp.uid); }, getFiles: function() { return _files; }, destroy: function() { Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); _files = _allowedExts = _options = null; } }); function _extractExts(accept) { var exts = []; for (var i = 0; i < accept.length; i++) { [].push.apply(exts, accept[i].extensions.split(/\s*,\s*/)); } return Basic.inArray('*', exts) === -1 ? exts : []; } function _isAcceptable(file) { var ext = Mime.getFileExtension(file.name); return !ext || !_allowedExts.length || Basic.inArray(ext, _allowedExts) !== -1; } function _readEntries(entries, cb) { var queue = []; Basic.each(entries, function(entry) { queue.push(function(cbcb) { _readEntry(entry, cbcb); }); }); Basic.inSeries(queue, function() { cb(); }); } function _readEntry(entry, cb) { if (entry.isFile) { entry.file(function(file) { if (_isAcceptable(file)) { _files.push(file); } cb(); }, function() { // fire an error event maybe cb(); }); } else if (entry.isDirectory) { _readDirEntry(entry, cb); } else { cb(); // not file, not directory? what then?.. } } function _readDirEntry(dirEntry, cb) { var entries = [], dirReader = dirEntry.createReader(); // keep quering recursively till no more entries function getEntries(cbcb) { dirReader.readEntries(function(moreEntries) { if (moreEntries.length) { [].push.apply(entries, moreEntries); getEntries(cbcb); } else { cbcb(); } }, cbcb); } // ...and you thought FileReader was crazy... getEntries(function() { _readEntries(entries, cb); }); } } return (extensions.FileDrop = FileDrop); }); // Included from: src/javascript/runtime/html5/file/FileReader.js /** * FileReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/file/FileReader @private */ define("moxie/runtime/html5/file/FileReader", [ "moxie/runtime/html5/Runtime", "moxie/core/utils/Encode", "moxie/core/utils/Basic" ], function(extensions, Encode, Basic) { function FileReader() { var _fr, _convertToBinary = false; Basic.extend(this, { read: function(op, blob) { var target = this; _fr = new window.FileReader(); _fr.addEventListener('progress', function(e) { target.trigger(e); }); _fr.addEventListener('load', function(e) { target.trigger(e); }); _fr.addEventListener('error', function(e) { target.trigger(e, _fr.error); }); _fr.addEventListener('loadend', function() { _fr = null; }); if (Basic.typeOf(_fr[op]) === 'function') { _convertToBinary = false; _fr[op](blob.getSource()); } else if (op === 'readAsBinaryString') { // readAsBinaryString is depricated in general and never existed in IE10+ _convertToBinary = true; _fr.readAsDataURL(blob.getSource()); } }, getResult: function() { return _fr && _fr.result ? (_convertToBinary ? _toBinary(_fr.result) : _fr.result) : null; }, abort: function() { if (_fr) { _fr.abort(); } }, destroy: function() { _fr = null; } }); function _toBinary(str) { return Encode.atob(str.substring(str.indexOf('base64,') + 7)); } } return (extensions.FileReader = FileReader); }); // Included from: src/javascript/runtime/html5/xhr/XMLHttpRequest.js /** * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global ActiveXObject:true */ /** @class moxie/runtime/html5/xhr/XMLHttpRequest @private */ define("moxie/runtime/html5/xhr/XMLHttpRequest", [ "moxie/runtime/html5/Runtime", "moxie/core/utils/Basic", "moxie/core/utils/Mime", "moxie/core/utils/Url", "moxie/file/File", "moxie/file/Blob", "moxie/xhr/FormData", "moxie/core/Exceptions", "moxie/core/utils/Env", "moxie/core/JSON" ], function(extensions, Basic, Mime, Url, File, Blob, FormData, x, Env, parseJSON) { function XMLHttpRequest() { var _xhr , _filename ; Basic.extend(this, { send: function(meta, data) { var target = this , isGecko2_5_6 = (Env.browser === 'Mozilla' && Env.version >= 4 && Env.version < 7) , isAndroidBrowser = Env.browser === 'Android Browser' , mustSendAsBinary = false ; // extract file name _filename = meta.url.replace(/^.+?\/([\w\-\.]+)$/, '$1').toLowerCase(); _xhr = _getNativeXHR(); _xhr.open(meta.method, meta.url, meta.async, meta.user, meta.password); // prepare data to be sent if (data instanceof Blob) { if (data.isDetached()) { mustSendAsBinary = true; } data = data.getSource(); } else if (data instanceof FormData) { if (data.hasBlob()) { if (data.getBlob().isDetached()) { data = _prepareMultipart.call(target, data); // _xhr must be instantiated and be in OPENED state mustSendAsBinary = true; } else if ((isGecko2_5_6 || isAndroidBrowser) && Basic.typeOf(data.getBlob().getSource()) === 'blob' && window.FileReader) { // Gecko 2/5/6 can't send blob in FormData: https://bugzilla.mozilla.org/show_bug.cgi?id=649150 // Android browsers (default one and Dolphin) seem to have the same issue, see: #613 _preloadAndSend.call(target, meta, data); return; // _preloadAndSend will reinvoke send() with transmutated FormData =%D } } // transfer fields to real FormData if (data instanceof FormData) { // if still a FormData, e.g. not mangled by _prepareMultipart() var fd = new window.FormData(); data.each(function(value, name) { if (value instanceof Blob) { fd.append(name, value.getSource()); } else { fd.append(name, value); } }); data = fd; } } // if XHR L2 if (_xhr.upload) { if (meta.withCredentials) { _xhr.withCredentials = true; } _xhr.addEventListener('load', function(e) { target.trigger(e); }); _xhr.addEventListener('error', function(e) { target.trigger(e); }); // additionally listen to progress events _xhr.addEventListener('progress', function(e) { target.trigger(e); }); _xhr.upload.addEventListener('progress', function(e) { target.trigger({ type: 'UploadProgress', loaded: e.loaded, total: e.total }); }); // ... otherwise simulate XHR L2 } else { _xhr.onreadystatechange = function onReadyStateChange() { // fake Level 2 events switch (_xhr.readyState) { case 1: // XMLHttpRequest.OPENED // readystatechanged is fired twice for OPENED state (in IE and Mozilla) - neu break; // looks like HEADERS_RECEIVED (state 2) is not reported in Opera (or it's old versions) - neu case 2: // XMLHttpRequest.HEADERS_RECEIVED break; case 3: // XMLHttpRequest.LOADING // try to fire progress event for not XHR L2 var total, loaded; try { if (Url.hasSameOrigin(meta.url)) { // Content-Length not accessible for cross-domain on some browsers total = _xhr.getResponseHeader('Content-Length') || 0; // old Safari throws an exception here } if (_xhr.responseText) { // responseText was introduced in IE7 loaded = _xhr.responseText.length; } } catch(ex) { total = loaded = 0; } target.trigger({ type: 'progress', lengthComputable: !!total, total: parseInt(total, 10), loaded: loaded }); break; case 4: // XMLHttpRequest.DONE // release readystatechange handler (mostly for IE) _xhr.onreadystatechange = function() {}; // usually status 0 is returned when server is unreachable, but FF also fails to status 0 for 408 timeout if (_xhr.status === 0) { target.trigger('error'); } else { target.trigger('load'); } break; } }; } // set request headers if (!Basic.isEmptyObj(meta.headers)) { Basic.each(meta.headers, function(value, header) { _xhr.setRequestHeader(header, value); }); } // request response type if ("" !== meta.responseType && 'responseType' in _xhr) { if ('json' === meta.responseType && !Env.can('return_response_type', 'json')) { // we can fake this one _xhr.responseType = 'text'; } else { _xhr.responseType = meta.responseType; } } // send ... if (!mustSendAsBinary) { _xhr.send(data); } else { if (_xhr.sendAsBinary) { // Gecko _xhr.sendAsBinary(data); } else { // other browsers having support for typed arrays (function() { // mimic Gecko's sendAsBinary var ui8a = new Uint8Array(data.length); for (var i = 0; i < data.length; i++) { ui8a[i] = (data.charCodeAt(i) & 0xff); } _xhr.send(ui8a.buffer); }()); } } target.trigger('loadstart'); }, getStatus: function() { // according to W3C spec it should return 0 for readyState < 3, but instead it throws an exception try { if (_xhr) { return _xhr.status; } } catch(ex) {} return 0; }, getResponse: function(responseType) { var I = this.getRuntime(); try { switch (responseType) { case 'blob': var file = new File(I.uid, _xhr.response); // try to extract file name from content-disposition if possible (might be - not, if CORS for example) var disposition = _xhr.getResponseHeader('Content-Disposition'); if (disposition) { // extract filename from response header if available var match = disposition.match(/filename=([\'\"'])([^\1]+)\1/); if (match) { _filename = match[2]; } } file.name = _filename; // pre-webkit Opera doesn't set type property on the blob response if (!file.type) { file.type = Mime.getFileMime(_filename); } return file; case 'json': if (!Env.can('return_response_type', 'json')) { return _xhr.status === 200 ? parseJSON(_xhr.responseText) : null; } return _xhr.response; case 'document': return _getDocument(_xhr); default: return _xhr.responseText !== '' ? _xhr.responseText : null; // against the specs, but for consistency across the runtimes } } catch(ex) { return null; } }, getAllResponseHeaders: function() { try { return _xhr.getAllResponseHeaders(); } catch(ex) {} return ''; }, abort: function() { if (_xhr) { _xhr.abort(); } }, destroy: function() { self = _filename = null; } }); // here we go... ugly fix for ugly bug function _preloadAndSend(meta, data) { var target = this, blob, fr; // get original blob blob = data.getBlob().getSource(); // preload blob in memory to be sent as binary string fr = new window.FileReader(); fr.onload = function() { // overwrite original blob data.append(data.getBlobName(), new Blob(null, { type: blob.type, data: fr.result })); // invoke send operation again self.send.call(target, meta, data); }; fr.readAsBinaryString(blob); } function _getNativeXHR() { if (window.XMLHttpRequest && !(Env.browser === 'IE' && Env.version < 8)) { // IE7 has native XHR but it's buggy return new window.XMLHttpRequest(); } else { return (function() { var progIDs = ['Msxml2.XMLHTTP.6.0', 'Microsoft.XMLHTTP']; // if 6.0 available, use it, otherwise failback to default 3.0 for (var i = 0; i < progIDs.length; i++) { try { return new ActiveXObject(progIDs[i]); } catch (ex) {} } })(); } } // @credits Sergey Ilinsky (http://www.ilinsky.com/) function _getDocument(xhr) { var rXML = xhr.responseXML; var rText = xhr.responseText; // Try parsing responseText (@see: http://www.ilinsky.com/articles/XMLHttpRequest/#bugs-ie-responseXML-content-type) if (Env.browser === 'IE' && rText && rXML && !rXML.documentElement && /[^\/]+\/[^\+]+\+xml/.test(xhr.getResponseHeader("Content-Type"))) { rXML = new window.ActiveXObject("Microsoft.XMLDOM"); rXML.async = false; rXML.validateOnParse = false; rXML.loadXML(rText); } // Check if there is no error in document if (rXML) { if ((Env.browser === 'IE' && rXML.parseError !== 0) || !rXML.documentElement || rXML.documentElement.tagName === "parsererror") { return null; } } return rXML; } function _prepareMultipart(fd) { var boundary = '----moxieboundary' + new Date().getTime() , dashdash = '--' , crlf = '\r\n' , multipart = '' , I = this.getRuntime() ; if (!I.can('send_binary_string')) { throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); } _xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary); // append multipart parameters fd.each(function(value, name) { // Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(), // so we try it here ourselves with: unescape(encodeURIComponent(value)) if (value instanceof Blob) { // Build RFC2388 blob multipart += dashdash + boundary + crlf + 'Content-Disposition: form-data; name="' + name + '"; filename="' + unescape(encodeURIComponent(value.name || 'blob')) + '"' + crlf + 'Content-Type: ' + value.type + crlf + crlf + value.getSource() + crlf; } else { multipart += dashdash + boundary + crlf + 'Content-Disposition: form-data; name="' + name + '"' + crlf + crlf + unescape(encodeURIComponent(value)) + crlf; } }); multipart += dashdash + boundary + dashdash + crlf; return multipart; } } return (extensions.XMLHttpRequest = XMLHttpRequest); }); // Included from: src/javascript/runtime/html5/utils/BinaryReader.js /** * BinaryReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/utils/BinaryReader @private */ define("moxie/runtime/html5/utils/BinaryReader", [], function() { return function() { var II = false, bin; // Private functions function read(idx, size) { var mv = II ? 0 : -8 * (size - 1), sum = 0, i; for (i = 0; i < size; i++) { sum |= (bin.charCodeAt(idx + i) << Math.abs(mv + i*8)); } return sum; } function putstr(segment, idx, length) { length = arguments.length === 3 ? length : bin.length - idx - 1; bin = bin.substr(0, idx) + segment + bin.substr(length + idx); } function write(idx, num, size) { var str = '', mv = II ? 0 : -8 * (size - 1), i; for (i = 0; i < size; i++) { str += String.fromCharCode((num >> Math.abs(mv + i*8)) & 255); } putstr(str, idx, size); } // Public functions return { II: function(order) { if (order === undefined) { return II; } else { II = order; } }, init: function(binData) { II = false; bin = binData; }, SEGMENT: function(idx, length, segment) { switch (arguments.length) { case 1: return bin.substr(idx, bin.length - idx - 1); case 2: return bin.substr(idx, length); case 3: putstr(segment, idx, length); break; default: return bin; } }, BYTE: function(idx) { return read(idx, 1); }, SHORT: function(idx) { return read(idx, 2); }, LONG: function(idx, num) { if (num === undefined) { return read(idx, 4); } else { write(idx, num, 4); } }, SLONG: function(idx) { // 2's complement notation var num = read(idx, 4); return (num > 2147483647 ? num - 4294967296 : num); }, STRING: function(idx, size) { var str = ''; for (size += idx; idx < size; idx++) { str += String.fromCharCode(read(idx, 1)); } return str; } }; }; }); // Included from: src/javascript/runtime/html5/image/JPEGHeaders.js /** * JPEGHeaders.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/JPEGHeaders @private */ define("moxie/runtime/html5/image/JPEGHeaders", [ "moxie/runtime/html5/utils/BinaryReader" ], function(BinaryReader) { return function JPEGHeaders(data) { var headers = [], read, idx, marker, length = 0; read = new BinaryReader(); read.init(data); // Check if data is jpeg if (read.SHORT(0) !== 0xFFD8) { return; } idx = 2; while (idx <= data.length) { marker = read.SHORT(idx); // omit RST (restart) markers if (marker >= 0xFFD0 && marker <= 0xFFD7) { idx += 2; continue; } // no headers allowed after SOS marker if (marker === 0xFFDA || marker === 0xFFD9) { break; } length = read.SHORT(idx + 2) + 2; // APPn marker detected if (marker >= 0xFFE1 && marker <= 0xFFEF) { headers.push({ hex: marker, name: 'APP' + (marker & 0x000F), start: idx, length: length, segment: read.SEGMENT(idx, length) }); } idx += length; } read.init(null); // free memory return { headers: headers, restore: function(data) { var max, i; read.init(data); idx = read.SHORT(2) == 0xFFE0 ? 4 + read.SHORT(4) : 2; for (i = 0, max = headers.length; i < max; i++) { read.SEGMENT(idx, 0, headers[i].segment); idx += headers[i].length; } data = read.SEGMENT(); read.init(null); return data; }, strip: function(data) { var headers, jpegHeaders, i; jpegHeaders = new JPEGHeaders(data); headers = jpegHeaders.headers; jpegHeaders.purge(); read.init(data); i = headers.length; while (i--) { read.SEGMENT(headers[i].start, headers[i].length, ''); } data = read.SEGMENT(); read.init(null); return data; }, get: function(name) { var array = []; for (var i = 0, max = headers.length; i < max; i++) { if (headers[i].name === name.toUpperCase()) { array.push(headers[i].segment); } } return array; }, set: function(name, segment) { var array = [], i, ii, max; if (typeof(segment) === 'string') { array.push(segment); } else { array = segment; } for (i = ii = 0, max = headers.length; i < max; i++) { if (headers[i].name === name.toUpperCase()) { headers[i].segment = array[ii]; headers[i].length = array[ii].length; ii++; } if (ii >= array.length) { break; } } }, purge: function() { headers = []; read.init(null); read = null; } }; }; }); // Included from: src/javascript/runtime/html5/image/ExifParser.js /** * ExifParser.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/ExifParser @private */ define("moxie/runtime/html5/image/ExifParser", [ "moxie/core/utils/Basic", "moxie/runtime/html5/utils/BinaryReader" ], function(Basic, BinaryReader) { return function ExifParser() { // Private ExifParser fields var data, tags, Tiff, offsets = {}, tagDescs; data = new BinaryReader(); tags = { tiff : { /* The image orientation viewed in terms of rows and columns. 1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. 2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side. 3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. 4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. 5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. 6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. */ 0x0112: 'Orientation', 0x010E: 'ImageDescription', 0x010F: 'Make', 0x0110: 'Model', 0x0131: 'Software', 0x8769: 'ExifIFDPointer', 0x8825: 'GPSInfoIFDPointer' }, exif : { 0x9000: 'ExifVersion', 0xA001: 'ColorSpace', 0xA002: 'PixelXDimension', 0xA003: 'PixelYDimension', 0x9003: 'DateTimeOriginal', 0x829A: 'ExposureTime', 0x829D: 'FNumber', 0x8827: 'ISOSpeedRatings', 0x9201: 'ShutterSpeedValue', 0x9202: 'ApertureValue' , 0x9207: 'MeteringMode', 0x9208: 'LightSource', 0x9209: 'Flash', 0x920A: 'FocalLength', 0xA402: 'ExposureMode', 0xA403: 'WhiteBalance', 0xA406: 'SceneCaptureType', 0xA404: 'DigitalZoomRatio', 0xA408: 'Contrast', 0xA409: 'Saturation', 0xA40A: 'Sharpness' }, gps : { 0x0000: 'GPSVersionID', 0x0001: 'GPSLatitudeRef', 0x0002: 'GPSLatitude', 0x0003: 'GPSLongitudeRef', 0x0004: 'GPSLongitude' } }; tagDescs = { 'ColorSpace': { 1: 'sRGB', 0: 'Uncalibrated' }, 'MeteringMode': { 0: 'Unknown', 1: 'Average', 2: 'CenterWeightedAverage', 3: 'Spot', 4: 'MultiSpot', 5: 'Pattern', 6: 'Partial', 255: 'Other' }, 'LightSource': { 1: 'Daylight', 2: 'Fliorescent', 3: 'Tungsten', 4: 'Flash', 9: 'Fine weather', 10: 'Cloudy weather', 11: 'Shade', 12: 'Daylight fluorescent (D 5700 - 7100K)', 13: 'Day white fluorescent (N 4600 -5400K)', 14: 'Cool white fluorescent (W 3900 - 4500K)', 15: 'White fluorescent (WW 3200 - 3700K)', 17: 'Standard light A', 18: 'Standard light B', 19: 'Standard light C', 20: 'D55', 21: 'D65', 22: 'D75', 23: 'D50', 24: 'ISO studio tungsten', 255: 'Other' }, 'Flash': { 0x0000: 'Flash did not fire.', 0x0001: 'Flash fired.', 0x0005: 'Strobe return light not detected.', 0x0007: 'Strobe return light detected.', 0x0009: 'Flash fired, compulsory flash mode', 0x000D: 'Flash fired, compulsory flash mode, return light not detected', 0x000F: 'Flash fired, compulsory flash mode, return light detected', 0x0010: 'Flash did not fire, compulsory flash mode', 0x0018: 'Flash did not fire, auto mode', 0x0019: 'Flash fired, auto mode', 0x001D: 'Flash fired, auto mode, return light not detected', 0x001F: 'Flash fired, auto mode, return light detected', 0x0020: 'No flash function', 0x0041: 'Flash fired, red-eye reduction mode', 0x0045: 'Flash fired, red-eye reduction mode, return light not detected', 0x0047: 'Flash fired, red-eye reduction mode, return light detected', 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode', 0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected', 0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected', 0x0059: 'Flash fired, auto mode, red-eye reduction mode', 0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode', 0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode' }, 'ExposureMode': { 0: 'Auto exposure', 1: 'Manual exposure', 2: 'Auto bracket' }, 'WhiteBalance': { 0: 'Auto white balance', 1: 'Manual white balance' }, 'SceneCaptureType': { 0: 'Standard', 1: 'Landscape', 2: 'Portrait', 3: 'Night scene' }, 'Contrast': { 0: 'Normal', 1: 'Soft', 2: 'Hard' }, 'Saturation': { 0: 'Normal', 1: 'Low saturation', 2: 'High saturation' }, 'Sharpness': { 0: 'Normal', 1: 'Soft', 2: 'Hard' }, // GPS related 'GPSLatitudeRef': { N: 'North latitude', S: 'South latitude' }, 'GPSLongitudeRef': { E: 'East longitude', W: 'West longitude' } }; function extractTags(IFD_offset, tags2extract) { var length = data.SHORT(IFD_offset), i, ii, tag, type, count, tagOffset, offset, value, values = [], hash = {}; for (i = 0; i < length; i++) { // Set binary reader pointer to beginning of the next tag offset = tagOffset = IFD_offset + 12 * i + 2; tag = tags2extract[data.SHORT(offset)]; if (tag === undefined) { continue; // Not the tag we requested } type = data.SHORT(offset+=2); count = data.LONG(offset+=2); offset += 4; values = []; switch (type) { case 1: // BYTE case 7: // UNDEFINED if (count > 4) { offset = data.LONG(offset) + offsets.tiffHeader; } for (ii = 0; ii < count; ii++) { values[ii] = data.BYTE(offset + ii); } break; case 2: // STRING if (count > 4) { offset = data.LONG(offset) + offsets.tiffHeader; } hash[tag] = data.STRING(offset, count - 1); continue; case 3: // SHORT if (count > 2) { offset = data.LONG(offset) + offsets.tiffHeader; } for (ii = 0; ii < count; ii++) { values[ii] = data.SHORT(offset + ii*2); } break; case 4: // LONG if (count > 1) { offset = data.LONG(offset) + offsets.tiffHeader; } for (ii = 0; ii < count; ii++) { values[ii] = data.LONG(offset + ii*4); } break; case 5: // RATIONAL offset = data.LONG(offset) + offsets.tiffHeader; for (ii = 0; ii < count; ii++) { values[ii] = data.LONG(offset + ii*4) / data.LONG(offset + ii*4 + 4); } break; case 9: // SLONG offset = data.LONG(offset) + offsets.tiffHeader; for (ii = 0; ii < count; ii++) { values[ii] = data.SLONG(offset + ii*4); } break; case 10: // SRATIONAL offset = data.LONG(offset) + offsets.tiffHeader; for (ii = 0; ii < count; ii++) { values[ii] = data.SLONG(offset + ii*4) / data.SLONG(offset + ii*4 + 4); } break; default: continue; } value = (count == 1 ? values[0] : values); if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') { hash[tag] = tagDescs[tag][value]; } else { hash[tag] = value; } } return hash; } function getIFDOffsets() { var idx = offsets.tiffHeader; // Set read order of multi-byte data data.II(data.SHORT(idx) == 0x4949); // Check if always present bytes are indeed present if (data.SHORT(idx+=2) !== 0x002A) { return false; } offsets.IFD0 = offsets.tiffHeader + data.LONG(idx += 2); Tiff = extractTags(offsets.IFD0, tags.tiff); if ('ExifIFDPointer' in Tiff) { offsets.exifIFD = offsets.tiffHeader + Tiff.ExifIFDPointer; delete Tiff.ExifIFDPointer; } if ('GPSInfoIFDPointer' in Tiff) { offsets.gpsIFD = offsets.tiffHeader + Tiff.GPSInfoIFDPointer; delete Tiff.GPSInfoIFDPointer; } return true; } // At the moment only setting of simple (LONG) values, that do not require offset recalculation, is supported function setTag(ifd, tag, value) { var offset, length, tagOffset, valueOffset = 0; // If tag name passed translate into hex key if (typeof(tag) === 'string') { var tmpTags = tags[ifd.toLowerCase()]; for (var hex in tmpTags) { if (tmpTags[hex] === tag) { tag = hex; break; } } } offset = offsets[ifd.toLowerCase() + 'IFD']; length = data.SHORT(offset); for (var i = 0; i < length; i++) { tagOffset = offset + 12 * i + 2; if (data.SHORT(tagOffset) == tag) { valueOffset = tagOffset + 8; break; } } if (!valueOffset) { return false; } data.LONG(valueOffset, value); return true; } // Public functions return { init: function(segment) { // Reset internal data offsets = { tiffHeader: 10 }; if (segment === undefined || !segment.length) { return false; } data.init(segment); // Check if that's APP1 and that it has EXIF if (data.SHORT(0) === 0xFFE1 && data.STRING(4, 5).toUpperCase() === "EXIF\0") { return getIFDOffsets(); } return false; }, TIFF: function() { return Tiff; }, EXIF: function() { var Exif; // Populate EXIF hash Exif = extractTags(offsets.exifIFD, tags.exif); // Fix formatting of some tags if (Exif.ExifVersion && Basic.typeOf(Exif.ExifVersion) === 'array') { for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) { exifVersion += String.fromCharCode(Exif.ExifVersion[i]); } Exif.ExifVersion = exifVersion; } return Exif; }, GPS: function() { var GPS; GPS = extractTags(offsets.gpsIFD, tags.gps); // iOS devices (and probably some others) do not put in GPSVersionID tag (why?..) if (GPS.GPSVersionID && Basic.typeOf(GPS.GPSVersionID) === 'array') { GPS.GPSVersionID = GPS.GPSVersionID.join('.'); } return GPS; }, setExif: function(tag, value) { // Right now only setting of width/height is possible if (tag !== 'PixelXDimension' && tag !== 'PixelYDimension') {return false;} return setTag('exif', tag, value); }, getBinary: function() { return data.SEGMENT(); }, purge: function() { data.init(null); data = Tiff = null; offsets = {}; } }; }; }); // Included from: src/javascript/runtime/html5/image/JPEG.js /** * JPEG.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/JPEG @private */ define("moxie/runtime/html5/image/JPEG", [ "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/runtime/html5/image/JPEGHeaders", "moxie/runtime/html5/utils/BinaryReader", "moxie/runtime/html5/image/ExifParser" ], function(Basic, x, JPEGHeaders, BinaryReader, ExifParser) { function JPEG(binstr) { var _binstr, _br, _hm, _ep, _info, hasExif; function _getDimensions() { var idx = 0, marker, length; // examine all through the end, since some images might have very large APP segments while (idx <= _binstr.length) { marker = _br.SHORT(idx += 2); if (marker >= 0xFFC0 && marker <= 0xFFC3) { // SOFn idx += 5; // marker (2 bytes) + length (2 bytes) + Sample precision (1 byte) return { height: _br.SHORT(idx), width: _br.SHORT(idx += 2) }; } length = _br.SHORT(idx += 2); idx += length - 2; } return null; } _binstr = binstr; _br = new BinaryReader(); _br.init(_binstr); // check if it is jpeg if (_br.SHORT(0) !== 0xFFD8) { throw new x.ImageError(x.ImageError.WRONG_FORMAT); } // backup headers _hm = new JPEGHeaders(binstr); // extract exif info _ep = new ExifParser(); hasExif = !!_ep.init(_hm.get('app1')[0]); // get dimensions _info = _getDimensions.call(this); Basic.extend(this, { type: 'image/jpeg', size: _binstr.length, width: _info && _info.width || 0, height: _info && _info.height || 0, setExif: function(tag, value) { if (!hasExif) { return false; // or throw an exception } if (Basic.typeOf(tag) === 'object') { Basic.each(tag, function(value, tag) { _ep.setExif(tag, value); }); } else { _ep.setExif(tag, value); } // update internal headers _hm.set('app1', _ep.getBinary()); }, writeHeaders: function() { if (!arguments.length) { // if no arguments passed, update headers internally return (_binstr = _hm.restore(_binstr)); } return _hm.restore(arguments[0]); }, stripHeaders: function(binstr) { return _hm.strip(binstr); }, purge: function() { _purge.call(this); } }); if (hasExif) { this.meta = { tiff: _ep.TIFF(), exif: _ep.EXIF(), gps: _ep.GPS() }; } function _purge() { if (!_ep || !_hm || !_br) { return; // ignore any repeating purge requests } _ep.purge(); _hm.purge(); _br.init(null); _binstr = _info = _hm = _ep = _br = null; } } return JPEG; }); // Included from: src/javascript/runtime/html5/image/PNG.js /** * PNG.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/PNG @private */ define("moxie/runtime/html5/image/PNG", [ "moxie/core/Exceptions", "moxie/core/utils/Basic", "moxie/runtime/html5/utils/BinaryReader" ], function(x, Basic, BinaryReader) { function PNG(binstr) { var _binstr, _br, _hm, _ep, _info; _binstr = binstr; _br = new BinaryReader(); _br.init(_binstr); // check if it's png (function() { var idx = 0, i = 0 , signature = [0x8950, 0x4E47, 0x0D0A, 0x1A0A] ; for (i = 0; i < signature.length; i++, idx += 2) { if (signature[i] != _br.SHORT(idx)) { throw new x.ImageError(x.ImageError.WRONG_FORMAT); } } }()); function _getDimensions() { var chunk, idx; chunk = _getChunkAt.call(this, 8); if (chunk.type == 'IHDR') { idx = chunk.start; return { width: _br.LONG(idx), height: _br.LONG(idx += 4) }; } return null; } function _purge() { if (!_br) { return; // ignore any repeating purge requests } _br.init(null); _binstr = _info = _hm = _ep = _br = null; } _info = _getDimensions.call(this); Basic.extend(this, { type: 'image/png', size: _binstr.length, width: _info.width, height: _info.height, purge: function() { _purge.call(this); } }); // for PNG we can safely trigger purge automatically, as we do not keep any data for later _purge.call(this); function _getChunkAt(idx) { var length, type, start, CRC; length = _br.LONG(idx); type = _br.STRING(idx += 4, 4); start = idx += 4; CRC = _br.LONG(idx + length); return { length: length, type: type, start: start, CRC: CRC }; } } return PNG; }); // Included from: src/javascript/runtime/html5/image/ImageInfo.js /** * ImageInfo.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/ImageInfo @private */ define("moxie/runtime/html5/image/ImageInfo", [ "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/runtime/html5/image/JPEG", "moxie/runtime/html5/image/PNG" ], function(Basic, x, JPEG, PNG) { /** Optional image investigation tool for HTML5 runtime. Provides the following features: - ability to distinguish image type (JPEG or PNG) by signature - ability to extract image width/height directly from it's internals, without preloading in memory (fast) - ability to extract APP headers from JPEGs (Exif, GPS, etc) - ability to replace width/height tags in extracted JPEG headers - ability to restore APP headers, that were for example stripped during image manipulation @class ImageInfo @constructor @param {String} binstr Image source as binary string */ return function(binstr) { var _cs = [JPEG, PNG], _img; // figure out the format, throw: ImageError.WRONG_FORMAT if not supported _img = (function() { for (var i = 0; i < _cs.length; i++) { try { return new _cs[i](binstr); } catch (ex) { // console.info(ex); } } throw new x.ImageError(x.ImageError.WRONG_FORMAT); }()); Basic.extend(this, { /** Image Mime Type extracted from it's depths @property type @type {String} @default '' */ type: '', /** Image size in bytes @property size @type {Number} @default 0 */ size: 0, /** Image width extracted from image source @property width @type {Number} @default 0 */ width: 0, /** Image height extracted from image source @property height @type {Number} @default 0 */ height: 0, /** Sets Exif tag. Currently applicable only for width and height tags. Obviously works only with JPEGs. @method setExif @param {String} tag Tag to set @param {Mixed} value Value to assign to the tag */ setExif: function() {}, /** Restores headers to the source. @method writeHeaders @param {String} data Image source as binary string @return {String} Updated binary string */ writeHeaders: function(data) { return data; }, /** Strip all headers from the source. @method stripHeaders @param {String} data Image source as binary string @return {String} Updated binary string */ stripHeaders: function(data) { return data; }, /** Dispose resources. @method purge */ purge: function() {} }); Basic.extend(this, _img); this.purge = function() { _img.purge(); _img = null; }; }; }); // Included from: src/javascript/runtime/html5/image/MegaPixel.js /** (The MIT License) Copyright (c) 2012 Shinichi Tomita ; Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * Mega pixel image rendering library for iOS6 Safari * * Fixes iOS6 Safari's image file rendering issue for large size image (over mega-pixel), * which causes unexpected subsampling when drawing it in canvas. * By using this library, you can safely render the image with proper stretching. * * Copyright (c) 2012 Shinichi Tomita * Released under the MIT license */ /** @class moxie/runtime/html5/image/MegaPixel @private */ define("moxie/runtime/html5/image/MegaPixel", [], function() { /** * Rendering image element (with resizing) into the canvas element */ function renderImageToCanvas(img, canvas, options) { var iw = img.naturalWidth, ih = img.naturalHeight; var width = options.width, height = options.height; var x = options.x || 0, y = options.y || 0; var ctx = canvas.getContext('2d'); if (detectSubsampling(img)) { iw /= 2; ih /= 2; } var d = 1024; // size of tiling canvas var tmpCanvas = document.createElement('canvas'); tmpCanvas.width = tmpCanvas.height = d; var tmpCtx = tmpCanvas.getContext('2d'); var vertSquashRatio = detectVerticalSquash(img, iw, ih); var sy = 0; while (sy < ih) { var sh = sy + d > ih ? ih - sy : d; var sx = 0; while (sx < iw) { var sw = sx + d > iw ? iw - sx : d; tmpCtx.clearRect(0, 0, d, d); tmpCtx.drawImage(img, -sx, -sy); var dx = (sx * width / iw + x) << 0; var dw = Math.ceil(sw * width / iw); var dy = (sy * height / ih / vertSquashRatio + y) << 0; var dh = Math.ceil(sh * height / ih / vertSquashRatio); ctx.drawImage(tmpCanvas, 0, 0, sw, sh, dx, dy, dw, dh); sx += d; } sy += d; } tmpCanvas = tmpCtx = null; } /** * Detect subsampling in loaded image. * In iOS, larger images than 2M pixels may be subsampled in rendering. */ function detectSubsampling(img) { var iw = img.naturalWidth, ih = img.naturalHeight; if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image var canvas = document.createElement('canvas'); canvas.width = canvas.height = 1; var ctx = canvas.getContext('2d'); ctx.drawImage(img, -iw + 1, 0); // subsampled image becomes half smaller in rendering size. // check alpha channel value to confirm image is covering edge pixel or not. // if alpha value is 0 image is not covering, hence subsampled. return ctx.getImageData(0, 0, 1, 1).data[3] === 0; } else { return false; } } /** * Detecting vertical squash in loaded image. * Fixes a bug which squash image vertically while drawing into canvas for some images. */ function detectVerticalSquash(img, iw, ih) { var canvas = document.createElement('canvas'); canvas.width = 1; canvas.height = ih; var ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); var data = ctx.getImageData(0, 0, 1, ih).data; // search image edge pixel position in case it is squashed vertically. var sy = 0; var ey = ih; var py = ih; while (py > sy) { var alpha = data[(py - 1) * 4 + 3]; if (alpha === 0) { ey = py; } else { sy = py; } py = (ey + sy) >> 1; } canvas = null; var ratio = (py / ih); return (ratio === 0) ? 1 : ratio; } return { isSubsampled: detectSubsampling, renderTo: renderImageToCanvas }; }); // Included from: src/javascript/runtime/html5/image/Image.js /** * Image.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html5/image/Image @private */ define("moxie/runtime/html5/image/Image", [ "moxie/runtime/html5/Runtime", "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/core/utils/Encode", "moxie/file/Blob", "moxie/runtime/html5/image/ImageInfo", "moxie/runtime/html5/image/MegaPixel", "moxie/core/utils/Mime", "moxie/core/utils/Env" ], function(extensions, Basic, x, Encode, Blob, ImageInfo, MegaPixel, Mime, Env) { function HTML5Image() { var me = this , _img, _imgInfo, _canvas, _binStr, _blob , _modified = false // is set true whenever image is modified , _preserveHeaders = true ; Basic.extend(this, { loadFromBlob: function(blob) { var comp = this, I = comp.getRuntime() , asBinary = arguments.length > 1 ? arguments[1] : true ; if (!I.can('access_binary')) { throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR); } _blob = blob; if (blob.isDetached()) { _binStr = blob.getSource(); _preload.call(this, _binStr); return; } else { _readAsDataUrl.call(this, blob.getSource(), function(dataUrl) { if (asBinary) { _binStr = _toBinary(dataUrl); } _preload.call(comp, dataUrl); }); } }, loadFromImage: function(img, exact) { this.meta = img.meta; _blob = new Blob(null, { name: img.name, size: img.size, type: img.type }); _preload.call(this, exact ? (_binStr = img.getAsBinaryString()) : img.getAsDataURL()); }, getInfo: function() { var I = this.getRuntime(), info; if (!_imgInfo && _binStr && I.can('access_image_binary')) { _imgInfo = new ImageInfo(_binStr); } info = { width: _getImg().width || 0, height: _getImg().height || 0, type: _blob.type || Mime.getFileMime(_blob.name), size: _binStr && _binStr.length || _blob.size || 0, name: _blob.name || '', meta: _imgInfo && _imgInfo.meta || this.meta || {} }; return info; }, downsize: function() { _downsize.apply(this, arguments); }, getAsCanvas: function() { if (_canvas) { _canvas.id = this.uid + '_canvas'; } return _canvas; }, getAsBlob: function(type, quality) { if (type !== this.type) { // if different mime type requested prepare image for conversion _downsize.call(this, this.width, this.height, false); } return new Blob(null, { type: type, data: me.getAsBinaryString.call(this, type, quality) }); }, getAsDataURL: function(type) { var quality = arguments[1] || 90; // if image has not been modified, return the source right away if (!_modified) { return _img.src; } if ('image/jpeg' !== type) { return _canvas.toDataURL('image/png'); } else { try { // older Geckos used to result in an exception on quality argument return _canvas.toDataURL('image/jpeg', quality/100); } catch (ex) { return _canvas.toDataURL('image/jpeg'); } } }, getAsBinaryString: function(type, quality) { // if image has not been modified, return the source right away if (!_modified) { // if image was not loaded from binary string if (!_binStr) { _binStr = _toBinary(me.getAsDataURL(type, quality)); } return _binStr; } if ('image/jpeg' !== type) { _binStr = _toBinary(me.getAsDataURL(type, quality)); } else { var dataUrl; // if jpeg if (!quality) { quality = 90; } try { // older Geckos used to result in an exception on quality argument dataUrl = _canvas.toDataURL('image/jpeg', quality/100); } catch (ex) { dataUrl = _canvas.toDataURL('image/jpeg'); } _binStr = _toBinary(dataUrl); if (_imgInfo) { _binStr = _imgInfo.stripHeaders(_binStr); if (_preserveHeaders) { // update dimensions info in exif if (_imgInfo.meta && _imgInfo.meta.exif) { _imgInfo.setExif({ PixelXDimension: this.width, PixelYDimension: this.height }); } // re-inject the headers _binStr = _imgInfo.writeHeaders(_binStr); } // will be re-created from fresh on next getInfo call _imgInfo.purge(); _imgInfo = null; } } _modified = false; return _binStr; }, destroy: function() { me = null; _purge.call(this); this.getRuntime().getShim().removeInstance(this.uid); } }); function _getImg() { if (!_canvas && !_img) { throw new x.ImageError(x.DOMException.INVALID_STATE_ERR); } return _canvas || _img; } function _toBinary(str) { return Encode.atob(str.substring(str.indexOf('base64,') + 7)); } function _toDataUrl(str, type) { return 'data:' + (type || '') + ';base64,' + Encode.btoa(str); } function _preload(str) { var comp = this; _img = new Image(); _img.onerror = function() { _purge.call(this); comp.trigger('error', new x.ImageError(x.ImageError.WRONG_FORMAT)); }; _img.onload = function() { comp.trigger('load'); }; _img.src = /^data:[^;]*;base64,/.test(str) ? str : _toDataUrl(str, _blob.type); } function _readAsDataUrl(file, callback) { var comp = this, fr; // use FileReader if it's available if (window.FileReader) { fr = new FileReader(); fr.onload = function() { callback(this.result); }; fr.onerror = function() { comp.trigger('error', new x.FileException(x.FileException.NOT_READABLE_ERR)); }; fr.readAsDataURL(file); } else { return callback(file.getAsDataURL()); } } function _downsize(width, height, crop, preserveHeaders) { var self = this, ctx, scale, mathFn, x, y, img, imgWidth, imgHeight, orientation; _preserveHeaders = preserveHeaders; // we will need to check this on export // take into account orientation tag orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1; if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation // swap dimensions var mem = width; width = height; height = mem; } img = _getImg(); // unify dimensions mathFn = !crop ? Math.min : Math.max; scale = mathFn(width/img.width, height/img.height); // we only downsize here if (scale > 1 && (!crop || preserveHeaders)) { // when cropping one of dimensions may still exceed max, so process it anyway this.trigger('Resize'); return; } imgWidth = Math.round(img.width * scale); imgHeight = Math.round(img.height * scale); // prepare canvas if necessary if (!_canvas) { _canvas = document.createElement("canvas"); } ctx = _canvas.getContext('2d'); // scale image and canvas if (crop) { _canvas.width = width; _canvas.height = height; } else { _canvas.width = imgWidth; _canvas.height = imgHeight; } // if dimensions of the resulting image still larger than canvas, center it x = imgWidth > _canvas.width ? Math.round((imgWidth - _canvas.width) / 2) : 0; y = imgHeight > _canvas.height ? Math.round((imgHeight - _canvas.height) / 2) : 0; if (!_preserveHeaders) { _rotateToOrientaion(_canvas.width, _canvas.height, orientation); } _drawToCanvas.call(this, img, _canvas, -x, -y, imgWidth, imgHeight); this.width = _canvas.width; this.height = _canvas.height; _modified = true; self.trigger('Resize'); } function _drawToCanvas(img, canvas, x, y, w, h) { if (Env.OS === 'iOS') { // avoid squish bug in iOS6 MegaPixel.renderTo(img, canvas, { width: w, height: h, x: x, y: y }); } else { var ctx = canvas.getContext('2d'); ctx.drawImage(img, x, y, w, h); } } /** * Transform canvas coordination according to specified frame size and orientation * Orientation value is from EXIF tag * @author Shinichi Tomita */ function _rotateToOrientaion(width, height, orientation) { switch (orientation) { case 5: case 6: case 7: case 8: _canvas.width = height; _canvas.height = width; break; default: _canvas.width = width; _canvas.height = height; } /** 1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. 2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side. 3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. 4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. 5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. 6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. 7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. 8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. */ var ctx = _canvas.getContext('2d'); switch (orientation) { case 2: // horizontal flip ctx.translate(width, 0); ctx.scale(-1, 1); break; case 3: // 180 rotate left ctx.translate(width, height); ctx.rotate(Math.PI); break; case 4: // vertical flip ctx.translate(0, height); ctx.scale(1, -1); break; case 5: // vertical flip + 90 rotate right ctx.rotate(0.5 * Math.PI); ctx.scale(1, -1); break; case 6: // 90 rotate right ctx.rotate(0.5 * Math.PI); ctx.translate(0, -height); break; case 7: // horizontal flip + 90 rotate right ctx.rotate(0.5 * Math.PI); ctx.translate(width, -height); ctx.scale(-1, 1); break; case 8: // 90 rotate left ctx.rotate(-0.5 * Math.PI); ctx.translate(-width, 0); break; } } function _purge() { if (_imgInfo) { _imgInfo.purge(); _imgInfo = null; } _binStr = _img = _canvas = _blob = null; _modified = false; } } return (extensions.Image = HTML5Image); }); // Included from: src/javascript/runtime/flash/Runtime.js /** * Runtime.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global ActiveXObject:true */ /** Defines constructor for Flash runtime. @class moxie/runtime/flash/Runtime @private */ define("moxie/runtime/flash/Runtime", [ "moxie/core/utils/Basic", "moxie/core/utils/Env", "moxie/core/utils/Dom", "moxie/core/Exceptions", "moxie/runtime/Runtime" ], function(Basic, Env, Dom, x, Runtime) { var type = 'flash', extensions = {}; /** Get the version of the Flash Player @method getShimVersion @private @return {Number} Flash Player version */ function getShimVersion() { var version; try { version = navigator.plugins['Shockwave Flash']; version = version.description; } catch (e1) { try { version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); } catch (e2) { version = '0.0'; } } version = version.match(/\d+/g); return parseFloat(version[0] + '.' + version[1]); } /** Constructor for the Flash Runtime @class FlashRuntime @extends Runtime */ function FlashRuntime(options) { var I = this, initTimer; options = Basic.extend({ swf_url: Env.swf_url }, options); Runtime.call(this, options, type, { access_binary: function(value) { return value && I.mode === 'browser'; }, access_image_binary: function(value) { return value && I.mode === 'browser'; }, display_media: Runtime.capTrue, do_cors: Runtime.capTrue, drag_and_drop: false, report_upload_progress: function() { return I.mode === 'client'; }, resize_image: Runtime.capTrue, return_response_headers: false, return_response_type: function(responseType) { return !Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) || I.mode === 'browser'; }, return_status_code: function(code) { return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]); }, select_file: Runtime.capTrue, select_multiple: Runtime.capTrue, send_binary_string: function(value) { return value && I.mode === 'browser'; }, send_browser_cookies: function(value) { return value && I.mode === 'browser'; }, send_custom_headers: function(value) { return value && I.mode === 'browser'; }, send_multipart: Runtime.capTrue, slice_blob: Runtime.capTrue, stream_upload: function(value) { return value && I.mode === 'browser'; }, summon_file_dialog: false, upload_filesize: function(size) { return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client'; }, use_http_method: function(methods) { return !Basic.arrayDiff(methods, ['GET', 'POST']); } }, { // capabilities that require specific mode access_binary: function(value) { return value ? 'browser' : 'client'; }, access_image_binary: function(value) { return value ? 'browser' : 'client'; }, report_upload_progress: function(value) { return value ? 'browser' : 'client'; }, return_response_type: function(responseType) { return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser']; }, return_status_code: function(code) { return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser']; }, send_binary_string: function(value) { return value ? 'browser' : 'client'; }, send_browser_cookies: function(value) { return value ? 'browser' : 'client'; }, send_custom_headers: function(value) { return value ? 'browser' : 'client'; }, stream_upload: function(value) { return value ? 'client' : 'browser'; }, upload_filesize: function(size) { return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser'; } }, 'client'); // minimal requirement Flash Player 10 if (getShimVersion() < 10) { this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before } Basic.extend(this, { getShim: function() { return Dom.get(this.uid); }, shimExec: function(component, action) { var args = [].slice.call(arguments, 2); return I.getShim().exec(this.uid, component, action, args); }, init: function() { var html, el, container; container = this.getShimContainer(); // if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc) Basic.extend(container.style, { position: 'absolute', top: '-8px', left: '-8px', width: '9px', height: '9px', overflow: 'hidden' }); // insert flash object html = '' + '' + '' + '' + ''; if (Env.browser === 'IE') { el = document.createElement('div'); container.appendChild(el); el.outerHTML = html; el = container = null; // just in case } else { container.innerHTML = html; } // Init is dispatched by the shim initTimer = setTimeout(function() { if (I && !I.initialized) { // runtime might be already destroyed by this moment I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); } }, 5000); }, destroy: (function(destroy) { // extend default destroy method return function() { destroy.call(I); clearTimeout(initTimer); // initialization check might be still onwait options = initTimer = destroy = I = null; }; }(this.destroy)) }, extensions); } Runtime.addConstructor(type, FlashRuntime); return extensions; }); // Included from: src/javascript/runtime/flash/file/Blob.js /** * Blob.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/file/Blob @private */ define("moxie/runtime/flash/file/Blob", [ "moxie/runtime/flash/Runtime", "moxie/file/Blob" ], function(extensions, Blob) { var FlashBlob = { slice: function(blob, start, end, type) { var self = this.getRuntime(); if (start < 0) { start = Math.max(blob.size + start, 0); } else if (start > 0) { start = Math.min(start, blob.size); } if (end < 0) { end = Math.max(blob.size + end, 0); } else if (end > 0) { end = Math.min(end, blob.size); } blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || ''); if (blob) { blob = new Blob(self.uid, blob); } return blob; } }; return (extensions.Blob = FlashBlob); }); // Included from: src/javascript/runtime/flash/file/FileInput.js /** * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/file/FileInput @private */ define("moxie/runtime/flash/file/FileInput", [ "moxie/runtime/flash/Runtime" ], function(extensions) { var FileInput = { init: function(options) { this.getRuntime().shimExec.call(this, 'FileInput', 'init', { name: options.name, accept: options.accept, multiple: options.multiple }); this.trigger('ready'); } }; return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/flash/file/FileReader.js /** * FileReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/file/FileReader @private */ define("moxie/runtime/flash/file/FileReader", [ "moxie/runtime/flash/Runtime", "moxie/core/utils/Encode" ], function(extensions, Encode) { var _result = ''; function _formatData(data, op) { switch (op) { case 'readAsText': return Encode.atob(data, 'utf8'); case 'readAsBinaryString': return Encode.atob(data); case 'readAsDataURL': return data; } return null; } var FileReader = { read: function(op, blob) { var target = this, self = target.getRuntime(); // special prefix for DataURL read mode if (op === 'readAsDataURL') { _result = 'data:' + (blob.type || '') + ';base64,'; } target.bind('Progress', function(e, data) { if (data) { _result += _formatData(data, op); } }); return self.shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid); }, getResult: function() { return _result; }, destroy: function() { _result = null; } }; return (extensions.FileReader = FileReader); }); // Included from: src/javascript/runtime/flash/file/FileReaderSync.js /** * FileReaderSync.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/file/FileReaderSync @private */ define("moxie/runtime/flash/file/FileReaderSync", [ "moxie/runtime/flash/Runtime", "moxie/core/utils/Encode" ], function(extensions, Encode) { function _formatData(data, op) { switch (op) { case 'readAsText': return Encode.atob(data, 'utf8'); case 'readAsBinaryString': return Encode.atob(data); case 'readAsDataURL': return data; } return null; } var FileReaderSync = { read: function(op, blob) { var result, self = this.getRuntime(); result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid); if (!result) { return null; // or throw ex } // special prefix for DataURL read mode if (op === 'readAsDataURL') { result = 'data:' + (blob.type || '') + ';base64,' + result; } return _formatData(result, op, blob.type); } }; return (extensions.FileReaderSync = FileReaderSync); }); // Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js /** * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/xhr/XMLHttpRequest @private */ define("moxie/runtime/flash/xhr/XMLHttpRequest", [ "moxie/runtime/flash/Runtime", "moxie/core/utils/Basic", "moxie/file/Blob", "moxie/file/File", "moxie/file/FileReaderSync", "moxie/xhr/FormData", "moxie/runtime/Transporter", "moxie/core/JSON" ], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter, parseJSON) { var XMLHttpRequest = { send: function(meta, data) { var target = this, self = target.getRuntime(); function send() { meta.transport = self.mode; self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data); } function appendBlob(name, blob) { self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid); data = null; send(); } function attachBlob(blob, cb) { var tr = new Transporter(); tr.bind("TransportingComplete", function() { cb(this.result); }); tr.transport(blob.getSource(), blob.type, { ruid: self.uid }); } // copy over the headers if any if (!Basic.isEmptyObj(meta.headers)) { Basic.each(meta.headers, function(value, header) { self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object }); } // transfer over multipart params and blob itself if (data instanceof FormData) { var blobField; data.each(function(value, name) { if (value instanceof Blob) { blobField = name; } else { self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value); } }); if (!data.hasBlob()) { data = null; send(); } else { var blob = data.getBlob(); if (blob.isDetached()) { attachBlob(blob, function(attachedBlob) { blob.destroy(); appendBlob(blobField, attachedBlob); }); } else { appendBlob(blobField, blob); } } } else if (data instanceof Blob) { if (data.isDetached()) { attachBlob(data, function(attachedBlob) { data.destroy(); data = attachedBlob.uid; send(); }); } else { data = data.uid; send(); } } else { send(); } }, getResponse: function(responseType) { var frs, blob, self = this.getRuntime(); blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob'); if (blob) { blob = new File(self.uid, blob); if ('blob' === responseType) { return blob; } else if (!!~Basic.inArray(responseType, ["", "text"])) { frs = new FileReaderSync(); return frs.readAsText(blob); } else if ('arraybuffer' === responseType) { // do something } else if ('json' === responseType) { frs = new FileReaderSync(); try { return parseJSON(frs.readAsText(blob)); } catch (ex) { return null; } } } return null; }, abort: function(upload_complete_flag) { var self = this.getRuntime(); self.shimExec.call(this, 'XMLHttpRequest', 'abort'); this.dispatchEvent('readystatechange'); // this.dispatchEvent('progress'); this.dispatchEvent('abort'); if (!upload_complete_flag) { // this.dispatchEvent('uploadprogress'); } } }; return (extensions.XMLHttpRequest = XMLHttpRequest); }); // Included from: src/javascript/runtime/flash/runtime/Transporter.js /** * Transporter.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/runtime/Transporter @private */ define("moxie/runtime/flash/runtime/Transporter", [ "moxie/runtime/flash/Runtime", "moxie/file/Blob" ], function(extensions, Blob) { var Transporter = { getAsBlob: function(type) { var self = this.getRuntime() , blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type) ; if (blob) { return new Blob(self.uid, blob); } return null; } }; return (extensions.Transporter = Transporter); }); // Included from: src/javascript/runtime/flash/image/Image.js /** * Image.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/flash/image/Image @private */ define("moxie/runtime/flash/image/Image", [ "moxie/runtime/flash/Runtime", "moxie/core/utils/Basic", "moxie/runtime/Transporter", "moxie/file/Blob", "moxie/file/FileReaderSync" ], function(extensions, Basic, Transporter, Blob, FileReaderSync) { var Image = { loadFromBlob: function(blob) { var comp = this, self = comp.getRuntime(); function exec(srcBlob) { self.shimExec.call(comp, 'Image', 'loadFromBlob', srcBlob.uid); comp = self = null; } if (blob.isDetached()) { // binary string var tr = new Transporter(); tr.bind("TransportingComplete", function() { exec(tr.result.getSource()); }); tr.transport(blob.getSource(), blob.type, { ruid: self.uid }); } else { exec(blob.getSource()); } }, loadFromImage: function(img) { var self = this.getRuntime(); return self.shimExec.call(this, 'Image', 'loadFromImage', img.uid); }, getAsBlob: function(type, quality) { var self = this.getRuntime() , blob = self.shimExec.call(this, 'Image', 'getAsBlob', type, quality) ; if (blob) { return new Blob(self.uid, blob); } return null; }, getAsDataURL: function() { var self = this.getRuntime() , blob = self.Image.getAsBlob.apply(this, arguments) , frs ; if (!blob) { return null; } frs = new FileReaderSync(); return frs.readAsDataURL(blob); } }; return (extensions.Image = Image); }); // Included from: src/javascript/runtime/silverlight/Runtime.js /** * RunTime.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global ActiveXObject:true */ /** Defines constructor for Silverlight runtime. @class moxie/runtime/silverlight/Runtime @private */ define("moxie/runtime/silverlight/Runtime", [ "moxie/core/utils/Basic", "moxie/core/utils/Env", "moxie/core/utils/Dom", "moxie/core/Exceptions", "moxie/runtime/Runtime" ], function(Basic, Env, Dom, x, Runtime) { var type = "silverlight", extensions = {}; function isInstalled(version) { var isVersionSupported = false, control = null, actualVer, actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0; try { try { control = new ActiveXObject('AgControl.AgControl'); if (control.IsVersionSupported(version)) { isVersionSupported = true; } control = null; } catch (e) { var plugin = navigator.plugins["Silverlight Plug-In"]; if (plugin) { actualVer = plugin.description; if (actualVer === "1.0.30226.2") { actualVer = "2.0.30226.2"; } actualVerArray = actualVer.split("."); while (actualVerArray.length > 3) { actualVerArray.pop(); } while ( actualVerArray.length < 4) { actualVerArray.push(0); } reqVerArray = version.split("."); while (reqVerArray.length > 4) { reqVerArray.pop(); } do { requiredVersionPart = parseInt(reqVerArray[index], 10); actualVersionPart = parseInt(actualVerArray[index], 10); index++; } while (index < reqVerArray.length && requiredVersionPart === actualVersionPart); if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) { isVersionSupported = true; } } } } catch (e2) { isVersionSupported = false; } return isVersionSupported; } /** Constructor for the Silverlight Runtime @class SilverlightRuntime @extends Runtime */ function SilverlightRuntime(options) { var I = this, initTimer; options = Basic.extend({ xap_url: Env.xap_url }, options); Runtime.call(this, options, type, { access_binary: Runtime.capTrue, access_image_binary: Runtime.capTrue, display_media: Runtime.capTrue, do_cors: Runtime.capTrue, drag_and_drop: false, report_upload_progress: Runtime.capTrue, resize_image: Runtime.capTrue, return_response_headers: function(value) { return value && I.mode === 'client'; }, return_response_type: Runtime.capTrue, return_status_code: function(code) { return I.mode === 'client' || !Basic.arrayDiff(code, [200, 404]); }, select_file: Runtime.capTrue, select_multiple: Runtime.capTrue, send_binary_string: Runtime.capTrue, send_browser_cookies: function(value) { return value && I.mode === 'browser'; }, send_custom_headers: function(value) { return value && I.mode === 'client'; }, send_multipart: Runtime.capTrue, slice_blob: Runtime.capTrue, stream_upload: true, summon_file_dialog: false, upload_filesize: Runtime.capTrue, use_http_method: function(methods) { return I.mode === 'client' || !Basic.arrayDiff(methods, ['GET', 'POST']); } }, { // capabilities that require specific mode return_response_headers: function(value) { return value ? 'client' : 'browser'; }, return_status_code: function(code) { return Basic.arrayDiff(code, [200, 404]) ? 'client' : ['client', 'browser']; }, send_browser_cookies: function(value) { return value ? 'browser' : 'client'; }, send_custom_headers: function(value) { return value ? 'client' : 'browser'; }, use_http_method: function(methods) { return Basic.arrayDiff(methods, ['GET', 'POST']) ? 'client' : ['client', 'browser']; } }); // minimal requirement if (!isInstalled('2.0.31005.0') || Env.browser === 'Opera') { this.mode = false; } Basic.extend(this, { getShim: function() { return Dom.get(this.uid).content.Moxie; }, shimExec: function(component, action) { var args = [].slice.call(arguments, 2); return I.getShim().exec(this.uid, component, action, args); }, init : function() { var container; container = this.getShimContainer(); container.innerHTML = '' + '' + '' + '' + '' + '' + ''; // Init is dispatched by the shim initTimer = setTimeout(function() { if (I && !I.initialized) { // runtime might be already destroyed by this moment I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR)); } }, Env.OS !== 'Windows'? 10000 : 5000); // give it more time to initialize in non Windows OS (like Mac) }, destroy: (function(destroy) { // extend default destroy method return function() { destroy.call(I); clearTimeout(initTimer); // initialization check might be still onwait options = initTimer = destroy = I = null; }; }(this.destroy)) }, extensions); } Runtime.addConstructor(type, SilverlightRuntime); return extensions; }); // Included from: src/javascript/runtime/silverlight/file/Blob.js /** * Blob.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/file/Blob @private */ define("moxie/runtime/silverlight/file/Blob", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/file/Blob" ], function(extensions, Basic, Blob) { return (extensions.Blob = Basic.extend({}, Blob)); }); // Included from: src/javascript/runtime/silverlight/file/FileInput.js /** * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/file/FileInput @private */ define("moxie/runtime/silverlight/file/FileInput", [ "moxie/runtime/silverlight/Runtime" ], function(extensions) { var FileInput = { init: function(options) { function toFilters(accept) { var filter = ''; for (var i = 0; i < accept.length; i++) { filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.'); } return filter; } this.getRuntime().shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.name, options.multiple); this.trigger('ready'); } }; return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/silverlight/file/FileDrop.js /** * FileDrop.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/file/FileDrop @private */ define("moxie/runtime/silverlight/file/FileDrop", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Dom", "moxie/core/utils/Events" ], function(extensions, Dom, Events) { // not exactly useful, since works only in safari (...crickets...) var FileDrop = { init: function() { var comp = this, self = comp.getRuntime(), dropZone; dropZone = self.getShimContainer(); Events.addEvent(dropZone, 'dragover', function(e) { e.preventDefault(); e.stopPropagation(); e.dataTransfer.dropEffect = 'copy'; }, comp.uid); Events.addEvent(dropZone, 'dragenter', function(e) { e.preventDefault(); var flag = Dom.get(self.uid).dragEnter(e); // If handled, then stop propagation of event in DOM if (flag) { e.stopPropagation(); } }, comp.uid); Events.addEvent(dropZone, 'drop', function(e) { e.preventDefault(); var flag = Dom.get(self.uid).dragDrop(e); // If handled, then stop propagation of event in DOM if (flag) { e.stopPropagation(); } }, comp.uid); return self.shimExec.call(this, 'FileDrop', 'init'); } }; return (extensions.FileDrop = FileDrop); }); // Included from: src/javascript/runtime/silverlight/file/FileReader.js /** * FileReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/file/FileReader @private */ define("moxie/runtime/silverlight/file/FileReader", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/file/FileReader" ], function(extensions, Basic, FileReader) { return (extensions.FileReader = Basic.extend({}, FileReader)); }); // Included from: src/javascript/runtime/silverlight/file/FileReaderSync.js /** * FileReaderSync.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/file/FileReaderSync @private */ define("moxie/runtime/silverlight/file/FileReaderSync", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/file/FileReaderSync" ], function(extensions, Basic, FileReaderSync) { return (extensions.FileReaderSync = Basic.extend({}, FileReaderSync)); }); // Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js /** * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/xhr/XMLHttpRequest @private */ define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/xhr/XMLHttpRequest" ], function(extensions, Basic, XMLHttpRequest) { return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest)); }); // Included from: src/javascript/runtime/silverlight/runtime/Transporter.js /** * Transporter.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/runtime/Transporter @private */ define("moxie/runtime/silverlight/runtime/Transporter", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/runtime/Transporter" ], function(extensions, Basic, Transporter) { return (extensions.Transporter = Basic.extend({}, Transporter)); }); // Included from: src/javascript/runtime/silverlight/image/Image.js /** * Image.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/silverlight/image/Image @private */ define("moxie/runtime/silverlight/image/Image", [ "moxie/runtime/silverlight/Runtime", "moxie/core/utils/Basic", "moxie/runtime/flash/image/Image" ], function(extensions, Basic, Image) { return (extensions.Image = Basic.extend({}, Image)); }); // Included from: src/javascript/runtime/html4/Runtime.js /** * Runtime.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global File:true */ /** Defines constructor for HTML4 runtime. @class moxie/runtime/html4/Runtime @private */ define("moxie/runtime/html4/Runtime", [ "moxie/core/utils/Basic", "moxie/core/Exceptions", "moxie/runtime/Runtime", "moxie/core/utils/Env" ], function(Basic, x, Runtime, Env) { var type = 'html4', extensions = {}; function Html4Runtime(options) { var I = this , Test = Runtime.capTest , True = Runtime.capTrue ; Runtime.call(this, options, type, { access_binary: Test(window.FileReader || window.File && File.getAsDataURL), access_image_binary: false, display_media: Test(extensions.Image && (Env.can('create_canvas') || Env.can('use_data_uri_over32kb'))), do_cors: false, drag_and_drop: false, filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10); }()), resize_image: function() { return extensions.Image && I.can('access_binary') && Env.can('create_canvas'); }, report_upload_progress: false, return_response_headers: false, return_response_type: function(responseType) { return !!~Basic.inArray(responseType, ['json', 'text', 'document', '']); }, return_status_code: function(code) { return !Basic.arrayDiff(code, [200, 404]); }, select_file: function() { return Env.can('use_fileinput'); }, select_multiple: false, send_binary_string: false, send_custom_headers: false, send_multipart: true, slice_blob: false, stream_upload: function() { return I.can('select_file'); }, summon_file_dialog: Test(function() { // yeah... some dirty sniffing here... return (Env.browser === 'Firefox' && Env.version >= 4) || (Env.browser === 'Opera' && Env.version >= 12) || (Env.browser === 'IE' && Env.version >= 10) || !!~Basic.inArray(Env.browser, ['Chrome', 'Safari']); }()), upload_filesize: True, use_http_method: function(methods) { return !Basic.arrayDiff(methods, ['GET', 'POST']); } }); Basic.extend(this, { init : function() { this.trigger("Init"); }, destroy: (function(destroy) { // extend default destroy method return function() { destroy.call(I); destroy = I = null; }; }(this.destroy)) }); Basic.extend(this.getShim(), extensions); } Runtime.addConstructor(type, Html4Runtime); return extensions; }); // Included from: src/javascript/runtime/html4/file/FileInput.js /** * FileInput.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html4/file/FileInput @private */ define("moxie/runtime/html4/file/FileInput", [ "moxie/runtime/html4/Runtime", "moxie/core/utils/Basic", "moxie/core/utils/Dom", "moxie/core/utils/Events", "moxie/core/utils/Mime", "moxie/core/utils/Env" ], function(extensions, Basic, Dom, Events, Mime, Env) { function FileInput() { var _uid, _files = [], _mimes = [], _options; function addInput() { var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid; uid = Basic.guid('uid_'); shimContainer = I.getShimContainer(); // we get new ref everytime to avoid memory leaks in IE if (_uid) { // move previous form out of the view currForm = Dom.get(_uid + '_form'); if (currForm) { Basic.extend(currForm.style, { top: '100%' }); } } // build form in DOM, since innerHTML version not able to submit file for some reason form = document.createElement('form'); form.setAttribute('id', uid + '_form'); form.setAttribute('method', 'post'); form.setAttribute('enctype', 'multipart/form-data'); form.setAttribute('encoding', 'multipart/form-data'); Basic.extend(form.style, { overflow: 'hidden', position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }); input = document.createElement('input'); input.setAttribute('id', uid); input.setAttribute('type', 'file'); input.setAttribute('name', 'Filedata'); input.setAttribute('accept', _mimes.join(',')); Basic.extend(input.style, { fontSize: '999px', opacity: 0 }); form.appendChild(input); shimContainer.appendChild(form); // prepare file input to be placed underneath the browse_button element Basic.extend(input.style, { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }); if (Env.browser === 'IE' && Env.version < 10) { Basic.extend(input.style, { filter : "progid:DXImageTransform.Microsoft.Alpha(opacity=0)" }); } input.onchange = function() { // there should be only one handler for this var file; if (!this.value) { return; } if (this.files) { file = this.files[0]; } else { file = { name: this.value }; } _files = [file]; this.onchange = function() {}; // clear event handler addInput.call(comp); // after file is initialized as o.File, we need to update form and input ids comp.bind('change', function() { var input = Dom.get(uid), form = Dom.get(uid + '_form'), file; if (comp.files.length && input && form) { file = comp.files[0]; input.setAttribute('id', file.uid); form.setAttribute('id', file.uid + '_form'); // set upload target form.setAttribute('target', file.uid + '_iframe'); } input = form = null; }, 998); input = form = null; comp.trigger('change'); }; // route click event to the input if (I.can('summon_file_dialog')) { browseButton = Dom.get(_options.browse_button); Events.removeEvent(browseButton, 'click', comp.uid); Events.addEvent(browseButton, 'click', function(e) { if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file] input.click(); } e.preventDefault(); }, comp.uid); } _uid = uid; shimContainer = currForm = browseButton = null; // trigger ready event asynchronously comp.trigger({ type: 'ready', async: true }); } Basic.extend(this, { init: function(options) { var comp = this, I = comp.getRuntime(), shimContainer; // figure out accept string _options = options; _mimes = options.accept.mimes || Mime.extList2mimes(options.accept, I.can('filter_by_extension')); shimContainer = I.getShimContainer(); (function() { var browseButton, zIndex, top; browseButton = Dom.get(options.browse_button); // Route click event to the input[type=file] element for browsers that support such behavior if (I.can('summon_file_dialog')) { if (Dom.getStyle(browseButton, 'position') === 'static') { browseButton.style.position = 'relative'; } zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1; browseButton.style.zIndex = zIndex; shimContainer.style.zIndex = zIndex - 1; } /* Since we have to place input[type=file] on top of the browse_button for some browsers, browse_button loses interactivity, so we restore it here */ top = I.can('summon_file_dialog') ? browseButton : shimContainer; Events.addEvent(top, 'mouseover', function() { comp.trigger('mouseenter'); }, comp.uid); Events.addEvent(top, 'mouseout', function() { comp.trigger('mouseleave'); }, comp.uid); Events.addEvent(top, 'mousedown', function() { comp.trigger('mousedown'); }, comp.uid); Events.addEvent(Dom.get(options.container), 'mouseup', function() { comp.trigger('mouseup'); }, comp.uid); browseButton = null; }()); addInput.call(this); shimContainer = null; }, getFiles: function() { return _files; }, disable: function(state) { var input; if ((input = Dom.get(_uid))) { input.disabled = !!state; } }, destroy: function() { var I = this.getRuntime(), shimContainer = I.getShimContainer(); Events.removeAllEvents(shimContainer, this.uid); Events.removeAllEvents(_options && Dom.get(_options.container), this.uid); Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid); if (shimContainer) { shimContainer.innerHTML = ''; } _uid = _files = _mimes = _options = null; } }); } return (extensions.FileInput = FileInput); }); // Included from: src/javascript/runtime/html4/file/FileReader.js /** * FileReader.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html4/file/FileReader @private */ define("moxie/runtime/html4/file/FileReader", [ "moxie/runtime/html4/Runtime", "moxie/runtime/html5/file/FileReader" ], function(extensions, FileReader) { return (extensions.FileReader = FileReader); }); // Included from: src/javascript/runtime/html4/xhr/XMLHttpRequest.js /** * XMLHttpRequest.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html4/xhr/XMLHttpRequest @private */ define("moxie/runtime/html4/xhr/XMLHttpRequest", [ "moxie/runtime/html4/Runtime", "moxie/core/utils/Basic", "moxie/core/utils/Dom", "moxie/core/utils/Url", "moxie/core/Exceptions", "moxie/core/utils/Events", "moxie/file/Blob", "moxie/xhr/FormData", "moxie/core/JSON" ], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData, parseJSON) { function XMLHttpRequest() { var _status, _response, _iframe; function cleanup(cb) { var target = this, uid, form, inputs, i, hasFile = false; if (!_iframe) { return; } uid = _iframe.id.replace(/_iframe$/, ''); form = Dom.get(uid + '_form'); if (form) { inputs = form.getElementsByTagName('input'); i = inputs.length; while (i--) { switch (inputs[i].getAttribute('type')) { case 'hidden': inputs[i].parentNode.removeChild(inputs[i]); break; case 'file': hasFile = true; // flag the case for later break; } } inputs = []; if (!hasFile) { // we need to keep the form for sake of possible retries form.parentNode.removeChild(form); } form = null; } // without timeout, request is marked as canceled (in console) setTimeout(function() { Events.removeEvent(_iframe, 'load', target.uid); if (_iframe.parentNode) { // #382 _iframe.parentNode.removeChild(_iframe); } // check if shim container has any other children, if - not, remove it as well var shimContainer = target.getRuntime().getShimContainer(); if (!shimContainer.children.length) { shimContainer.parentNode.removeChild(shimContainer); } shimContainer = _iframe = null; cb(); }, 1); } Basic.extend(this, { send: function(meta, data) { var target = this, I = target.getRuntime(), uid, form, input, blob; _status = _response = null; function createIframe() { var container = I.getShimContainer() || document.body , temp = document.createElement('div') ; // IE 6 won't be able to set the name using setAttribute or iframe.name temp.innerHTML = ''; _iframe = temp.firstChild; container.appendChild(_iframe); /* _iframe.onreadystatechange = function() { console.info(_iframe.readyState); };*/ Events.addEvent(_iframe, 'load', function() { // _iframe.onload doesn't work in IE lte 8 var el; try { el = _iframe.contentWindow.document || _iframe.contentDocument || window.frames[_iframe.id].document; // try to detect some standard error pages if (/^4\d{2}\s/.test(el.title) && el.getElementsByTagName('address').length) { // standard Apache style _status = el.title.replace(/^(\d+).*$/, '$1'); } else { _status = 200; // get result _response = Basic.trim(el.body.innerHTML); // we need to fire these at least once target.trigger({ type: 'progress', loaded: _response.length, total: _response.length }); if (blob) { // if we were uploading a file target.trigger({ type: 'uploadprogress', loaded: blob.size || 1025, total: blob.size || 1025 }); } } } catch (ex) { if (Url.hasSameOrigin(meta.url)) { // if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm // which obviously results to cross domain error (wtf?) _status = 404; } else { cleanup.call(target, function() { target.trigger('error'); }); return; } } cleanup.call(target, function() { target.trigger('load'); }); }, target.uid); } // end createIframe // prepare data to be sent and convert if required if (data instanceof FormData && data.hasBlob()) { blob = data.getBlob(); uid = blob.uid; input = Dom.get(uid); form = Dom.get(uid + '_form'); if (!form) { throw new x.DOMException(x.DOMException.NOT_FOUND_ERR); } } else { uid = Basic.guid('uid_'); form = document.createElement('form'); form.setAttribute('id', uid + '_form'); form.setAttribute('method', meta.method); form.setAttribute('enctype', 'multipart/form-data'); form.setAttribute('encoding', 'multipart/form-data'); form.setAttribute('target', uid + '_iframe'); I.getShimContainer().appendChild(form); } if (data instanceof FormData) { data.each(function(value, name) { if (value instanceof Blob) { if (input) { input.setAttribute('name', name); } } else { var hidden = document.createElement('input'); Basic.extend(hidden, { type : 'hidden', name : name, value : value }); form.appendChild(hidden); } }); } // set destination url form.setAttribute("action", meta.url); createIframe(); form.submit(); target.trigger('loadstart'); }, getStatus: function() { return _status; }, getResponse: function(responseType) { if ('json' === responseType) { // strip off
..
tags that might be enclosing the response if (Basic.typeOf(_response) === 'string') { try { return parseJSON(_response.replace(/^\s*]*>/, '').replace(/<\/pre>\s*$/, '')); } catch (ex) { return null; } } } else if ('document' === responseType) { } return _response; }, abort: function() { var target = this; if (_iframe && _iframe.contentWindow) { if (_iframe.contentWindow.stop) { // FireFox/Safari/Chrome _iframe.contentWindow.stop(); } else if (_iframe.contentWindow.document.execCommand) { // IE _iframe.contentWindow.document.execCommand('Stop'); } else { _iframe.src = "about:blank"; } } cleanup.call(this, function() { // target.dispatchEvent('readystatechange'); target.dispatchEvent('abort'); }); } }); } return (extensions.XMLHttpRequest = XMLHttpRequest); }); // Included from: src/javascript/runtime/html4/image/Image.js /** * Image.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /** @class moxie/runtime/html4/image/Image @private */ define("moxie/runtime/html4/image/Image", [ "moxie/runtime/html4/Runtime", "moxie/runtime/html5/image/Image" ], function(extensions, Image) { return (extensions.Image = Image); }); expose(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/file/FileDrop","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/core/JSON","moxie/image/Image","moxie/core/utils/Events"]); })(this);/** * o.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global moxie:true */ /** Globally exposed namespace with the most frequently used public classes and handy methods. @class o @static @private */ (function() { "use strict"; var o = {}, inArray = moxie.core.utils.Basic.inArray; // directly add some public classes // (we do it dynamically here, since for custom builds we cannot know beforehand what modules were included) (function addAlias(ns) { var name, itemType; for (name in ns) { itemType = typeof(ns[name]); if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) { addAlias(ns[name]); } else if (itemType === 'function') { o[name] = ns[name]; } } })(window.moxie); // add some manually o.Env = window.moxie.core.utils.Env; o.Mime = window.moxie.core.utils.Mime; o.Exceptions = window.moxie.core.Exceptions; // expose globally window.mOxie = o; if (!window.o) { window.o = o; } return o; })();  _application/x-javascript_khttps://cf.dropboxstatic.com/static/coffee/compiled/modules/clean/contacts/bloodhound_contacts-vflTxA4vb.jsObplist00{|X$versionX$objectsY$archiverT$top)#)*0123UVWXYZ[\]^_`abcdefghijklmnopqtuvU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 &('$%&'(WNS.base[NS.relative_khttps://cf.dropboxstatic.com/static/coffee/compiled/modules/clean/contacts/bloodhound_contacts-vflTxA4vb.js+,-.Z$classnameX$classesUNSURL-/XNSObject#AîLj456ETWNS.keysZNS.objects789:;<=>?@ABCD FGHIJKLMNOPQRS !"#$%\Content-Type_Access-Control-Allow-Origin]Last-Modified[X-Amz-Cf-Id_Content-EncodingVServerSViaWExpires_Transfer-Encoding]Cache-ControlTDate_Strict-Transport-SecurityZConnectionWX-Cache_application/x-javascriptQ*_Thu, 26 Mar 2015 02:36:14 GMT_85X1vcvFe2Yk5iRYi5x2ddmd78OpxelWDsT5L8XNdByU9wKBU1sM_zw==TgzipUnginx_@1.1 24ddefa04ec34b3d93c7235c7976548c.cloudfront.net (CloudFront)_Thu, 31 Dec 2037 23:55:55 GMTXIdentity_max-age=315360000, private_Thu, 26 Mar 2015 03:03:59 GMT_#max-age=15552000; includeSubDomainsZkeep-alive_Miss from cloudfront+,rs\NSDictionaryr/@_application/x-javascript+,wx_NSHTTPURLResponseyz/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiver}~_WebResourceResponse#-27ciY^irx{.<H[bfn<AG!8=JMPkpO@// Generated by CoffeeScript 1.7.1 define(['jquery', 'external/typeahead.bundle', 'modules/clean/contacts/cache', 'modules/clean/viewer'], function($j, typeahead_bundle, _arg, Viewer) { var BloodhoundContacts, Contacts, DefaultContactsCache; DefaultContactsCache = _arg.DefaultContactsCache; BloodhoundContacts = (function() { function BloodhoundContacts() { this.contacts = new Bloodhound({ datumTokenizer: function(datum) { return [datum.name, datum.email, datum.fname, datum.lname].concat(datum.name_tokens); }, queryTokenizer: function(query) { return [$j.trim(query)]; }, limit: 10, sorter: this._contacts_sorter, local: [] }); this.contacts.initialize(); if (Viewer.get_viewer().is_signed_in) { DefaultContactsCache.load_contacts(false, false, (function(_this) { return function(contacts) { return _this._init_contacts(contacts); }; })(this)); } } BloodhoundContacts.prototype._contacts_sorter = function(a, b) { if (a.priority > b.priority) { return -1; } else if (a.priority < b.priority) { return 1; } return 0; }; BloodhoundContacts.prototype._init_contacts = function(contacts) { this._update_contacts(contacts); return DefaultContactsCache.register_for_updates("bloodhound_contacts", (function(_this) { return function(contacts) { return _this._update_contacts(contacts); }; })(this)); }; BloodhoundContacts.prototype._update_contacts = function(contacts) { this.contacts.clear(); return this.contacts.add(contacts.contacts); }; BloodhoundContacts.prototype.get = function(query, callback) { return this.contacts.get(query, (function(_this) { return function(matches) { return callback(matches); }; })(this)); }; return BloodhoundContacts; })(); Contacts = new BloodhoundContacts(); return Contacts; }); //# sourceMappingURL=bloodhound_contacts.map  _application/x-javascript_Qhttps://cf.dropboxstatic.com/static/javascript/compiled/dropbox-mini-vfl5Ve3fE.jsObplist00{|X$versionX$objectsY$archiverT$top)#)*0123UVWXYZ[\]^_`abcdefghijklmnopqtuvU$null  !"R$6S$10R$2R$7R$3S$11R$8V$classR$4R$9R$0R$5R$1 &('$%&'(WNS.base[NS.relative_Qhttps://cf.dropboxstatic.com/static/javascript/compiled/dropbox-mini-vfl5Ve3fE.js+,-.Z$classnameX$classesUNSURL-/XNSObject#AîR456ETWNS.keysZNS.objects789:;<=>?@ABCD FGHIJKLMNOPQRS !"#$%\Content-Type_Access-Control-Allow-Origin]Last-Modified[X-Amz-Cf-Id_Content-EncodingVServerSViaWExpires_Transfer-Encoding]Cache-ControlTDate_Strict-Transport-SecurityZConnectionWX-Cache_application/x-javascriptQ*_Thu, 26 Mar 2015 02:36:51 GMT_8Ld9j4H76ryLwMCW-_kCBsTiNLTJbP3z-J6VstG4ISSNUcZ3uEp_rfQ==TgzipUnginx_@1.1 f145f877ae14c50350b47836403597d7.cloudfront.net (CloudFront)_Thu, 31 Dec 2037 23:55:55 GMTXIdentity_max-age=315360000, private_Thu, 26 Mar 2015 03:03:59 GMT_#max-age=15552000; includeSubDomainsZkeep-alive_Miss from cloudfront+,rs\NSDictionaryr/_application/x-javascript+,wx_NSHTTPURLResponseyz/_NSHTTPURLResponse]NSURLResponse_NSKeyedArchiver}~_WebResourceResponse#-27ci?DOX^ajsuw~".AHLThv{"'-p#03<W\ptO-define("dropbox",["modules/clean/undo","modules/core/controller_registry","modules/clean/browse_interface","modules/clean/multiaccount_login","modules/clean/datetime","modules/clean/base64","modules/clean/video_util","modules/clean/contacts/types","modules/core/uri","modules/clean/em_string","external/purify","modules/clean/db_bubble","modules/core/exception","libs","modules/clean/uirequest","jquery","modules/core/ordered_dictionary","modules/clean/components/bubble_picker","modules/clean/history","modules/clean/ajax","modules/clean/sso_login_checks","modules/core/notify","modules/clean/third_party/third_party_constants","modules/clean/components/ajax_form","modules/clean/sharing/shared_link_for_sf","modules/clean/react/modal","modules/clean/contacts/list","modules/clean/job_progress","modules/core/i18n","modules/clean/top_notif","modules/core/dom","modules/clean/web_timing_logger","modules/clean/account/email","modules/clean/dbmodal","modules/clean/teams/team_folder_modal","modules/clean/sharing/share_inband","modules/clean/contacts/importer","modules/clean/payments/credit_card_util","modules/core/cookies","modules/clean/dbmodal_loading","modules/clean/display_format","modules/clean/payments/cash","modules/clean/event_load","modules/clean/contacts/facebook_modal","modules/clean/contacts/facebook_oauth","modules/clean/account/email_verify_reasons","modules/clean/image_size","modules/clean/payments/dfb_util","modules/clean/viewer","modules/clean/contacts/cache","modules/clean/analytics","modules/clean/photos/legacy_thumb_loader","modules/core/browser","modules/clean/sprite","modules/clean/filepath","modules/clean/clipboard","modules/core/html"],function(Q,bx,ew,bp,bF,ac,a7,P,C,bu,cw,ap,dz,bV,ba,bg,aK,bc,dZ,cc,bH,Y,aH,bR,dt,b0,m,w,aY,b5,y,dG,ct,cB,dk,dc,U,em,a9,cb,at,df,ae,dB,dP,dQ,Z,cy,ck,dN,aQ,a6,bC,b7,an,q,eu){var A={};var bJ=dz.alertd;var cj=dz.assert;var d6=dz.reportException;var d7=dz.stackTrace;var da=b0.SimpleModal;var cL=w.Job;var dX=w.ModalProgress;var aR=aY.ungettext;var dW=aY._;var c7=aY.N_;var B=aY.E_;var eo=aY.render_sentences;var en=b5.TopNotificationBar;var d9=b5.EUCookieNotificationBar;var o=b5.ExpiredIOSNotificationBar;var dE=b5.PackratUnlimitedOptInNotificationBar;var bS=b5.DfBAdminEarlyAccessSharingControlsBar;var bO=b5.DfBAdminEarlyAccessFtsBar;var aB=b5.LocaleSwitchBar;var aj=ct.ChangeEmail;var ds=ct.EmailVerification;var dw=cB.DBModal;var dp=cB.DBModalStack;var cM=cB.DBUserModal;var aW=df.Cash;var es=df.CashUtil;var au=Z.image_best_fit_size;var et=cy.DfBTransitionInfoFetcher;var ch=dN.ContactsCache;var bB=dN.DefaultContactsCache;var dH,ek,cG;INLINE_JS.$=$;INLINE_JS.$u=$u;Function.prototype.defer=Function.prototype.defer.wrap(function(ex){var T;T=$A(arguments).slice(1);this.__tb__=d7();return ex.apply(this,T)});String.prototype.evalScripts=String.prototype.evalScripts.wrap(function(ex){var T,ey;T=$A(arguments).slice(1);try{return ex.apply(this,T)}catch(ez){ey=ez;return cj(0,ey.toString())}});dH=A.Jcached={cache:{},set:function(ex,ey,T){var ez;ez=dH.cache[ex];if(ez==null){ez=dH.cache[ex]={}}ez.value=ey;return ez.expires=T?new Date().getTime()+T:0},get:function(T){var ex;ex=dH.cache[T];if((ex==null)||new Date().getTime()>ex.expires){delete dH.cache[T];return false}return ex.value}};Function.prototype.cached=function(T){var ey,ex;ex=Math.random();ey=this;return function(){var ez;ez=dH.get(ex);if(ez!==false){return ez}ez=ey();dH.set(ex,ez,T);return ez}};Array.prototype.sort_by_key=function(ex,ey){var T;if(ey==null){ey=false}T=ey?-1:1;return this.sort(function(ez,eA){ez=ex(ez);eA=ex(eA);if(ezeA){return T*1}else{return 0}}})};Array.prototype.contains=function(T){return this.indexOf(T)!==-1};Array.prototype.remove=function(ex,T){T=T||ex+1;return this.splice(ex,T-ex)};Array.prototype.removeItem=function(ex){var T;T=this.indexOf(ex);if(T>=0){return this.remove(T)}else{return false}};Array.prototype.dict_by=function(T){var ez,eA,ey,eB,ex;ey={};for(ez=eB=0,ex=this.length;eBeE&&(ez.top+eA.height)<(eD.height-eE)){return}eF=ez.topView debug');Y.error(new eu(eR))}else{Y.error()}}eI(false);if(eK){eK(eP)}if(eP.status===403){eO=du.session_storage_get("reload-timestamp");if(!eO||bF.time()-eO>30*1000){du.session_storage_set("reload-timestamp",bF.time());location.reload(true)}}return cj(eD.noAutonotify||((eQ=eP.status)===403||eQ===404||eQ===502),"Ajax "+eP.status+" on "+eP.request.url)};eD.onComplete=(function(eO){return function(eP){if(eP.responseText.length&&T){if(eP.responseText.indexOf("async_task_started:")!==0){return T(eP)}}}})(this);eD.onSuccess=(function(eO){return function(eY){var eX,eP,e4,e1,eZ,eQ,e3,eS,eU,e2,eR,eV,e0,eW,eT;eR=bF.time()-eY.request.start_time;if(cL.handled(eY.request.job_id)){return}if(!eY.responseText.length){if(!eD.job){eC(eY);if(ey(eY)){return}if(!eD.noAutonotify){if(!eY||eY.status!==0){Y.error()}}if(eK){eK(eY)}}}else{if(eY.responseText.indexOf("err:")===0){if(!eD.noAutonotify){eQ=eY.responseText.substr(4);if(eD.html_in_error_msg){eQ=new eu(eQ)}Y.error(eQ)}if(eK){eK(eY)}}else{if(eY.responseText.indexOf("async_task_started:")===0){eO.async_task_id=eY.responseText.split(":")[1];dA.watch(eO)}else{if(eG){if(eY.responseText.indexOf("ok:")===0){Y.success(eY.responseText.substr(3))}eG(eY)}}e2=eY.getHeader("X-Server-Response-Time")||"-1";if(eD.log_timing){dG.log_ajax_transition.defer(eR,void 0,void 0,void 0,e2,eF=aS.absolutize(eO.url))}eX=bg("#cprofile");if(!eD.no_watch&&eX.length){eU=""+Constants.REQUEST_ID+"-"+(eY.getHeader("X-Dropbox-Request-Id"));eF=eY.request.url.replace(/[^/]*\/\/[^/]+/,"").replace(/\?.*$/,"");e1="Ajax: "+eF+" ("+e2+"ms)";e3="/profile/cprofile?request_id="+eU;eS=eY.request.url;if(eS.indexOf(Constants.BLOCK_CLUSTER)!==-1){e3+="&block=1"}else{eW=Constants.BATCH_THUMB_ENDPOINTS;for(eV=0,e0=eW.length;eV').attr("href",e3).text(e1);eP=eX.find(".ajax");if(eP.length>=10){eP.last().remove()}eX.prepend(eZ)}if(bg("#gandalf_panel").length&&eY.request.url.substring(0,14)!=="/gandalf_panel"){if((eT=window.gandalf_panel)!=null){eT.add(eY.request.url,eY.getHeader("X-Dropbox-Request-Id"))}}}}return eI(true)}})(this);eD.onException=function(eP,eQ){var eR,eO;if(window.console){throw eQ}eR=("Error with AJAX callback for: "+eF+" :::: ")+eQ.toString();eO=d7();eO.pop();return d6(eR,bC.get_href(),"",eO.join("\n"))};if(eD.job){eF+=(eF.indexOf("?")===-1?"?":"&")+"long_running=1"}if(eD.subject_user&&!((eH=eD.parameters)!=null?eH[Constants.UID_PARAM_NAME]:void 0)){eF=C.parse(eF).updateQuery(Constants.UID_PARAM_NAME,eD.subject_user).toString()}eJ=$H({url:eF});if(eD.parameters){eJ.update(eD.parameters);eB=eJ.keys();for(ez=0,eL=eB.length;ez])+)?>|<\/\w+>/gi,"")};jQuery.fn.controller=function(T){if(typeof monkey_check==="function"){monkey_check()}if(T!=null){return this.data("jscontroller",T)}else{return this.data("jscontroller")}};jQuery.fn.hasScrollBar=function(){if(typeof monkey_check==="function"){monkey_check()}return this.get(0).scrollHeight>this.height()};jQuery.fn.viewportOffset=function(){if(typeof monkey_check==="function"){monkey_check()}return y.viewport_offset(this)};jQuery.fn.visible=function(){if(typeof monkey_check==="function"){monkey_check()}return jQuery(this).is(":visible")};jQuery.fn.clonePosition=function(ex,T){if(typeof monkey_check==="function"){monkey_check()}y.clone_position(this,ex,T);return this};jQuery.format=function(ex,T){if(typeof monkey_check==="function"){monkey_check()}return ex.replace(/\{([^}]+)\}/g,function(ez,ey){if(ey in T){return T[ey]}else{return ez}})};jQuery.cachedScript=function(ex,T){if(typeof monkey_check==="function"){monkey_check()}T=bg.extend(T||{},{dataType:"script",cache:true,url:ex});return jQuery.ajax(T)};jQuery.browser=bC;jQuery.addSubjectParam=function(ey,T){var ex;if(typeof monkey_check==="function"){monkey_check()}if(ey.subject_user&&!((ex=ey.data)!=null?ex[Constants.UID_PARAM_NAME]:void 0)){return T[Constants.UID_PARAM_NAME]=String(ey.subject_user)}};jQuery.ajaxPrefilter(function(T,ez,ey){var ex;if(!ez.noDropboxDefaults){ex={t:a9.read(Constants.JS_CSRF_COOKIE),is_xhr:true};jQuery.addSubjectParam(ez,ex);if(jQuery.ajaxSettings.restrict!=null){ex.restrict=jQuery.ajaxSettings.restrict}T.data=bg.param(bg.extend(ez.data,ex),true);return false}});jQuery.ajax.retryOnce=function(ez,T,ex){var ey;if(typeof monkey_check==="function"){monkey_check()}if(T!=="abort"&&((ey=ez.status)===0||ey===500||ey===502||ey===503)&&!this.xhr_retry){this.xhr_retry=true;return jQuery.ajax(this)}};var d2,cK,dj,aS,du,cZ,cV=function(T,ex){return function(){return T.apply(ex,arguments)}};du=INLINE_JS.Util=A.Util={set_min_body_height_to_viewport_height:function(){var T;T=$(document.body);if(T!=null?T.style:void 0){return T.style.minHeight=y.viewport_dimensions().height+"px"}},scroll_to_thumb:function(T){var eA,ez,ey,ex;ez=T.cumulativeOffset().top;eA=T.getHeight();ex=y.scroll_offsets().top;ey=y.viewport_dimensions().height;if(ezex+ey){return y.scroll_to(0,ez-ey/2)}},decode_sort_key:function(ey){var eA,ez,ex,T;T=[];for(ez=0,ex=ey.length;ezeA;ez=0<=eA?++eB:--eB){if(ey[ez]==null){return 1}if(typeof T[ez]!==typeof ey[ez]){if(typeof T[ez]==="string"){return 1}else{return -1}}else{if(T[ez]!==ey[ez]){if(T[ez]>ey[ez]){return 1}else{return -1}}}}if(ey.length>T.length){return -1}else{return 0}},add_sort_arrow_mouseover:function(T,eA,ey,ex){var eD,eB,eE,eC,ez;eC=$$(ey);ez=[];for(eB=0,eE=eC.length;eBeC;ez=0<=eC?++eD:--eD){eA=ex[ez];if(ez!==0){eA=", "+eA}eB=new bu(eA).length;if(eB>T){break}T-=eB;ey+=eA}return{str:ey,snipped:ex.length-ez}},start_of_day:function(T){var ex;ex=new Date();ex.setTime(T.getTime());ex.setHours(0);ex.setMinutes(0);ex.setSeconds(0);ex.setMilliseconds(0);return ex},to_iso8601_date:function(ez,ex,ey){var T;if(ex==null){ex=false}if(ey==null){ey=false}if(ex){T=ez.getUTCFullYear().toString()+"-"+(ez.getUTCMonth()+1).toString().lpad(2)+"-"+ez.getUTCDate().toString().lpad(2);if(ey){T+=" "+ez.getUTCHours().toString().lpad(2)+":"+ez.getUTCMinutes().toString().lpad(2)+":"+ez.getUTCSeconds().toString().lpad(2)}}else{T=ez.getFullYear().toString()+"-"+(ez.getMonth()+1).toString().lpad(2)+"-"+ez.getDate().toString().lpad(2);if(ey){T+=" "+ez.getHours().toString().lpad(2)+":"+ez.getMinutes().toString().lpad(2)+":"+ez.getSeconds().toString().lpad(2)}}return T},to_mysql_date:function(eA,T,ey){var ex,eB,ez;ex=eA.getFullYear().toString()+"-"+(eA.getMonth()+1).toString().lpad(2)+"-"+eA.getDate().toString().lpad(2);ez=eA.getHours().toString().lpad(2)+":"+eA.getMinutes().toString().lpad(2)+":"+eA.getSeconds().toString().lpad(2);eB="."+eA.getMilliseconds().toString().lpad(3);if(!T){return ex}if(!ey){return ex+" "+ez}return ex+" "+ez+eB},from_mysql_date:function(ex){var ez,eB,ey,eD,T,eC,eA;eD=ex.split(" ");ez=eD[0];eC=eD.length>1?eD[1]:false;eB=ez.split("-");cj(eB.length===3,"weird date format on "+this+", expected yyyy-mm-dd");ey=new Date(eB[0],parseInt(eB[1],10)-1,eB[2]);if(eC){eA=eC.split(":");cj(eA.length===3,"weird time format on "+this+", expected hh:mm:ss.ms");ey.setHours(eA[0]);ey.setMinutes(eA[1]);T=eA[2].split(".");ey.setSeconds(T[0]);if(T.length>1){ey.setMilliseconds(T[1])}}return ey},make_table:function(T,eD){var ey,eC,eE,ex,eA,ez,eB;eE=new Element("table",eD);ex=new Element("tbody");eE.__sert(ex);for(eC in T){eB=T[eC];ez=new Element("tr");eA=new Element("td").insert(eC);ey=new Element("td").insert(eB);ez.__sert(eA);ez.__sert(ey);ex.__sert(ez)}return eE},validate_email:function(T){var ex;ex=new RegExp("^['&A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,15}$","i");return ex.test(T)},scrollTop:function(){return window.scrollY||document.documentElement.scrollTop||0},scrollLeft:function(){return window.scrollX||document.documentElement.scrollLeft||0},scried:{},scry:function(ey){var ex,T;T=this.scried;ex=T[ey];if(!ex){ex=$(ey);T[ey]=ex}return ex},urlquote:function(T){return T.split("/").map(encodeURIComponent).join("/")},ie8:Prototype.Browser.IE&&document.documentMode&&true,ie:Prototype.Browser.IE,log:function(){var ex,T;if(!Constants.IS_PROD){if(Prototype.Browser.IE){return(ex=$("ieconsole"))!=null?ex.innerHTML+=$A(arguments).join(" ")+"
":void 0}else{return typeof console!=="undefined"&&console!==null?(T=console.log)!=null?T.apply(console,$A(arguments)):void 0:void 0}}},childElement:function(ey,ex){var T;T=this.childElementWithIndex(ey,ex);return T[0]},childElementWithIndex:function(eD,ey){var eA,eC,ez,ex,eB,T;eA=0;ex=eD.childNodes;for(ez=eB=0,T=ex.length;eBez){ex=Math.floor(ey/2+ez/2);eC=eB(T[ex],eD);if(eC>0){ey=ex}else{if(eC<0){ez=ex+1}else{return ex}}}if(eA){return ez}else{return -1}},nonce:function(){var ey,T,ex;ey=new Date();ex=ey.getTime().toString();T=Math.floor(Math.random()*1000000).toString().lpad(6);return ex+T},focus:function(ex){if(ex){ex=$(ex);try{return ex.focus()}catch(T){}}},sumStyles:function(ez,eA){var T,ey,eB,ex;ey=0;if(ez){for(eB=0,ex=eA.length;eB0?""+ex+"px":"auto"})},async_load_script:function(ex){var T;T=function(){var ez,ey;ey=document.createElement("script");ey.src=ex;ey.type="text/javascript";ey.async=true;ez=document.getElementsByTagName("script")[0];return ez.parentNode.insertBefore(ey,ez)};if(document.readyState==="complete"){return T()}else{if(window.attachEvent!=null){return window.attachEvent("onload",T)}else{return window.addEventListener("load",T,false)}}},smart_window_load:function(T){if(document.readyState==="complete"){return T.defer()}else{return Event.observe(window,"load",T)}},isNumber:function(T){return !isNaN(Number(T,10))},shorten_url:function(T,ex){return new Ajax.DBRequest("/shorten_url",{parameters:{url:T},onSuccess:function(ey){return ex(ey.responseText)}})},falsy_to_empty:function(T){return T||""},preloaded_images:{},preload_image:function(ez,ey,ex){var T;if(this.preloaded_images[ez]){return}T=new Image();if(ey!=null){Element.extend(T).observe("error",ey)}if(ex!=null){Element.extend(T).observe("load",ex)}T.src=ez;return this.preloaded_images[ez]=T},get_preloaded_image:function(T){if(this.preloaded_images[T]){return this.preloaded_images[T].clone()}else{return new Element("img",{src:T})}},clear_selected:function(){var T;if(window.getSelection){T=window.getSelection();if(T.removeAllRanges){return T.removeAllRanges()}}else{if(document.selection){return document.selection.empty()}}},is_mac:function(){return navigator.appVersion.indexOf("Mac")!==-1},is_windows:function(){return navigator.appVersion.indexOf("Windows")!==-1},in_scrollbar:function(T){var ey,ex;ey=20;ex=y.viewport_dimensions();return T>ex.width-ey},freshbutton_overlay:function(ex,T){var ez,ey;ey=ex instanceof jQuery&&ex||bg(ex);ez=T instanceof jQuery&&T||bg(T);ey.on("mouseover",(function(eA){return function(){return ez.addClass("hovered")}})(this));ey.on("mouseout",(function(eA){return function(){ez.removeClass("hovered");return ez.removeClass("pressed")}})(this));ey.on("mousedown",(function(eA){return function(){ez.removeClass("hovered");return ez.addClass("pressed")}})(this));return ey.on("mouseup",(function(eA){return function(){return ez.removeClass("pressed")}})(this))},isElm:function(T){if(typeof HTMLElement==="object"){return T instanceof HTMLElement}else{return T&&typeof T==="object"&&T.nodeType===1&&typeof T.nodeName==="string"}},_track_twitter_chars_left:function(ex,ey){var T;clearInterval(this.chars_left_interval);T=(function(ez){return function(){var eA,eB;eA=$("twitter-chars");eB=ey-$F(ex).strip().length;if(eB<0){eA.addClassName("too-long")}else{eA.removeClassName("too-long")}return eA.__date(eB)}})(this);return this.chars_left_interval=setInterval(T,250)},session_storage_set:function(T,ex){if(!window.sessionStorage||!window.JSON){return}return window.sessionStorage.setItem(T,JSON.stringify(ex))},session_storage_get:function(T){if(window.sessionStorage&&window.JSON){return JSON.parse(window.sessionStorage.getItem(T))}},pdf_plugins:function(){var ey,ex,T;T=/Chrome PDF|Adobe Reader|Adobe PDF|Acrobat/gi;return ey=(function(){var eC,eA,eB,ez;eB=window.navigator.plugins;ez=[];for(eC=0,eA=eB.length;eC';return $("flashcb").innerHTML=ex}}};var ai;ai=A.RequestWatcher={reqs:[],working_msg:dW("Still working...",{comment:"Comment about waiting for a process to complete"}),last_notification:null,TIMEOUT:10,watch:function(ex,ey){var T;T=this.reqs;if(!T.length){this.int_id=setInterval(this.check_up.bind(this),500)}if(ey){ex.skip_message=true}return T.push([ex,bF.time()])},check_up:function(){return this.scan(false)},remove:function(T){return this.scan(T)},scan:function(eB){var eF,ex,ez,T,eD,eC,ey,eE,eA;ex=bF.time();ez=[];eA=this.reqs;for(ey=0,eE=eA.length;ey4000&&!eD.skip_message){eD.skip_message=true;if(Y.isShown()&&Y.current()===!Q.undo_notification){this.last_notification=Y.success(this.working_msg)}}if(eF>this.TIMEOUT*1000&&eD.job){eD.transport.abort()}if(eD!==eB){ez.push([eD,eC])}else{eD.transport.abort()}}this.reqs=ez;if(!ez.length){return clearInterval(this.int_id)}},clearWorkingMessage:function(){if(Y.isShown()&&Y.current()===this.last_notification){return Y.clear()}}};bg(function(){var ey,ex,ez,T;ez=Prototype.Browser;T=[];for(ey in ez){ex=ez[ey];if(ex===true){T.push(bg(document.body).addClass(ey.toLowerCase()))}}return T});var c9,aM,cz=[].slice;c9=A.HTML5_HISTORY=Modernizr.history;bg((function(T){return function(){return dZ.init()}})(this));aM=A.HashRouter={watch_timer:null,callback_map:{},last_hash:"",last_prefix:"",_get_location:function(){return window.location.href},_set_location:function(T){return window.location.href=T},_replace_location:function(T){return window.location.replace(T)},init:function(){return this.watch_timer=setInterval(this.check_hash.bind(this),300)},watch:function(T,ex){this.callback_map[T]=ex;if(!this.watch_timer){return this.init()}},check_hash:function(){var ex,ey,ez,eB,eA,T;eB=this._get_location().split("#")[1];if(eB!=null){eB=eB.replace(/%27/g,"'")}if(this.last_hash===eB){return}this.last_hash=eB;if(this.last_prefix&&eB===""){eB=this.last_prefix+":"}else{if(!eB){return}}T=eB.split(":");eA=T.first();this.last_prefix=eA;ez=this.callback_map[eA];if(ez!=null){ey=(function(){var eF,eD,eE,eC;eE=T.slice(1);eC=[];for(eF=0,eD=eE.length;eF

");bg("#share_parent_folder_button").on("click",(function(eE){return function(eF){er.hide();return eE.show_shared_folder_options_modal(ey,eA)}})(this));return er.show(eB,$("share_subfolder"))};return T})();var cH;cH=A.InviteFormController=(function(){function T(ez,ey,ex,eE,eD,eC){var eB,eA;this.user=ez;this.$form=ey;this.members=ex;this.invitees=eE;this.new_style_groups=eD;this.team_only=this.$form.data("team-only");eA={tokens:[",",";"],include_fb:true,members:this.members,invitees:this.invitees,new_style_groups:this.new_style_groups,contacts_only:true};if(this.user.role==="work"){eB=Autocompleter.TeamTokenizer;eA.team_only=this.team_only}else{eB=Autocompleter.ContactsTokenizer;eA.include_team=true}if(this.user.role==="work"&&(__CIRCULAR_DEPENDENCY__.GroupsApi!=null)){eA.include_new_style_groups=true}this.sharing_options_auto_completer=new eB(this.user,eC+"-new-collab-input",eC+"-new-whobulk",eC+"-hidden-input",eA);bT._create(this.$form.find(".custom-message-container")[0]);if(this.user.role==="work"){this.team_shared_folder_controller=new i(this.$form)}}T.prototype.listen=function(){return this.sharing_options_auto_completer.listen()};T.prototype.reset_autocompleter=function(){return this.sharing_options_auto_completer.clearTokens()};T.prototype.tokenize=function(){return this.sharing_options_auto_completer.tokenize_emails_input(true)};T.prototype.reset_options=function(){return bg(this.sharing_options_auto_completer.get_entry_container()).hide()};T.prototype.set_team_only=function(ex){this.team_only=ex;return this.sharing_options_auto_completer.setTeamOnly(ex)};T.prototype.extract_invitees=function(){var eA,ez,ey,eD,eC,ex,eB;eD={};eB=["emails","fb_ids","group_ids","new_style_group_ids"];for(eC=0,ex=eB.length;eC=this.num_total)){bg("#more-members-spinner").hide();return}bg("#more-members-spinner").show();ez={};ez[Constants.UID_PARAM_NAME]=this.user.id;ez.start=this.start;ez.max_results=this.max_results;ey=C({path:"/share_options"+this.path}).toString();this.$root.removeClass("ajax-loading");new ba(this.$root,ey,{data:ez,success:(function(eA){return function(eE,eB,eF){var eC,eD;if(((eD=eE.data)!=null?eD.options:void 0)!=null){eC=eE.data.options;if((eA.members!=null)&&(eC.folder_members!=null)){Array.prototype.push.apply(eA.members,eC.folder_members)}if((eA.invitees!=null)&&(eC.folder_invitees!=null)){Array.prototype.push.apply(eA.invitees,eC.folder_invitees)}if((eA.new_style_groups!=null)&&(eC.new_style_groups!=null)){Array.prototype.push.apply(eA.new_style_groups,eC.new_style_groups)}}return eA.maybe_load_more()}})(this),error:(function(eA){return function(eD,eB,eC){return Y.error("Unable to load all members of this folder.")}})(this)});return this.start=this.start+this.max_results};T.prototype.submit_invitations=function(){var eA,ez,eC,ey,eB,ex;this.invite_form_controller.tokenize();eC=this.invite_form_controller.extract_invitees();eB=this.invite_form_controller.get_custom_message();eA=this.invite_form_controller.get_access_type();ey=$u.clone(this.log_extras);ey.access_type=eA;aQ.SharedFolderActivityLogger.log("web","invite_modal_send_invites_button",this.user,ey);ex=(function(eD){return function(eF){var eE;eE=dw.get_containing_modal(eD.$root);if(eE&&eE instanceof cb){eE.fetch()}else{dp.pop()}Y.success(eF.responseText);return document.fire(av.SF_INVITE,{target_ns_id:eD.ns_id,user_id:eD.user.id})}})(this);ez=(function(eD){return function(eE){return d4.show_validation_error(eE,eD.$root.find(".tokenized_autocompleter_container"))}})(this);return this.sharing_api.invite_more_to_folder(this.ns_id,eC,eB,eA,ex,ez)};T.prototype.reinvite_user=function(ez,ex,ey){return this.sharing_api.reinvite_user(ex,ey,(function(eA){return function(eH){var eE,eF,eG,eD,eB,eC;eD=JSON.parse(eH.responseText);eB=eD.status;if(eB==="OK"){eC=dW("%(email_or_fbname)s was reinvited successfully");eC=eC.format({email_or_fbname:ez});return Y.success(eC)}else{eG=eD.reason;if(eG==="ACCEPTED"){eE=dW("That invitation has already been accepted.")}else{if(eG==="DECLINED"){eE=dW("That invitation has already been declined.")}else{eE=dW("You no longer have permission to perform this action.")}}Y.error(eE);if(eD.reload){eF=dw.get_containing_modal(eA.$root);if(eF&&eF instanceof cb){return eF.fetch()}}}}})(this))};T.prototype.update_sf_perms=function(ey){var ez,eA,ex;this.$root.find("#change-sf-perm-saving").show();ez=(ey?1:0);ex=(function(eB){return function(eC){if(ey){Y.success(dW("Editors can now manage membership of this folder."))}else{Y.success(dW("Editors can no longer manage membership of this folder."))}return eB.$root.find("#change-sf-perm-saving").hide()}})(this);eA=(function(eB){return function(eC){if(eC.responseText.indexOf("err:")===0){Y.error(eC.responseText.substr(4))}else{Y.error(dW("Error updating your preference! Please try again."))}return eB.$root.find("#change-sf-perm-saving").hide()}})(this);return this.sharing_api.update_sf_permissions(this.ns_id,ez,ex,eA)};T.prototype.update_tf_access=function(ey){var ez,ex;ex=(function(eA){return function(eB){if(ey){return Y.success(dW("Team members can now change folder contents."))}else{return Y.success(dW("Team members can no longer change folder contents."))}}})(this);ez=(function(eA){return function(eB){return Y.error(dW("Error updating your preference! Please try again."))}})(this);return this.sharing_api.update_group_access_type(this.ns_id,this.$root.data("group-gid"),ey,ex,ez)};T.prototype.show_kick_user_modal=function(ez,ey,ex){return dp.push(new ea(this.user,{element_id:"kick-confirm-modal",ns_id:this.ns_id,user_name:ez,folder_path:this.path,user_id:ex}))};T.prototype.show_kick_group_modal=function(ex,ey){return dp.push(new aF(this.user,{element_id:"kick-group-confirm-modal",ns_id:this.ns_id,group_name:ex,folder_path:this.path,group_id:ey}))};T.prototype.show_transfer_user_modal=function(ez,ey,ex){return dp.push(new bn(this.user,{element_id:"transfer-confirm-modal",user_id:ex,user_name:ez,ns_id:this.ns_id,folder_path:this.path}))};T.prototype.show_uninvite_modal=function(ez,ex,ey){return dp.push(new aw(this.user,{element_id:"uninvite-confirm-modal",email_or_fbname:ez,ns_id:ex,invite_id:ey,folder_path:this.path}))};T.prototype.show_unshare_folder_modal=function(){return dp.push(new bE(this.user,{element_id:"unshare-confirm-modal",team_shared_folder:this.team_shared_folder,ns_id:this.ns_id,folder_path:this.path}))};T.prototype.show_access_request_link_modal=function(){return dp.push(new cJ(this.user.id,this.path,void 0,true))};T.prototype.show_owner_leave_folder_warning=function(){return Y.error(dW("You can't leave this folder because you're the owner. You must transfer ownership to another member before you can leave."))};T.prototype.show_leave_folder_modal=function(){return dp.push(new cU(this.user,{element_id:"leave-confirm-modal",team_shared_folder:this.team_shared_folder,ns_id:this.ns_id,folder_path:this.path}))};T.prototype.toggle_to_invite_mode=function(){var ex;this.$allow_members_table.show();this.$folder_management_buttons.hide();this.$invite_form.removeClass("collapsed");return(ex=this.sf_access_type)!=null?ex.show():void 0};T.prototype.toggle_from_invite_mode=function(){var ey,ex;this.$allow_members_table.hide();this.$folder_management_buttons.show();this.$invite_form.addClass("collapsed");if((ey=this.sf_access_type)!=null){ey.hide()}return(ex=this.invite_form_controller)!=null?ex.reset_autocompleter():void 0};T.prototype.show_folder_settings=function(ex){aQ.SharedFolderActivityLogger.log("web","invite_modal_change_settings",this.user,this.log_extras);ex.preventDefault();dp.register(dU.SAVED_PERMISSIONS,(function(ey){return function(eA,ez){if(ez!=null){return ey.set_team_only(ez)}}})(this));return dp.push(new dU(this.user,this.path,this.ns_id))};T.prototype.show_email_verification=function(ex){dp.pop();return ds.get_for_user(this.user).show()};T.prototype.set_team_only=function(ex){var ey;this.invite_form_controller.set_team_only(ex);ey=this.$invite_form.add(this.$root.find(".external-invite-message,.member-info .folder-settings"));if(ex){return ey.addClass("team-only")}else{return ey.removeClass("team-only")}};return T})();cU=A.LeaveFolderModal=(function(T){cm(ex,T);function ex(){this.before_show=cV(this.before_show,this);this.on_show=cV(this.on_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);return ex.__super__.constructor.apply(this,arguments)}ex.prototype.on_confirm_button_click=function(ez){var ey;ez.preventDefault();ey=this.$modal_window.find("#keep_files").prop("checked");return this.sharing_api.leave_folder(this.ns_id,ey,(function(eA){return function(){var eB;eB=dW("You removed yourself from '%(msg)s'.").format({msg:bu.em_snippet(an.filename(eA.path),25)});Y.success(eB);document.fire(av.SF_LEAVE,{target_ns_id:eA.ns_id,folder_deleted:!ey,user_id:eA.user.id});return dp.clear()}})(this))};ex.prototype.on_show=function(){ex.__super__.on_show.apply(this,arguments);if(this.team_shared_folder){this.$modal_window.find(".keep_files_option").hide();return this.$modal_window.find(".keep_files_option").find("input").prop("checked",false)}else{this.$modal_window.find(".keep_files_option").show();return this.$modal_window.find(".keep_files_option").find("input").prop("checked",true)}};ex.prototype.before_show=function(){var ey;ey=dW("Leave the shared folder '%(folder_name)s'");ey=ey.format({folder_name:bu.em_snippet(an.filename(this.path),14)});return this.format({".db-modal-title-text":ey})};return ex})(de);bE=A.UnshareFolderModal=(function(ex){cm(T,ex);function T(){this.before_show=cV(this.before_show,this);this.on_show=cV(this.on_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);return T.__super__.constructor.apply(this,arguments)}T.prototype.on_confirm_button_click=function(ez){var ey;ez.preventDefault();ey=this.$modal_window.find("#keep_files").prop("checked");return this.sharing_api.unshare_folder(this.ns_id,ey,(function(eA){return function(){var eB;eB=dW("Unshared folder '%(folder_name)s'");eB=eB.format({folder_name:bu.em_snippet(an.filename(eA.path),25)});Y.success(eB);document.fire(av.SF_UNSHARE,{target_ns_id:eA.ns_id,user_id:eA.user.id});return dp.clear()}})(this))};T.prototype.on_show=function(){T.__super__.on_show.apply(this,arguments);if(this.team_shared_folder){this.$modal_window.find(".tsf_unshare_desc").show();return this.$modal_window.find(".regular_unshare_desc").hide()}else{this.$modal_window.find(".tsf_unshare_desc").hide();return this.$modal_window.find(".regular_unshare_desc").show()}};T.prototype.before_show=function(){var ey;ey=dW("Unshare '%(folder_name)s'");ey=ey.format({folder_name:bu.em_snippet(an.filename(this.path),21)});return this.format({".db-modal-title-text":ey})};return T})(de);aw=A.UninviteModal=(function(ex){cm(T,ex);function T(ey,ez){this.before_show=cV(this.before_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.email_or_fbname=ez.email_or_fbname;this.ns_id=ez.ns_id;this.invite_id=ez.invite_id;T.__super__.constructor.call(this,ey,ez)}T.prototype.on_confirm_button_click=function(ey){ey.preventDefault();return this.sharing_api.cancel_invite(this.ns_id,this.invite_id,(function(ez){return function(eF){var eD,eE,eC,eA,eB;eC=JSON.parse(eF.responseText);eA=eC.status;if(eA==="OK"){eB=dW("%(email_or_fbname)s has been uninvited.").format({email_or_fbname:ez.email_or_fbname});Y.success(eB)}else{eE=eC.reason;if(eE==="ACCEPTED"){eD=dW("That invitation has already been accepted.")}else{if(eE==="DECLINED"){eD=dW("That invitation has already been declined.")}}Y.error(eD)}return dp.pop()}})(this))};T.prototype.before_show=function(ey){var ez;ez=dW("Uninvite %(email_or_fbname)s?").format({email_or_fbname:bu.em_snippet(this.email_or_fbname,20)});return this.format({".uninvite-confirm-nickname":this.email_or_fbname,".uninvite-confirm-folder-name":an.filename(this.path),".db-modal-title-text":ez})};return T})(de);ea=A.KickUserModal=(function(T){cm(ex,T);function ex(ey,ez){this.user=ey;this.options=ez;this.before_show=cV(this.before_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.user_id=ez.user_id;this.user_name=ez.user_name;ex.__super__.constructor.call(this,ey,ez)}ex.prototype.on_confirm_button_click=function(eA){var ey,ez;eA.preventDefault();ey=this.$modal_window.find("#keep-files-check").prop("checked");this.sharing_api.kick(this.ns_id,this.user_id,ey,(function(eB){return function(){Y.success(dW("User removed successfully."));bA.reload_folder_info_if_two_account();return dp.pop()}})(this));ez={ns_id:this.ns_id,kick_user_id:this.user_id,keep_files:ey};return aQ.SharedFolderActivityLogger.log("web","invite_modal_kick_collaborator",this.user,ez)};ex.prototype.before_show=function(ey){var ez;ez=dW("Remove %(person_name)s from this folder?");ez=ez.format({person_name:this.user_name});return this.format({".kick-confirm-nickname":this.user_name,".db-modal-title-text":ez})};return ex})(de);aF=A.KickGroupModal=(function(T){cm(ex,T);function ex(ey,ez){this.user=ey;this.options=ez;this.before_show=cV(this.before_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.group_id=ez.group_id;this.group_name=ez.group_name;ex.__super__.constructor.call(this,ey,ez)}ex.prototype.on_confirm_button_click=function(ey){ey.preventDefault();return __CIRCULAR_DEPENDENCY__.GroupsApi.remove_namespace_from_group({group_id:this.group_id,ns_id:this.ns_id},(function(ez){return function(){Y.success(dW("Group removed successfully."));bA.reload_folder_info_if_two_account();return dp.pop()}})(this))};ex.prototype.before_show=function(){var ey;ey=dW("Remove %(group_name)s from this folder?");ey=ey.format({group_name:this.group_name});return this.format({".kick-confirm-nickname":this.group_name,".db-modal-title-text":ey})};return ex})(de);b6=A.MakeOwnerModal=(function(ex){cm(T,ex);function T(ey,ez){this.user=ey;this.options=ez;this.before_show=cV(this.before_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.member_uid=ez.member_uid;this.member_name=ez.member_name;this.ns_id=ez.ns_id;this.access_type=ez.access_type;T.__super__.constructor.call(this,ey,ez)}T.prototype.on_confirm_button_click=function(ey){ey.preventDefault();return this.sharing_api.update_member_access_type(this.ns_id,this.member_uid,this.access_type,(function(ez){return function(){Y.success(dW("%(name)s now is the owner.").format({name:ez.member_name}));return dp.pop()}})(this))};T.prototype.before_show=function(){var ey;ey=dW("Make %(name)s the owner of this folder?");ey=ey.format({name:bu.em_snippet(this.member_name,14)});return this.format({".make-owner-confirm-nickname":this.member_name,".db-modal-title-text":ey})};return T})(de);bn=A.TransferOwnershipModal=(function(ex){cm(T,ex);function T(ey,ez){this.user=ey;this.options=ez;this.before_show=cV(this.before_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.user_id=ez.user_id;this.user_name=ez.user_name;T.__super__.constructor.call(this,ey,ez)}T.prototype.on_confirm_button_click=function(ey){ey.preventDefault();return this.sharing_api.transfer_ownership(this.ns_id,this.user_id,(function(ez){return function(eA){Y.success(dW("Ownership changed successfully"));return dp.pop()}})(this))};T.prototype.before_show=function(){var ey;ey=dW("Make %(person_name)s the owner of this folder?");ey=ey.format({person_name:bu.em_snippet(this.user_name,14)});return this.format({".change_sf_owner-confirm-nickname":this.user_name,".db-modal-title-text":ey})};return T})(de);dU=A.ExistingSharedFolderPermissionsModal=(function(ex){cm(T,ex);T.SAVED_PERMISSIONS="existing_sf_permissions:saved";function T(ez,eA,ey){var eC,eB;this.user=ez;this.path=eA;this.ns_id=ey;eC={ns_id:this.ns_id,folder_name:this.path};eC[Constants.UID_PARAM_NAME]=this.user.id;eB=dW("'%(folder_name)s' settings");eB=eB.format({folder_name:bu.em_snippet(an.filename(this.path),13)});T.__super__.constructor.call(this,{element_id:"folder-permissions-modal",title:eB,endpoint_url:"/share_ajax/folder_settings",parameters:eC})}return T})(cb);L=A.ExistingSharedFolderPermissionsContent=(function(){function T(ey,ez,ex){this.$form=ey;this.ns_id=ex;this._submit=cV(this._submit,this);this.user=ck.get_viewer().get_user_by_id(ez);this.sharing_api=new aZ(this.user);this.sharing_api.loading_elem=this.$form;this._listen()}T.prototype._listen=function(){this.$form.find(".confirm-button").click(this._submit);return this.$form.find(".cancel-button").click(this._cancel)};T.prototype._cancel=function(){return dp.pop()};T.prototype._submit=function(eC){var eD,ex,eA,ez,ey,eB;eC.preventDefault();ex=this.$form.find("input[name=audience]:checked").val();eA=this.$form.find("input[name=inviter]:checked").val();ey=this.$form.find("input[name=shared_link_policy]:checked").val();eD=(eB=this.$form.find("input[name=activity_feed_enabled]:checked"))!=null?eB.val():void 0;this.sharing_api.update_sf_team_permissions(this.ns_id,ex,eA,ey,eD,(function(eE){return function(eG){var eF,eH;eF=JSON.parse(eG.responseText);eH=eF.team_only_invite;Y.success(eF.message);dp.trigger(dU.SAVED_PERMISSIONS,eH);return dp.pop()}})(this));false;ez={ns_id:this.ns_id,audience:ex,inviter:eA};return aQ.SharedFolderActivityLogger.log("web","settings_modal_save",this.user,ez)};return T})();var aL,dv,ee,dm,d4,bZ,b9,dO,cD,bP,bs,cv,cu,cs,cq,am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez},cV=function(T,ex){return function(){return T.apply(ex,arguments)}};aL=A.BaseShareAFolderWizardModal=(function(T){cm(ex,T);ex.prototype.base_title=null;ex.prototype.personal_title=null;ex.prototype.work_title=null;function ex(ey,ez){this.user=ey;this.options=ez;ex.__super__.constructor.call(this,this.options);this.sharing_api=new aZ(this.user)}ex.prototype.before_show=function(){var ey;this.sharing_api.loading_elem=this.$modal_window;ey=this.base_title;if(ck.get_viewer().is_paired){if(this.user.role==="personal"){ey=this.personal_title}else{ey=this.work_title.format({team_name:ck.get_viewer().team_name})}}return this.format({".db-modal-title-text":ey})};return ex})(dw);dO=A.ShareAFolderWizardModal=(function(T){cm(ex,T);function ex(ey,ez){this.user=ey;this.options=ez;ex.__super__.constructor.call(this,this.user,this.options);this.base_title=dW("Share a folder");this.personal_title=dW("Share a folder from your personal Dropbox");this.work_title=dW("Share a folder from your %(team_name)s Dropbox")}ex.prototype.on_show=function(){this.$modal_window.find("input#create-new-sf").prop("checked",true);this.$modal_window.find("a.back").on("click",(function(ey){return function(ez){ez.preventDefault();p.start_wizard_without_user();return ey.hide()}})(this));return this.$modal_window.find("#new-or-existing-sf li").on("click",(function(ey){return function(ez){bg(ez.currentTarget).find('input[name="sf_type"]').prop("checked",true);if(ey.$modal_window.find("input#create-new-sf").is(":checked")){return aQ.SharedFolderActivityLogger.log("web","new_or_existing_modal_new_folder",ey.user)}else{return aQ.SharedFolderActivityLogger.log("web","new_or_existing_modal_existing_folder",ey.user)}}})(this))};ex.prototype.on_confirm_button_click=function(eE){var eB,eD,ey,eA,eC,ez;eE.preventDefault();eD=this.$modal_window.find("input#create-new-sf").is(":checked");if(eD){eA=null;if(this.user.role==="work"){eC="shared-folder-type-wizard-modal";ez=dw.get_template(eC);if(ez.length){eA=new bs(this.user,{element_id:eC})}}if(eA===null){eA=new bP(this.user,{element_id:"share-new-folder-wizard-modal"})}this.hide();ey={selection:"new_folder"};aQ.SharedFolderActivityLogger.log("web","new_or_existing_modal_next_button",this.user,ey);return eA.show()}eB=this.$modal_window.find(".ajax-loading-indicator").show();return bg.ajax({url:"/share_ajax/account_has_existing_folders",type:"post",subject_user:this.user,success:(function(eF){return function(eG){var eH;eG=JSON.parse(eG);if(eG===true){eA=new cD(eF.user,{element_id:"share-existing-folder-wizard-modal"});ey.has_existing_folder=true}else{eH=dW("You don't have any existing folders. Please create and share a new folder.");eA=new bP(eF.user,{element_id:"share-new-folder-wizard-modal",error_msg:eH});ey.has_existing_folder=false}eF.hide();return eA.show()}})(this),error:(function(eF){return function(){return Y.error()}})(this),complete:(function(eF){return function(){return eB.hide()}})(this)},ey={selection:"existing_folder"},aQ.SharedFolderActivityLogger.log("web","new_or_existing_modal_next_button",this.user,ey))};return ex})(aL);bs=A.SharedFolderTypeWizardModal=(function(ex){cm(T,ex);function T(ey,ez){this.user=ey;this.options=ez;T.__super__.constructor.call(this,this.user,this.options);this.work_title=dW("Share a folder from your %(team_name)s Dropbox")}T.prototype.on_show=function(){this.$modal_window.find("input#team-folder-option").prop("checked",true);this.$modal_window.find("a.back").on("click",(function(ey){return function(ez){ez.preventDefault();p.start_wizard_for_user(ey.user);return ey.hide()}})(this));return this.$modal_window.find("#shared-folder-type li").on("click",(function(ey){return function(ez){bg(ez.currentTarget).find('input[name="shared_folder_type"]').prop("checked",true);if(ey.$modal_window.find("input#team-folder-option").is(":checked")){return aQ.SharedFolderActivityLogger.log("web","shared_folder_type_team_folder",ey.user)}else{return aQ.SharedFolderActivityLogger.log("web","shared_folder_type_shared_folder",ey.user)}}})(this))};T.prototype.on_confirm_button_click=function(eC){var ey,eA,eB,ez;eC.preventDefault();ey=(function(eD){return function(eG,eE){var eF;eG.preventDefault();eE.hide();eF=new eD.constructor(eD.user,eD.options);return eF.show()}})(this);eA=this.$modal_window.find("input#team-folder-option").is(":checked");if(eA){eB=new dk({element_id:"new-team-folder-modal",open_created_folder:true,back_fn:ey});ez="team_folder"}else{eB=new bP(this.user,{element_id:"share-new-folder-wizard-modal",back_fn:ey});ez="shared_folder"}aQ.SharedFolderActivityLogger.log("web","shared_folder_type_next_button",this.user,{selection:ez});this.hide();return eB.show()};return T})(aL);d4=A.InlineModalValidationError=(function(){function T(){}T.show_validation_error=function(eE,eA){var eB,eC,ez,ey,eD,ex;if(eE.responseText.indexOf("err:{")===0){ex=eE.responseText.substr(4);eD=JSON.parse(ex);for(eC in eD){eB=eD[eC];if("message_text" in eB){ey=eA.find("span.error-message");if(ey.length===0){ey=bg("").addClass("error-message");eA.prepend(ey)}ey.text(eB.message_text);return}}eA.find("span.error-message").remove();return Y.error()}else{eA.find("span.error-message").remove();if(eE.responseText.indexOf("err:")===0){ez=eE.responseText.substr(4);return Y.error(ez)}else{return Y.error()}}};return T})();cv=A.TeamSharedFolderWizardModalPage1=(function(T){cm(ex,T);function ex(ey,ez){this.user=ey;this.options=ez;this.__fix_position=cV(this.__fix_position,this);ex.__super__.constructor.apply(this,arguments);this.options.focus="#new-team-shared-folder-wizard-page1 input[type=text]";this.base_title=dW("Now, let's set up your team");this.options.vertical_offset=5}ex.prototype.on_show=function(){var ez,eB,ey,eA;eA=this.$modal_window.find(".suggestion-input");for(eB=0,ey=eA.length;eB0){this.inviter_restriction=ey.is(":checked")?"all":"me"}if(this.is_file){ez=new ee(this.user,{element_id:"confirm-share-new-file-wizard-modal",invitees:eD,msg:eC,access_type:eA,audience_restriction:this.audience_restriction,inviter_restriction:this.inviter_restriction,shared_link_policy_restriction:this.shared_link_policy_restriction,file_path:this.folder_name});this.hide();ez.show();return aQ.SharedFolderActivityLogger.log("web","single_file_unshared_invite_modal_continued",this.user,this.log_extras)}else{return this.share_folder(eD,eC,eA,true,false)}};T.prototype.share_folder=function(eD,eA,ey,eE,eC,ez){var eI,eB,eF,eH,eG;if(eE==null){eE=true}if(eC==null){eC=false}if(ez==null){ez=false}eB=(function(eJ){return function(eK){return d4.show_validation_error(eK,eJ.$modal_window.find(".tokenized_autocompleter_container"))}})(this);eH=(function(eJ){return function(eM){var eL,eK;eK=JSON.parse(eM.responseText);Y.success(eK.success_msg);if(eJ.progress_ever_blocked_by_verify){aQ.SharedFolderActivityLogger.log("web","email_verify_sharing_modal_share_succeess",eJ.user,eF)}document.fire(av.SF_NEW,{sf_info:bA.decode_sort_key(eK.sf_info)});if(eE){eJ.hide()}if(ez){eL=new cI(eJ.user,an.normalize(eJ.folder_name));return eL.show()}}})(this);if(this.must_check_verified&&!this.user.is_email_verified){this.progress_ever_blocked_by_verify=true;aQ.SharedFolderActivityLogger.log("web","email_verify_sharing_modal_blocked_on_verify",this.user,eF);this.$modal_window.find(".confirm-button").prop("disabled",true);eG=dW("Verification email sent to %(email)s").format({email:this.user.email});eI=ds.get_for_user(this.user);eI.send_email("share_folder",function(){return Y.success(eG)});bg("#resend-email-verification-link").click(function(){return eI.send_email("share_folder",function(){return Y.success(eG)})});this.$modal_window.find(".email-verify-message").show();return eI.ensure_polling((function(eJ){return function(){aQ.SharedFolderActivityLogger.log("web","email_verify_sharing_modal_unblocked",eJ.user,eF);Y.success(dW("Email verified. Try sharing your folder again."));eJ.$modal_window.find(".confirm-button").prop("disabled",false);return eJ.$modal_window.find(".email-verify-message").hide()}})(this))}else{this.sharing_api.share_folder(this.new_folder,this.folder_name,eD,eA,this.audience_restriction,this.inviter_restriction,this.shared_link_policy_restriction,ey,eC,eH,eB);eF={path:this.folder_name,access_type:ey};aQ.SharedFolderActivityLogger.log("web","invite_modal_share_folder_button",this.user,eF);return bg(document).trigger("db:invite_to_new_folder:share")}};T.prototype.insert_folder_settings=function(ez,ey,eB){var eA;this.audience_restriction=ez;this.inviter_restriction=ey;this.shared_link_policy_restriction=eB;eA=this.$modal_window.find(".invite-more-form, .external-invite-message,.folder-settings");if(this.audience_restriction==="team"){this.invite_form_controller.set_team_only(true);return eA.addClass("team-only")}else{this.invite_form_controller.set_team_only(false);return eA.removeClass("team-only")}};return T})(dw);ee=A.ConfirmShareNewFileWizardModal=(function(T){cm(ex,T);function ex(ey,ez){this.user=ey;this.options=ez;ex.__super__.constructor.call(this,this.options);this.file_path=this.options.file_path;this.file_name=an.filename(this.file_path);this.folder_name=an.filename_without_extension(this.file_name);this.folder_path=an.parent_dir(this.file_path)+"/"+this.folder_name;this.invitees=this.options.invitees;this.msg=this.options.msg;this.audience_restriction=this.options.audience_restriction;this.inviter_restriction=this.options.inviter_restriction;this.shared_link_policy_restriction=this.options.shared_link_policy_restriction;this.access_type=this.options.access_type;this.sharing_api=new aZ(this.user);this.log_extras={path:this.file_path}}ex.prototype.before_show=function(){this.format({".confirm-share-file-invitees":this.format_invitees(),".confirm-share-file-name":this.file_name,".confirm-share-folder-name":this.folder_name});return aQ.SharedFolderActivityLogger.log("web","single_file_unshared_info_modal_displayed",this.user,this.log_extras)};ex.prototype.on_confirm_button_click=function(eA){var ez,ey;ez=(function(eB){return function(eE){var eC,eD,eF;aQ.SharedFolderActivityLogger.log("web","single_file_unshared_sharing_failed",eB.user,eB.log_extras);eF=bR.extract_errors(eE.responseText);if(eF===false){return}else{if(typeof eF==="string"){Y.error(eF)}else{if(typeof eF==="object"){for(eD in eF){eC=eF[eD];if("message_text" in eC){Y.error(eC.message_text);break}}}}}return eB.hide()}})(this);ey=(function(eB){return function(){var eC;aQ.SharedFolderActivityLogger.log("web","single_file_unshared_sharing_succeeded",eB.user,eB.log_extras);eC=dW("%(folder_name)s was shared successfully.").format({folder_name:eB.folder_name});Y.success(eC);return eB.hide()}})(this);this.sharing_api.share_file(this.folder_path,this.file_path,this.invitees,this.msg,this.audience_restriction,this.inviter_restriction,this.shared_link_policy_restriction,this.access_type,ey,ez);return aQ.SharedFolderActivityLogger.log("web","single_file_unshared_info_modal_confirmed",this.user,this.log_extras)};ex.prototype.format_invitees=function(){var eD,eC,eA,ez,ey,eB;if(!this.invitees){return dW("others")}eD=this.invitees.emails[0];eC=this.invitees.fb_ids[0];eA=this.invitees.group_ids[0];ez=this.invitees.new_style_group_ids[0];if(!eD.length){return dW("others")}ey=eD[0];eB=eD.length+eC.length+eA.length+ez.length;if(eB>1){ey=ey+dW(" and others")}return ey};return ex})(dw);dv=A.ConfirmShareExistingFileWizardModal=(function(ex){cm(T,ex);function T(ey,ez){this.user=ey;this.options=ez;T.__super__.constructor.call(this,this.options);this.folder_name=this.options.folder_name;this.folder_path=this.options.folder_path;this.log_extras={path:this.folder_name}}T.prototype.before_show=function(){this.format({".confirm-share-existing-folder-name":this.folder_name});return aQ.SharedFolderActivityLogger.log("web","single_file_shared_info_modal_displayed",this.user,this.log_extras)};T.prototype.on_confirm_button_click=function(ez){var ey;aQ.SharedFolderActivityLogger.log("web","single_file_shared_info_modal_confirmed",this.user,this.log_extras);ey=new cI(this.user,this.folder_path);this.hide();return ey.show()};return T})(dw);b9=A.NewSharedFolderPermissionsContent=(function(){T.SAVED_PERMISSIONS="new_sf_permissions:saved";function T(ex){this.$form=ex;this._submit=cV(this._submit,this);this._listen()}T.prototype._listen=function(){this.$form.find(".confirm-button").click(this._submit);return this.$form.find(".cancel-button").click(this._cancel)};T.prototype._cancel=function(){return dp.pop()};T.prototype._submit=function(eA){var ey,ez,ex;eA.preventDefault();ey=this.$form.find("input[name=audience]:checked").val();ez=this.$form.find("input[name=inviter]:checked").val();ex=this.$form.find("input[name=shared_link_policy]:checked").val();dp.trigger(T.SAVED_PERMISSIONS,{audience:ey,inviter:ez,shared_link_policy:ex});return dp.pop()};return T})();var cW;cW=A.SharingShmodel=(function(){function T(){}T.shmodel=function(ey,ex){return new cJ(b3.active_user.id,ey,ex).show()};return T})();var bA;bA=INLINE_JS.Sharing=A.Sharing={init:function(eB,eA,ex,ez,ey,T){this.is_merged=eA;[eB.current,eB.past].each((function(eC){return function(eD){return eD.each(function(eE){return eC.decode_sort_key(eE)})}})(this));this._state={sf_info:eB,cmp:{"#sf-current":this._modified_cmp,"#sf-past":this._modified_cmp},is_ascending:{"#sf-current":false,"#sf-past":false},inbox_counts:{}};if(eA){this.role_picker=bg("#role-selector").controller();this.role_picker.on_state_change=this._render.bind(this);bp.set_during_login_callback((function(eC){return function(eE,eD){c3.set_not_logged_in_role_and_email(null,null);return eC._reload_folder_info(function(){return eD()},function(eF){eD(dW("Error displaying shared folders"));return window.location.reload()})}})(this))}c3.set_is_merged(eA);c3.set_not_logged_in_role_and_email(ex,ez);c3.set_team_name(ey);c3.set_show_inbox(T);this._listen();this._tmpl=eu.tmpl("sf_list_item_tmpl");this._render();this.refresh_inbox_counts(true);return bg("#sf-view").show()},is_share_page:function(){return this._state!=null},decode_sort_key:function(T){cj((T.encoded_sort_key!=null)&&(T.sort_key==null),"expected encoded sort keys on each elm");T.sort_key=du.decode_sort_key(T.encoded_sort_key);delete T.encoded_sort_key;return T},reload_folder_info_if_two_account:function(){if(this._showing_two_accounts()){return this._reload_folder_info()}},_reload_folder_info:function(ey,T){var ex;if(!this.is_share_page()){return}ex=(function(ez){return function(eA){var eB;eB=JSON.parse(eA.responseText);ez._state.sf_info=eB;ez._render();return typeof ey==="function"?ey():void 0}})(this);return new b1().get_folder_info(ex,T)},refresh_inbox_counts:function(T){return new b1().get_inbox_counts((function(ex){return function(ey){return ex._update_inbox_counts(ey,T)}})(this))},_update_inbox_counts:function(ex,eA){var eD,ey,T,eC,eB,ez;ez=0;for(eC in ex){eD=ex[eC];ez+=eD}bg("#inbox-count").text(ez);bg("#inbox-count").toggleClass("show",ez>0);if(!this.is_share_page()){return}ey=function(eF,eE){var eG;for(eC in eF){eG=eF[eC];if(eE[eC]!==eF[eC]){return false}}return true};if((!eA)&&this._state&&ey(this._state.inbox_counts,ex)){return}this._state.inbox_counts=ex;if(ez){T=new Element("a",{id:"new-invites-link",href:"#"});T.__sert(b7.make("web","email_32",{"class":"link-img"}));eB=aR("%(total_count)d new shared folder invitation","%(total_count)d new shared folder invitations",ez);eB+=" \n";eB=eB.format({total_count:ez});T.__sert(eB);T.observe("click",(function(eE){return function(eF){Event.stop(eF);return eE.show_invites()}})(this));$("invites-box").show();$("invites-box").__date(T)}else{$("invites-box").hide()}if(ez>0&&c3.show_inbox){c3.set_show_inbox(false);return this.show_invites()}},register_accept:function(T){bg(T).closest(".sf-invite-action").addClass("loading");new ba(bg(T),T.action,{data:bt.collect_form_vars(T),complete:(function(ex){return function(ez,ey){bg(T).closest(".sf-invite-action").removeClass("loading");ex.refresh_inbox_counts();return ex._reload_folder_info()}})(this),success:(function(ex){return function(eC,ey,eE){var ez,eB,eD,eA;eC=(eA=JSON.parse(eE.responseText))!=null?eA.data:void 0;ez=bg(T).closest(".sf-invite-action");ez.addClass("sf-accepted");if(eC!=null?eC.redirect:void 0){eB=ez.find(".view-folder-button");return eB.click(function(){return window.location.href=eC!=null?eC.redirect:void 0})}else{eD=bg(T).closest(".invitation-row").attr("data-invite-id");return ex._remove_invite_row(eD)}}})(this)});return false},register_decline:function(ex,ez){var T,ey;T=bg(ex).closest("form");if((ey=T.closest(".sf-invite-action"))!=null){ey.addClass("loading")}if(T.length){new ba(T,T[0].action,{data:bt.collect_form_vars(T[0]),complete:(function(eA){return function(eD,eC){var eB;if((eB=T.closest(".sf-invite-action"))!=null){eB.removeClass("loading")}eA._remove_invite_row(ez);eA.refresh_inbox_counts();return eA._reload_folder_info()}})(this)})}return false},_remove_invite_row:function(eA){var T,ez,ey,ex;T=bg("#invites-container");ez=T.find('[data-invite-id="'+eA+'"]');if(ez){ex=ez.parent("tbody");ez.remove();if(ex.children().length===0){T.find(".invitation-table-container").hide();T.find(".message-bottom").removeClass("message-bottom");T.find(".message-top").removeClass("message-top");if(T.find(".invites-message").length===0){ey=dw.get_containing_modal(T);return ey!=null?ey.hide():void 0}}}},_listen:function(){var ey,ex,T;this.listen_modals();ey=(function(ez){return function(eB,eJ,eE){var eF,eA,eI,eH,eG,eL,eC,eK,eD;eD=ez._get_current_sf_list_info(eE),eH=eD[0],eI=eD[1];cj(eJ,"SF _transfer w/o target_ns_id");for(eF=eC=0,eK=eH.length;eC1){return true}}}return false},contact_importer_show:function(){var ey,ex,T,ez;ey=this.get_entry_container();if(((ex=ey.firstChild)!=null?(T=ex.firstChild)!=null?T.value:void 0:void 0)>0){this.old_display=ey.style.display}else{this.old_contents="
    ";this.old_display="none"}this.contact_importer_render_buttons();if((ez=$("flash_copy_container"))!=null){ez.hide()}return this.element.focus()},contact_importer_unshow:function(){var T;this.hasFocus=true;this.changed=false;this.updateChoices(this.old_contents);this.get_entry_container().style.display=this.old_display;return(T=$("flash_copy_container"))!=null?T.show():void 0},contact_importer_render_buttons:function(){var T;T=this.get_contact_importer_button_list();this.hasFocus=true;return this.updateChoices("
      "+(T.join(""))+"
    ")},get_contact_importer_button_list:function(){var eA,ex,ez,T,ey;ex=[];ey=aH.contact_services();for(ez=0,T=ey.length;ez1){T=this.options.tokens[0]+" "}else{T=""}ex.innerHTML+=T;this.active=false;this.updateElement(ex);return bg(this.element).trigger("db:autocompleted")}},a5=function(T,ex){var ey;ey=bg("
    ");ey.addClass(T);if(typeof ex==="string"||ex instanceof String){ey.text(ex)}else{ey.append(ex)}return ey},{setOptions:function(ex){var T;if(ex==null){ex={}}T={choices:5,selector:(function(ey){return function(){var eD,eZ,eY,eT,fo,eP,eS,e9,eG,eH,fr,eK,e7,fq,eA,fm,e2,eV,eR,e8,e6,eO,fi,eE,e5,fp,e3,fb,e4,fa,fg,ez,ff,fn,eN,eW,eB,fd,e1,fe,eC,eX,e0,eM,eF,fl,fk,fj,fh,eU,eL,eJ,eI,fc,eQ;e1=bg("
      ");e7=ey.getToken().toLowerCase();fi=ey.options.array.length;fo=ey.options.choices;eS=ey.options.array;fb=ey.options.larray;fd=[];if(e7.indexOf(" ")===-1){fd.push("\\s+")}if(e7.indexOf("+")===-1){fd.push("\\+")}if(e7.indexOf("@")===-1){fd.push("@")}if(e7.indexOf(".")===-1){fd.push("\\.")}if(e7.indexOf("<")===-1){fd.push("<")}eB=RegExp("("+fd.join("|")+")");e8=0;while(e8").css("border-color",eZ).css("color",eZ).text(eY)}break;case P.CAROUSEL_ROOM:eK.push("",eP.name);eX=e3.name;fc=eP.members;for(fl=0,eU=fc.length;fl").text(eK[eO].substr(fm,e7.length));fe=document.createTextNode(eK[eO].substr(fm+e7.length));eK[eO]=[eE,ez,fe];break}}if(eP.type===P.FB){eK.push(dW("Facebook message"))}if(fm!==-1){if(eR){eV=bg('').attr("src",eR)}else{if(e2){eV=e2}}eN=a5("autocomplete-line",eK[0]);e0=a5("autocomplete-line autocomplete-secondary",eK[1]);e5=a5("autocomplete-left",eV);eC=a5(null,[eN,e0]);fp=bg("
    • ").attr("value",e8).append(e5,eC);e1.append(fp)}e8++}if(!bg(ey.element).hasClass("no-contacts-importer")){if(ey.contacts_importer.has_unconnected_services()){e6=dW("Import contacts");eH=null;eM=false;e9=bg(ey.element).closest(".tokenized_autocompleter_container");fq=e9.data("exp-rule");eA=e9.data("exp-variant");eW=e9.attr("data-exp-data");if(fq==="import-contacts-text-experiment"&&(eA==="SELECT_PROVIDER"||eA==="SELECT_PROVIDER_POP"||eA==="SELECT_PROVIDER_POP_LONG")){if(eA==="SELECT_PROVIDER_POP_LONG"){e6=eW===aH.GOOGLE?dW("Select from your Gmail contacts"):eW===aH.YAHOO?dW("Select from your Yahoo contacts"):dW("Select from your contacts")}else{e6=eW===aH.GOOGLE?dW("Select from Gmail"):eW===aH.YAHOO?dW("Select from Yahoo contacts"):dW("Select from contacts")}if(eA==="SELECT_PROVIDER_POP"||eA==="SELECT_PROVIDER_POP_LONG"){if((eW===aH.GOOGLE||eW===aH.YAHOO)&&!ey.contacts_importer.connected_services[eW]){eH=e6;e6=null}else{eF=true}if(eF){if(ey.contacts_importer.has_connected_services()){eH=null;e6=dW("Import Contacts")}else{e6=eH=null;eM=true}}}}if(eH){fr=ey._autocompleter_contact_import_item_tmpl({email_provider_num:eW,email_provider_img:aH.to_img(eW),email_provider_name:eH,bottom_text:"",is_suggestion:0}).toHTML();e1.append(fr)}if(e6){eV=b7.make("web","user_add");eN=a5("autocomplete-line autocomplete-line-center",e6);e5=a5("autocomplete-left",eV);eC=a5(null,[eN]);fp=bg("
    • ").addClass("contacts-importer").append(e5,eC);e1.append(fp)}if(eM){eQ=ey.get_contact_importer_button_list();for(fh=0,eI=eQ.length;fh").parent().html();ey.old_contents=eD;return eD}})(this)};return this.options=Object.extend(T,ex)}});var cl;cl=A.Token=Class.create({initialize:function(ex,T,ey,ez){this.element=$(ex);this.token_manager=ey;this.hidden_input=T;this.element.token=this;this.selected=false;this.info=ez;return bg(this.element).closest(".tokenized_autocompleter_container").click(this.onclick.bindAsEventListener(this))},select:function(){var T;this.token_manager.token=this;if((T=this.hidden_input)!=null){T.element.activate()}this.selected=true;return this.element.addClassName("token_selected")},deselect:function(){if(this.token_manager.token===this){this.token_manager.token=null}this.selected=false;return this.element.removeClassName("token_selected")},onclick:function(T){if(T&&T.preventDefault){T.preventDefault()}if(this.detect(T)&&!this.selected){return this.select()}else{return this.deselect()}},remove:function(T){return this.token_manager.remove(this)},detect:function(ez){var ex,ey,T;ey=ez.target?ez.target:ez.srcElement;T=ey.token;ex=ey;while((T==null)&&ex.parentNode){ex=ex.parentNode;T=ex.token}return(T!=null)&&T.element===this.element}});var K;K=A.TokenManager=Class.create({initialize:function(ex,ey,T){this.shift_boundary_right_func=ey;this.shift_boundary_left_func=T;this.element=ex;this.tokens=[];return this.token=null},add:function(T){this.tokens.push(T);return this.element.fire("token:add",T.info)},populate:function(){var eC,ey,eA,ez,eB,ex,T;ez=this.element.select(".token");T=[];for(eB=0,ex=ez.length;eB0){if(this.token){this.token.deselect()}return this.tokens[T-1].select()}else{if(this.shift_boundary_left_func!=null){return this.shift_boundary_left_func()}}},shift_right:function(){var T;T=this.tokens.indexOf(this.token);if(this.token){this.token.deselect()}if(T+1=0){ex=false;eA="Already member"}else{if(bl.call(this.invitees,ey)>=0){ex=false;eA="Already invited"}else{if(T===P.NEW_STYLE_GROUP){if(bl.call(this.new_style_groups,ey)>=0){ex=false;eA="Already member group"}else{ex=true;eA="Group"}}}}}if(ey===this.user.email||ey===this.user.id){eA="You";ex=!this.contacts_only}if(!ez&&ey){ez=ey.toString()}return{display:ez,value:ey,type:T,valid:ex,bubble_title:eA}},COMPOUND_EMAIL_REGEX:/([^<>]+)<([^@>]+@[^@>]+)>/,parse_compound_email:function(ex){var T,ey;T=ex.match(this.COMPOUND_EMAIL_REGEX);if(T){ey=this.createTokenInfo(T[0],T[2],P.EMAIL);return ey}return null},tokenize_emails_input:function(eF,eA){var eK,eE,eB,eJ,ey,eL,eI,eH,eC,eP,eD,ez,ex,T,eM,eO,eN,eG;eE=this.options.tokens;eH=this.get_regexp_from_delimiters(eE);if(this.options.single_token){eJ=[this.element.value]}else{eJ=this.element.value.split(eH)}eP="";if(!eF){eP=eJ[eJ.length-1];eI=this.clean_email_addr(eE,eP);eJ=eJ.slice(0,eJ.length-1);if((eG=eP[eP.length-1])===" "||eG===">"){if(eI.match(this.COMPOUND_EMAIL_REGEX)||du.validate_email(eI)){eJ.push(eI);eP=""}}}eK=false;eD=[];if(eJ.length>0){for(ez=0,eM=eJ.length;ez0){for(T=0,eN=eJ.length;T=this.max_textbox_height){eH.setStyle({"overflow-y":"auto"})}else{eH.setStyle({"overflow-y":"hidden"})}}eP=eF;eI=bg(".tokenizer-link",eH.parentNode);if(eI.length>0){eP-=eI.width()}eG=this.token_manager.tokens;eD=false;eK=0;for(ey=0,eN=eG.length;eyeF){eK=eC;eD=true}else{if(eC>eF){eK=0;eD=true}else{eK=eL}}}eJ=eP-eK;eM=this.element.value.length*7;if(eM>eJ){eJ=eF}this.set_input_size(eJ);if(this.import_links.length&&this.import_links_visible){if(eD||eF-eK-eM<1.25*this.import_links_width){this.import_links_visible=false;eE=this.import_links;ex=[];for(T=0,eO=eE.length;T=0),"The 'id-value' of an autocompleter-entry is not a valid Third Party contact import service");ez=aH.to_name(eB);if(this.contacts_importer.connected_services[eB]){Y.success(dW("You're already connected to %(service_name)s").format({service_name:ez}));return}if(bl.call(aH.contact_services(),eB)>=0){if(bg(ex).attr("suggestion")==="1"){return this.contacts_importer.auth_import(eB,"suggestion")}else{return this.contacts_importer.auth_import(eB)}}else{return cj(false,"Should never get here. entry_value: "+eB)}}else{ey=this.options.array[ex.value];T=ey.type===P.FB?ey.fb_id:ey.type===P.USER_GROUP?ey.group_id:ey.type===P.NEW_STYLE_GROUP?ey.group_id:ey.type===P.CAROUSEL_ROOM?ey.members:ey.email;this.set_input_size(1);eA=this.createTokenInfo(ey.name.strip(),T,ey.type);this.addContact(eA);bt.clear_errors(this.element.up("form"));this.dynamically_resize_input();this.index=0;return this.element.focus()}}},addContact:function(eG){var eQ,eL,eR,eH,eT,eD,eO,ex,eI,eM,eS,eW,ey,eE,eK,eN,eF,eP,eA,ez,T,eU,eX,eV,eJ,eC,eB;if(eG.type===P.CAROUSEL_ROOM&&!eG.processed){eJ=eG.value;for(eA=0,eU=eJ.length;eA").addClass(eM);eK.on("click",function(eY){this.parentNode.parentNode.parentNode.parentNode.parentNode.token.remove(eY);return false});eW=new Element("input",{type:"hidden",name:eO,value:eG.value.toString()});eI=new Element("a",{"class":"title_bubble token "+eM,href:"#",tabindex:"-1",title:eG.bubble_title});eD=new Element("span");if(this.options.wrap_name){ey=new Element("div",{"class":"token-display-text"});ey.__sert(eG.display);eS=ey;eL=1}else{eS=eG.display;eL=0}eC=[eW,eT,eS];for(T=0,eV=eC.length;T=0){ex=false;eC="Already member"}else{if(bl.call(this.invitees,ey)>=0){ex=false;eC="Already invited"}else{if(T===P.EMAIL&&!this.team_contacts[ey]){ex=this.warn_only;eB=true}else{if(T===P.FB){ex=this.warn_only;eB=true}else{if(T===P.NEW_STYLE_GROUP){if(bl.call(this.new_style_groups,ey)>=0){ex=false;eC="Already member group"}else{ex=true;eC="Group"}}}}}}}if(ey===this.user.email||ey===this.user.id){eC="You";ex=!this.contacts_only}if(!eA&&ey){eA=ey.toString()}return ez={display:eA,value:ey,type:T,valid:ex,external:eB,bubble_title:eC}},getTokenClass:function(T){if(!T.valid){return"token-error"}if(T.external){return"token-warn"}return"token-valid"},notifyExternal:function(ex){var T,ey,ez;ez=ex.memo;if(ez.external){ey=this.token_manager.tokens.filter(function(eA){return eA.info.external});T=ey?ey.length:0;return this.element.fire("sf:token:external",{count:T})}}});var i;i=A.TeamSharedFolderInviteController=(function(){function T(ex){var ey;this.element=$(ex[0]);ey=this.element.down(".new-collab-input");ey.observe("sf:token:external",this.handle_external.bind(this))}T.prototype.handle_external=function(ey){var ex,ez;ex=ey.memo.count;ez=this.element.down(".external-invite-message");if(ex>1){cT.fillVal(ex,"external-invite-num");if(ez!=null){ez.removeClassName("single")}return ez!=null?ez.show():void 0}else{if(ex===1){if(ez!=null){ez.addClassName("single")}return ez!=null?ez.show():void 0}else{return ez!=null?ez.hide():void 0}}};return T})();var ad;ad=INLINE_JS.SharingModel=A.SharingModel={ALBUM_THUMB_SIZE:260,ALBUM_PADDING:40,THUMBS_BATCH_SIZE:12,filename:null,c2d_vars:{},is_folder:false,is_album:false,gallery_enabled:false,gallery_showing:false,send_link_autocompleter:null,team_only_shmodel:false,owner_name:null,init:function(ex,T,ey){this.filename=ex;this.c2d_vars=T;this.c2d_url=ey!=null?ey:"/sm/c2d";this.init_logger();return on_script_loaded((function(ez){return function(){var eB,eH,eI,eG,eF,eE,eD,eC,eA;eH=$("login-create-an-account");if(eH){eH.writeAttribute("href","/register?signup_tag=shmodel")}scrollTo(1,0);scrollTo(0,0);if((eG=bg("#c2d-register-form"))!=null){eG.on("submit",ez.c2d_register.bind(ez))}if((eF=bg("#c2d-login-form"))!=null){eF.on("submit",ez.c2d_login.bind(ez))}if((eE=bg("#c2d-twofactor-login-form"))!=null){eE.on("submit",ez.c2d_twofactor_login.bind(ez))}if((eD=bg("#download_button_link[data-dl-link]"))!=null){eD.on("click",ez.download_zip)}ez.set_viewport_size();eB=function(eK,eJ){return ez.do_c2d(eJ.id)};bg("#c2d-modal .login-form").on((eC=__CONDITIONAL_JS__.LoginForm)!=null?eC.LOGIN_SUCCESS:void 0,eB);bg("#c2d-modal .register-form").on((eA=__CIRCULAR_DEPENDENCY__.RegisterForm)!=null?eA.REGISTER_SUCCESS:void 0,eB);eI=C.parse(window.location.href);if(eI.getQuery()["force_dl"]){eI.updateQuery({force_dl:0,dl:1});return window.location=eI.toString()}}})(this))},init_folder:function(T,ey,ex){this.gallery_enabled=T;this.gallery_showing=ey;this.is_folder=true;this.init_lightbox(ex);return on_script_loaded((function(ez){return function(){return ez.load_thumbs()}})(this))},init_album:function(){this.is_album=true;this._resize_album_view();return Event.observe(window,"resize",this._resize_album_view.bind(this))},init_file:function(){this.is_folder=false;if(!this.c2d_vars.subpath&&(this.c2d_vars.item_id==null)&&!this.c2d_vars.is_package){return this.c2d_vars.subpath="/"+this.filename}},get_thumbnail_for_file:function(ex){var ey,T;T=ex.icon.split("_");T.pop();ey=T.join("_");return"/static/images/icons128/"+ey+".png"},init_logger:function(){on_script_loaded((function(T){return function(){var ey,ex;ey=$("login-hover-link");if(ey){ey.observe("click",function(){return aA.log(aA.CLICK_SIGN_IN)});ey.observe("click",function(){return c8.log("click_sign_in")})}if($("download_button_link")){aA.attachLogListener(aA.CLICK_DOWNLOAD,$("download_button_link"))}ey=$("add_to_my_dropbox_link");if(ey){aA.attachLogListener(aA.CLICK_ADD_TO_MY_DROPBOX,ey);c8.attachLogListener("click_add_to_my_dropbox",ey)}if($$(".remove-link").length){aA.attachLogListener(aA.REMOVE_LINK,$$(".remove-link")[0])}if($$(".shmodel-filename").length){aA.attachLogListener(aA.CLICK_FILENAME,$$(".shmodel-filename")[0])}ey=$("default_content_download_button");if(ey){aA.attachLogListener(aA.CLICK_DOWNLOAD,ey)}ey=$("default_content_a2md");if(ey){aA.attachLogListener(aA.CLICK_ADD_TO_MY_DROPBOX,ey)}ey=bg("#login-create-an-account")[0];aA.attachLogListener(aA.CLICK_SIGNUP_THRU_DEFAULT_DROPDOWN,ey);ey=bg("#login-hover-cont .login-form")[0];aA.attachLogListener(aA.LOGIN_THRU_DEFAULT_DROPDOWN,ey);return(ex=bg("#share-button"))!=null?ex.click(function(ez){return aA.log(aA.CLICK_SHARE)}):void 0}})(this));return document.observe(ax.ACTIONS_ADDED,(function(T){return function(){var eA,ez,ex,ey;ey=$("view_original");if(ey){aA.attachLogListener("shmodel_lightbox_click_vieworiginal",ey)}ez=$("lightbox_share_link");if(ez){aA.attachLogListener("shmodel_lightbox_click_getlink",ez)}ex=bg("lightbox-share-link");if(ex[0]){aA.attachLogListener("shmodel_lightbox_click_getlink",ex[0])}eA=$("lightbox_download_link");if(eA){return aA.attachLogListener("shmodel_lightbox_click_download",eA)}}})(this))},set_team_only_shmodel:function(ex,T){this.team_only_shmodel=ex;return this.owner_name=T},_resize_album_view:function(){var T;T=Math.floor((y.viewport_dimensions().width-2*this.ALBUM_PADDING)/this.ALBUM_THUMB_SIZE)*this.ALBUM_THUMB_SIZE;return $("content-wrapper").setStyle({display:"block",width:""+T+"px"})},init_lightbox:function(T){return ax.init_from_preview_objs(T,"#gallery-view-media li")},load_thumbs:function(){var ex,T;T=this.gallery_showing?$$(".gallery-icon-view img"):$$(".browse-files .icon");ex=function(ey){if(!ey.src.endsWith(b7.SPACER)){return ey.addClassName("thumbnail")}};return a6.batch_load_thumbs(T,this.THUMBS_BATCH_SIZE,ex)},switch_mode:function(eC){var ey,eD,eB,T,eA,ex,ez;ez=$A(["gallery","list"]);for(eA=0,ex=ez.length;eA%(owner)s. Once the link is removed, no one else will be able to view this folder.

      We\'ll notify %(owner_email)s. Do you want to continue?')}else{eA=dW('You are removing the link to "%(fname)s" created by %(owner)s. Once the link is removed, no one else will be able to view this file.

      We\'ll notify %(owner_email)s. Do you want to continue?')}eA=eA.format({fname:bu.em_snippet(ex,17),owner:eF,owner_email:eD})}else{eE=dW("Remove link to '%(name)s'").format({name:bu.em_snippet(ex,17)});if(ez){eA=dW("Are you sure you want to remove this link? Once the link is removed, nobody else will be able to view this folder.")}else{eA=dW("Are you sure you want to remove this link? Once the link is removed, nobody else will be able to view this file.")}}ey=bg("#disable-token-modal")[0];cT.fillVal(eA,"disable-token-desc")}return{title:eE,contents:ey}},confirm_remove:function(ex,eB,ey,T,ez,eF,eC,eE,eD){var eA;if(ey==null){ey=false}if(T==null){T=false}if(ez==null){ez=false}if(eF==null){eF=null}if(eC==null){eC=false}if(eE==null){eE=null}if(eD==null){eD=null}cj(eB,"confirm_remove missing tkey");cj(ex,"confirm_remove missing name");cj(eF,"confirm_remove missing user_id");cj(!eC||!T,"admin removal of collections not supported");cj(!eC||eE,"missing link owner name for admin removal");cj(!eC||eD,"missing link owner email for admin removal");if(!ck.get_viewer().is_uid_signed_in(eF)){bp.show_modal({user_id:eF,on_success:(function(eG){return function(){return eG.confirm_remove(ex,eB,ey,T,ez,eF,eC,eE,eD)}})(this)});return}eA=ad.prepare_confirm_remove_modal(ex,ey,T,ez,eF,eC,eE,eD);return er.show(eA.title,eA.contents,{token:eB,name:ex,is_album:T,user_id:eF})},confirm_remove_from_event_gid:function(T,eE,ey,eD,eA,eC,eB,ex){var ez;if(eA==null){eA=false}if(eC==null){eC=null}if(eB==null){eB=null}if(ex==null){ex=null}cj(eE,"confirm_remove missing event gid");cj(T,"confirm_remove missing name");cj(eD,"confirm_remove missing user_id");cj(ck.get_viewer().is_uid_signed_in(eD),"user not logged in");cj(!eA||eC,"missing link owner name for admin removal");cj(!eA||eB,"missing link owner email for admin removal");ez=ad.prepare_confirm_remove_modal(T,ey,false,false,eD,eA,eC,eB);return er.show(ez.title,ez.contents,{name:T,user_id:eD,activity_log_event_gid_dbase64:eE,redirect_to_member_id:ex})},do_remove:function(ez){var T,ey,ex;cj(ez.token||ez.activity_log_event_gid_dbase64,"missing token or event gid_dbase64");T=bg("#modal-content input").first();T.attr("disabled",true);bg("#modal-content").addClass("ajax-loading");ex=window.location.pathname;if((ex==="/links"||ex==="/links/your_links")||ex.match("^/home|^/work|^/personal")){return new Ajax.DBRequest("/sm/disable/"+ez.token,{subject_user:ez.user_id,onSuccess:(function(eA){return function(){var eB;er.hide();if(ez.is_album){eB=dW("Unshared '%(name)s'")}else{eB=dW("Removed link for '%(name)s'")}eB=eB.format({name:ez.name});Y.success(eB);return document.fire(av.LINKS_REMOVE,{token:ez.token})}})(this),onComplete:(function(eA){return function(){T.attr("disabled",false);return bg("#modal-content").removeClass("ajax-loading")}})(this)})}else{if(ez.token){ey=C({path:"/sm/disable/"+ez.token})}else{ey=C({path:"/sm/disable_by_event_gid/"+ez.activity_log_event_gid_dbase64});ey.updateQuery("redirect_to_member_id",ez.redirect_to_member_id).toString()}return bt.postRequest(ey.updateQuery(Constants.UID_PARAM_NAME,ez.user_id).toString())}},show_shmodal_onload:function(ey,ez,ex,T){if(T==null){T=null}return bg((function(eA){return function(){dZ.remove_query_param("m");if(!ck.get_viewer().is_uid_signed_in(T)){bp.show_modal({user_id:T,on_success:function(){return eA.show_shmodal_onload(ey,ez,ex,T)}});return}if((T!=null)&&ds.get_for_user(ck.get_viewer().get_user_by_id(T)).verified_or_show()){return eA.show_shmodal(ey,ez,ex,T)}else{if(T==null){cj(ck.get_viewer().is_paired,"Expected viewer to be paired.");return eA.show_share_shmodel_role_chooser(ey,ez,ex)}}}})(this))},show_shmodal:function(ex,eD,T,eJ){var eI,eF,eH,eE,eB,eC,ez,ey,eG,eA;this.url=ex;this.short_url=eD;if(!ck.get_viewer().is_uid_signed_in(eJ)){bp.show_modal({user_id:eJ,on_success:(function(eK){return function(){return eK.show_shmodal(ex,eD,T,eJ)}})(this)});return}ez=ck.get_viewer().get_user_by_id(eJ);if(ds.get_for_user(ez).verified_or_show()){eC="shmodal-user-"+eJ;er.show(this._get_shmodal_title(ez.is_team),cT.fromElm($(eC)));eB={};eB[Constants.UID_PARAM_NAME]=eJ;bt.add_vars("shmodal-send-form",eB);if(this._get_thumbnail_type()){eA=$$(".shmodal-image");for(ey=0,eG=eA.length;ey140){Y.error(dW("Your post must be 140 characters or less"));return}}cd.custom_show_posting=function(){$("twitter-chars").hide();return bt.add_loading($("shmodal-twitter-post-submit"))};return cd.custom_post(ex,(function(ey){return function(){er.hide();Y.success(dW("Successfully posted to Twitter"));aA.log("shmodal_tweet");return aQ.ViralLogger.log(ck.get_viewer().get_user_ids(),"shmodel","send",{src:"shmodel_twitter",file_type:ad.is_album?"collection":ad.is_folder?"folder":ad.filename.indexOf(".")===-1?"file":cp.EXTENSION_TO_CATEGORY[an.file_extension(ad.filename).toLowerCase()]||"file"})}})(this),T)},_get_shmodal_title:function(T){if(T==null){T=false}return this.generate_title_content(this._get_shmodal_title_text(),((function(ex){return function(){return ex.show_send_content()}})(this)),((function(ex){return function(){return ex.show_fb_content()}})(this)),((function(ex){return function(){return ex.show_twitter_content()}})(this)),T)},generate_title_content:function(ex,eE,eB,eG,ez){var eA,eC,T,eF,ey,eD;if(ez==null){ez=false}eF=bg("
      ",{id:"shmodal-title"});ey=bg("
      ",{id:"shmodal-title-text",text:ex});eF.append(ey);if(!ez){T=bg("",{id:"shmodal-send-toggle","class":"freshtoggle ft-left toggled"});T.html(b7.make("web","email_20"));T.on("click",eE);eC=bg("",{id:"shmodal-fb-toggle","class":"freshtoggle ft-middle"});eC.html(b7.make("web","fb_20"));eC.on("click",eB);eD=bg("",{id:"shmodal-twitter-toggle","class":"freshtoggle ft-right"});eD.html(b7.make("web","twitter_20"));eD.on("click",eG);eF.append([T,eC,eD])}eA=bg("
      ",{"class":"clear"});eF.append(eA);return eF[0]},_get_shmodal_title_text:function(){var ex,T;if(this.is_folder){ex=dW("Share link to \u2018%(folder_name)s\u2019");return ex=ex.format({folder_name:bu.em_snippet(this.filename,15)})}else{T=this._get_thumbnail_type();if(T===cp.CATEGORY_TO_TRANSLATION.IMAGE){return dW("Share this image")}else{if(T===cp.CATEGORY_TO_TRANSLATION.VIDEO){return dW("Share this video")}else{return dW("Share '%(filename)s'").format({filename:bu.em_snippet(this.filename,18)})}}}},_get_thumbnail_type:function(){var ex,T;if(this.filename.indexOf(".")===-1){return false}T=an.file_extension(this.filename).toLowerCase();ex=cp.EXTENSION_TO_CATEGORY[T];if(ex&&(ex==="IMAGE"||ex==="VIDEO")){return cp.CATEGORY_TO_TRANSLATION[ex]}return false},_populate_twitter_info:function(ey,T){var ez,ex;ez=this.is_folder?dW("Just shared some files using @Dropbox"):(ex=this._get_thumbnail_type(),ex&&ex===cp.CATEGORY_TO_TRANSLATION.IMAGE?dW("Just shared an image using @Dropbox"):dW("Just shared a file using @Dropbox"));$("shmodal-twitter-post-input").setValue(ez+" "+ey);du._track_twitter_chars_left("shmodal-twitter-post-input",140);if(cd.is_authed(T)){return cd.get_user_info(function(eA){$("shmodal-twitter-profile").down(".profile-pic").__date(new Element("img",{src:eA.profile_image_url_https}));$("shmodal-twitter-profile").down(".name").__date(eA.name);$("shmodal-twitter-profile").down(".username").__date("@"+eA.screen_name);$("modal").down(".twitter-post-sickinput").addClassName("shrank");return $("shmodal-twitter-profile").show()},T)}},download_zip:function(ez){var ex,ey,eA,T,eB;ex=bg("#download_button_link").attr("data-dl-link");eB=bg("#download_button_link").attr("data-test-link");T=bg("#download_button_link").attr("data-owner")==="true";eA=(function(eC){return function(eD){var eE;if(eD==="OK"){window.location=ex}else{if(eD.indexOf("err:")===0){if(T){eE=dW("The zip file is too large.")}else{eE=dW("The zip file is too large. Please add it to your Dropbox.")}Y.error(eE)}else{Y.error(dW("Failed to download zip file."))}}return false}})(this);ey=(function(eC){return function(eD){Y.error(dW("Failed to download zip file."));return false}})(this);if(eB&&bg.support.cors===true){bg.ajax({url:eB,type:"POST",success:eA,error:ey})}else{window.location=ex}return false},show_share_shmodel_role_chooser:function(ex,ey,T){if(this.shmodel_select_role_modal==null){this.shmodel_select_role_modal=new cY({element_id:"share-shmodel-select-role-modal",link_url:ex,short_url:ey,tokenizer_type:T})}return this.shmodel_select_role_modal.show().set_title(this._get_shmodal_title_text())},prompt_login_then_share:function(ex,ey,T,eA){var ez;ez=(function(eB){return function(){var eC;er.hide();bg("#role-selector option").removeClass("disabled");eC=ck.get_viewer().get_uid_by_role(eA);ck.get_viewer().sign_in_user_by_id(eC);aQ.ShmodelUILogger.log("via-shmodel-viewer");return ad.show_shmodal(ex,ey,T,eC)}})(this);if(!ck.get_viewer().is_role_signed_in(eA)){c3.not_logged_in_role=eA;return bp.show_modal({role:eA,on_success:ez})}else{return ez()}},show_c2d_modal:function(eD,ex){var eC,T,eB,ez,eA,ey;if(eD==null){eD=""}if(ex==null){ex=false}if(eD){if(eD===Constants.ROLE_PERSONAL){cj(this.team_only_shmodel!=="forbid","Can't copy to personal Dropbox if restricted")}if(!ck.get_viewer().is_role_signed_in(eD)){bp.show_modal({role:eD,on_success:(function(eE){return function(){return eE.show_c2d_modal(eD)}})(this)});return}}else{if(ck.get_viewer().is_paired){new aD({element_id:"select-role-modal"}).show();return}}if(eD){ez="#c2d-modal-"+eD}else{ez="#c2d-modal"}eA=this._c2d_modal_msg(eD,ck.get_viewer().team_name);eC=this._c2d_modal_button_msg(eD,ck.get_viewer().team_name);T=this._c2d_modal_desc(eD,ck.get_viewer().team_name);if(ex){T=this._c2d_modal_team_only_desc(ck.get_viewer().team_name)+"

      "+T}eB=this._c2d_modal_login_desc(eD,ck.get_viewer().team_name);cT.fillVal(T,"c2d-desc");cT.fillVal(eB,"c2d-login-desc");if((ey=bg(".c2d-submit-button"))!=null){ey.val(eC)}bg(".c2d-login-register-desc").hide();if(this.is_album){bg(".c2d-login-register-album-desc").show()}else{if(this.is_folder){bg(".c2d-login-register-folder-desc").show()}else{bg(".c2d-login-register-file-desc").show()}}return er.show(eA,bg(ez)[0],false,false,false,false)},_c2d_modal_msg:function(ez,ex){var T,ey;if(ez==null){ez=""}if(ex==null){ex=""}if(this.c2d_vars.title){return ey=this.c2d_vars.title}else{if(ez===Constants.ROLE_PERSONAL){ey=dW("Save '%(filename)s' to my personal Dropbox");return ey.format({filename:bu.em_snippet(this.filename,10)})}else{if(ez===Constants.ROLE_WORK){ey=dW("Save '%(filename)s' to my %(team_name)s Dropbox");T=Math.max(10,15-new bu(ex).length);return ey.format({filename:bu.em_snippet(this.filename,T),team_name:ex})}else{ey=dW("Save '%(filename)s' to my Dropbox");return ey.format({filename:bu.em_snippet(this.filename,15)})}}}},_c2d_modal_button_msg:function(ey,T){var ex;if(ey==null){ey=""}if(T==null){T=""}if(ey===Constants.ROLE_PERSONAL){return ex=dW("Save to my personal Dropbox")}else{if(ey===Constants.ROLE_WORK){ex=dW("Save to my %(team_name)s Dropbox");return ex.format({team_name:T})}else{return dW("Save to my Dropbox")}}},_c2d_modal_team_only_desc:function(T){var ex;if(this.is_album){ex=dW("You can only add this album to your %(team_name)s Dropbox because %(owner_name)s has restricted the album to members of %(team_name)s.")}else{if(this.is_folder){ex=dW("You can only add this folder to your %(team_name)s Dropbox because %(owner_name)s has restricted the folder to members of %(team_name)s.")}else{ex=dW("You can only add this file to your %(team_name)s Dropbox because %(owner_name)s has restricted the file to members of %(team_name)s.")}}return ex.format({owner_name:this.owner_name,team_name:T})},_c2d_modal_desc:function(ey,T){var ex;if(ey==null){ey=""}if(T==null){T=""}if(ey===Constants.ROLE_PERSONAL){if(this.is_album){if(this.team_only_shmodel==="warn"){ex=dW("The photos and videos in this album were sent from %(owner_name)s on your %(team_name)s team. Are you sure you want to copy them to your personal Dropbox?");return ex.format({owner_name:this.owner_name,team_name:T})}else{return ex=dW("The photos and videos in this album will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}}else{if(this.is_folder){if(this.team_only_shmodel==="warn"){ex=dW("This folder was sent from %(owner_name)s on your %(team_name)s team. Are you sure you want to copy it to your personal Dropbox?");return ex.format({owner_name:this.owner_name,team_name:T})}else{return ex=dW("This folder will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}}else{if(this.team_only_shmodel==="warn"){ex=dW("This file was sent from %(owner_name)s on your %(team_name)s team. Are you sure you want to copy it to your personal Dropbox?");return ex.format({owner_name:this.owner_name,team_name:T})}else{return ex=dW("This file will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}}}}else{if(ey===Constants.ROLE_WORK){if(this.is_album){ex=dW("The photos and videos in this album will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}else{if(this.is_folder){ex=dW("This folder will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}else{ex=dW("This file will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}}return ex.format({team_name:T})}else{if(this.is_album){return dW("The photos and videos in this album will be instantly saved to your Dropbox and downloaded to all the computers linked to your account.")}else{if(this.is_folder){return dW("This folder will be instantly saved to your Dropbox and downloaded to all the computers linked to your account.")}else{return dW("This file will be instantly saved to your Dropbox and downloaded to all the computers linked to your account.")}}}}},_c2d_modal_login_desc:function(ey,T){var ex;if(ey==null){ey=""}if(T==null){T=""}if(ey===Constants.ROLE_PERSONAL){if(this.is_album){return ex=dW("Once you sign in to your personal Dropbox, the photos and videos in this album will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}else{if(this.is_folder){return ex=dW("Once you sign in to your personal Dropbox, this folder will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}else{return ex=dW("Once you sign in to your personal Dropbox, this file will be instantly saved to your personal Dropbox and downloaded to all the computers linked to your personal account.")}}}else{if(ey===Constants.ROLE_WORK){if(this.is_album){ex=dW("Once you sign in to your %(team_name)s Dropbox, the photos and videos in this album will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}else{if(this.is_folder){ex=dW("Once you sign in to your %(team_name)s Dropbox, this folder will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}else{ex=dW("Once you sign in to your %(team_name)s Dropbox, this file will be instantly saved to your %(team_name)s Dropbox and downloaded to all the computers linked to your %(team_name)s account.")}}return ex.format({team_name:T})}}},c2d_register:function(ex){var T,ey;ex.preventDefault();T=$("c2d-register-form");ey=(function(ez){return function(eB){var eA;eA=JSON.parse(eB.responseText);return ez.do_c2d(eA.id)}})(this);return bt.ajax_submit(T,"/ajax_register",ey,false,$(T).down("input[type=submit]"))},c2d_login:function(ez,T){var ey,ex,eA;if(T==null){T="c2d-login-form"}ez.preventDefault();ey=$(T);eA=(function(eB){return function(eD){var eC;eC=JSON.parse(eD.responseText);switch(eC.status){case"OK":return eB.do_c2d(eC.id);case"TWOFACTOR":return eB.show_c2d_twofactor(eC.last_four_digits);case"SSO":return window.location=eC.sso_url}}})(this);ex=this.c2d_show_twofactor_error500.bind(this);return bt.ajax_submit(ey,"/ajax_login",eA,ex,$(ey).down("input[type=submit]"))},show_c2d_twofactor:function(T){$("c2d-login").hide();if(T){$("c2d-twofactor-login").addClassName("sms");cT.fillVal(T,"last-four-digits")}else{$("c2d-twofactor-login").removeClassName("sms")}$("c2d-resend-link").observe("click",this.c2d_resend_phone_code.bind(this));return $("c2d-twofactor-login").show()},hide_c2d_twofactor:function(){$("c2d-twofactor-login").hide();return $("c2d-login").show()},c2d_resend_phone_code:function(){if(this.c2d_is_resending()){return}this.c2d_show_resending();return new Ajax.DBRequest("/twofactor_resend",{onSuccess:(function(T){return function(ex){switch(ex.responseText.strip()){case"OK":return Y.success(dW("We sent you another code. It may take a few minutes to arrive."));case"UNREACHABLE":return T.c2d_show_twofactor_error_unreachable();case"BADCARRIER":return T.c2d_show_twofactor_error_bad_carrier();case"INVALIDNUMBER":return T.c2d_show_twofactor_error_invalid_number();case"NOTAMOBILE":return T.c2d_show_twofactor_error_not_a_mobile();case"EXPIRED":T.hide_c2d_twofactor();return Y.error(dW("Sorry, your phone code has expired. Please log in again."))}}})(this),onFailure:this.c2d_show_twofactor_error500.bind(this),cleanUp:this.c2d_hide_resending_with_delay.bind(this)})},c2d_twofactor_login:function(ey){var ex,T,ez;ey.preventDefault();if(!$("c2d-twofactor-code").getValue()){this.c2d_show_twofactor_error_invalid();return}ex=$("c2d-twofactor-login-form");ez=(function(eA){return function(eC){var eB;eB=JSON.parse(eC.responseText);switch(eB.status){case"OK":return eA.do_c2d(eB.id);case"INVALID":return eA.c2d_show_twofactor_error_invalid();case"EXPIRED":eA.hide_c2d_twofactor();return Y.error(dW("Sorry, your phone code has expired. Please log in again."))}}})(this);T=this.c2d_show_twofactor_error500.bind(this);return bt.ajax_submit(ex,"/ajax_verify_code",ez,T)},do_c2d:function(T){var ex;cj(T,"Must specify a user_id for saving to Dropbox.");ex=dW("Saving to your Dropbox...");if(ck.get_viewer().is_paired){if(ck.get_viewer().get_user_by_id(T).is_team){ex=dW("Saving to your %(team_name)s Dropbox...");ex=ex.format({team_name:ck.get_viewer().team_name})}else{ex=dW("Saving to your personal Dropbox...")}}Y.success(ex);er.hide();return new Ajax.DBRequest(this.c2d_url,{parameters:this.c2d_vars,job:this.is_folder,progress_text:ex,subject_user:T,onSuccess:(function(ey){return function(ez){if(ez.responseText&&ez.responseText[0]==="/"){return window.location.href=ez.responseText}else{if(ez.responseText==="snapshot_ok"){return Y.success(dW("Successfully saved to your Dropbox."))}}}})(this)})},c2d_show_twofactor_error:function(ex){var T;T=$("c2d-twofactor-error");T.__date(ex);return T.show()},c2d_hide_twofactor_error:function(T){return $("c2d-twofactor-error").__date()},c2d_show_twofactor_error500:function(){return this.c2d_show_twofactor_error(dW("Sorry, an error occured. Please try again later."))},c2d_show_twofactor_error_bad_carrier:function(){return this.c2d_show_twofactor_error(dW("Unfortunately, your carrier is not supported at this time."))},c2d_show_twofactor_error_invalid_number:function(){return this.c2d_show_twofactor_error(dW("That is not a valid phone number."))},c2d_show_twofactor_error_not_a_mobile:function(){return this.c2d_show_twofactor_error(dW("That phone number does not appear to be a valid mobile number."))},c2d_show_twofactor_error_unreachable:function(){return this.c2d_show_twofactor_error(dW("We couldn't reach your phone number. Are you sure it's correct?"))},c2d_show_twofactor_error_invalid:function(){return this.c2d_show_twofactor_error(dW("Invalid code."))},c2d_is_resending:function(){return $("c2d-resend-link").hasClassName("resending")},c2d_show_resending:function(){return $("c2d-resend-link").addClassName("resending")},c2d_hide_resending:function(){return $("c2d-resend-link").removeClassName("resending")},c2d_hide_resending_with_delay:function(){return setTimeout(this.c2d_hide_resending.bind(this),3000)}};var cP;cP=A.ShmodalPanes={SEND:0,FB:1,TWITTER:2,list:[0,1,2],_content_str:["shmodal-send-content","shmodal-fb-content","shmodal-twitter-content"],_toggle_str:["shmodal-send-toggle","shmodal-fb-toggle","shmodal-twitter-toggle"],_title_str:["Share by Email",dW("Share on Facebook"),dW("Share on Twitter")],to_content_str:function(T){return this._content_str[T]},to_toggle_str:function(T){return this._toggle_str[T]},to_title_str:function(T){if(T===0){return ad._get_shmodal_title_text()}return this._title_str[T]},to_focus_str:function(T){return this._focus_str[T]}};var R,by,cJ,bm,cV=function(T,ex){return function(){return T.apply(ex,arguments)}},am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez};cJ=INLINE_JS.ShareLinkModal=A.ShareLinkModal=(function(T){cm(ex,T);function ex(ey,eA,ez,eB){var eC;this.user_id=ey;if(eB==null){eB=false}this.before_show=cV(this.before_show,this);this.show=cV(this.show,this);this.prompt_login_then_show=cV(this.prompt_login_then_show,this);eC={origin:ez};eC[Constants.UID_PARAM_NAME]=this.user_id;ex.__super__.constructor.call(this,{element_id:"share-link-modal",endpoint_url:C({path:"/sm/share_link"+eA}).toString(),parameters:eC})}ex.prototype.prompt_login_then_show=function(){var ey;ey=(function(ez){return function(){er.hide();bg("#role-selector option").removeClass("disabled");ck.get_viewer().sign_in_user_by_id(ez.user_id);aQ.ShmodelUILogger.log("via-shmodel-viewer");return ez.show()}})(this);if(!ck.get_viewer().is_uid_signed_in(this.user_id)){return bp.show_modal({user_id:this.user_id,on_success:ey})}else{return ey()}};ex.prototype.show=function(){var ey;ey=ck.get_viewer().get_user_by_id(this.user_id);if(ds.get_for_user(ey).verified_or_show(dQ.SHMODAL)){return ex.__super__.show.call(this)}};ex.prototype.before_show=function(){var eB,eA,ey,ez;ez=this.$modal_window.find(".share-link-modal-content").length;if(ez){eB={"class":"ajax-loading-indicator",src:"/static/images/icons/ajax-loading-small.gif"};ey=bg("",eB);eA=bg("
      ",{"class":"loading-spinner"}).append(ey);return this.$modal_window.find(".dynamic-content").html(eA)}};return ex})(cb);bm=A.ShareLinkModalContent=(function(){function T(eB,eC,eD,eE,ex,ey,eH,eA,eF,eI){var eG,ez;this.owner_id=eB;this.tkey=eC;this.fq_path=eD;this.link=eE;this.filename=ex;this.tokenizer_type=ey;this.tokenizer_ctx_str=eH;this.fq_path_of_restricting_sf=eF;this.read_receipts_variant=eI;this._send_link=cV(this._send_link,this);this._show_shared_link_settings_modal=cV(this._show_shared_link_settings_modal,this);this._show_shared_folder_settings_modal=cV(this._show_shared_folder_settings_modal,this);this._select_all_text=cV(this._select_all_text,this);this._toggle_send_link_button=cV(this._toggle_send_link_button,this);this._toggle_recipients_outside_team_warning=cV(this._toggle_recipients_outside_team_warning,this);this._toggle_close_button_text=cV(this._toggle_close_button_text,this);this._listen=cV(this._listen,this);this._init_autocompleter=cV(this._init_autocompleter,this);this.$content=bg(".share-link-modal-content");this.modal=dw.get_containing_modal(this.$content);if(!this.modal){return}if(this.tokenizer_type==="shared_folder"){this.shared_folder_members=m.create_contacts_list(eA)}eG={filename:this.filename,fq_path:this.fq_path,tkey:this.tkey,user_id:this.owner_id};document.fire(av.LINKS_ADD,eG);this.modal.set_title(dW("Share link to \u2018%(filename)s\u2019").format({filename:bu.em_snippet(this.filename,15)}));this.collab_input_id=this.tokenizer_ctx_str+"-new-collab-input";this.$collab_input=this.$content.find("#"+this.collab_input_id);this.$send_link_button=this.$content.find(".confirm-button");this.$share_link_url_input=this.$content.find(".copy-link-input-container input[type='text']");this.$cancel_button=this.$content.find(".cancel-button");this._init_autocompleter();this._listen();if((ez=this.$share_link_url_input[0])!=null){ez.select()}}T.prototype._init_autocompleter=function(){var ex;ex={tokens:[",",";"],include_fb:true,include_team:true,team_only:this.tokenizer_type==="team_only",user_id:this.owner_id};if(this.tokenizer_type==="shared_folder"){this.autocompleter=new Autocompleter.SharedFolderTokenizer(ck.get_viewer().get_user_by_id(this.owner_id),this.collab_input_id,this.tokenizer_ctx_str+"-new-whobulk",this.tokenizer_ctx_str+"-hidden-input",ex,this.shared_folder_members)}else{if(this.tokenizer_type==="contacts"){this.autocompleter=new Autocompleter.ContactsTokenizer(ck.get_viewer().get_user_by_id(this.owner_id),this.collab_input_id,this.tokenizer_ctx_str+"-new-whobulk",this.tokenizer_ctx_str+"-hidden-input",ex)}else{this.autocompleter=new Autocompleter.TeamTokenizer(ck.get_viewer().get_user_by_id(this.owner_id),this.collab_input_id,this.tokenizer_ctx_str+"-new-whobulk",this.tokenizer_ctx_str+"-hidden-input",ex)}}bT.init();return this.$collab_input.focus()};T.prototype._listen=function(){var ey,ex,eB,eA,ez;this.$send_link_button.on("click",this._send_link);this.$share_link_url_input.on("click",this._select_all_text);this.$cancel_button.on("click",(function(eC){return function(eD){return dp.pop()}})(this));this.$content.find("#shared-link-permissions-link").on("click",this._show_shared_link_settings_modal);this.$content.find("#shared-folder-options-link").on("click",this._show_shared_folder_settings_modal);if((ey=this.$collab_input)!=null){ey.keyup(this._toggle_send_link_button)}if((ex=this.$collab_input[0])!=null){ex.observe("token:remove",this._toggle_send_link_button)}if((eB=this.$collab_input[0])!=null){eB.observe("token:add",this._toggle_close_button_text)}if((eA=this.$collab_input[0])!=null){eA.observe("token:remove",this._toggle_close_button_text)}return(ez=this.$collab_input[0])!=null?ez.observe("sf:token:external",this._toggle_recipients_outside_team_warning):void 0};T.prototype._toggle_close_button_text=function(ez){var ex,ey;ex=((ey=this.autocompleter)!=null?ey.token_manager.tokens.length:void 0)===0;if(ex){return this.$cancel_button.text(dW("Close"))}else{return this.$cancel_button.text(dW("Cancel"))}};T.prototype._toggle_recipients_outside_team_warning=function(ez){var ex,ey;ex=bg(".external-recipient-warning-message");if(ex.length){ey=ez.memo.count;if(ez.memo.shared_folder_warning){if(ey>0){return ex.show()}else{return ex.hide()}}else{if(ey>1){ex.find(".external-recpient-num").text(ey);return ex.removeClass("single").show()}else{if(ey===1){return ex.addClass("single").show()}else{return ex.hide()}}}}};T.prototype._toggle_send_link_button=function(ez){var ex,ey;ex=((ey=this.autocompleter)!=null?ey.token_manager.tokens.length:void 0)===0;ex=ex&&bg.trim(this.$collab_input.val())==="";return this.$send_link_button.prop("disabled",ex)};T.prototype._select_all_text=function(ex){return bg(ex.currentTarget)[0].select()};T.prototype._show_shared_folder_settings_modal=function(ey){var ex;ey.preventDefault();ex=ck.get_viewer().get_user_by_id(this.owner_id);return p.show_shared_folder_options_modal(this.fq_path_of_restricting_sf,ex)};T.prototype._show_shared_link_settings_modal=function(ey){var ex;ey.preventDefault();ex=new dl(this.owner_id,this.tkey);return dp.push(ex)};T.prototype._send_link=function(eB){var ez,ey,eA,ex,eC;eA=this.$content.find(".share-link-modal-send-form")[0];ex=this.get_shmodel_send_recipients(eA);eC=(function(eD){return function(eE){var eF;eF=aI.success_string_for_recipients(ex);Y.success(eF);dp.pop();aA.log("shmodal_send");if(eD.read_receipts_variant==="READ_RECEIPTS_SHOW_INTERESTS"){eD.read_receipts_modal=new by({element_id:"read_receipts_show_interests_modal",recipients:ex});return eD.read_receipts_modal.show()}}})(this);ey=(function(eD){return function(eE){return bt.remove_loading()}})(this);ez=this.$content.find(".tokenizer-submit-button")[0];return bt.ajax_submit(eA,"/sm/share",eC,ey,ez)};T.prototype.get_shmodel_send_recipients=function(ez){var eA,eI,eF,eJ,eK,eD,eG,ex,eC,eB,eH,ey,eE;cj(ez,"Must pass the shmodal send form into get_shmodel_send_recipients");eA=ez.select('input[name="emails"]');eI=ez.select('input[name="fb_ids"]');eF=ez.select('input[name="group_ids"]');eD=ez.select('input[name="new_style_group_ids"]');ex=[];eE=[eA,eI,eF,eD];for(eC=0,eH=eE.length;eC0;return R.$send_button.prop("disabled",T||ey)},_file_upload_errored:function(ey){var ex,T;ex=ey.memo.file;if(ex.id in R._uploading_fileids){T={message:ey.memo.message};aQ.SharedFolderActivityLogger.log("web","quick_send_file_errored",b3.active_user,T);return delete R._uploading_fileids[ex.id]}},_file_upload_completed:function(ex){var T;T=ex.memo.file;if(T.id in R._uploading_fileids){aQ.SharedFolderActivityLogger.log("web","quick_send_file_uploaded",b3.active_user,{});delete R._uploading_fileids[T.id];return R._toggle_send_button_state()}},get_folder_name:function(ez){var ex,ey,T;if(R.DEST_FOLDER){ez();return}T=function(eB){var eA;eA=JSON.parse(eB);R.DEST_FOLDER=eA.folder_name;return ez()};ex=function(){return Y.error(dW("We couldn\u2019t upload your file. Please try again."))};ey={};ey[Constants.UID_PARAM_NAME]=R.owner_id;return new cc.WebRequest({url:"/share/quick_send_folder_name",data:ey,success:T,error:ex})},is_quicksend_dest:function(T){var ex;ex=an.normalize(T);return ex===R.DEST_FOLDER},add_external_file:function(T){var ey,ex;ex=T.dest+T.name;if(R._has_added_fq_path(ex)){Y.success(dW("You\u2019ve already added this file."));document.fire(ca.CANCEL_EVT,{file:T});bg(document).trigger(ca.CANCEL_EVT,{file:T});return}T.fq_path=ex;T.bytes=T.size;R._uploading_fileids[T.id]=true;R._add_file(T,"external");ey=bg("#"+T.id);return ey.find(".upload-progress-bar").css({width:"0"})},add_dropbox_file:function(T){var ex;if(T.dir){Y.error(dW("Please select files instead of folders."));return}if(R._has_added_fq_path(T.fq_path)){Y.success(dW("You\u2019ve already added this file."));return}T.name=T.filename;R._add_file(T,"dropbox");ex=bg("#"+T.id);ex.find(".upload-progress-bar").css({width:"100%"});ex.addClass("complete");return setTimeout(function(){var ey;ey=ex.find(".status-col");ey.empty();return ey.append(b7.make("web","s_check"))},0)}};var dl,b4,am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez},cV=function(T,ex){return function(){return T.apply(ex,arguments)}};dl=A.SharedLinkSettingsModal=(function(ex){cm(T,ex);function T(ey,ez){var eA;this.owner_id=ey;this.tkey=ez;eA={tkey:this.tkey};eA[Constants.UID_PARAM_NAME]=this.owner_id;T.__super__.constructor.call(this,{element_id:"shared-link-settings-modal",endpoint_url:"/sm/shared_link_settings",parameters:eA})}return T})(cb);b4=A.SharedLinkSettingsModalContent=(function(){function T(ey,ez,ex,eB){var eC,eA;this.owner_id=ey;this.tkey=ez;this.filename=ex;this.saved_password_placeholder_value=eB;this._save_settings=cV(this._save_settings,this);this._toggle_password_input=cV(this._toggle_password_input,this);this._enable_password_input_for_editing=cV(this._enable_password_input_for_editing,this);this._date_change_callback=cV(this._date_change_callback,this);this._show_calendar=cV(this._show_calendar,this);this._hide_calendar=cV(this._hide_calendar,this);this._future_date=cV(this._future_date,this);this._enable_save_button=cV(this._enable_save_button,this);this._custom_expiry_click_handler=cV(this._custom_expiry_click_handler,this);this._hide_custom_expiry_label=cV(this._hide_custom_expiry_label,this);this._show_custom_expiry_label=cV(this._show_custom_expiry_label,this);this._toggle_expiration=cV(this._toggle_expiration,this);this._expiry_picker_callback=cV(this._expiry_picker_callback,this);this._listen=cV(this._listen,this);this._detect_and_handle_blur_when_password_empty=cV(this._detect_and_handle_blur_when_password_empty,this);this._is_clicked=cV(this._is_clicked,this);this._change_password_click=cV(this._change_password_click,this);this._init_expiration_section=cV(this._init_expiration_section,this);this.MS_PER_DAY=1000*60*60*24;this.$content=bg(".sharing-settings-modal-content");this.modal=dw.get_containing_modal(this.$content);if(!this.modal){return}eA=dW("'%(filename)s' settings").format({filename:bu.em_snippet(this.filename,18)});this.modal.set_title(eA);this.$form=this.$content.find(".shared-link-settings-modal-form");this.$save_button=this.$form.find(".confirm-button");this.$password_field_container=this.$form.find(".password-field-container");this.$password=this.$form.find(".link-password-container");this.$password_input=this.$password.find("input[name='password']");this.$password_label=this.$password.find("label");this.$change_password=this.$form.find(".change-link-password-container");this.$selected_expiry=this.$form.find(".selected-expiration");this.$unselected_expiry=this.$form.find(".unselected-expiration");this.$custom_expiry=this.$form.find(".custom-expiration");this.$selected_date_box=this.$form.find(".selected-date");this.$selected_date=this.$form.find(".selected-date-text");this.$calendar=this.$form.find("#expiration-calendar-container");this.$expiry_posix=this.$form.find("#expiration-posix");this.loaded_with_saved_password=this.$password_input.data("is-saved-password")==="yes";if(this.loaded_with_saved_password){this._show_password_input(eC=true)}this._init_expiration_section();this._listen()}T.prototype._init_expiration_section=function(){var ex;this.$form.find(".expiration-selection").show();if(this.$expiry_posix.val()){bg("#expiration-yes").prop("checked",true);ex=this._posix_time_to_date(parseInt(this.$expiry_posix.val()));this._set_selected_date_text(ex);return this._show_custom_expiry_label()}else{this.$selected_expiry.hide();this._hide_custom_expiry_label();return this.$unselected_expiry.show()}};T.prototype._change_password_click=function(ex){ex.preventDefault();return this._enable_password_input_for_editing()};T.prototype._is_clicked=function(ex,ey){return ex.is(ey.target)||ex.has(ey.target).length};T.prototype._detect_and_handle_blur_when_password_empty=function(ex){if(!this.$password.is(":visible")||this.$password_input.val()||this._is_clicked(this.$password_field_container,ex)){return}return this._show_password_input(true)};T.prototype._listen=function(){if(this.loaded_with_saved_password){bg(window).on("click",this._detect_and_handle_blur_when_password_empty);this.$change_password.find(".change-link-password").on("click",this._change_password_click)}this.$form.on("change",this._enable_save_button);this.$form.on("submit",this._save_settings);this.$save_button.on("click",this._save_settings);this.$content.find(".cancel-button").on("click",(function(ex){return function(ey){return dp.pop()}})(this));this.$content.find(".audience-selection input[type=radio]").on("change",this._toggle_password_input);this.$content.find(".expiration-selection input[type=radio]").on("change",this._toggle_expiration);return bg(window).on(bc.CHANGED,this._expiry_picker_callback)};T.prototype._expiry_picker_callback=function(eA,ez){var ex,ey;ex=ez.clicked_val;if(ex!=="custom"){ey=this._future_date(parseInt(ex));return this._set_expiration(ey)}else{this.$selected_expiry.hide();this._show_custom_expiry_label();this._set_selected_date_text(this._future_date(30));return this._show_calendar()}};T.prototype._toggle_expiration=function(ez){var ey,ex;if(bg(ez.currentTarget).attr("id")==="expiration-yes"){this.$selected_expiry.show();this._hide_custom_expiry_label();this.$unselected_expiry.hide();bg(".expiration-picker").controller().set_value(30);ex=30;ey=this._future_date(ex);this._set_expiration(ey);return this._set_selected_date_text(ey)}else{this.$expiry_posix.val("");this.$unselected_expiry.show();this.$selected_expiry.hide();this._hide_custom_expiry_label();return this._hide_calendar()}};T.prototype._show_custom_expiry_label=function(){this.$custom_expiry.show();this.$selected_expiry.hide();this.$unselected_expiry.hide();return bg(window).on("click",this._custom_expiry_click_handler)};T.prototype._hide_custom_expiry_label=function(){this.$custom_expiry.hide();return bg(window).off("click",this._custom_expiry_click_handler)};T.prototype._custom_expiry_click_handler=function(ex){if(this._is_clicked(this.$calendar,ex)){return}if(this.$selected_date_box.is(ex.target)||this.$selected_date_box.has(ex.target).length){if(this.$calendar.is(":visible")){return this.$calendar.hide()}else{return this._show_calendar()}}else{if(this.$calendar.is(":visible")){return this.$calendar.hide()}}};T.prototype._enable_save_button=function(ex){return this.$save_button.removeAttr("disabled")};T.prototype._future_date=function(ex){var ey;ey=du.start_of_day(new Date());ey.setDate(ey.getDate()+ex);return ey};T.prototype._hide_calendar=function(){return this.$calendar.hide()};T.prototype._show_calendar=function(){var ez,ey,ex;bg(".selected-date").off("click");if(!this.calendar){if(this.$expiry_posix.val()){ex=this._posix_time_to_date(parseInt(this.$expiry_posix.val()))}else{ex=this._future_date(30)}ey={disable_past:true,first_day:this._future_date(1),last_day:this._future_date(365),selected_date:ex,onDateChange:bg.proxy(this._date_change_callback,this)};this.calendar=new D("expiration-calendar-container",ey)}else{this.$calendar.show()}ez=this.$selected_date_box.offset().left;return this.$calendar.show().offset({left:ez})};T.prototype._posix_time_to_date=function(ex){return new Date(ex*1000)};T.prototype._set_selected_date_text=function(ex){return this.$selected_date.text(I.localize(ex))};T.prototype._set_expiration=function(ey){var ex,ez;cj(ey.getMilliseconds()===0);cj(ey.getSeconds()===0);cj(ey.getMinutes()===0);cj(ey.getHours()===0);ez=(ey.getTime()+this.MS_PER_DAY)/1000;ex=ez-1;return this.$expiry_posix.val(ex)};T.prototype._date_change_callback=function(ex){this._set_selected_date_text(ex);this._set_expiration(ex);this._enable_save_button();return this._hide_calendar()};T.prototype._show_password_input=function(eC){var eB,ez,ey,eA,ex;if(eC==null){eC=false}eB=this.$content.find("label[for=audience-password]").position().left;eA=this.$content.find("#audience-password").position().left;ez=eB-eA+10;this.$password.show().css({left:ez});this.$password_input.val("");if(eC){this.$password_input.addClass("disabled").attr("readonly","true");this.$password_input.data("is-saved-password","yes");ex="\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf";this.$password_label.text(ex).show();ey=this.$password.position();return this.$change_password.css({left:ey.left,top:ey.top}).show()}else{return this._enable_password_input_for_editing()}};T.prototype._enable_password_input_for_editing=function(){this.$change_password.hide();this.$password_input.removeAttr("readonly").removeClass("disabled");this.$password_input.data("is-saved-password","no");this.$password_label.text(dW("Set password")).show();this.$password_input.focus();return this._enable_save_button()};T.prototype._toggle_password_input=function(ex){var ey;if(bg(ex.currentTarget).attr("id")==="audience-password"){return this._show_password_input(ey=this.loaded_with_saved_password)}else{this.$password.hide();this.$change_password.hide();return this.$password_input.data("is-saved-password","no")}};T.prototype._save_settings=function(eA){var ey,ex,ez,eB;if(this.$password_input.data("is-saved-password")==="yes"){ez={type:"hidden",name:"password",value:this.saved_password_placeholder_value};ey=bg("",ez);this.$form.append(ey);this.$password_input.attr("name","inoperative_password")}eB=(function(eC){return function(eD){dp.pop();return Y.success(dW("Settings saved."))}})(this);ex=(function(eC){return function(eD){if(eC.$password.length&&eC.$password.is(":visible")){eC.$password_input.focus()}return bt.remove_loading()}})(this);return bt.ajax_submit(this.$form[0],"/sm/change_shared_link_settings",eB,ex,this.$save_button[0])};return T})();var dV,dS;dS=A.FoshmodalPanes=Object.clone(cP);dS.to_title_str=function(){var T,ex,eB,ez,eA,ey;if(dV.sharing_collection){ez=bu.em_snippet(dV.collection_to_share.name,18,1);return dW("Share '%(snippeted_name)s'").format({snippeted_name:ez})}else{T=dV._selection;ey=cC.categorize_files(T),ex=ey[0],eB=ey[1];if(ex&&eB){eA=aR("Share %(file_count)s item","Share %(file_count)s items",T.length)}else{if(ex){eA=aR("Share %(file_count)s photo","Share %(file_count)s photos",T.length)}else{eA=aR("Share %(file_count)s video","Share %(file_count)s videos",T.length)}}eA=eA.format({file_count:T.length});return eA}};dV=INLINE_JS.Foshmodal=A.Foshmodal={current_shmodel_url:null,current_short_url:null,callback_for_when_we_have_shmodel_url:null,current_foshmodal_pane:dS.SEND,send_link_autocompleter:null,sharing_collection:false,num_photos_to_share:null,working:false,collection_to_share:null,have_real_tkey:false,current_tkey:null,current_album_name:null,previous_album_name:null,_selection:null,lock:function(){if(this.working){return false}this.working=true;return this.working},unlock:function(){return this.working=false},clear_message_inputs:function(){$("shmodal-send-content").down(".custom-message-container").down(".textinput").setValue("");$("shmodal-fb-post-input").setValue("");return $("shmodal-twitter-post-input").setValue("")},refresh:function(){this.current_shmodel_url=null;this.current_short_url;this.callback_for_when_we_have_shmodel_url=null;this.current_foshmodal_pane=dS.SEND;this.sharing_collection=false;this.have_real_tkey=false;this.current_tkey=null;this.current_album_name=null;this.previous_album_name=null;ef.clear();this.clear_message_inputs();this.send_link_autocompleter.clearTokens();this.unlock();bg(".link-image").attr("src","static/images/empty_album_big.png");bt.remove_loading(bg("#modal").find(".tokenizer-submit-button")[0]);bt.remove_loading(bg("#modal").find(".foshmodal-copy-link")[0]);bt.remove_loading(bg("#shmodal-twitter-post-submit")[0]);return bt.remove_loading(bg("#shmodal-fb-post-submit")[0])},create_album_from_selected_photos:function(T){var ex;cj(this._selection.length,"This should never be called with an empty selection");cj(this.current_tkey!=null,"Missing tkey");cj(this.current_shmodel_url!=null,"Missing shmodel url");cj(this.current_short_url!=null,"Missing short url");cj(T!=null,"Missing collection info");T.is_anonymous=this.creating_anonymous_collection();T.share_tkey=this.current_tkey;T.shmodel_url=this.current_shmodel_url;T.short_url=this.current_short_url;return ex=new W(T)},set_shmodel_url:function(ex,T){if(this.have_real_tkey){this.current_shmodel_url=this.collection_to_share.shmodel_url;this.current_short_url=this.collection_to_share.short_url;this.current_tkey=this.collection_to_share.share_tkey;return typeof ex==="function"?ex():void 0}else{return new Ajax.DBRequest("/collection_create_dummy_token",{onSuccess:(function(ey){return function(eA){var ez;ez=JSON.parse(eA.responseText);ey.current_shmodel_url=ez.token_link;ey.current_short_url=ez.short_link;ey.current_tkey=ez.tkey;if(typeof ex==="function"){ex()}return typeof ey.callback_for_when_we_have_shmodel_url==="function"?ey.callback_for_when_we_have_shmodel_url():void 0}})(this),onFailure:function(){return typeof T==="function"?T():void 0}})}},attach_collection_to_token:function(ex,T){cj(this.collection_to_share!=null,"Should get called only when there is an existing collection");cj(this.current_shmodel_url!=null,"Should have a shmodel url before you call attach_collection_to_token");if(this.have_real_tkey){if(typeof ex==="function"){ex(this.collection_to_share.gid)}return}cj(this.current_tkey!=null,"should have tkey");return this.collection_to_share.attach_to_token(this.current_tkey,this.current_shmodel_url,this.current_short_url,ex,T)},create_collection_and_attach_to_token:function(eB,T){var ey,eA,ez,ex;cj(this.sharing_collection===false,"Should not get called when we already have a collection");cj(this.current_shmodel_url!=null,"Should have a shmodel url before you call create_collection_and_attach_to_token");eA=(function(eC){return function(eD){var eE;eE=JSON.parse(eD.responseText);eC.create_album_from_selected_photos(eE);return typeof eB==="function"?eB(eE.gid):void 0}})(this);ey=function(eC){return typeof T==="function"?T(eC):void 0};ez={tkey:this.current_tkey,collection_name:this.creating_anonymous_collection()?"":this.current_album_name,is_anonymous:this.creating_anonymous_collection(),item_counters:JSON.stringify((function(){var eF,eD,eE,eC;eE=this._selection;eC=[];for(eF=0,eD=eE.length;eF140){Y.error(dW("Your tweet must be 140 characters or less"));this.unlock();return}ey=(function(eA){return function(eB){cd.custom_show_posting=function(){$("twitter-chars").hide();return bt.add_loading($("shmodal-twitter-post-submit"))};cd.custom_post(ez,function(){er.hide();Y.success(dW("Your tweet has been posted!"));return eA.refresh()},T);aQ.ViralLogger.log(ck.get_viewer().get_user_ids(),"shmodel","send",{src:"photo_twitter",file_type:"collection"});return b8.log_share("share_twitter",eB,eA.num_photos_to_share,eA.creating_anonymous_collection(),!eA.sharing_collection)}})(this);ex=(function(eA){return function(){Y.error(dW("We couldn't share this album on Twitter. Please try again."));er.hide();return eA.refresh()}})(this);if(this.sharing_collection){return this.attach_collection_to_token(ey,ex)}else{return this.create_collection_and_attach_to_token(ey,ex)}},show_get_link_modal:function(ex,T,ey){var ez;er.show(dW("Link to %(album_name)s").format({album_name:T.escapeHTML()}),$("get-link-modal"));ez=$("get-link-modal").down(".link-input");ez.setValue(ex);ez.select();$("get-link-modal").down(".view-button").onclick=function(){window.open(ex,"_blank");return er.hide()};return $("get-link-modal").down(".done-button").onclick=function(){if(ey!=null){cg.flash_sidebar_album(ey)}return er.hide()}},update_current_album_name_text:function(T){this.current_album_name=$(dS.to_content_str(this.current_foshmodal_pane)).down(".album-name-input").value;if(this.current_foshmodal_pane===dS.FB){return this.set_fb_post_title(this.current_album_name)}},set_fb_post_title:function(eA){var ex,ez,ey,T;T=this.sharing_collection?bq.get_timeline().get_photos():this._selection;if(eA){if(this.num_photos_to_share===1){ex=eA}else{ex=dW("%(album_name_text)s (%(album_desc)s)",{comment:'e.g. album_desc is "5 photos and 1 video" and album_name_text is "my_album"'}).format({album_name_text:eA,album_desc:cC.file_desc(T)})}}else{if(T.length===1){ey=T[0];if(ey.preview_type==="photo"){ez=dW("Photo from %(date_taken)s")}else{ez=dW("Video from %(date_taken)s")}ex=ez.format({date_taken:bF.nice_date_with_month_name(new Date(ey.time_taken),true,true,true)})}else{ex=cC.file_desc(T)}}return $(dS.to_content_str(dS.FB)).down(".link-name").__date(ex)},set_current_album_name_text:function(ex,T){$(dS.to_content_str(ex)).down(".album-name-input").value=T;if(ex===dS.FB){return this.set_fb_post_title(T)}},show_content:function(eA){var ex,ez,T,ey;if(this.working){return}$("shmodal-title-text").__date(dS.to_title_str());ey=dS.list;for(ez=0,T=ey.length;ez1){eC=$$(".shmodal-image");ey=[];for(eB=0,eE=eC.length;eB0){eK(eS,function(eV,eU){if(eV!==eQ){if(eM(eR[eU])===eM(eV)&&!!~eO(eM(eV),["array","object"])){eI(eR[eU],eV)}else{eR[eU]=eV}}})}});return eR};var eK=function(eV,eW){var eU,eS,eR,eT;if(eV){try{eU=eV.length}catch(eQ){eU=eT}if(eU===eT){for(eS in eV){if(eV.hasOwnProperty(eS)){if(eW(eV[eS],eS)===false){return}}}}else{for(eR=0;eR=9)},use_data_uri_of:function(eN){return(eM.use_data_uri&&eN<33000||eM.use_data_uri_over32kb())},use_fileinput:function(){var eN=document.createElement("input");eN.setAttribute("type","file");return !eN.disabled}};return function(eO){var eN=[].slice.call(arguments);eN.shift();return eK.typeOf(eM[eO])==="function"?eM[eO].apply(this,eN):!!eM[eO]}}());var eE={can:eH,browser:eJ(eG),version:eL(navigator.userAgent)||eL(navigator.appVersion),OS:eJ(eI),swf_url:"../flash/Moxie.swf",xap_url:"../silverlight/Moxie.xap",global_event_dispatcher:"moxie.core.EventTarget.instance.dispatchEvent"};return eE});eD("moxie/core/utils/Dom",["moxie/core/utils/Env"],function(eF){var eG=function(eM){if(typeof eM!=="string"){return eM}return document.getElementById(eM)};var eH=function(eO,eN){var eM;if(eO.className===""){return false}eM=new RegExp("(^|\\s+)"+eN+"(\\s+|$)");return eM.test(eO.className)};var eI=function(eN,eM){if(!eH(eN,eM)){eN.className=eN.className===""?eM:eN.className.replace(/\s+$/,"")+" "+eM}};var eL=function(eO,eN){var eM=new RegExp("(^|\\s+)"+eN+"(\\s+|$)");eO.className=eO.className.replace(eM,function(eQ,eP,eR){return eP===" "&&eR===" "?" ":""})};var eE=function(eN,eM){if(eN.currentStyle){return eN.currentStyle[eM]}else{if(window.getComputedStyle){return window.getComputedStyle(eN,null)[eM]}}};var eK=function(eN,eR){var eS=0,eQ=0,eU,eT=document,eO,eP;eN=eN;eR=eR||eT.body;function eM(eY){var eW,eX,eV=0,eZ=0;if(eY){eX=eY.getBoundingClientRect();eW=eT.compatMode==="CSS1Compat"?eT.documentElement:eT.body;eV=eX.left+eW.scrollLeft;eZ=eX.top+eW.scrollTop}return{x:eV,y:eZ}}if(eN&&eN.getBoundingClientRect&&eF.browser==="IE"&&(!eT.documentMode||eT.documentMode<8)){eO=eM(eN);eP=eM(eR);return{x:eO.x-eP.x,y:eO.y-eP.y}}eU=eN;while(eU&&eU!=eR&&eU.nodeType){eS+=eU.offsetLeft||0;eQ+=eU.offsetTop||0;eU=eU.offsetParent}eU=eN.parentNode;while(eU&&eU!=eR&&eU.nodeType){eS-=eU.scrollLeft||0;eQ-=eU.scrollTop||0;eU=eU.parentNode}return{x:eS,y:eQ}};var eJ=function(eM){return{w:eM.offsetWidth||eM.clientWidth,h:eM.offsetHeight||eM.clientHeight}};return{get:eG,hasClass:eH,addClass:eI,removeClass:eL,getStyle:eE,getPos:eK,getSize:eJ}});eD("moxie/core/Exceptions",["moxie/core/utils/Basic"],function(eF){function eE(eI,eH){var eG;for(eG in eI){if(eI[eG]===eH){return eG}}return null}return{RuntimeError:(function(){var eG={NOT_INIT_ERR:1,NOT_SUPPORTED_ERR:9,JS_ERR:4};function eH(eI){this.code=eI;this.name=eE(eG,eI);this.message=this.name+": RuntimeError "+this.code}eF.extend(eH,eG);eH.prototype=Error.prototype;return eH}()),OperationNotAllowedException:(function(){function eG(eH){this.code=eH;this.name="OperationNotAllowedException"}eF.extend(eG,{NOT_ALLOWED_ERR:1});eG.prototype=Error.prototype;return eG}()),ImageError:(function(){var eG={WRONG_FORMAT:1,MAX_RESOLUTION_ERR:2};function eH(eI){this.code=eI;this.name=eE(eG,eI);this.message=this.name+": ImageError "+this.code}eF.extend(eH,eG);eH.prototype=Error.prototype;return eH}()),FileException:(function(){var eG={NOT_FOUND_ERR:1,SECURITY_ERR:2,ABORT_ERR:3,NOT_READABLE_ERR:4,ENCODING_ERR:5,NO_MODIFICATION_ALLOWED_ERR:6,INVALID_STATE_ERR:7,SYNTAX_ERR:8};function eH(eI){this.code=eI;this.name=eE(eG,eI);this.message=this.name+": FileException "+this.code}eF.extend(eH,eG);eH.prototype=Error.prototype;return eH}()),DOMException:(function(){var eG={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function eH(eI){this.code=eI;this.name=eE(eG,eI);this.message=this.name+": DOMException "+this.code}eF.extend(eH,eG);eH.prototype=Error.prototype;return eH}()),EventException:(function(){function eG(eH){this.code=eH;this.name="EventException"}eF.extend(eG,{UNSPECIFIED_EVENT_TYPE_ERR:0});eG.prototype=Error.prototype;return eG}())}});eD("moxie/core/EventTarget",["moxie/core/Exceptions","moxie/core/utils/Basic"],function(eE,eF){function eG(){var eH={};eF.extend(this,{uid:null,init:function(){if(!this.uid){this.uid=eF.guid("uid_")}},addEventListener:function(eM,eL,eJ,eK){var eI=this,eN;eM=eF.trim(eM);if(/\s/.test(eM)){eF.each(eM.split(/\s+/),function(eO){eI.addEventListener(eO,eL,eJ,eK)});return}eM=eM.toLowerCase();eJ=parseInt(eJ,10)||0;eN=eH[this.uid]&&eH[this.uid][eM]||[];eN.push({fn:eL,priority:eJ,scope:eK||this});if(!eH[this.uid]){eH[this.uid]={}}eH[this.uid][eM]=eN},hasEventListener:function(eI){return eI?!!(eH[this.uid]&&eH[this.uid][eI]):!!eH[this.uid]},removeEventListener:function(eK,eJ){eK=eK.toLowerCase();var eL=eH[this.uid]&&eH[this.uid][eK],eI;if(eL){if(eJ){for(eI=eL.length-1;eI>=0;eI--){if(eL[eI].fn===eJ){eL.splice(eI,1);break}}}else{eL=[]}if(!eL.length){delete eH[this.uid][eK];if(eF.isEmptyObj(eH[this.uid])){delete eH[this.uid]}}}},removeAllEventListeners:function(){if(eH[this.uid]){delete eH[this.uid]}},dispatchEvent:function(eO){var eN,eP,eM,eL,eK={},eJ=true;if(eF.typeOf(eO)!=="string"){eL=eO;if(eF.typeOf(eL.type)==="string"){eO=eL.type;if(eL.total&&eL.loaded){eK.total=eL.total;eK.loaded=eL.loaded}eK.async=eL.async||false}else{throw new eE.EventException(eE.EventException.UNSPECIFIED_EVENT_TYPE_ERR)}}if(eO.indexOf("::")!==-1){(function(eQ){eN=eQ[0];eO=eQ[1]}(eO.split("::")))}else{eN=this.uid}eO=eO.toLowerCase();eP=eH[eN]&&eH[eN][eO];if(eP){eP.sort(function(eR,eQ){return eQ.priority-eR.priority});eM=[].slice.call(arguments);eM.shift();eK.type=eO;eM.unshift(eK);var eI=[];eF.each(eP,function(eQ){eM[0].target=eQ.scope;if(eK.async){eI.push(function(eR){setTimeout(function(){eR(eQ.fn.apply(eQ.scope,eM)===false)},1)})}else{eI.push(function(eR){eR(eQ.fn.apply(eQ.scope,eM)===false)})}});if(eI.length){eF.inSeries(eI,function(eQ){eJ=!eQ})}}return eJ},bind:function(){this.addEventListener.apply(this,arguments)},unbind:function(){this.removeEventListener.apply(this,arguments)},unbindAll:function(){this.removeAllEventListeners.apply(this,arguments)},trigger:function(){return this.dispatchEvent.apply(this,arguments)},convertEventPropsToHandlers:function(eI){var eK;if(eF.typeOf(eI)!=="array"){eI=[eI]}for(var eJ=0;eJ>16&255;eJ=eV>>8&255;eI=eV&255;if(eR==64){eN[eW++]=String.fromCharCode(eK)}else{if(eQ==64){eN[eW++]=String.fromCharCode(eK,eJ)}else{eN[eW++]=String.fromCharCode(eK,eJ,eI)}}}while(eO>18&63;eT=eW>>12&63;eS=eW>>6&63;eR=eW&63;eN[eX++]=eM.charAt(eU)+eM.charAt(eT)+eM.charAt(eS)+eM.charAt(eR)}while(eP0){if(eW){fo.upload.dispatchEvent(fs)}fo.dispatchEvent(fs)}else{eZ=true;fo.dispatchEvent("error")}fp()});fa.bind("Abort",function(fs){fo.dispatchEvent(fs);fp()});fa.bind("Error",function(fs){eZ=true;fl("readyState",eR.DONE);fo.dispatchEvent("readystatechange");e7=true;fo.dispatchEvent(fs);fp()});fr.exec.call(fa,"XMLHttpRequest","send",{url:e5,method:fb,async:fj,user:fe,password:e2,headers:fc,mimeType:e6,encoding:e4,responseType:fo.responseType,withCredentials:fo.withCredentials,options:ff},fq)}if(typeof(ff.required_caps)==="string"){ff.required_caps=eK.parseCaps(ff.required_caps)}ff.required_caps=eM.extend({},ff.required_caps,{return_response_type:fo.responseType});if(fq instanceof eU){ff.required_caps.send_multipart=true}if(!e3){ff.required_caps.do_cors=true}if(ff.ruid){fn(fa.connectRuntime(ff))}else{fa.bind("RuntimeInit",function(fs,fr){fn(fr)});fa.bind("RuntimeError",function(fs,fr){fo.dispatchEvent("RuntimeError",fr)});fa.connectRuntime(ff)}}function e8(){fl("responseText","");fl("responseXML",null);fl("response",null);fl("status",0);fl("statusText","");e9=fi=null}}eR.UNSENT=0;eR.OPENED=1;eR.HEADERS_RECEIVED=2;eR.LOADING=3;eR.DONE=4;eR.prototype=eL.instance;return eR});eD("moxie/runtime/Transporter",["moxie/core/utils/Basic","moxie/core/utils/Encode","moxie/runtime/RuntimeClient","moxie/core/EventTarget"],function(eH,eE,eF,eI){function eG(){var eN,eL,eJ,eO,eR,eQ;eF.call(this);eH.extend(this,{uid:eH.guid("uid_"),state:eG.IDLE,result:null,transport:function(eW,eV,eU){var eT=this;eU=eH.extend({chunk_size:204798},eU);if((eN=eU.chunk_size%3)){eU.chunk_size+=3-eN}eQ=eU.chunk_size;eP.call(this);eJ=eW;eO=eW.length;if(eH.typeOf(eU)==="string"||eU.ruid){eM.call(eT,eV,this.connectRuntime(eU))}else{var eS=function(eY,eX){eT.unbind("RuntimeInit",eS);eM.call(eT,eV,eX)};this.bind("RuntimeInit",eS);this.connectRuntime(eU)}},abort:function(){var eS=this;eS.state=eG.IDLE;if(eL){eL.exec.call(eS,"Transporter","clear");eS.trigger("TransportingAborted")}eP.call(eS)},destroy:function(){this.unbindAll();eL=null;this.disconnectRuntime();eP.call(this)}});function eP(){eO=eR=0;eJ=this.result=null}function eM(eT,eU){var eS=this;eL=eU;eS.bind("TransportingProgress",function(eV){eR=eV.loaded;if(eReU){eQ=eU}eT=eE.btoa(eJ.substr(eR,eQ));eL.exec.call(eS,"Transporter","receive",eT,eO)}}eG.IDLE=0;eG.BUSY=1;eG.DONE=2;eG.prototype=eI.instance;return eG});eD("moxie/core/JSON",[],function(){return !!window.JSON&&JSON.parse||(function(){var eH,eF,eE={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},eQ,eO=function(eR){throw {name:"SyntaxError",message:eR,at:eH,text:eQ}},eK=function(eR){if(eR&&eR!==eF){eO("Expected '"+eR+"' instead of '"+eF+"'")}eF=eQ.charAt(eH);eH+=1;return eF},eJ=function(){var eS,eR="";if(eF==="-"){eR="-";eK("-")}while(eF>="0"&&eF<="9"){eR+=eF;eK()}if(eF==="."){eR+=".";while(eK()&&eF>="0"&&eF<="9"){eR+=eF}}if(eF==="e"||eF==="E"){eR+=eF;eK();if(eF==="-"||eF==="+"){eR+=eF;eK()}while(eF>="0"&&eF<="9"){eR+=eF;eK()}}eS=+eR;if(!isFinite(eS)){eO("Bad number")}else{return eS}},eL=function(){var eU,eT,eS="",eR;if(eF==='"'){while(eK()){if(eF==='"'){eK();return eS}else{if(eF==="\\"){eK();if(eF==="u"){eR=0;for(eT=0;eT<4;eT+=1){eU=parseInt(eK(),16);if(!isFinite(eU)){break}eR=eR*16+eU}eS+=String.fromCharCode(eR)}else{if(typeof eE[eF]==="string"){eS+=eE[eF]}else{break}}}else{eS+=eF}}}}eO("Bad string")},eN=function(){while(eF&&eF<=" "){eK()}},eG=function(){switch(eF){case"t":eK("t");eK("r");eK("u");eK("e");return true;case"f":eK("f");eK("a");eK("l");eK("s");eK("e");return false;case"n":eK("n");eK("u");eK("l");eK("l");return null}eO("Unexpected '"+eF+"'")},eP,eM=function(){var eR=[];if(eF==="["){eK("[");eN();if(eF==="]"){eK("]");return eR}while(eF){eR.push(eP());eN();if(eF==="]"){eK("]");return eR}eK(",");eN()}}eO("Bad array")},eI=function(){var eS,eR={};if(eF==="{"){eK("{");eN();if(eF==="}"){eK("}");return eR}while(eF){eS=eL();eN();eK(":");if(Object.hasOwnProperty.call(eR,eS)){eO('Duplicate key "'+eS+'"')}eR[eS]=eP();eN();if(eF==="}"){eK("}");return eR}eK(",");eN()}}eO("Bad object")};eP=function(){eN();switch(eF){case"{":return eI();case"[":return eM();case'"':return eL();case"-":return eJ();default:return eF>="0"&&eF<="9"?eJ():eG()}};return function(eU,eS){var eR;eQ=eU;eH=0;eF=" ";eR=eP();eN();if(eF){eO("Syntax error")}return typeof eS==="function"?(function eT(eY,eX){var eW,eV,eZ=eY[eX];if(eZ&&typeof eZ==="object"){for(eW in eZ){if(Object.prototype.hasOwnProperty.call(eZ,eW)){eV=eT(eZ,eW);if(eV!==eC){eZ[eW]=eV}else{delete eZ[eW]}}}}return eS.call(eY,eX,eZ)}({"":eR},"")):eR}}())});eD("moxie/image/Image",["moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/file/FileReaderSync","moxie/xhr/XMLHttpRequest","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/runtime/Transporter","moxie/core/utils/Env","moxie/core/EventTarget","moxie/file/Blob","moxie/file/File","moxie/core/utils/Encode","moxie/core/JSON"],function(eG,eK,eQ,eO,eR,eF,eP,eJ,eN,eT,eI,eM,eL,eH){var eS=["progress","load","error","resize","embedded"];function eE(){eP.call(this);eG.extend(this,{uid:eG.guid("uid_"),ruid:null,name:"",size:0,width:0,height:0,type:"",meta:{},clone:function(){this.load.apply(this,arguments)},load:function(){this.bind("Load Resize",function(){eV.call(this)},999);this.convertEventPropsToHandlers(eS);eW.apply(this,arguments)},downsize:function(e3,eZ,e2,e0){try{if(!this.size){throw new eQ.DOMException(eQ.DOMException.INVALID_STATE_ERR)}if(this.width>eE.MAX_RESIZE_WIDTH||this.height>eE.MAX_RESIZE_HEIGHT){throw new eQ.ImageError(eQ.ImageError.MAX_RESOLUTION_ERR)}if(!e3&&!eZ||eG.typeOf(e2)==="undefined"){e2=false}e3=e3||this.width;eZ=eZ||this.height;e0=(eG.typeOf(e0)==="undefined"?true:!!e0);this.getRuntime().exec.call(this,"Image","downsize",e3,eZ,e2,e0)}catch(e1){this.trigger("error",e1)}},crop:function(e1,eZ,e0){this.downsize(e1,eZ,true,e0)},getAsCanvas:function(){if(!eN.can("create_canvas")){throw new eQ.RuntimeError(eQ.RuntimeError.NOT_SUPPORTED_ERR)}var eZ=this.connectRuntime(this.ruid);return eZ.exec.call(this,"Image","getAsCanvas")},getAsBlob:function(eZ,e0){if(!this.size){throw new eQ.DOMException(eQ.DOMException.INVALID_STATE_ERR)}if(!eZ){eZ="image/jpeg"}if(eZ==="image/jpeg"&&!e0){e0=90}return this.getRuntime().exec.call(this,"Image","getAsBlob",eZ,e0)},getAsDataURL:function(eZ,e0){if(!this.size){throw new eQ.DOMException(eQ.DOMException.INVALID_STATE_ERR)}return this.getRuntime().exec.call(this,"Image","getAsDataURL",eZ,e0)},getAsBinaryString:function(eZ,e1){var e0=this.getAsDataURL(eZ,e1);return eL.atob(e0.substring(e0.indexOf("base64,")+7))},embed:function(e2){var fa=this,e7,e6,e8,e4,fb=arguments[1]||{},e1=this.width,e9=this.height,e3;function e0(){if(eN.can("create_canvas")){var fc=e7.getAsCanvas();if(fc){e2.appendChild(fc);fc=null;e7.destroy();fa.trigger("embedded");return}}var fe=e7.getAsDataURL(e6,e8);if(!fe){throw new eQ.ImageError(eQ.ImageError.WRONG_FORMAT)}if(eN.can("use_data_uri_of",fe.length)){e2.innerHTML='';e7.destroy();fa.trigger("embedded")}else{var fd=new eJ();fd.bind("TransportingComplete",function(){e3=fa.connectRuntime(this.result.ruid);fa.bind("Embedded",function(){eG.extend(e3.getShimContainer().style,{top:"0px",left:"0px",width:e7.width+"px",height:e7.height+"px"});e3=null},999);e3.exec.call(fa,"ImageView","display",this.result.uid,e1,e9);e7.destroy()});fd.transport(eL.atob(fe.substring(fe.indexOf("base64,")+7)),e6,eG.extend({},fb,{required_caps:{display_media:true},runtime_order:"flash,silverlight",container:e2}))}}try{if(!(e2=eK.get(e2))){throw new eQ.DOMException(eQ.DOMException.INVALID_NODE_TYPE_ERR)}if(!this.size){throw new eQ.DOMException(eQ.DOMException.INVALID_STATE_ERR)}if(this.width>eE.MAX_RESIZE_WIDTH||this.height>eE.MAX_RESIZE_HEIGHT){throw new eQ.ImageError(eQ.ImageError.MAX_RESOLUTION_ERR)}e6=fb.type||this.type||"image/jpeg";e8=fb.quality||90;e4=eG.typeOf(fb.crop)!=="undefined"?fb.crop:false;if(fb.width){e1=fb.width;e9=fb.height||e1}else{var eZ=eK.getSize(e2);if(eZ.w&&eZ.h){e1=eZ.w;e9=eZ.h}}e7=new eE();e7.bind("Resize",function(){e0.call(fa)});e7.bind("Load",function(){e7.downsize(e1,e9,e4,false)});e7.clone(this,false);return e7}catch(e5){this.trigger("error",e5)}},destroy:function(){if(this.ruid){this.getRuntime().exec.call(this,"Image","destroy");this.disconnectRuntime()}this.unbindAll()}});function eV(e0){if(!e0){e0=this.getRuntime().exec.call(this,"Image","getInfo")}if(e0){if(eG.typeOf(e0.meta)==="string"){try{this.meta=eH(e0.meta)}catch(eZ){}}else{this.meta=e0.meta}}eG.extend(this,{size:parseInt(e0.size,10),width:parseInt(e0.width,10),height:parseInt(e0.height,10),type:e0.type});if(this.name===""){this.name=e0.name}}function eW(e1){var e0=eG.typeOf(e1);try{if(e1 instanceof eE){if(!e1.size){throw new eQ.DOMException(eQ.DOMException.INVALID_STATE_ERR)}eU.apply(this,arguments)}else{if(e1 instanceof eI){if(!~eG.inArray(e1.type,["image/jpeg","image/png"])){throw new eQ.ImageError(eQ.ImageError.WRONG_FORMAT)}eX.apply(this,arguments)}else{if(eG.inArray(e0,["blob","file"])!==-1){eW.call(this,new eM(null,e1),arguments[1])}else{if(e0==="string"){if(/^data:[^;]*;base64,/.test(e1)){eW.call(this,new eI(null,{data:e1}),arguments[1])}else{eY.apply(this,arguments)}}else{if(e0==="node"&&e1.nodeName.toLowerCase()==="img"){eW.call(this,e1.src,arguments[1])}else{throw new eQ.DOMException(eQ.DOMException.TYPE_MISMATCH_ERR)}}}}}}catch(eZ){this.trigger("error",eZ)}}function eU(eZ,e0){var e1=this.connectRuntime(eZ.ruid);this.ruid=e1.uid;e1.exec.call(this,"Image","loadFromImage",eZ,(eG.typeOf(e0)==="undefined"?true:e0))}function eX(e1,e2){var e0=this;e0.name=e1.name||"";function eZ(e3){e0.ruid=e3.uid;e3.exec.call(e0,"Image","loadFromBlob",e1)}if(e1.isDetached()){this.bind("RuntimeInit",function(e4,e3){eZ(e3)});if(e2&&typeof(e2.required_caps)==="string"){e2.required_caps=eF.parseCaps(e2.required_caps)}this.connectRuntime(eG.extend({required_caps:{access_image_binary:true,resize_image:true}},e2))}else{eZ(this.connectRuntime(e1.ruid))}}function eY(e1,e0){var eZ=this,e2;e2=new eR();e2.open("get",e1);e2.responseType="blob";e2.onprogress=function(e3){eZ.trigger(e3)};e2.onload=function(){eX.call(eZ,e2.response,true)};e2.onerror=function(e3){eZ.trigger(e3)};e2.onloadend=function(){e2.destroy()};e2.bind("RuntimeError",function(e4,e3){eZ.trigger("RuntimeError",e3)});e2.send(null,e0)}}eE.MAX_RESIZE_WIDTH=6500;eE.MAX_RESIZE_HEIGHT=6500;eE.prototype=eT.instance;return eE});eD("moxie/runtime/html5/Runtime",["moxie/core/utils/Basic","moxie/core/Exceptions","moxie/runtime/Runtime","moxie/core/utils/Env"],function(eJ,eE,eG,eF){var eI="html5",eH={};function eK(eM){var eL=this,eP=eG.capTest,eO=eG.capTrue;var eN=eJ.extend({access_binary:eP(window.FileReader||window.File&&window.File.getAsDataURL),access_image_binary:function(){return eL.can("access_binary")&&!!eH.Image},display_media:eP(eF.can("create_canvas")||eF.can("use_data_uri_over32kb")),do_cors:eP(window.XMLHttpRequest&&"withCredentials" in new XMLHttpRequest()),drag_and_drop:eP(function(){var eQ=document.createElement("div");return(("draggable" in eQ)||("ondragstart" in eQ&&"ondrop" in eQ))&&(eF.browser!=="IE"||eF.version>9)}()),filter_by_extension:eP(function(){return(eF.browser==="Chrome"&&eF.version>=28)||(eF.browser==="IE"&&eF.version>=10)}()),return_response_headers:eO,return_response_type:function(eQ){if(eQ==="json"){return true}else{return eF.can("return_response_type",eQ)}},return_status_code:eO,report_upload_progress:eP(window.XMLHttpRequest&&new XMLHttpRequest().upload),resize_image:function(){return eL.can("access_binary")&&eF.can("create_canvas")},select_file:function(){return eF.can("use_fileinput")&&window.File},select_folder:function(){return eL.can("select_file")&&eF.browser==="Chrome"&&eF.version>=21},select_multiple:function(){return eL.can("select_file")&&!(eF.browser==="Safari"&&eF.OS==="Windows")},send_binary_string:eP(window.XMLHttpRequest&&(new XMLHttpRequest().sendAsBinary||(window.Uint8Array&&window.ArrayBuffer))),send_custom_headers:eP(window.XMLHttpRequest),send_multipart:function(){return !!(window.XMLHttpRequest&&new XMLHttpRequest().upload&&window.FormData)||eL.can("send_binary_string")},slice_blob:eP(window.File&&(File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice)),stream_upload:function(){return eL.can("slice_blob")&&eL.can("send_multipart")},summon_file_dialog:eP(function(){return(eF.browser==="Firefox"&&eF.version>=4)||(eF.browser==="Opera"&&eF.version>=12)||(eF.browser==="IE"&&eF.version>=10)||!!~eJ.inArray(eF.browser,["Chrome","Safari"])}()),upload_filesize:eO},arguments[2]);eG.call(this,eM,(arguments[1]||eI),eN);eJ.extend(this,{init:function(){this.trigger("Init")},destroy:(function(eQ){return function(){eQ.call(eL);eQ=eL=null}}(this.destroy))});eJ.extend(this.getShim(),eH)}eG.addConstructor(eI,eK);return eH});eD("moxie/runtime/html5/file/Blob",["moxie/runtime/html5/Runtime","moxie/file/Blob"],function(eF,eG){function eE(){function eH(eJ,eM,eI){var eK;if(window.File.prototype.slice){try{eJ.slice();return eJ.slice(eM,eI)}catch(eL){return eJ.slice(eM,eI-eM)}}else{if((eK=window.File.prototype.webkitSlice||window.File.prototype.mozSlice)){return eK.call(eJ,eM,eI)}else{return null}}}this.slice=function(){return new eG(this.getRuntime().uid,eH.apply(this,arguments))}}return(eF.Blob=eE)});eD("moxie/core/utils/Events",["moxie/core/utils/Basic"],function(eK){var eL={},eH="moxie_"+eK.guid();function eG(){this.returnValue=false}function eF(){this.cancelBubble=true}var eI=function(eQ,eM,eR,eO){var eP,eN;eM=eM.toLowerCase();if(eQ.addEventListener){eP=eR;eQ.addEventListener(eM,eP,false)}else{if(eQ.attachEvent){eP=function(){var eS=window.event;if(!eS.target){eS.target=eS.srcElement}eS.preventDefault=eG;eS.stopPropagation=eF;eR(eS)};eQ.attachEvent("on"+eM,eP)}}if(!eQ[eH]){eQ[eH]=eK.guid()}if(!eL.hasOwnProperty(eQ[eH])){eL[eQ[eH]]={}}eN=eL[eQ[eH]];if(!eN.hasOwnProperty(eM)){eN[eM]=[]}eN[eM].push({func:eP,orig:eR,key:eO})};var eJ=function(eR,eM,eS){var eP,eO;eM=eM.toLowerCase();if(eR[eH]&&eL[eR[eH]]&&eL[eR[eH]][eM]){eP=eL[eR[eH]][eM]}else{return}for(var eN=eP.length-1;eN>=0;eN--){if(eP[eN].orig===eS||eP[eN].key===eS){if(eR.removeEventListener){eR.removeEventListener(eM,eP[eN].func,false)}else{if(eR.detachEvent){eR.detachEvent("on"+eM,eP[eN].func)}}eP[eN].orig=null;eP[eN].func=null;eP.splice(eN,1);if(eS!==eO){break}}}if(!eP.length){delete eL[eR[eH]][eM]}if(eK.isEmptyObj(eL[eR[eH]])){delete eL[eR[eH]];try{delete eR[eH]}catch(eQ){eR[eH]=eO}}};var eE=function(eN,eM){if(!eN||!eN[eH]){return}eK.each(eL[eN[eH]],function(eP,eO){eJ(eN,eO,eM)})};return{addEvent:eI,removeEvent:eJ,removeAllEvents:eE}});eD("moxie/runtime/html5/file/FileInput",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(eI,eK,eH,eF,eG,eE){function eJ(){var eM=[],eL;eK.extend(this,{init:function(eW){var eN=this,eU=eN.getRuntime(),eT,eP,eQ,eV,eS,eR;eL=eW;eM=[];eQ=eL.accept.mimes||eG.extList2mimes(eL.accept,eU.can("filter_by_extension"));eP=eU.getShimContainer();eP.innerHTML='";eT=eH.get(eU.uid);eK.extend(eT.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"});eV=eH.get(eL.browse_button);if(eU.can("summon_file_dialog")){if(eH.getStyle(eV,"position")==="static"){eV.style.position="relative"}eS=parseInt(eH.getStyle(eV,"z-index"),10)||1;eV.style.zIndex=eS;eP.style.zIndex=eS-1;eF.addEvent(eV,"click",function(eY){var eX=eH.get(eU.uid);if(eX&&!eX.disabled){eX.click()}eY.preventDefault()},eN.uid)}eR=eU.can("summon_file_dialog")?eV:eP;eF.addEvent(eR,"mouseover",function(){eN.trigger("mouseenter")},eN.uid);eF.addEvent(eR,"mouseout",function(){eN.trigger("mouseleave")},eN.uid);eF.addEvent(eR,"mousedown",function(){eN.trigger("mousedown")},eN.uid);eF.addEvent(eH.get(eL.container),"mouseup",function(){eN.trigger("mouseup")},eN.uid);eT.onchange=function eO(){eM=[];if(eL.directory){eK.each(this.files,function(eY){if(eY.name!=="."){eM.push(eY)}})}else{eM=[].slice.call(this.files)}if(eE.browser!=="IE"){this.value=""}else{var eX=this.cloneNode(true);this.parentNode.replaceChild(eX,this);eX.onchange=eO}eN.trigger("change")};eN.trigger({type:"ready",async:true});eP=null},getFiles:function(){return eM},disable:function(eP){var eO=this.getRuntime(),eN;if((eN=eH.get(eO.uid))){eN.disabled=!!eP}},destroy:function(){var eO=this.getRuntime(),eN=eO.getShimContainer();eF.removeAllEvents(eN,this.uid);eF.removeAllEvents(eL&&eH.get(eL.container),this.uid);eF.removeAllEvents(eL&&eH.get(eL.browse_button),this.uid);if(eN){eN.innerHTML=""}eM=eL=null}})}return(eI.FileInput=eJ)});eD("moxie/runtime/html5/file/FileDrop",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime"],function(eH,eI,eG,eE,eF){function eJ(){var eM=[],eP=[],eL;eI.extend(this,{init:function(eT){var eS=this,eU;eL=eT;eP=eN(eL.accept);eU=eL.container;eE.addEvent(eU,"dragover",function(eV){eV.preventDefault();eV.stopPropagation();eV.dataTransfer.dropEffect="copy"},eS.uid);eE.addEvent(eU,"drop",function(eW){eW.preventDefault();eW.stopPropagation();eM=[];if(eW.dataTransfer.items&&eW.dataTransfer.items[0].webkitGetAsEntry){var eV=[];eI.each(eW.dataTransfer.items,function(eX){eV.push(eX.webkitGetAsEntry())});eQ(eV,function(){eS.trigger("drop")})}else{eI.each(eW.dataTransfer.files,function(eX){if(eK(eX)){eM.push(eX)}});eS.trigger("drop")}},eS.uid);eE.addEvent(eU,"dragenter",function(eV){eV.preventDefault();eV.stopPropagation();eS.trigger("dragenter")},eS.uid);eE.addEvent(eU,"dragleave",function(eV){eV.preventDefault();eV.stopPropagation();eS.trigger("dragleave")},eS.uid)},getFiles:function(){return eM},destroy:function(){eE.removeAllEvents(eL&&eG.get(eL.container),this.uid);eM=eP=eL=null}});function eN(eU){var eT=[];for(var eS=0;eS=4&&eJ.version<7),eV=eJ.browser==="Android Browser",e0=false;eS=e2.url.replace(/^.+?\/([\w\-\.]+)$/,"$1").toLowerCase();eU=eT();eU.open(e2.method,e2.url,e2.async,e2.user,e2.password);if(eZ instanceof eH){if(eZ.isDetached()){e0=true}eZ=eZ.getSource()}else{if(eZ instanceof eO){if(eZ.hasBlob()){if(eZ.getBlob().isDetached()){eZ=eR.call(e1,eZ);e0=true}else{if((eY||eV)&&eF.typeOf(eZ.getBlob().getSource())==="blob"&&window.FileReader){eP.call(e1,e2,eZ);return}}}if(eZ instanceof eO){var eX=new window.FormData();eZ.each(function(e4,e3){if(e4 instanceof eH){eX.append(e3,e4.getSource())}else{eX.append(e3,e4)}});eZ=eX}}}if(eU.upload){if(e2.withCredentials){eU.withCredentials=true}eU.addEventListener("load",function(e3){e1.trigger(e3)});eU.addEventListener("error",function(e3){e1.trigger(e3)});eU.addEventListener("progress",function(e3){e1.trigger(e3)});eU.upload.addEventListener("progress",function(e3){e1.trigger({type:"UploadProgress",loaded:e3.loaded,total:e3.total})})}else{eU.onreadystatechange=function eW(){switch(eU.readyState){case 1:break;case 2:break;case 3:var e5,e3;try{if(eE.hasSameOrigin(e2.url)){e5=eU.getResponseHeader("Content-Length")||0}if(eU.responseText){e3=eU.responseText.length}}catch(e4){e5=e3=0}e1.trigger({type:"progress",lengthComputable:!!e5,total:parseInt(e5,10),loaded:e3});break;case 4:eU.onreadystatechange=function(){};if(eU.status===0){e1.trigger("error")}else{e1.trigger("load")}break}}}if(!eF.isEmptyObj(e2.headers)){eF.each(e2.headers,function(e3,e4){eU.setRequestHeader(e4,e3)})}if(""!==e2.responseType&&"responseType" in eU){if("json"===e2.responseType&&!eJ.can("return_response_type","json")){eU.responseType="text"}else{eU.responseType=e2.responseType}}if(!e0){eU.send(eZ)}else{if(eU.sendAsBinary){eU.sendAsBinary(eZ)}else{(function(){var e3=new Uint8Array(eZ.length);for(var e4=0;e4>Math.abs(eJ+eM*8))&255)}eE(eO,eK,eN)}return{II:function(eJ){if(eJ===eC){return eH}else{eH=eJ}},init:function(eJ){eH=false;eF=eJ},SEGMENT:function(eJ,eL,eK){switch(arguments.length){case 1:return eF.substr(eJ,eF.length-eJ-1);case 2:return eF.substr(eJ,eL);case 3:eE(eK,eJ,eL);break;default:return eF}},BYTE:function(eJ){return eI(eJ,1)},SHORT:function(eJ){return eI(eJ,2)},LONG:function(eJ,eK){if(eK===eC){return eI(eJ,4)}else{eG(eJ,eK,4)}},SLONG:function(eJ){var eK=eI(eJ,4);return(eK>2147483647?eK-4294967296:eK)},STRING:function(eJ,eK){var eL="";for(eK+=eJ;eJ=65488&&eH<=65495){eG+=2;continue}if(eH===65498||eH===65497){break}eI=eJ.SHORT(eG+2)+2;if(eH>=65505&&eH<=65519){eL.push({hex:eH,name:"APP"+(eH&15),start:eG,length:eI,segment:eJ.SEGMENT(eG,eI)})}eG+=eI}eJ.init(null);return{headers:eL,restore:function(eO){var eM,eN;eJ.init(eO);eG=eJ.SHORT(2)==65504?4+eJ.SHORT(4):2;for(eN=0,eM=eL.length;eN=eR.length){break}}},purge:function(){eL=[];eJ.init(null);eJ=null}}}});eD("moxie/runtime/html5/image/ExifParser",["moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(eG,eF){return function eE(){var eL,eI,eH,eJ={},eO;eL=new eF();eI={tiff:{274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},exif:{36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},gps:{0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"}};eO={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire.",1:"Flash fired.",5:"Strobe return light not detected.",7:"Strobe return light detected.",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}};function eK(eP,eX){var eR=eL.SHORT(eP),eU,e0,e1,eW,eV,eQ,eS,eY,eZ=[],eT={};for(eU=0;eU4){eS=eL.LONG(eS)+eJ.tiffHeader}for(e0=0;e04){eS=eL.LONG(eS)+eJ.tiffHeader}eT[e1]=eL.STRING(eS,eV-1);continue;case 3:if(eV>2){eS=eL.LONG(eS)+eJ.tiffHeader}for(e0=0;e01){eS=eL.LONG(eS)+eJ.tiffHeader}for(e0=0;e0=65472&&eU<=65475){eT+=5;return{height:eN.SHORT(eT),width:eN.SHORT(eT+=2)}}eV=eN.SHORT(eT+=2);eT+=eV-2}return null}eL=eS;eN=new eI();eN.init(eL);if(eN.SHORT(0)!==65496){throw new eE.ImageError(eE.ImageError.WRONG_FORMAT)}eP=new eG(eS);eO=new eF();eK=!!eO.init(eP.get("app1")[0]);eR=eQ.call(this);eJ.extend(this,{type:"image/jpeg",size:eL.length,width:eR&&eR.width||0,height:eR&&eR.height||0,setExif:function(eT,eU){if(!eK){return false}if(eJ.typeOf(eT)==="object"){eJ.each(eT,function(eW,eV){eO.setExif(eV,eW)})}else{eO.setExif(eT,eU)}eP.set("app1",eO.getBinary())},writeHeaders:function(){if(!arguments.length){return(eL=eP.restore(eL))}return eP.restore(arguments[0])},stripHeaders:function(eT){return eP.strip(eT)},purge:function(){eM.call(this)}});if(eK){this.meta={tiff:eO.TIFF(),exif:eO.EXIF(),gps:eO.GPS()}}function eM(){if(!eO||!eP||!eN){return}eO.purge();eP.purge();eN.init(null);eL=eR=eP=eO=eN=null}}return eH});eD("moxie/runtime/html5/image/PNG",["moxie/core/Exceptions","moxie/core/utils/Basic","moxie/runtime/html5/utils/BinaryReader"],function(eE,eH,eG){function eF(eQ){var eJ,eL,eN,eM,eP;eJ=eQ;eL=new eG();eL.init(eJ);(function(){var eR=0,eT=0,eS=[35152,20039,3338,6666];for(eT=0;eTeR?eR-eS:e0;var eU=0;while(eUeL?eL-eU:e0;eK.clearRect(0,0,e0,e0);eK.drawImage(e2,-eU,-eS);var eP=(eU*eW/eL+eN)<<0;var eQ=Math.ceil(eV*eW/eL);var eO=(eS*eT/eR/eY+eM)<<0;var eZ=Math.ceil(e1*eT/eR/eY);eX.drawImage(eH,0,0,eV,e1,eP,eO,eQ,eZ);eU+=e0}eS+=e0}eH=eK=null}function eF(eJ){var eI=eJ.naturalWidth,eL=eJ.naturalHeight;if(eI*eL>1024*1024){var eK=document.createElement("canvas");eK.width=eK.height=1;var eH=eK.getContext("2d");eH.drawImage(eJ,-eI+1,0);return eH.getImageData(0,0,1,1).data[3]===0}else{return false}}function eG(eL,eI,eQ){var eH=document.createElement("canvas");eH.width=1;eH.height=eQ;var eR=eH.getContext("2d");eR.drawImage(eL,0,0);var eK=eR.getImageData(0,0,1,eQ).data;var eO=0;var eM=eQ;var eP=eQ;while(eP>eO){var eJ=eK[(eP-1)*4+3];if(eJ===0){eM=eP}else{eO=eP}eP=(eM+eO)>>1}eH=null;var eN=(eP/eQ);return(eN===0)?1:eN}return{isSubsampled:eF,renderTo:eE}});eD("moxie/runtime/html5/image/Image",["moxie/runtime/html5/Runtime","moxie/core/utils/Basic","moxie/core/Exceptions","moxie/core/utils/Encode","moxie/file/Blob","moxie/runtime/html5/image/ImageInfo","moxie/runtime/html5/image/MegaPixel","moxie/core/utils/Mime","moxie/core/utils/Env"],function(eK,eE,eL,eH,eF,eN,eM,eG,eI){function eJ(){var eY=this,eX,e2,eW,eS,e0,e4=false,eP=true;eE.extend(this,{loadFromBlob:function(e7){var e6=this,e8=e6.getRuntime(),e5=arguments.length>1?arguments[1]:true;if(!e8.can("access_binary")){throw new eL.RuntimeError(eL.RuntimeError.NOT_SUPPORTED_ERR)}e0=e7;if(e7.isDetached()){eS=e7.getSource();eV.call(this,eS);return}else{e1.call(this,e7.getSource(),function(e9){if(e5){eS=e3(e9)}eV.call(e6,e9)})}},loadFromImage:function(e5,e6){this.meta=e5.meta;e0=new eF(null,{name:e5.name,size:e5.size,type:e5.type});eV.call(this,e6?(eS=e5.getAsBinaryString()):e5.getAsDataURL())},getInfo:function(){var e5=this.getRuntime(),e6;if(!e2&&eS&&e5.can("access_image_binary")){e2=new eN(eS)}e6={width:eT().width||0,height:eT().height||0,type:e0.type||eG.getFileMime(e0.name),size:eS&&eS.length||e0.size||0,name:e0.name||"",meta:e2&&e2.meta||this.meta||{}};return e6},downsize:function(){eO.apply(this,arguments)},getAsCanvas:function(){if(eW){eW.id=this.uid+"_canvas"}return eW},getAsBlob:function(e5,e6){if(e5!==this.type){eO.call(this,this.width,this.height,false)}return new eF(null,{type:e5,data:eY.getAsBinaryString.call(this,e5,e6)})},getAsDataURL:function(e6){var e7=arguments[1]||90;if(!e4){return eX.src}if("image/jpeg"!==e6){return eW.toDataURL("image/png")}else{try{return eW.toDataURL("image/jpeg",e7/100)}catch(e5){return eW.toDataURL("image/jpeg")}}},getAsBinaryString:function(e6,e8){if(!e4){if(!eS){eS=e3(eY.getAsDataURL(e6,e8))}return eS}if("image/jpeg"!==e6){eS=e3(eY.getAsDataURL(e6,e8))}else{var e7;if(!e8){e8=90}try{e7=eW.toDataURL("image/jpeg",e8/100)}catch(e5){e7=eW.toDataURL("image/jpeg")}eS=e3(e7);if(e2){eS=e2.stripHeaders(eS);if(eP){if(e2.meta&&e2.meta.exif){e2.setExif({PixelXDimension:this.width,PixelYDimension:this.height})}eS=e2.writeHeaders(eS)}e2.purge();e2=null}}e4=false;return eS},destroy:function(){eY=null;eQ.call(this);this.getRuntime().getShim().removeInstance(this.uid)}});function eT(){if(!eW&&!eX){throw new eL.ImageError(eL.DOMException.INVALID_STATE_ERR)}return eW||eX}function e3(e5){return eH.atob(e5.substring(e5.indexOf("base64,")+7))}function eZ(e6,e5){return"data:"+(e5||"")+";base64,"+eH.btoa(e6)}function eV(e6){var e5=this;eX=new Image();eX.onerror=function(){eQ.call(this);e5.trigger("error",new eL.ImageError(eL.ImageError.WRONG_FORMAT))};eX.onload=function(){e5.trigger("load")};eX.src=/^data:[^;]*;base64,/.test(e6)?e6:eZ(e6,e0.type)}function e1(e7,e8){var e6=this,e5;if(window.FileReader){e5=new FileReader();e5.onload=function(){e8(this.result)};e5.onerror=function(){e6.trigger("error",new eL.FileException(eL.FileException.NOT_READABLE_ERR))};e5.readAsDataURL(e7)}else{return e8(e7.getAsDataURL())}}function eO(e6,fh,fa,ff){var fi=this,fj,e8,e7,fe,fd,e9,fc,fb,e5;eP=ff;e5=(this.meta&&this.meta.tiff&&this.meta.tiff.Orientation)||1;if(eE.inArray(e5,[5,6,7,8])!==-1){var fg=e6;e6=fh;fh=fg}e9=eT();e7=!fa?Math.min:Math.max;e8=e7(e6/e9.width,fh/e9.height);if(e8>1&&(!fa||ff)){this.trigger("Resize");return}fc=Math.round(e9.width*e8);fb=Math.round(e9.height*e8);if(!eW){eW=document.createElement("canvas")}fj=eW.getContext("2d");if(fa){eW.width=e6;eW.height=fh}else{eW.width=fc;eW.height=fb}fe=fc>eW.width?Math.round((fc-eW.width)/2):0;fd=fb>eW.height?Math.round((fb-eW.height)/2):0;if(!eP){eU(eW.width,eW.height,e5)}eR.call(this,e9,eW,-fe,-fd,fc,fb);this.width=eW.width;this.height=eW.height;e4=true;fi.trigger("Resize")}function eR(e8,e9,e5,fb,e7,fa){if(eI.OS==="iOS"){eM.renderTo(e8,e9,{width:e7,height:fa,x:e5,y:fb})}else{var e6=e9.getContext("2d");e6.drawImage(e8,e5,fb,e7,fa)}}function eU(e8,e5,e7){switch(e7){case 5:case 6:case 7:case 8:eW.width=e5;eW.height=e8;break;default:eW.width=e8;eW.height=e5}var e6=eW.getContext("2d");switch(e7){case 2:e6.translate(e8,0);e6.scale(-1,1);break;case 3:e6.translate(e8,e5);e6.rotate(Math.PI);break;case 4:e6.translate(0,e5);e6.scale(1,-1);break;case 5:e6.rotate(0.5*Math.PI);e6.scale(1,-1);break;case 6:e6.rotate(0.5*Math.PI);e6.translate(0,-e5);break;case 7:e6.rotate(0.5*Math.PI);e6.translate(e8,-e5);e6.scale(-1,1);break;case 8:e6.rotate(-0.5*Math.PI);e6.translate(-e8,0);break}}function eQ(){if(e2){e2.purge();e2=null}eS=eX=eW=e0=null;e4=false}}return(eK.Image=eJ)});eD("moxie/runtime/flash/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(eF,eI,eG,eL,eE){var eJ="flash",eK={};function eH(){var eN;try{eN=navigator.plugins["Shockwave Flash"];eN=eN.description}catch(eP){try{eN=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(eO){eN="0.0"}}eN=eN.match(/\d+/g);return parseFloat(eN[0]+"."+eN[1])}function eM(eO){var eN=this,eP;eO=eF.extend({swf_url:eI.swf_url},eO);eE.call(this,eO,eJ,{access_binary:function(eQ){return eQ&&eN.mode==="browser"},access_image_binary:function(eQ){return eQ&&eN.mode==="browser"},display_media:eE.capTrue,do_cors:eE.capTrue,drag_and_drop:false,report_upload_progress:function(){return eN.mode==="client"},resize_image:eE.capTrue,return_response_headers:false,return_response_type:function(eQ){return !eF.arrayDiff(eQ,["","text","json","document"])||eN.mode==="browser"},return_status_code:function(eQ){return eN.mode==="browser"||!eF.arrayDiff(eQ,[200,404])},select_file:eE.capTrue,select_multiple:eE.capTrue,send_binary_string:function(eQ){return eQ&&eN.mode==="browser"},send_browser_cookies:function(eQ){return eQ&&eN.mode==="browser"},send_custom_headers:function(eQ){return eQ&&eN.mode==="browser"},send_multipart:eE.capTrue,slice_blob:eE.capTrue,stream_upload:function(eQ){return eQ&&eN.mode==="browser"},summon_file_dialog:false,upload_filesize:function(eQ){return eF.parseSizeStr(eQ)<=2097152||eN.mode==="client"},use_http_method:function(eQ){return !eF.arrayDiff(eQ,["GET","POST"])}},{access_binary:function(eQ){return eQ?"browser":"client"},access_image_binary:function(eQ){return eQ?"browser":"client"},report_upload_progress:function(eQ){return eQ?"browser":"client"},return_response_type:function(eQ){return eF.arrayDiff(eQ,["","text","json","document"])?"browser":["client","browser"]},return_status_code:function(eQ){return eF.arrayDiff(eQ,[200,404])?"browser":["client","browser"]},send_binary_string:function(eQ){return eQ?"browser":"client"},send_browser_cookies:function(eQ){return eQ?"browser":"client"},send_custom_headers:function(eQ){return eQ?"browser":"client"},stream_upload:function(eQ){return eQ?"client":"browser"},upload_filesize:function(eQ){return eF.parseSizeStr(eQ)>=2097152?"client":"browser"}},"client");if(eH()<10){this.mode=false}eF.extend(this,{getShim:function(){return eG.get(this.uid)},shimExec:function(eR,eS){var eQ=[].slice.call(arguments,2);return eN.getShim().exec(this.uid,eR,eS,eQ)},init:function(){var eR,eS,eQ;eQ=this.getShimContainer();eF.extend(eQ.style,{position:"absolute",top:"-8px",left:"-8px",width:"9px",height:"9px",overflow:"hidden"});eR='';if(eI.browser==="IE"){eS=document.createElement("div");eQ.appendChild(eS);eS.outerHTML=eR;eS=eQ=null}else{eQ.innerHTML=eR}eP=setTimeout(function(){if(eN&&!eN.initialized){eN.trigger("Error",new eL.RuntimeError(eL.RuntimeError.NOT_INIT_ERR))}},5000)},destroy:(function(eQ){return function(){eQ.call(eN);clearTimeout(eP);eO=eP=eQ=eN=null}}(this.destroy))},eK)}eE.addConstructor(eJ,eM);return eK});eD("moxie/runtime/flash/file/Blob",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(eF,eG){var eE={slice:function(eJ,eL,eH,eK){var eI=this.getRuntime();if(eL<0){eL=Math.max(eJ.size+eL,0)}else{if(eL>0){eL=Math.min(eL,eJ.size)}}if(eH<0){eH=Math.max(eJ.size+eH,0)}else{if(eH>0){eH=Math.min(eH,eJ.size)}}eJ=eI.shimExec.call(this,"Blob","slice",eL,eH,eK||"");if(eJ){eJ=new eG(eI.uid,eJ)}return eJ}};return(eF.Blob=eE)});eD("moxie/runtime/flash/file/FileInput",["moxie/runtime/flash/Runtime"],function(eE){var eF={init:function(eG){this.getRuntime().shimExec.call(this,"FileInput","init",{name:eG.name,accept:eG.accept,multiple:eG.multiple});this.trigger("ready")}};return(eE.FileInput=eF)});eD("moxie/runtime/flash/file/FileReader",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(eH,eE){var eF="";function eG(eJ,eK){switch(eK){case"readAsText":return eE.atob(eJ,"utf8");case"readAsBinaryString":return eE.atob(eJ);case"readAsDataURL":return eJ}return null}var eI={read:function(eM,eK){var eL=this,eJ=eL.getRuntime();if(eM==="readAsDataURL"){eF="data:"+(eK.type||"")+";base64,"}eL.bind("Progress",function(eO,eN){if(eN){eF+=eG(eN,eM)}});return eJ.shimExec.call(this,"FileReader","readAsBase64",eK.uid)},getResult:function(){return eF},destroy:function(){eF=null}};return(eH.FileReader=eI)});eD("moxie/runtime/flash/file/FileReaderSync",["moxie/runtime/flash/Runtime","moxie/core/utils/Encode"],function(eG,eE){function eF(eI,eJ){switch(eJ){case"readAsText":return eE.atob(eI,"utf8");case"readAsBinaryString":return eE.atob(eI);case"readAsDataURL":return eI}return null}var eH={read:function(eL,eK){var eI,eJ=this.getRuntime();eI=eJ.shimExec.call(this,"FileReaderSync","readAsBase64",eK.uid);if(!eI){return null}if(eL==="readAsDataURL"){eI="data:"+(eK.type||"")+";base64,"+eI}return eF(eI,eL,eK.type)}};return(eG.FileReaderSync=eH)});eD("moxie/runtime/flash/xhr/XMLHttpRequest",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/file/Blob","moxie/file/File","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/runtime/Transporter","moxie/core/JSON"],function(eK,eE,eG,eJ,eI,eM,eH,eF){var eL={send:function(eU,eP){var eR=this,eV=eR.getRuntime();function eO(){eU.transport=eV.mode;eV.shimExec.call(eR,"XMLHttpRequest","send",eU,eP)}function eQ(eX,eW){eV.shimExec.call(eR,"XMLHttpRequest","appendBlob",eX,eW.uid);eP=null;eO()}function eS(eX,eW){var eY=new eH();eY.bind("TransportingComplete",function(){eW(this.result)});eY.transport(eX.getSource(),eX.type,{ruid:eV.uid})}if(!eE.isEmptyObj(eU.headers)){eE.each(eU.headers,function(eW,eX){eV.shimExec.call(eR,"XMLHttpRequest","setRequestHeader",eX,eW.toString())})}if(eP instanceof eM){var eT;eP.each(function(eX,eW){if(eX instanceof eG){eT=eW}else{eV.shimExec.call(eR,"XMLHttpRequest","append",eW,eX)}});if(!eP.hasBlob()){eP=null;eO()}else{var eN=eP.getBlob();if(eN.isDetached()){eS(eN,function(eW){eN.destroy();eQ(eT,eW)})}else{eQ(eT,eN)}}}else{if(eP instanceof eG){if(eP.isDetached()){eS(eP,function(eW){eP.destroy();eP=eW.uid;eO()})}else{eP=eP.uid;eO()}}else{eO()}}},getResponse:function(eQ){var eN,eP,eO=this.getRuntime();eP=eO.shimExec.call(this,"XMLHttpRequest","getResponseAsBlob");if(eP){eP=new eJ(eO.uid,eP);if("blob"===eQ){return eP}else{if(!!~eE.inArray(eQ,["","text"])){eN=new eI();return eN.readAsText(eP)}else{if("arraybuffer"===eQ){}else{if("json"===eQ){eN=new eI();try{return eF(eN.readAsText(eP))}catch(eR){return null}}}}}}return null},abort:function(eO){var eN=this.getRuntime();eN.shimExec.call(this,"XMLHttpRequest","abort");this.dispatchEvent("readystatechange");this.dispatchEvent("abort");if(!eO){}}};return(eK.XMLHttpRequest=eL)});eD("moxie/runtime/flash/runtime/Transporter",["moxie/runtime/flash/Runtime","moxie/file/Blob"],function(eE,eG){var eF={getAsBlob:function(eJ){var eI=this.getRuntime(),eH=eI.shimExec.call(this,"Transporter","getAsBlob",eJ);if(eH){return new eG(eI.uid,eH)}return null}};return(eE.Transporter=eF)});eD("moxie/runtime/flash/image/Image",["moxie/runtime/flash/Runtime","moxie/core/utils/Basic","moxie/runtime/Transporter","moxie/file/Blob","moxie/file/FileReaderSync"],function(eF,eH,eG,eJ,eI){var eE={loadFromBlob:function(eN){var eM=this,eL=eM.getRuntime();function eK(eP){eL.shimExec.call(eM,"Image","loadFromBlob",eP.uid);eM=eL=null}if(eN.isDetached()){var eO=new eG();eO.bind("TransportingComplete",function(){eK(eO.result.getSource())});eO.transport(eN.getSource(),eN.type,{ruid:eL.uid})}else{eK(eN.getSource())}},loadFromImage:function(eL){var eK=this.getRuntime();return eK.shimExec.call(this,"Image","loadFromImage",eL.uid)},getAsBlob:function(eM,eN){var eL=this.getRuntime(),eK=eL.shimExec.call(this,"Image","getAsBlob",eM,eN);if(eK){return new eJ(eL.uid,eK)}return null},getAsDataURL:function(){var eM=this.getRuntime(),eL=eM.Image.getAsBlob.apply(this,arguments),eK;if(!eL){return null}eK=new eI();return eK.readAsDataURL(eL)}};return(eF.Image=eE)});eD("moxie/runtime/silverlight/Runtime",["moxie/core/utils/Basic","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/runtime/Runtime"],function(eF,eI,eH,eL,eE){var eJ="silverlight",eK={};function eM(eV){var eY=false,eR=null,eN,eO,eP,eX,eQ,eT=0;try{try{eR=new ActiveXObject("AgControl.AgControl");if(eR.IsVersionSupported(eV)){eY=true}eR=null}catch(eU){var eS=navigator.plugins["Silverlight Plug-In"];if(eS){eN=eS.description;if(eN==="1.0.30226.2"){eN="2.0.30226.2"}eO=eN.split(".");while(eO.length>3){eO.pop()}while(eO.length<4){eO.push(0)}eP=eV.split(".");while(eP.length>4){eP.pop()}do{eX=parseInt(eP[eT],10);eQ=parseInt(eO[eT],10);eT++}while(eT';eP=setTimeout(function(){if(eN&&!eN.initialized){eN.trigger("Error",new eL.RuntimeError(eL.RuntimeError.NOT_INIT_ERR))}},eI.OS!=="Windows"?10000:5000)},destroy:(function(eQ){return function(){eQ.call(eN);clearTimeout(eP);eO=eP=eQ=eN=null}}(this.destroy))},eK)}eE.addConstructor(eJ,eG);return eK});eD("moxie/runtime/silverlight/file/Blob",["moxie/runtime/silverlight/Runtime","moxie/core/utils/Basic","moxie/runtime/flash/file/Blob"],function(eE,eF,eG){return(eE.Blob=eF.extend({},eG))});eD("moxie/runtime/silverlight/file/FileInput",["moxie/runtime/silverlight/Runtime"],function(eE){var eF={init:function(eH){function eG(eJ){var eK="";for(var eI=0;eI=28)||(eG.browser==="IE"&&eG.version>=10)}()),resize_image:function(){return eI.Image&&eL.can("access_binary")&&eG.can("create_canvas")},report_upload_progress:false,return_response_headers:false,return_response_type:function(eP){return !!~eK.inArray(eP,["json","text","document",""])},return_status_code:function(eP){return !eK.arrayDiff(eP,[200,404])},select_file:function(){return eG.can("use_fileinput")},select_multiple:false,send_binary_string:false,send_custom_headers:false,send_multipart:true,slice_blob:false,stream_upload:function(){return eL.can("select_file")},summon_file_dialog:eO(function(){return(eG.browser==="Firefox"&&eG.version>=4)||(eG.browser==="Opera"&&eG.version>=12)||(eG.browser==="IE"&&eG.version>=10)||!!~eK.inArray(eG.browser,["Chrome","Safari"])}()),upload_filesize:eN,use_http_method:function(eP){return !eK.arrayDiff(eP,["GET","POST"])}});eK.extend(this,{init:function(){this.trigger("Init")},destroy:(function(eP){return function(){eP.call(eL);eP=eL=null}}(this.destroy))});eK.extend(this.getShim(),eI)}eH.addConstructor(eJ,eF);return eI});eD("moxie/runtime/html4/file/FileInput",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Events","moxie/core/utils/Mime","moxie/core/utils/Env"],function(eI,eK,eH,eF,eG,eE){function eJ(){var eO,eM=[],eP=[],eL;function eN(){var eS=this,eV=eS.getRuntime(),eU,eT,eQ,eX,eR,eW;eW=eK.guid("uid_");eU=eV.getShimContainer();if(eO){eQ=eH.get(eO+"_form");if(eQ){eK.extend(eQ.style,{top:"100%"})}}eX=document.createElement("form");eX.setAttribute("id",eW+"_form");eX.setAttribute("method","post");eX.setAttribute("enctype","multipart/form-data");eX.setAttribute("encoding","multipart/form-data");eK.extend(eX.style,{overflow:"hidden",position:"absolute",top:0,left:0,width:"100%",height:"100%"});eR=document.createElement("input");eR.setAttribute("id",eW);eR.setAttribute("type","file");eR.setAttribute("name","Filedata");eR.setAttribute("accept",eP.join(","));eK.extend(eR.style,{fontSize:"999px",opacity:0});eX.appendChild(eR);eU.appendChild(eX);eK.extend(eR.style,{position:"absolute",top:0,left:0,width:"100%",height:"100%"});if(eE.browser==="IE"&&eE.version<10){eK.extend(eR.style,{filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"})}eR.onchange=function(){var eY;if(!this.value){return}if(this.files){eY=this.files[0]}else{eY={name:this.value}}eM=[eY];this.onchange=function(){};eN.call(eS);eS.bind("change",function(){var eZ=eH.get(eW),e1=eH.get(eW+"_form"),e0;if(eS.files.length&&eZ&&e1){e0=eS.files[0];eZ.setAttribute("id",e0.uid);e1.setAttribute("id",e0.uid+"_form");e1.setAttribute("target",e0.uid+"_iframe")}eZ=e1=null},998);eR=eX=null;eS.trigger("change")};if(eV.can("summon_file_dialog")){eT=eH.get(eL.browse_button);eF.removeEvent(eT,"click",eS.uid);eF.addEvent(eT,"click",function(eY){if(eR&&!eR.disabled){eR.click()}eY.preventDefault()},eS.uid)}eO=eW;eU=eQ=eT=null;eS.trigger({type:"ready",async:true})}eK.extend(this,{init:function(eT){var eQ=this,eS=eQ.getRuntime(),eR;eL=eT;eP=eT.accept.mimes||eG.extList2mimes(eT.accept,eS.can("filter_by_extension"));eR=eS.getShimContainer();(function(){var eU,eW,eV;eU=eH.get(eT.browse_button);if(eS.can("summon_file_dialog")){if(eH.getStyle(eU,"position")==="static"){eU.style.position="relative"}eW=parseInt(eH.getStyle(eU,"z-index"),10)||1;eU.style.zIndex=eW;eR.style.zIndex=eW-1}eV=eS.can("summon_file_dialog")?eU:eR;eF.addEvent(eV,"mouseover",function(){eQ.trigger("mouseenter")},eQ.uid);eF.addEvent(eV,"mouseout",function(){eQ.trigger("mouseleave")},eQ.uid);eF.addEvent(eV,"mousedown",function(){eQ.trigger("mousedown")},eQ.uid);eF.addEvent(eH.get(eT.container),"mouseup",function(){eQ.trigger("mouseup")},eQ.uid);eU=null}());eN.call(this);eR=null},getFiles:function(){return eM},disable:function(eR){var eQ;if((eQ=eH.get(eO))){eQ.disabled=!!eR}},destroy:function(){var eR=this.getRuntime(),eQ=eR.getShimContainer();eF.removeAllEvents(eQ,this.uid);eF.removeAllEvents(eL&&eH.get(eL.container),this.uid);eF.removeAllEvents(eL&&eH.get(eL.browse_button),this.uid);if(eQ){eQ.innerHTML=""}eO=eM=eP=eL=null}})}return(eI.FileInput=eJ)});eD("moxie/runtime/html4/file/FileReader",["moxie/runtime/html4/Runtime","moxie/runtime/html5/file/FileReader"],function(eE,eF){return(eE.FileReader=eF)});eD("moxie/runtime/html4/xhr/XMLHttpRequest",["moxie/runtime/html4/Runtime","moxie/core/utils/Basic","moxie/core/utils/Dom","moxie/core/utils/Url","moxie/core/Exceptions","moxie/core/utils/Events","moxie/file/Blob","moxie/xhr/FormData","moxie/core/JSON"],function(eJ,eF,eI,eE,eK,eM,eH,eN,eG){function eL(){var eQ,eO,eR;function eP(eS){var eX=this,eV,eW,eT,eU,eY=false;if(!eR){return}eV=eR.id.replace(/_iframe$/,"");eW=eI.get(eV+"_form");if(eW){eT=eW.getElementsByTagName("input");eU=eT.length;while(eU--){switch(eT[eU].getAttribute("type")){case"hidden":eT[eU].parentNode.removeChild(eT[eU]);break;case"file":eY=true;break}}eT=[];if(!eY){eW.parentNode.removeChild(eW)}eW=null}setTimeout(function(){eM.removeEvent(eR,"load",eX.uid);if(eR.parentNode){eR.parentNode.removeChild(eR)}var eZ=eX.getRuntime().getShimContainer();if(!eZ.children.length){eZ.parentNode.removeChild(eZ)}eZ=eR=null;eS()},1)}eF.extend(this,{send:function(e0,eU){var eW=this,eZ=eW.getRuntime(),eV,eT,eY,eS;eQ=eO=null;function eX(){var e1=eZ.getShimContainer()||document.body,e2=document.createElement("div");e2.innerHTML='';eR=e2.firstChild;e1.appendChild(eR);eM.addEvent(eR,"load",function(){var e4;try{e4=eR.contentWindow.document||eR.contentDocument||window.frames[eR.id].document;if(/^4\d{2}\s/.test(e4.title)&&e4.getElementsByTagName("address").length){eQ=e4.title.replace(/^(\d+).*$/,"$1")}else{eQ=200;eO=eF.trim(e4.body.innerHTML);eW.trigger({type:"progress",loaded:eO.length,total:eO.length});if(eS){eW.trigger({type:"uploadprogress",loaded:eS.size||1025,total:eS.size||1025})}}}catch(e3){if(eE.hasSameOrigin(e0.url)){eQ=404}else{eP.call(eW,function(){eW.trigger("error")});return}}eP.call(eW,function(){eW.trigger("load")})},eW.uid)}if(eU instanceof eN&&eU.hasBlob()){eS=eU.getBlob();eV=eS.uid;eY=eI.get(eV);eT=eI.get(eV+"_form");if(!eT){throw new eK.DOMException(eK.DOMException.NOT_FOUND_ERR)}}else{eV=eF.guid("uid_");eT=document.createElement("form");eT.setAttribute("id",eV+"_form");eT.setAttribute("method",e0.method);eT.setAttribute("enctype","multipart/form-data");eT.setAttribute("encoding","multipart/form-data");eT.setAttribute("target",eV+"_iframe");eZ.getShimContainer().appendChild(eT)}if(eU instanceof eN){eU.each(function(e3,e1){if(e3 instanceof eH){if(eY){eY.setAttribute("name",e1)}}else{var e2=document.createElement("input");eF.extend(e2,{type:"hidden",name:e1,value:e3});eT.appendChild(e2)}})}eT.setAttribute("action",e0.url);eX();eT.submit();eW.trigger("loadstart")},getStatus:function(){return eQ},getResponse:function(eS){if("json"===eS){if(eF.typeOf(eO)==="string"){try{return eG(eO.replace(/^\s*]*>/,"").replace(/<\/pre>\s*$/,""))}catch(eT){return null}}}else{if("document"===eS){}}return eO},abort:function(){var eS=this;if(eR&&eR.contentWindow){if(eR.contentWindow.stop){eR.contentWindow.stop()}else{if(eR.contentWindow.document.execCommand){eR.contentWindow.document.execCommand("Stop")}else{eR.src="about:blank"}}}eP.call(this,function(){eS.dispatchEvent("abort")})}})}return(eJ.XMLHttpRequest=eL)});eD("moxie/runtime/html4/image/Image",["moxie/runtime/html4/Runtime","moxie/runtime/html5/image/Image"],function(eF,eE){return(eF.Image=eE)});T(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/file/FileDrop","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/core/JSON","moxie/image/Image","moxie/core/utils/Events"])})(this);(function(){var ey={},ex=moxie.core.utils.Basic.inArray;(function T(eA){var ez,eB;for(ez in eA){eB=typeof(eA[ez]);if(eB==="object"&&!~ex(ez,["Exceptions","Env","Mime"])){T(eA[ez])}else{if(eB==="function"){ey[ez]=eA[ez]}}}})(window.moxie);ey.Env=window.moxie.core.utils.Env;ey.Mime=window.moxie.core.utils.Mime;ey.Exceptions=window.moxie.core.Exceptions;window.mOxie=ey;if(!window.o){window.o=ey}return ey})();(function(eA,eC,ez){var ey=eA.setTimeout,eB={};function T(eE){var eD=eE.required_features,eF={};function eG(eI,eJ,eH){var eK={chunks:"slice_blob",resize:"send_binary_string",jpgresize:"send_binary_string",pngresize:"send_binary_string",progress:"report_upload_progress",multi_selection:"select_multiple",max_file_size:"access_binary",dragdrop:"drag_and_drop",drop_element:"drag_and_drop",headers:"send_custom_headers",canSendBinary:"send_binary",triggerDialog:"summon_file_dialog"};if(eK[eI]){eF[eK[eI]]=eJ}else{if(!eH){eF[eI]=eJ}}}if(typeof(eD)==="string"){ex.each(eD.split(/\s*,\s*/),function(eH){eG(eH,true)})}else{if(typeof(eD)==="object"){ex.each(eD,function(eI,eH){eG(eH,eI)})}else{if(eD===true){if(!eE.multipart){eF.send_binary_string=true}if(eE.chunk_size>0){eF.slice_blob=true}ex.each(eE,function(eI,eH){eG(eH,!!eI,true)})}}}return eF}var ex={VERSION:"2.0.0beta",STOPPED:1,STARTED:2,QUEUED:1,UPLOADING:2,FAILED:4,DONE:5,GENERIC_ERROR:-100,HTTP_ERROR:-200,IO_ERROR:-300,SECURITY_ERROR:-400,INIT_ERROR:-500,FILE_SIZE_ERROR:-600,FILE_EXTENSION_ERROR:-601,FILE_DUPLICATE_ERROR:-602,IMAGE_FORMAT_ERROR:-700,IMAGE_MEMORY_ERROR:-701,IMAGE_DIMENSIONS_ERROR:-702,mimeTypes:eC.mimes,ua:eC.ua,typeOf:eC.typeOf,extend:eC.extend,guid:eC.guid,each:eC.each,getPos:eC.getPos,getSize:eC.getSize,xmlEncode:function(eE){var eF={"<":"lt",">":"gt","&":"amp",'"':"quot","'":"#39"},eD=/[<>&\"\']/g;return eE?(""+eE).replace(eD,function(eG){return eF[eG]?"&"+eF[eG]+";":eG}):eE},toArray:eC.toArray,inArray:eC.inArray,addI18n:eC.addI18n,translate:eC.translate,isEmptyObj:eC.isEmptyObj,hasClass:eC.hasClass,addClass:eC.addClass,removeClass:eC.removeClass,getStyle:eC.getStyle,addEvent:eC.addEvent,removeEvent:eC.removeEvent,removeAllEvents:eC.removeAllEvents,cleanName:function(eD){var eE,eF;eF=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"];for(eE=0;eE0?"&":"?")+eF}return eE},formatSize:function(eD){if(eD===ez||/\D/.test(eD)){return ex.translate("N/A")}if(eD>1099511627776){return Math.round(eD/1099511627776,1)+" "+ex.translate("tb")}if(eD>1073741824){return Math.round(eD/1073741824,1)+" "+ex.translate("gb")}if(eD>1048576){return Math.round(eD/1048576,1)+" "+ex.translate("mb")}if(eD>1024){return Math.round(eD/1024,1)+" "+ex.translate("kb")}return eD+" "+ex.translate("b")},parseSize:eC.parseSizeStr,predictRuntime:function(eF,eE){var eD,eG;if(eE){eF.runtimes=eE}eD=new ex.Uploader(eF);eG=eD.runtime;eD.destroy();return eG},addFileFilter:function(eE,eD){eB[eE]=eD}};ex.addFileFilter("mime_types",(function(){var eE,eF;function eD(eG){var eH=[];ex.each(eG,function(eI){ex.each(eI.extensions.split(/,/),function(eJ){if(/^\s*\*\s*$/.test(eJ)){eH.push("\\.*")}else{eH.push("\\."+eJ.replace(new RegExp("["+("/^$.*+?|()[]{}\\".replace(/./g,"\\$&"))+"]","g"),"\\$&"))}})});return new RegExp("("+eH.join("|")+")$","i")}return function(eI,eH,eG){if(!eF||eI!=eE){eF=eD(eI);eE=[].slice.call(eI)}if(!eF.test(eH.name)){this.trigger("Error",{code:ex.FILE_EXTENSION_ERROR,message:ex.translate("File extension error."),file:eH});eG(false)}else{eG(true)}}}()));ex.addFileFilter("max_file_size",function(eG,eE,eD){var eF;if(eE.size!==eF&&eG&&eE.size>eG){this.trigger("Error",{code:ex.FILE_SIZE_ERROR,message:ex.translate("File size error."),file:eE});eD(false)}else{eD(true)}});ex.addFileFilter("prevent_duplicates",function(eG,eE,eD){if(eG){var eF=this.files.length;while(eF--){if(eE.name===this.files[eF].name&&eE.size===this.files[eF].size){this.trigger("Error",{code:ex.FILE_DUPLICATE_ERROR,message:ex.translate("Duplicate file error."),file:eE});eD(false);return}}}eD(true)});ex.Uploader=function(eH){var eE=[],eR={},eO={},eG,eM,eJ=false,eK,eL,eQ;function eF(){var eU,eV=0,eT;if(this.state==ex.STARTED){for(eT=0;eT0?Math.ceil(eT.loaded/eT.size*100):100;eI()}function eI(){var eU,eT;eM.reset();for(eU=0;eU0?Math.ceil(eM.uploaded/eE.length*100):0}else{eM.bytesPerSec=Math.ceil(eM.loaded/((+new Date()-eG||1)/1000));eM.percent=eM.size>0?Math.ceil(eM.loaded/eM.size*100):0}}function eD(){var eT=this,eV=0;var eU={accept:eH.filters.mime_types,runtime_order:eH.runtimes,required_caps:eO,swf_url:eH.flash_swf_url,xap_url:eH.silverlight_xap_url};ex.each(eH.runtimes.split(/\s*,\s*/),function(eW){if(eH[eW]){eU[eW]=eH[eW]}});eC.inSeries([function(eW){if(eH.browse_button){eK=new eC.FileInput(ex.extend({},eU,{name:eH.file_data_name,multiple:eH.multi_selection,container:eH.container,browse_button:eH.browse_button}));eK.onready=function(){var eX=eC.Runtime.getInfo(this.ruid);eC.extend(eT.features,{chunks:eX.can("slice_blob"),multipart:eX.can("send_multipart"),multi_selection:eX.can("select_multiple")});eV++;eW()};eK.onchange=function(){eT.addFile(this.files)};eK.bind("mouseenter mouseleave mousedown mouseup",function(eY){if(!eJ){var eX=eC.get(eH.browse_button);if(eX){if(eH.browse_button_hover){if("mouseenter"===eY.type){eC.addClass(eX,eH.browse_button_hover)}else{if("mouseleave"===eY.type){eC.removeClass(eX,eH.browse_button_hover)}}}if(eH.browse_button_active){if("mousedown"===eY.type){eC.addClass(eX,eH.browse_button_active)}else{if("mouseup"===eY.type){eC.removeClass(eX,eH.browse_button_active)}}}eX=null}}});eK.bind("error runtimeerror",function(){eK=null;eW()});eK.init()}else{eW()}},function(eW){if(eH.drop_element){eL=new eC.FileDrop(ex.extend({},eU,{drop_zone:eH.drop_element}));eL.onready=function(){var eX=eC.Runtime.getInfo(this.ruid);eT.features.dragdrop=eX.can("drag_and_drop");eV++;eW()};eL.ondrop=function(){eT.addFile(this.files)};eL.bind("error runtimeerror",function(){eL=null;eW()});eL.init()}else{eW()}}],function(){if(typeof(eH.init)=="function"){eH.init(eT)}else{ex.each(eH.init,function(eX,eW){eT.bind(eW,eX)})}if(eV){eT.trigger("PostInit")}else{eT.trigger("Error",{code:ex.INIT_ERROR,message:ex.translate("Init error.")})}})}function eS(eU,eT){if(eU.ruid){var eV=eC.Runtime.getInfo(eU.ruid);if(eV){return eV.can(eT)}}return false}function eN(eV,eX,eT){var eU=new eC.Image();try{eU.onload=function(){eU.downsize(eX.width,eX.height,eX.crop,eX.preserve_headers)};eU.onresize=function(){eT(this.getAsBlob(eV.type,eX.quality));this.destroy()};eU.onerror=function(){eT(eV)};eU.load(eV)}catch(eW){eT(eV)}}eM=new ex.QueueProgress();eH=ex.extend({runtimes:eC.Runtime.order,max_retries:0,multipart:true,multi_selection:true,file_data_name:"file",flash_swf_url:"js/Moxie.swf",silverlight_xap_url:"js/Moxie.xap",send_chunk_number:true},eH);if(eH.resize){eH.resize=ex.extend({preserve_headers:true,crop:false},eH.resize)}if(ex.typeOf(eH.filters)==="array"){eH.filters={mime_types:eH.filters}}eH.filters=ex.extend({mime_types:[],prevent_duplicates:!!eH.prevent_duplicates,max_file_size:eH.max_file_size},eH.filters);eH.filters.max_file_size=ex.parseSize(eH.filters.max_file_size)||0;eH.chunk_size=ex.parseSize(eH.chunk_size)||0;eH.required_features=eO=T(ex.extend({},eH));ex.extend(this,{id:ex.guid(),state:ex.STOPPED,features:{},runtime:eC.Runtime.thatCan(eO,eH.runtimes),files:eE,settings:eH,total:eM,init:function(){var eT=this;eH.browse_button=eC.get(eH.browse_button);eH.drop_element=eC.get(eH.drop_element);if(typeof(eH.preinit)=="function"){eH.preinit(eT)}else{ex.each(eH.preinit,function(eV,eU){eT.bind(eU,eV)})}if(!eH.browse_button||!eH.url){this.trigger("Error",{code:ex.INIT_ERROR,message:ex.translate("Init error.")});return}eT.bind("FilesAdded",function(eV,eU){[].push.apply(eE,eU);ey(function(){eT.trigger("QueueChanged");eT.refresh()},1)});eT.bind("CancelUpload",function(){if(eQ){eQ.abort()}});if(eH.unique_names){eT.bind("BeforeUpload",function(eU,eV){var eX=eV.name.match(/\.([^.]+)$/),eW="part";if(eX){eW=eX[1]}eV.target_name=eV.id+"."+eW})}eT.bind("UploadFile",function(e2,eZ){var eW=e2.settings.url,eX=e2.features,e0=eH.chunk_size,e3=eH.max_retries,eU,e1=0;if(eZ.loaded){e1=eZ.loaded=e0*Math.floor(eZ.loaded/e0)}function eY(){if(e3-->0){ey(eV,1)}else{eZ.loaded=e1;e2.trigger("Error",{code:ex.HTTP_ERROR,message:ex.translate("HTTP Error."),file:eZ,response:eQ.responseText,status:eQ.status,responseHeaders:eQ.getAllResponseHeaders()})}}function eV(){var e6,e5,e4,e7;if(eZ.status==ex.DONE||eZ.status==ex.FAILED||e2.state==ex.STOPPED){return}e4={name:eZ.target_name||eZ.name};if(e0&&eX.chunks&&eU.size>e0){e7=Math.min(e0,eU.size-e1);e6=eU.slice(e1,e1+e7)}else{e7=eU.size;e6=eU}if(e0&&eX.chunks){if(eH.send_chunk_number){e4.chunk=Math.ceil(e1/e0);e4.chunks=Math.ceil(eU.size/e0)}else{e4.offset=e1;e4.total=eU.size}}else{e4.chunk=0;e4.chunks=1}eQ=new eC.XMLHttpRequest();eQ.withCredentials=true;if(eQ.upload){eQ.upload.onprogress=function(e8){eZ.loaded=Math.min(eZ.size,e1+e8.loaded);e2.trigger("UploadProgress",eZ)}}eQ.onload=function(){if(eQ.status>=400){eY();return}if(e7=eU.size){if(eZ.size!=eZ.origSize){eU.destroy();eU=null}e2.trigger("UploadProgress",eZ);eZ.status=ex.DONE;e2.trigger("FileUploaded",eZ,{response:eQ.responseText,status:eQ.status,responseHeaders:eQ.getAllResponseHeaders()})}else{e3=eH.max_retries;ey(eV,1)}};eQ.onerror=function(){eY()};eQ.onloadend=function(){this.destroy();eQ=null};if(e2.settings.multipart&&eX.multipart){e4.name=eZ.target_name||eZ.name;eQ.open("post",eW,true);ex.each(e2.settings.headers,function(e9,e8){eQ.setRequestHeader(e8,e9)});e5=new eC.FormData();ex.each(ex.extend(e4,e2.settings.multipart_params),function(e9,e8){e5.append(e8,e9)});e5.append(e2.settings.file_data_name,e6);eQ.send(e5,{runtime_order:e2.settings.runtimes,required_caps:eO,swf_url:e2.settings.flash_swf_url,xap_url:e2.settings.silverlight_xap_url})}else{eW=ex.buildUrl(e2.settings.url,ex.extend(e4,e2.settings.multipart_params));eQ.open("post",eW,true);eQ.setRequestHeader("Content-Type","application/octet-stream");ex.each(e2.settings.headers,function(e9,e8){eQ.setRequestHeader(e8,e9)});eQ.send(e6,{runtime_order:e2.settings.runtimes,required_caps:eO,swf_url:e2.settings.flash_swf_url,xap_url:e2.settings.silverlight_xap_url})}}eU=eZ.getSource();if(!eC.isEmptyObj(e2.settings.resize)&&eS(eU,"send_binary_string")&&!!~eC.inArray(eU.type,["image/jpeg","image/png"])){eN.call(this,eU,e2.settings.resize,function(e4){eU=e4;eZ.size=e4.size;eV()})}else{eV()}});eT.bind("UploadProgress",function(eU,eV){eP(eV)});eT.bind("StateChanged",function(eU){if(eU.state==ex.STARTED){eG=(+new Date())}else{if(eU.state==ex.STOPPED){for(var eV=eU.files.length-1;eV>=0;eV--){if(eU.files[eV].status==ex.UPLOADING){eU.files[eV].status=ex.QUEUED;eI()}}}}});eT.bind("QueueChanged",eI);eT.bind("Error",function(eU,eV){if(eV.file){eV.file.status=ex.FAILED;eP(eV.file);if(eU.state==ex.STARTED){ey(function(){eF.call(eT)},1)}}});eT.bind("FileUploaded",function(){eI();ey(function(){eF.call(eT)},1)});eT.trigger("Init",{runtime:this.runtime});eD.call(this)},refresh:function(){if(eK){eK.trigger("Refresh")}this.trigger("Refresh")},start:function(){if(this.state!=ex.STARTED){this.state=ex.STARTED;this.trigger("StateChanged");eF.call(this)}},stop:function(){if(this.state!=ex.STOPPED){this.state=ex.STOPPED;this.trigger("StateChanged");this.trigger("CancelUpload")}},disableBrowse:function(){eJ=arguments[0]!==ez?arguments[0]:true;if(eK){eK.disable(eJ)}this.trigger("DisableBrowse",eJ)},getFile:function(eU){var eT;for(eT=eE.length-1;eT>=0;eT--){if(eE[eT].id===eU){return eE[eT]}}},addFile:function(eU,eV){var e0=this,eX=[],eT=[],eZ;function eW(){var e2=eL||eK;if(e2){return e2.getRuntime().uid}return false}function eY(e4,e3){var e2=[];eC.each(e0.settings.filters,function(e6,e5){if(eB[e5]){e2.push(function(e7){eB[e5].call(e0,e6,e4,function(e8){e7(!e8)})})}});eC.inSeries(e2,e3)}function e1(e2){var e3=eC.typeOf(e2);if(e2 instanceof eC.File){if(!e2.ruid&&!e2.isDetached()){if(!eZ){return false}e2.ruid=eZ;e2.connectRuntime(eZ)}e1(new ex.File(e2))}else{if(e2 instanceof eC.Blob){e1(e2.getSource());e2.destroy()}else{if(e2 instanceof ex.File){if(eV){e2.name=eV}eX.push(function(e4){eY(e2,function(e5){if(!e5){eT.push(e2)}e4()})})}else{if(eC.inArray(e3,["file","blob"])!==-1){e1(new eC.File(null,e2))}else{if(e3==="node"&&eC.typeOf(e2.files)==="filelist"){eC.each(e2.files,e1)}else{if(e3==="array"){eV=null;eC.each(e2,e1)}}}}}}}eZ=eW();e1(eU);if(eX.length){eC.inSeries(eX,function(){if(eT.length){e0.trigger("FilesAdded",eT)}})}},removeFile:function(eU){var eV=typeof(eU)==="string"?eU:eU.id;for(var eT=eE.length-1;eT>=0;eT--){if(eE[eT].id===eV){return this.splice(eT,1)[0]}}},splice:function(eV,eT){var eU=eE.splice(eV===ez?0:eV,eT===ez?eE.length:eT);this.trigger("FilesRemoved",eU);this.trigger("QueueChanged");ex.each(eU,function(eW){eW.destroy()});return eU},trigger:function(eU){var eW=eR[eU.toLowerCase()],eV,eT;if(eW){eT=Array.prototype.slice.call(arguments);eT[0]=this;for(eV=0;eV=0;eU--){if(eW[eU].func===eV){eW.splice(eU,1);break}}}else{eW=[]}if(!eW.length){delete eR[eT]}}},unbindAll:function(){var eT=this;ex.each(eR,function(eV,eU){eT.unbind(eU)})},destroy:function(){this.stop();ex.each(eE,function(eT){eT.destroy()});eE=[];if(eK){eK.destroy();eK=null}if(eL){eL.destroy();eL=null}eO={};eG=eM=eJ=eQ=null;this.trigger("Destroy");this.unbindAll();eR={}}})};ex.File=(function(){var eE={};function eD(eF){ex.extend(this,{id:ex.guid(),name:eF.name||eF.fileName,type:eF.type||"",size:eF.size||eF.fileSize,origSize:eF.size||eF.fileSize,loaded:0,percent:0,status:ex.QUEUED,lastModifiedDate:eF.lastModifiedDate||(new Date()).toLocaleString(),getNative:function(){var eG=this.getSource().getSource();return eC.inArray(eC.typeOf(eG),["blob","file"])!==-1?eG:null},getSource:function(){if(!eE[this.id]){return null}return eE[this.id]},destroy:function(){var eG=this.getSource();if(eG){eG.destroy();delete eE[this.id]}}});eE[this.id]=eF}return eD}());ex.QueueProgress=function(){var eD=this;eD.size=0;eD.loaded=0;eD.uploaded=0;eD.failed=0;eD.queued=0;eD.percent=0;eD.bytesPerSec=0;eD.reset=function(){eD.size=eD.loaded=eD.uploaded=eD.failed=eD.queued=eD.percent=eD.bytesPerSec=0}};eA.plupload=ex}(window,mOxie));var d0,ah,cx,dg,ca,dr,a3,bl=[].indexOf||function(ey){for(var ex=0,T=this.length;ex .moxie-shim").each(function(eB){if(eB.observe){du.freshbutton_overlay(eB,$("choose-button"));return du.freshbutton_overlay(eB,$("add-button"))}});return ah.clear()},init_basic:function(){du.freshbutton_overlay($("file-box"),$("basic-choose-button"));$("file-box").observe("click",function(T){return document.fire(ca.CHOOSE_FILE_BASIC)});$("basic-choose-button").observe("mousemove",function(ey){var ex,T,ez;ex=$("modal").cumulativeOffset();ez=ey.clientY-ex.top-3;T=ey.clientX-ex.left-$("file-box").getWidth()+3;return $("file-box").setStyle({top:ez+"px",left:T+"px"})});return $("file-box").observe("change",function(){var eA,ey,eB,ez,T,ex;er.hide=function(){};$("modal-x").hide();$("basic-upload-desc").hide();$("basic-upload-buttons").hide();$("file-box").hide();ey=$("file-box").getValue().split("\\").pop();ez=b7.make("web",an.file_icon(ey));$("basic-upload-status").down(".icon").__date(ez);eA=dW("Uploading %(filename)s").format({filename:bu.em_snippet(ey,25)});$("basic-upload-status").down(".file-desc").__date(eA);$("basic-upload-status").show();$("basic-uploading-message").show();eB=$("file-box").files;ex=0;if(eB){T=eB[0].lastModifiedDate;if(T){ex=Math.round(Date.parse(T)/1000)||0}}if(!ex){ex=Math.round(Date.parse(new Date)/1000)}$("mtime-utc").value=ex;return $("basic-upload-form").submit()})},initPLU:function(ex,T){return(function(ey){return function(){var eA,ez;eA={url:"https://"+Constants.BLOCK_CLUSTER+"/chunked_upload",file_data_name:"file",runtimes:ey.runtimes,multipart_params:{},multipart:false,max_file_size:"10000mb",chunk_size:"8mb",max_retries:2,browse_button:ey.choose_button_id,container:"flash-upload-container",preinit:{PostInit:function(){if(ex){ex()}return ey.uploaderLoaded()},Error:ey.uploadError.bind(ey)},init:{FilesAdded:ey.fileQueued.bind(ey),UploadProgress:ey.uploadProgress.bind(ey),FileUploaded:ey.uploadSuccess.bind(ey),BeforeUpload:ey.prepareFileForUploading.bind(ey),ChunkUploaded:ey.chunkUploaded.bind(ey),UploadComplete:ah.finished.bind(ah),Refresh:function(){if(ey.PLU.runtime==="flash"&&$("upload-running-buttons").visible()){bg("#flash-upload-container").clonePosition(bg("#add-button"));bg("#flash-upload-container > .moxie-shim")[0].style.width="100%";return bg("#flash-upload-container > .moxie-shim")[0].style.height="100%"}}},flash_swf_url:Constants.static_url_moxie_swf};if(T!=null){bg.extend(eA,T)}ez=new plupload.Uploader(eA);ey.PLU=ez;return ey.PLU.init()}})(this)},reset:function(){if(ah.uploading&&ah.current_file){this.PLU.removeFile(ah.current_file)}return cx.hide()},show_upload:function(){$("upload-desc").hide();$("dnd-upload-desc").hide();$("upload-files-list").show();$("upload-start-buttons").hide();$("upload-running-buttons").show();$("hide-button").show();$("done-button").hide();if(!$("modal-overlay").visible()){return cx.show()}},updatePostParams:function(ey){var ex,T;T=this.PLU.settings.multipart_params;for(ex in ey){if(ey.hasOwnProperty(ex)){T[ex]=ey[ex]}}return this.PLU.settings.multipart_params=T},fileQueued:function(ex,eB){var eA,ez,T,ey;for(ez=0,T=eB.length;ezlearn more.'),response:"",responseHeaders:"",status:400};this.uploadError(this.PLU,ey);return false}ez={dest:ah.next().dest,t:a9.read(Constants.JS_CSRF_COOKIE)};ez[Constants.UID_PARAM_NAME]=b3.active_user;ca.updatePostParams(ez);this.PLU.start();ah.last_update_time=0;ah.last_update_size=0;return true},pause:function(){return ca.PLU.stop()},uploadProgress:function(ex,T){if(!ah.cancelled_files[T.id]){document.fire(this.UPDATE_EVT,{file:T,percent_complete:T.loaded/T.size});return bg(document).trigger(this.UPDATE_EVT,{file:T,percent_complete:T.loaded/T.size})}},generateUploadId:function(){var T,ex,ez,ey;T="";for(ex=ey=0;ey<=15;ex=++ey){T+=String.fromCharCode(Math.floor(Math.random()*256))}ez=ac.encode(T);ez=ez.replace(/\+/g,"-");ez=ez.replace(/\//g,"_");ez=ez.replace(/\=*$/,"");return ez},chunkUploaded:function(ex,ey,ez){var T;T=JSON.parse(ez.response||"");return this.updatePostParams({offset:T.offset})},prepareFileForUploading:function(){var T;T=ah.next();return this.updatePostParams({reported_total_size:T.size,dest:T.dest,t:a9.read(Constants.JS_CSRF_COOKIE),upload_id:this.generateUploadId(),offset:0})},uploadSuccess:function(eA,ez,ey){var ex,T;try{T=JSON.parse(ey.response)}catch(eB){ex=eB;T=null}if(ey.response==="{'error': 'quota'}"){document.fire(this.ERROR_EVT,{file:ez,message:dW("Quota exceeded"),tooltip_text:dW("Your upload failed because you are over quota.")});return bg(document).trigger(this.ERROR_EVT,{file:ez,message:dW("Quota exceeded"),tooltip_text:dW("Your upload failed because you are over quota.")})}else{if(ey.response==="{'error': 'empty'}"){document.fire(this.CANCEL_EVT,{file:ez,message:dW("Empty File")});return bg(document).trigger(this.CANCEL_EVT,{file:ez,message:dW("Empty File")})}else{if(ey.response==="{'error': 'ignored'}"){document.fire(this.CANCEL_EVT,{file:ez,message:dW("File Ignored")});return bg(document).trigger(this.CANCEL_EVT,{file:ez,message:dW("File Ignored")})}else{if((T!=null?T.status:void 0)==="complete"){document.fire(this.COMPLETE_EVT,{file:ez});return bg(document).trigger(this.COMPLETE_EVT,{file:ez})}else{document.fire(this.ERROR_EVT,{file:ez});return bg(document).trigger(this.ERROR_EVT,{file:ez})}}}}},uploadComplete:function(ex,T){document.fire(this.COMPLETE_EVT,{file:T});return bg(document).trigger(this.COMPLETE_EVT,{file:T})},uploadError:function(eA,T){var ez,ex,ey;if((ey=T.file.id,bl.call(ah.file_ids(),ey)<0)&&T.code!==ca.APPLE_PACKAGE_ERROR){document.fire(this.QUEUE_EVT,{files:[T.file]});bg(document).trigger(this.QUEUE_EVT,{files:[T.file]})}ex=(function(){switch(T.code){case plupload.FILE_SIZE_ERROR:return dW("File too large");default:return dW("Upload Error")}})();this.show_upload();ez={file:T.file,error_code:T.code,message:ex};if(T!=null?T.tooltip_text:void 0){ez.tooltip_text=T.tooltip_text}document.fire(this.ERROR_EVT,ez);return bg(document).trigger(this.ERROR_EVT,ez)},grabURL:function(){var T;T=$F("file-box");if(/(^http|^https|^ftp):\/\//.match(T)){$("url").value=T}return true},treeview_handler:function(ex,T){var ey;cT.fillVal(ex,"dest-folder");ey=$("basic-uploader-url");if(ey){ey.href=ey.href.replace(/(\/upload)(.*)(\?basic=1)/,function(eB,eA,eC,ez){return eA+du.urlquote(ex)+ez})}return ah.clear()},new_folder:function(){bD.hide();er.show(dW("Create new folder..."),cT.fromElm("create-folder"),{action:this.do_new_folder.bind(this,b3.active_user),wit_group:"new-folder-confirm"});if(!du.ie){return bg("#first-treeview-link").trigger("click")}},do_new_folder:function(T){var ey,ex;if(!er.vars.selected_path){Y.error(dW("Please select a parent folder."));return}ex=$F("entered-name");ey=er.vars.selected_path;return new Ajax.DBRequest("/cmd/new"+du.urlquote(ey)+"?to_path="+du.urlquote(ex),{subject_user:T,onSuccess:(function(ez){return function(eA){ez.treeview_handler(an.normalize(ey)+"/"+ex);return bD.schedule_reset()}})(this),cleanUp:function(){}})},uploaderLoaded:function(){$("upload-loading").hide();$("choose-button").show();if(ca.PLU.runtime==="flash"){bg("#flash-upload-container").clonePosition(bg("#choose-button"));bg("#flash-upload-container > .moxie-shim")[0].style.top="0px";bg("#flash-upload-container > .moxie-shim")[0].style.left="0px";bg("#flash-upload-container > .moxie-shim")[0].style.width="100%";return bg("#flash-upload-container > .moxie-shim")[0].style.height="100%"}else{bg("#"+this.choose_button_id).click((function(T){return function(ex){return bg("#"+T.PLU.id+"_html5").click()}})(this));return bg("#add-button").click((function(T){return function(ex){return bg("#choose-button").click()}})(this))}}};ah=A.FileQueue={init:function(){return ah._listen()},_listen:function(){document.observe(ca.QUEUE_EVT,ah._file_queued.bind(this));document.observe(ca.QUEUE_ERROR_EVT,ah._file_queue_errored.bind(this));document.observe(ca.UPDATE_EVT,ah._file_updated.bind(this));document.observe(ca.COMPLETE_EVT,ah._file_completed.bind(this));document.observe(ca.ERROR_EVT,ah._file_errored.bind(this));return document.observe(ca.CANCEL_EVT,ah._file_cancelled.bind(this))},_file_queued:function(eB){var ey,eA,ex,ez,T;ez=eB.memo.files;T=[];for(eA=0,ex=ez.length;eAbasic uploader to upload via the website.');bg(document).on("click","a#basic_link",function(){c1.show_basic_upload();return false})}eB.down(".error-msg").__date(ey);ez=eB.down(".error-details");ez.observe("mouseover",function(){return dI.show(ez,T)});return eB.down(".error-col").show()},_file_cancelled:function(ex){var T,ey;T=ex.memo.file;ey=$(T.id);ey.addClassName("cancelled");ey.down(".dest-col").__date(dW(ex.memo.message||"Canceled"));ey.down(".time-col").__date();ey.down(".status-col").__date(b7.make("web","cancelsync"));return ey.down(".upload-progress-bar").setStyle({width:"100%"})}};d0=A.BulkUpload={init:function(){this.elem=$("bulk-upload-status");return d0._listen()},_listen:function(){document.observe(ca.QUEUE_EVT,d0._file_queued.bind(this));return document.observe(ca.UPDATE_EVT,d0._file_updated.bind(this))},_file_queued:function(ex){var T;T=new Element("a",{"class":"small-x-button"});T.observe("click",function(){var eA,eC,eB,ez,ey;ah.all_cancelled=true;eA=ah.file_ids().slice(0);ey=[];for(eB=0,ez=eA.length;eB1){this.elem.removeClassName("error");this.elem.removeClassName("complete");this.elem.removeClassName("cancelled");ey=aR("%d file","%d files",ah.num_non_cancelled_files()).format(ah.num_non_cancelled_files());this.elem.down(".num-files").__date(ey);ex=dW("- %(size)s").format({size:at.format_bytes(ca.PLU.total.size)});this.elem.down(".size").__date(ex);if(ah.formatted_time){T=dW("%(time_left)s left").format({time_left:ah.formatted_time});this.elem.down(".time-left").__date(T)}this.elem.down(".upload-progress-bar").style.width=Math.min(100,(ah.totalPercentage()*100||0).toFixed(2))+"%";this.elem.show();if(ca.PLU.runtime==="flash"){return bg("#flash-upload-container").clonePosition(bg("#add-button"))}}},update_errors:function(){var T;T=aR("- %d error","- %d errors",ah.errors()).format(ah.errors());return $("bulk-upload-status").down(".num-errors").__date(T)},completed:function(){var ex,T;$("hide-button").hide();$("done-button").show();if(ah.num_files()>1){this.elem.addClassName("complete");ex=aR("Uploaded %d file","Uploaded %d files",ah.num_non_cancelled_files()).format(ah.num_non_cancelled_files());this.elem.down(".num-files").__date(ex);T=dW("- %(size)s").format({size:at.format_bytes(ah.completed_size())});this.elem.down(".size").__date(T);this.elem.down(".num-errors").__date();this.elem.down(".time-left").__date();this.elem.down(".status").__date(b7.make("web","s_check"));return this.elem.down(".upload-progress-bar").style.width="100%"}},errored:function(){var T;$("hide-button").hide();$("done-button").show();this.completed();T=aR("- %d error","- %d errors",ah.errors()).format(ah.errors());return this.elem.down(".num-errors").__date(T)},cancelled:function(){$("hide-button").hide();$("done-button").show();if(ah.num_files()>1){this.elem.addClassName("cancelled");this.elem.down(".num-files").__date(dW("All uploads canceled"));this.elem.down(".size").__date();this.elem.down(".num-errors").__date();this.elem.down(".time-left").__date();this.elem.down(".status").__date(b7.make("web","cancelsync"));return this.elem.down(".upload-progress-bar").style.width="100%"}}};cx=A.InlineUploadStatus={FILENAME_SNIPPET_LENGTH:30,init:function(){return this._listen()},_listen:function(){document.observe(ca.QUEUE_EVT,cx._file_queued.bind(this));return document.observe(ca.UPDATE_EVT,cx._file_updated.bind(this))},_file_queued:function(ey){var ex,T;ex=$("inline-upload-status");ex.removeClassName("error");ex.removeClassName("complete");ex.down(".icon").__date(b7.make("web","s_sync"));ex.down(".file-desc").__date(dW("Starting upload..."));ex.down(".num-errors").__date();T=aR("%d file","%d files",ah.num_left()).format(ah.num_left());ex.down(".view-details").__date(T);ex.down(".status").__date();return ex.down(".inline-upload-progress").style.width="0%"},_file_updated:function(eC){var eB,ey,ez,eA,ex,T;eB=$("inline-upload-status");ey=eC.memo.file;eB.down(".icon").__date(b7.make("web","s_sync"));ez=dW("Uploading %(filename)s").format({filename:bu.em_snippet(ey.name,this.FILENAME_SNIPPET_LENGTH)});eB.down(".file-desc").__date(ez);if(ah.num_left()>1){T=aR("%d file left","%d files left",ah.num_left()-1).format(ah.num_left()-1);eB.down(".view-details").__date(T)}else{eB.down(".view-details").__date(dW("View details"))}if(ah.formatted_time){ex=dW("%(time_left)s left").format({time_left:ah.formatted_time});eB.down(".status").__date(ex)}eA=ey.percent+"%";return eB.down(".inline-upload-progress").style.width=eA},update_errors:function(){var T,ex;T=$("inline-upload-status");ex=aR("- %d error","- %d errors",ah.errors()).format(ah.errors());return T.down(".num-errors").__date(ex)},add_x_button:function(){var T,ex;ex=new Element("a",{"class":"small-x-button"});ex.observe("click",function(){cx.hide();return ca.reset()});T=$("inline-upload-status");return T.down(".status").__date(ex)},completed:function(){var ex,T;ex=$("inline-upload-status");ex.addClassName("complete");ex.removeClassName("error");ex.down(".icon").__date(b7.make("web","s_check"));if(ah.num_files()>1){T=dW("Uploaded %(num_files)d files").format({num_files:ah.num_non_cancelled_files()})}else{T=dW("Uploaded %(filename)s").format({filename:bu.em_snippet(ah.current_file.name,this.FILENAME_SNIPPET_LENGTH)})}ex.down(".file-desc").__date(T);ex.down(".num-errors").__date();ex.down(".view-details").__date(dW("View details"));this.add_x_button();return ex.down(".inline-upload-progress").style.width="100%"},errored:function(){var ey,ex,T,ez;ey=$("inline-upload-status");ey.addClassName("error");ey.removeClassName("complete");ey.down(".icon").__date(b7.make("web","nosync"));ex=void 0;if(ah.num_files()>1){ex=dW("Uploaded %(num_completed)d of %(num_files)d files").format({num_completed:ah.num_non_cancelled_files()-ah.errors(),num_files:ah.num_non_cancelled_files()});ey.down(".file-desc").__date(ex);ez=aR("- %d error","- %d errors",ah.errors()).format(ah.errors());ey.down(".num-errors").__date(ez)}else{if(ah.current_file!=null){T=bu.em_snippet(ah.current_file.name,this.FILENAME_SNIPPET_LENGTH)}ex=T?dW("Unable to upload %(filename)s").format({filename:T}):dW("Unable to upload file");ey.down(".file-desc").__date(ex);ey.down(".num-errors").__date()}ey.down(".view-details").__date(dW("View details"));this.add_x_button();return ey.down(".inline-upload-progress").style.width="100%"},show:function(T){return $("inline-upload-status").show()},hide:function(){return $("inline-upload-status").hide()}};a3=A.UploadPrep={_drop_indicators:false,_drop_dest_folder:null,file_counter:0,current_req:null,_notifications_cleared:false,supported:function(){return Prototype.BrowserFeatures.DB_CORS},enabled:function(){return a3.supported()&&b3.inside_dir&&!(b3.in_search_mode()&&bK.fulltext_search_enabled)},browse_indicators_enabled:function(){var ez,ex,ey,T;if(!a3.enabled()){return false}ex=["file-preview-modal","modal-overlay"];if(ca.choose_button_id.startsWith("wizard-")){ex.push("wizard-overlay")}for(ey=0,T=ex.length;ey0},_show_border_drop_indicators:function(){return $$(".external-drop-indicator").each(function(T){return bg(T).css("opacity",0).fadeTo(500,0.6)})},_hide_border_drop_indicators:function(){return $$(".external-drop-indicator").invoke("hide")},show_drop_indicators:function(ex){var T;if(!a3._drop_indicators){if(a3.modal_indicators_enabled()){T=$("upload-modal-dropzone");bg(T).clonePosition(bg("#modal"),{setLeft:false,setTop:false});bg(T).fadeIn(500);a3._show_border_drop_indicators()}else{if(a3.browse_indicators_enabled()){br._add_drop_indicators(ex)}else{return}}$("drag-status").removeClassName("active");return a3._drop_indicators=true}},hide_drop_indicators:function(){if(a3._drop_indicators){a3._hide_border_drop_indicators();br._remove_drop_indicators();if(!a3._notifications_cleared){Y.clear()}$("upload-modal-dropzone").hide();$("drag-status").addClassName("active");setTimeout((function(){a3._drop_indicators=false;a3._drop_dest_folder=null;return a3._notifications_cleared=false}),500)}return a3._notifications_cleared=true},folder_dragover:function(T){var ex;if(a3.browse_indicators_enabled()&&a3._drop_indicators){if(dg.disabled){if(a3._drop_dest_folder==null){ex=dW("You can't upload files because you're out of space.");Y.error(ex,60);a3._notifications_cleared=false;a3._show_border_drop_indicators()}}else{if(T!==a3._drop_dest_folder){if(T===b3.containing_fq_path()){if(b3.inside_read_only_shared_folder){ex=dW("You don't have permission to add to this folder.");Y.error(ex,60)}else{ex=dW("Drop your file to %(upload_action)s",{comment:"upload_action is a phrase like 'upload to folder 'XYZ'"}).format({upload_action:c1.upload_plain_snippet()});Y.success(new eu(ex),60);a3._show_border_drop_indicators()}a3._notifications_cleared=false}else{Y.clear();a3._hide_border_drop_indicators()}}}return a3._drop_dest_folder=T}},supports_recursive_upload:function(T){var ex;return window.File&&window.FileReader&&window.FileList&&window.Blob&&(T!=null?(ex=T[0])!=null?ex.webkitGetAsEntry:void 0:void 0)},upload:function(ey,eA,ex){var ez,eC,eB,T;if(ex==null){ex=null}if(b3.inside_read_only_shared_folder){return}if(dg.disabled){eC=dW("You can't upload files because you're out of space.");return Y.error(eC)}else{if(a3.supports_recursive_upload(ex)){return a3._recursive_upload(ey,ex)}else{for(eB=0,T=eA.length;eB advanced uploader instead.').format({name:eN.name});Y.error(new eu(eM));return bg("#use-advanced-uploader").on("click",function(eO){eO.preventDefault();return c1.show_upload()})};eJ=3000;eC=0;ey=function(){var eL;while(eB.length){eG=eB.pop();if(eG!==null){if(eG.isDirectory){(function(eN){var eM;eM=eN.createReader();ez+=1;return eM.readEntries(function(eO){var eR,eQ,eP;if(eO.length!==0){for(eQ=0,eP=eO.length;eQeJ&&!eC){eC=1;Y.error(dW("The Dropbox website can't upload more than %(max_files)s files.").format({max_files:eJ}));return}if(ez||eK){return ey.defer()}else{if(ex.length){return a3._upload(ex)}}};return ey()},_upload:function(ez,ex){var T,ey;if(ex==null){ex=null}if(ex){T=this._parse_upload_items(ex)}ey=function(){var eC,eE,eB,eD,eA;eA=[];for(eE=0,eB=ez.length;eE-1&&(T!=null?(eD=T[eC.name])!=null?eD.isDirectory:void 0:void 0)){eC.is_directory=true}eC.id=plupload.guid();eA.push(ca.PLU.addFile(eC))}return eA};if($("modal").visible()){return ey()}else{c1.show_upload(ey);return er.hide(null,true)}},_parse_upload_items:function(ex){var ey,ez,eA,T;ey={};for(eA=0,T=ex.length;eA%(items)s from your Dropbox?").format({items:an.filename(ey).escapeHTML()}),confirm_text:dW("Delete"),cancel_text:dW("Cancel"),confirm_callback:(function(eA){return function(){if(ex){return c1.do_nonbrowse_delete(T,[ey])}else{return c1.do_delete(T,ey)}}})(this)})},show_bulk_delete:function(T,ex){return da.show({title_text:aR("Delete %(item_count)s item?","Delete %(item_count)s items?",ex.length).format({item_count:ex.length}),body_html:aR("Are you sure you want to delete %(item_count)s item from your Dropbox?","Are you sure you want to delete %(item_count)s items from your Dropbox?",ex.length).format({item_count:ex.length}),confirm_text:dW("Delete"),cancel_text:dW("Cancel"),confirm_callback:(function(ey){return function(){return c1.do_bulk_delete(T,ex)}})(this)})},show_purge:function(T,ex){return da.show({title_text:ex?dW("Permanently delete folder?"):dW("Permanently delete file?"),body_html:dW("Are you sure you want to permanently delete %(items)s from your Dropbox?").format({items:an.filename(T).escapeHTML()}),confirm_text:dW("Permanently delete"),cancel_text:dW("Cancel"),confirm_callback:(function(ey){return function(){return c1.do_purge(b3.find_file(T))}})(this)})},show_bulk_purge:function(T){return da.show({title_text:aR("Permanently delete %d item?","Permanently delete %d items?",T.length).format(T.length),body_html:aR("Are you sure you want to permanently delete %(item_count)s item from your Dropbox?","Are you sure you want to permanently delete %(item_count)s items from your Dropbox?",T.length).format({item_count:T.length}),confirm_text:dW("Permanently delete"),cancel_text:dW("Cancel"),confirm_callback:(function(ex){return function(){return c1.do_bulk_purge(T)}})(this)})},show_bulk_restore:function(ex,T){return da.show({title_text:aR("Restore %d item...","Restore %d items...",ex.length).format(ex.length),body_html:aR("Are you sure you want to restore %(item_count)s item?","Are you sure you want to restore %(item_count)s items?",ex.length).format({item_count:ex.length}),confirm_text:dW("Restore"),cancel_text:dW("Cancel"),confirm_callback:(function(ey){return function(){return c1.do_bulk_restore(ex)}})(this)})},wrap_strong:function(T){if(b3.containing_fq_path()===""){return T.escapeHTML()}else{return""+T.escapeHTML()+""}},upload_snippet:function(ey){var T,ex;if(ey==null){ey=1000}if(ck.get_viewer().is_paired&&b3.active_user.is_team){ex=bu.em_snippet(ck.get_viewer().team_name,ey).escapeHTML()}if(b3.containing_fq_path()===""){if(ck.get_viewer().is_paired){if(b3.active_user.is_team){return dW(" upload to your %(team_name)s Dropbox",{comment:"Used after the string 'drop your file to...' or 'choose a file to...'"}).format({team_name:ex})}else{return dW(" upload to your personal Dropbox",{comment:"Used after the string 'drop your file to...' or 'choose a file to...'"})}}else{return dW(" upload to your Dropbox")}}else{T=bu.em_snippet(an.filename(b3.containing_fq_path()),ey).escapeHTML();if(ck.get_viewer().is_paired){if(b3.active_user.is_team){return dW(" upload to the folder %(folder)s in your %(team_name)s Dropbox",{comment:"Used after the string 'drop your file to...' or 'choose a file to...'"}).format({folder:T,team_name:ex})}else{return dW(" upload to the folder %(folder)s in your personal Dropbox",{comment:"Used after the string 'drop your file to...' or 'choose a file to...'"}).format({folder:T})}}else{return dW(" upload to the folder %(folder)s",{comment:"Used after the string 'drop your file to...' or 'choose a file to...'"}).format({folder:T})}}},upload_short_snippet:function(ey){var ex,T;if(ey==null){ey=1000}T=b3.containing_fq_path();if(!T){return dW("Upload to Dropbox",{comment:"Upload a file to the root Dropbox folder"})}ex=bu.em_snippet(an.filename(T),ey);return dW("Upload to '%(folder_name)s'",{comment:"Upload a file to some folder on the website"}).format({folder_name:ex})},upload_plain_snippet:function(T){if(T==null){T=1000}return this.upload_snippet(T).replace("","'").replace("","'")},show_upload:function(eE,T,eB){var ey,eC,ex,ez,eD,eA;ey=b3.containing_fq_path();if(dg.disabled){cT.fillVal(this.wrap_strong(an.filename(ey)),"disabled-upload-foldername");ex=this.upload_short_snippet(20);er.show(ex,$("disabled-upload-modal"),{},false);return}bg(document).trigger(this.SHOW_UPLOAD_EVT,{source:T,has_callback:eE!=null});if((!FlashDetect.versionAtLeast(9))&&ca.runtimes==="flash"){c1.show_basic_upload();$("enhanced-upload-toggle").hide();return}cT.fillVal(this.upload_snippet(20),"upload-foldername");cT.fillVal(this.upload_plain_snippet(10),"dnd-upload-foldername");if($("upload-desc").visible()&&a3.supported()){$("upload-desc").hide();$("dnd-upload-desc").show()}ex=this.upload_short_snippet(20);er.show(ex,cT.fromElm("advanced-upload-modal"),{wit_group:"advanced-uploader"},false,false,ah.num_files());eA=[$("modal").down(".basic-link-start"),$("modal").down(".basic-link-running")];for(ez=0,eD=eA.length;ez0,"Tried to copy 0 files");if(typeof ex==="undefined"){if(typeof er.vars.selected_path==="undefined"){Y.error(dW("You need to select a destination for the file."));return}else{ex=er.vars.selected_path}}ex=an.normalize(ex);ey=0;for(eC=0,T=eB.length;eC%(location)s'.","Copied %(count)d items to '%(location)s'.",eJ);eF=eF.format({count:eJ,location:eL});Q.notifyWithUndo(new eu(eF),eG,c1.do_rollback);eD=[];eI=eK.responseText.evalJSON().new_browse_files;for(eH=0,eE=eI.length;eH0&&eD&&eD!==Constants.root_ns){if(eA.sandboxes>0){if(eF.is_sandbox()){return dW("You're not allowed to put an application folder inside another application folder.")}else{if(eF.is_shared_folder()){return dW("You're not allowed to put an application folder inside a shared folder.")}}}else{if(eA.shared_folders>0){if(eF.is_sandbox()){return dW("You're not allowed to put a shared folder inside an application folder.")}else{if(eF.is_shared_folder()){return dW("You're not allowed to put a shared folder inside another shared folder.")}}}}return dW("You're not allowed to nest special folders.")}if(b3.public_folder_enabled){if(ey==="/Public"&&eA.target_namespaces>0){return dW("You're not allowed to move shared folders to your Public folder.")}}if(eA.public_folder>0){return dW("You're not allowed to move your Public folder.")}if(eA.deleted>0){return dW("Moving deleted folders or files is not allowed.")}},do_move:function(ey,ex){var T;ey=ey||er.vars.fq_path;ex=ex||er.vars.selected_path;T=b3.find_file(ey);cj(T,"Trying to move a file we couldn't find.");return c1.do_bulk_move([T],ex)},do_bulk_move:function(eA,eB){var ey,ez,T,ex;b3.pre_action_selection=eg.get_selected_fq_paths();eA=eA||er.vars.files;if(!eA){return}cj(eA.length>0,"Tried to move 0 files");T=eB||er.vars.selected_path||"";T=an.normalize(T);ey=c1.bulk_move_error(eA,T);if(ey){Y.error(ey);return}ez=eA.pluck("fq_path");Y.clear();ex="/cmd/move";return new Ajax.DBRequest(ex,{parameters:{files:ez,to_path:T},subject_user:b3.active_user,job:true,html_in_error_msg:true,progress_text:dW("Moving..."),onSuccess:function(eF){var eE,eD,eC,eG;eE=eF.responseText.evalJSON().changesets;eD=ez.length;eC=bu.em_snippet(an.filename(T),c1.NOTIFICATION_SNIPPET_LEN).escapeHTML();eG=aR("Moved %(count)d item to '%(location)s'.","Moved %(count)d items to '%(location)s'.",eD);eG=eG.format({count:eD,location:eC});Q.notifyWithUndo(new eu(eG),eE,c1.do_rollback);$("reload-link").observe("click",function(){return aN.set_path_url(null,T)});bD.schedule_reset();return document.fire(av.MOVE,{files:eA,to_fq_path:T})}})},do_rollback:function(T){return new Ajax.DBRequest("/cmd/rollback",{parameters:{ns_to_cs:JSON.stringify(T)},subject_user:b3.active_user,job:true,html_in_error_msg:true,progress_text:dW("Undoing..."),onSuccess:function(ex){var ey;ey=dW("Undo complete.");Y.success(ey);cj(b3.pre_action_selection instanceof Array,"Expected a selection from before the action to be undone");if(b3.in_search_mode()){bK.select_fq_paths=b3.pre_action_selection;bK.force_reload()}else{if(ax.shown){b3.select_fq_paths=b3.pre_action_selection}else{b3.select_fq_paths=b3.pre_action_selection;b3.force_reload()}}return b3.pre_action_selection=false}})},do_bulk_delete:function(T,ez){var ex,ey;b3.pre_action_selection=eg.get_selected_fq_paths();ez=ez||er.vars.files;cj(ez.length>0,"Tried to delete 0 files");ey=(function(){var eC,eB,eA;eA=[];for(eC=0,eB=ez.length;eC0,"Tried to purge 0 files");T=ex.collect(function(ez){return ez.fq_path});ey=aR("Permanently deleted %d item","Permanently deleted %d items",T.length).format(T.length);return new Ajax.DBRequest("/cmd/purge",{parameters:{files:T},subject_user:b3.active_user,job:true,html_in_error_msg:true,progress_text:dW("Deleting..."),onSuccess:function(ez){Y.success(ey);bD.schedule_reset();return document.fire(av.PURGE,{files:ex})}})},do_bulk_restore:function(ey){var ex,ez,T;ey=ey||er.vars.files;T=er.vars.user;cj(ey.length>0,"Tried to restore 0 files");ex=ey.collect(function(eA){return eA.fq_path});ez=aR("Restored %d item","Restored %d items",ex.length,{comment:"meaning, successfully restored x files and folders"}).format(ex.length);return new Ajax.DBRequest("/cmd/restore",{parameters:{files:ex},subject_user:b3.active_user,job:true,html_in_error_msg:true,progress_text:dW("Restoring..."),onSuccess:function(eA){Y.success(ez);bD.schedule_reset();return document.fire(av.RESTORE,{files:ey})}})},do_folder_restore:function(ex,T){var ey;ey=function(ez){var eB,eA;eB=dW("Restoring '%(folder_name)s'").format({folder_name:an.filename(ex)});eA=ez.responseText;if(eA.startsWith("err:")){eA=eA.substring(4);bg("#async-result").html(eA);Y.error(new eu(eA),60)}else{eB=dW("Restored '%(folder_name)s'").format({folder_name:an.filename(ex)});bg("#status-of-files").text(dW("Restored files"));Y.success(eB,60)}bg("#restore-done-heading").text(eB);bg(".pre-restore").hide();return bg(".post-restore").show()};return new Ajax.DBRequest("/cmd/restore",{parameters:{files:[ex]},job:true,html_in_error_msg:true,progress_text:dW("Restoring..."),onSuccess:ey,onFailure:ey,subject_user:T})},do_bulk_download:function(ey){var eA,ex,ez,T;eA=new Element("form",{action:C({scheme:"https",authority:Constants.BLOCK_CLUSTER,path:"/zip_batch"}).updateQuery(Constants.UID_PARAM_NAME,b3.active_user.id).toString(),method:"post"});for(ez=0,T=ey.length;ez0){return eA.style.width=ex+"px"}}};var aT;aT=A.BrowseStyleRows={register_all:function(){var ez,ey,T,ex;ex=$$(".bs-row");for(ey=0,T=ex.length;ey",{action:this.action,method:"post"});bt.add_vars(ez[0],{locale:ey,locale_cont:eA||window.location.href,t:a9.read(Constants.JS_CSRF_COOKIE)});bg(document.body).append(ez);return ez.submit()};return T})(dw);a0=A.TeamLocaleSelectorModal=(function(T){cm(ex,T);function ex(){return ex.__super__.constructor.apply(this,arguments)}ex.prototype.action="https://"+Constants.WEBSERVER+"/team/admin/set_locale";return ex})(el);var db;db=A.LoginDropdown={init:function(){var T;T=bg("#login-hover-link");if(!(T.length>0)){return}this.login_link=T;return this.register()},register:function(T){this.login_link.on("click",this.click.bind(this));this.login_link.on("mousedown",this.mousedown.bind(this));this.login_link.on("focus",this.click.bind(this));return $(document.body).on("click",this.unclick.bind(this))},mousedown:function(T){return this.clicking=true},click:function(T){T.preventDefault();if(this.clicking&&T.type==="focus"){return}this.clicking=false;if(this.down){return this.unclick()}bg(document).trigger("dropdownOpened",[1]);this.down=true;this.login_link.parent().addClass("down");return bg("input[name='login_email']").focus()},unclick:function(ex){var T;if(ex){T=bg(ex.target);if(T[0].match("#top-login-wrapper, #top-login-wrapper *")){return}}if(this.down){bg(document).trigger("dropdownClosed",[1])}this.down=false;return this.login_link.parent().removeClass("down")}};var er;er=__CONDITIONAL_JS__.Modal=INLINE_JS.Modal=A.Modal={KEY_SCOPE:"modal",width:640,vertical_offset:90,show:function(eI,eE,eF,eK,ey,eG,eC,eD,eJ){var ex,eA,eH,T,ez,eB;if(eF==null){eF=false}if(eK==null){eK=false}if(ey==null){ey=false}if(eG==null){eG=false}if(eC==null){eC=""}if(eD==null){eD=true}if(eJ==null){eJ=false}if(er.shown()){er._cleanup()}ey=ey||this.width;eA="#modal-content .error-message, #modal-content .error-removable, #modal-content .error-bubble";$$(eA).invoke("hide");if(ah.uploading&&!eG){bJ(dW("You can't do this while uploading."));return false}cj(eE,"Missing modal content!");ez=this.vars._prev_scope;this.vars=eF||{};this.vars._prev_scope=ez;$("modal").setStyle({width:""+ey+"px",margin:"0 0 0 "+(Math.floor(-ey/2).toString())+"px"});this.vars.extra_class="";if(eC){$("modal").addClassName(eC);this.vars.extra_class=eC}if(!eG){if(ah.num_files()){ca.reset();ah.clear()}T=du.childElement($("modal-content"),0);if(T&&T!==eE){$("grave-yard").__sert(T)}ex=new Element("div");ex.update(eE);$("modal-content").__sert(ex);if(eE.show){eE.show()}Element.show("modal")}bg("#modal-overlay").off("click");if(eD){bg("#modal-overlay").on("click",function(eL){er.hide(null,false,true);eL.preventDefault();return eL.stopPropagation()})}else{bg("#modal-overlay").on("click",function(eL){eL.preventDefault();return eL.stopPropagation()})}this.fix_position();$("modal-overlay").show();$("modal-behind").setStyle({width:""+(ey+20)+"px",margin:"0 0 0 "+(Math.floor(-ey/2-10).toString())+"px"});bg("#modal-behind").css("opacity",0.2);$("modal-behind").show();if(eK){$("modal-content").select("#"+eK.id).first().focus()}else{if(!du.ie){eH=$("modal").down("input[type=submit]")||$("modal").down("input[type=button]");if(eH){eH.focus()}}}if(!this.track_id){this.track_resizes()}if(eI){if(du.isElm(eI)){bg("#modal-title").html(eI)}else{bg("#modal-title").text(eI)}bg("#modal-title").show();eB=bg("#modal-title").text();d2("Modal.show:",eB)}else{bg("#modal-title").hide();d2("Modal.show")}O.register(false,"modal");this.keydownHandler=this.keydown.bind(this);document.observe("keydown",this.keydownHandler);$("modal-content").style.height="auto";if(key.getScope()!==this.KEY_SCOPE){this.vars._prev_scope=key.getScope()}key.setScope(this.KEY_SCOPE);this.prevent_hide_if_loading=eJ;bg("#modal").find("input").filter(":visible:first").focus();if(this.in_viewport()){this.scroll_locked=true;y.scroll_lock_document()}bg(document).trigger("modalOpened",[1]);return false},in_viewport:function(){var ey,T,ex,eA,ez;ey=bg("#modal");T=ey.height();ez=ey.width();ex=y.viewport_dimensions();eA=y.viewport_offset(ey);return eA.left>0&&eA.top>0&&eA.left+ez",{id:eL,"class":"title_bubble_container"});if(!eG){eN.css({opacity:0});eN.addClass("has-transition")}if(eK.hasClass("white")){eN.addClass("white")}if(eK.hasClass("black")){eN.addClass("black")}eN.text(eK.attr("data-title"));eE=eK.attr("data-title-hide-tail")!=="yes";if(eE){eH=bg("
      ",{"class":"tail"});eN.append(eH)}bg(document.body).append(eN);eD=eC(eK[0],eN[0]);eF=ex(eD,eN[0],eK[0]);eN.clonePosition(eK,{setWidth:false,setHeight:false,offsetTop:eF.top-eB,offsetLeft:eF.left});eN.addClass("position-"+eD);if(eE){eH.clonePosition(eK,{setWidth:false,setHeight:false,offsetTop:eF.top-eB+eF.tail_offset_top+bg(eN).outerHeight(),offsetLeft:eF.left+eF.tail_offset_left+(bg(eN).outerWidth()/2)})}eJ=function(){var eO;if(!((eN.data("pending-delay"))&&(eK.data("bubble-id")===eL))){return}eO=(parseInt(eK.data("title-fade-time")))||400;return eN.fadeIn(eO)};if(eG){eN.hide();eN.data("pending-delay",true);return setTimeout(eJ,eG)}else{return eN.css({opacity:""})}};eC=function(eH,eD){var eG,eF,eE;eH=$(eH);eE=eH.getAttribute("data-title-position");eG=document.viewport.getDimensions();eF=eH.viewportOffset();if(!(eE==="above"||eE==="below"||eE==="right"||eE==="left")){eE="above"}if(eE==="left"){if(eF.lefteN.width){eL=eN.width-eJ.left-eK.width;eO=eD-eL-5}else{eL=eD;eO=-5}}if(eF==="left"||eF==="right"){if(eF==="right"){eL=eI.getWidth()+eG}else{eL=(-1*eK.width)-eG}eP=eI.getHeight()/2-eK.height/2;if(eJ.top+eP+eK.height>eN.height){eH=eN.height-eJ.top-eK.height;eE=eP-eH-5}else{eH=eP;eE=-5}}return{left:eL,top:eH,tail_offset_left:eO,tail_offset_top:eE}};ez=function(eE){var eD,eF,eG;eG=bg(eE!=null?eE.currentTarget:void 0);eD=bg("#"+eG.data("bubble-id"));if(eD.data("pending-delay")){eD.removeData("pending-delay");eF=(parseInt(eG.data("title-fade-time")))||400;return eD.fadeOut(eF,function(){return eD.remove()})}else{return eD.remove()}};return{init:function(){bg(document).on("mouseenter",".title_bubble",eA);bg(document).on("mouseleave",".title_bubble",ez).on("mouseup",".title_bubble",ez);bg(document).on("mouseenter",".title_bubble_sticky",eA);return bg(document).on("mouseleave",".title_bubble_sticky",ez)},set_vertical_space:T,hide_all:function(){return bg(".title_bubble_container").remove()}}})();var dI;dI=INLINE_JS.Tooltip=A.Tooltip={attach:function(eB,ey,T,ex){var eA,ez;if(ex==null){ex={}}eB=$(eB);T=(T?$(T):null);eA=dL.make(ey,eB.tail_position,ex.tail_position,ex.width,ex);eA.setStyle({display:"none",position:"absolute"});$("floaters").__sert(eA);if(eB.match("#modal-content *")||eB.match(".db-modal-content *")){eA.style.zIndex="13001"}else{eA.style.zIndex=""}if(eB.tail_position==="right"){ez=(du.ie?32:12);eA.style.marginLeft=-(eA.getWidth()+eB.getWidth()+ez)+"px"}eB.tooltip=eA;eB.out_target=(T?true:false);eB.observe("mouseout",this.mouseout("target",eB));eB.observe("mouseover",this.mouseover("target",eB));eB.out_trigger=(T?false:true);if(T){T.observe("mouseout",this.mouseout("trigger",eB));T.observe("mouseover",this.mouseover("trigger",eB))}eB.out_tooltip=true;eA.observe("mouseout",this.mouseout("tooltip",eB));return eA.observe("mouseover",this.mouseover("tooltip",eB))},update:function(ex,T){if(ex.tooltip){return $(ex.tooltip).update(T)}},mouseover:function(T,ex){return function(){return ex["out_"+T]=false}},mouseout:function(T,ex){return function(){ex["out_"+T]=true;return dI.hide_if_out.defer(ex)}},show_by:function(ex){var ey,T;ey=bg(ex.tooltip);ex=bg(ex);ey.show();T=Math.floor(ey[0].offsetHeight/2);return ey.clonePosition(ex,{setWidth:false,setHeight:false,offsetTop:Math.floor(ex[0].offsetHeight/2)-T,offsetLeft:ex[0].offsetWidth+1})},hide_if_out:function(T){var ex;if(!T.out_target||!T.out_trigger||!T.out_tooltip){return}ex=$(T.tooltip);return ex.hide()},show:function(eA,ez,ex,T,ey){if(T==null){T="left"}eA=$(eA);if(!eA.tail_position){eA.tail_position=T}ex=(ex?$(ex):null);if(!eA.tooltip){this.attach(eA,ez,ex,ey)}return this.show_by(eA)}};var bD;bD=INLINE_JS.TreeView=A.TreeView={tv:{},loaded:false,set_params:function(T){return this.ajax_params=T},init:function(ey,T,ez){var ex;if(ez==null){ez="treeview"}this.tv[ez]={};ex=this.tv[ez];ex.autohide=(T===null?true:T);ex.handler=ey;ex.viewdiv=$(ez);ex.hidefunc=this.hide.bindAsEventListener(this);this.ajax_params={};document.observe(bf.ADD,(function(eA){return function(eB){return eA.schedule_reset()}})(this));document.observe(bf.REMOVE,(function(eA){return function(eB){return eA.schedule_reset()}})(this));return document.observe(bf.MOVE,(function(eA){return function(eB){return eA.schedule_reset()}})(this))},schedule_reset:function(){return this.loaded=false},reset:function(ez){var ex,ey,T;ex={url:"/ajax_subtreeview",type:"post",data:bg.extend({},this.ajax_params),success:(function(eA){return function(eC){var eD,eB;eB=[];for(eD in eA.tv){if(eA.tv.hasOwnProperty(eD)){eA.tv[eD].viewdiv.down(".treeview-folders").update(eC);if(ez&&ez.onSuccess){eB.push(ez.onSuccess(eC))}else{eB.push(void 0)}}else{eB.push(void 0)}}return eB}})(this)};if(ez!=null?ez.user:void 0){ex.subject_user=ez.user;T=ck.get_role_title(ez.user);if(ck.get_viewer().is_paired){if(ez.user.is_team){ey="s_briefcase"}else{ey="s_house"}}else{ey="dropbox"}if(!T){T=dW("Dropbox")}bg("#first-treeview-link span").text(T);b7.replace(bg("#root-img")[0],"web","dropbox",ey)}else{bg("#first-treeview-link span").text(dW("Dropbox"))}return bg.ajax(ex)},toggle:function(ey,ex){var T;Event.stop(ey);T=this.tv[ex||"treeview"];if(T.shown){T.shown=false;this.hide(ey,ex)}else{T.shown=true;this.show(ey.target,ex)}return false},hide:function(ey,ex){var T;T=this.tv[ex||"treeview"];if(!ey||!$(ey.target).descendantOf(T.viewdiv)){T.viewdiv.hide();Event.stopObserving(window,"click",T.hidefunc);return T.shown=false}},show:function(ey,ex){var ez,T;T=this.tv[ex||"treeview"];ey=$(ey);ey.blur();ez=ey.cumulativeOffset();T.viewdiv.setStyle({top:(ez.top+ey.getHeight())+"px",left:(ez.left-4)+"px"});T.viewdiv.show();return Event.observe(window,"click",T.hidefunc)},toggleNode:function(ex){var T;ex=$(ex);T=ex.down("img");if(T.className.match("bullet_plus")){b7.replace(T,"web","bullet_plus","bullet_minus")}else{b7.replace(T,"web","bullet_minus","bullet_plus")}ex.up().next("div").toggle();ex.blur();return false},toggleNodeAjax:function(ez,T,ex){var ey,eA;if(ez.fetched_children){return this.toggleNode(ez)}ez=$(ez);ey=ez.down("img");eA=b7._get(ey);ey.src="/static/images/icons/ajax-loading-small.gif";bg.ajax({url:"/ajax_subtreeview"+T,type:"post",data:bg.extend({},this.ajax_params),subject_user:ex,success:(function(eB){return function(eC){var eD;eD=new Element("div",{style:"display: none;"}).update(eC);ez.up().__sert({after:eD});ez.fetched_children=true;b7._set(ey,eA);return eB.toggleNode(ez)}})(this),complete:function(){if(/loading/.match(ey.src)){return b7._set(ey,eA)}}});return false},handle:function(ey,ex){var ez,T;ez=$H(this.tv).keys();T=$(ex).ancestors().find(function(eA){return ez.include(eA.id)});if(!T){return}T=this.tv[T.id];bg(document).trigger("db:treeview_selected",[ey]);if(T.handler){T.handler(ey,ex)}if(T.autohide){this.hide(T.id)}return false},move:function(ey,ez,ex){var T;T=$(ey);if(!this.loaded){this.reset({onSuccess:(function(eA){return function(){eA.loaded=1;return eA.move(ey,ez,ex)}})(this),user:ex!=null?ex.user:void 0})}else{if(ex&&ex.onSuccess){ex.onSuccess()}}cj(T,"Couldn't find tree_id");cj($(ez),"Couldn't find location_id");$(ez).appendChild(T);return T.show()}};var aC;aC=A.ULSelectMenu=(function(){var ez,eD,ey,eE,eF,eA,eC,T,eB,ex,eG;ez=function(eH){return eH.removeClassName("shown")};eG=function(eH){return eH.toggleClassName("shown")};eC=function(){return this.removeClassName("hover")};eA=function(){return this.addClassName("hover")};T=function(eL,eK){var eH,eM,eJ,eI;eI=[];for(eM=0,eJ=eK.length;eMT){return false}if(eB<1||eB>12){return false}if(ez<=0){return false}if(eB===2){ex=((eA%4)===0)&&(((eA%100)!==0)||((eA%400)===0));if(ex){return ez<=29}else{return ez<=28}}else{if(eB===4||eB===6||eB===9||eB===11){return ez<=30}else{return ez<=31}}},change_date:function(T,ez,ex){var ey;if(!this.is_valid_date(T,ez,ex)){return}ey=ex!==this.view_date.getFullYear()||ez!==this.view_date.getMonth();this.selected_date.setDate(T);this.selected_date.setMonth(ez);this.selected_date.setFullYear(ex);if(ey){this.view_date.setMonth(ez);this.view_date.setFullYear(ex);this.render()}else{bg(this.container).find(".selected").removeClass("selected");bg(this.container).find("a#day"+T+"-"+ez).addClass("selected")}if(this.options.onDateChange){return this.options.onDateChange(this.selected_date)}},render:function(){var ez,eF,eD,eB,eA,ex,eC,ey,eE,T;eF=this.render_days();eB=bg(".current-month",eF);eC=eB.first().data("date");ex=eB.last().data("date");T=eC<=this.options.first_day;eE=ex>=this.options.last_day;ez=new Element("div");ez.addClassName("calendar clearfix");if(!eE){this._next_month=(function(eG){return this._change_month(eG,this.view_date.getMonth()+1)}).bind(this);eA=new Element("a");eA.addClassName("changemonth next");eA.update(b7.make("web","arrowright",{}));Event.observe(eA,"click",this._next_month);ez.__sert(eA)}if(!T){this._prev_month=(function(eG){return this._change_month(eG,this.view_date.getMonth()-1)}).bind(this);ey=new Element("a");ey.addClassName("changemonth prev");ey.update(b7.make("web","arrowleft",{}));Event.observe(ey,"click",this._prev_month);ez.__sert(ey)}eD=new Element("h5");eD.update(dW("%(month)s %(year)s",{comment:"For example 'January 2010'. This is used as part of a calendar."}).format({month:bF.month_name(this.view_date.getMonth()),year:this.view_date.getFullYear()}));ez.__sert(eD);ez.__sert(eF);return this.container.__date(ez)},render_days:function(){var eD,eC,T,eB,ex,eA,ez,ey;eC=new Date(this.view_date.getFullYear(),this.view_date.getMonth(),1);ez=eC.getDay();eD=new Element("div");eD.addClassName("days");for(T=ey=ez;ez<=0?ey<0:ey>0;T=ez<=0?++ey:--ey){eA=new Date(eC.getFullYear(),eC.getMonth(),eC.getDate());eA.setDate(eA.getDate()-T);eD.__sert(this.render_day(eA,true))}eB=new Date(this.view_date.getFullYear(),this.view_date.getMonth(),1);while(eB.getMonth()===this.view_date.getMonth()){eD.__sert(this.render_day(eB));eB=new Date(this.view_date.getFullYear(),this.view_date.getMonth(),eB.getDate()+1)}ex=new Date(this.view_date.getFullYear(),this.view_date.getMonth()+1,0);while(ex.getDay()!==6){ex=new Date(ex.getFullYear(),ex.getMonth(),ex.getDate()+1);eD.__sert(this.render_day(ex,true))}return eD},render_day:function(ex,ez){var T,ey;ey=!ez;if(this.options.last_day){ez=ez||ex>this.options.last_day}if(this.options.first_day){ez=ez||ex=0;return s.change(eA,eB.target.getValue())})}return bg(".shared-additional-info").attr("name","shared_additional_info")},change:function(ey,T){var ex;bg(".downgrade-other-reason .error-message").hide();if(ey){return}ex="#downgrade-info-"+T;bg(".downgrade-info").hide();bg(ex).show();bg(".downgrade-info textarea").removeAttr("name");bg(ex+" textarea").attr("name","additional_info");return bg("input[name=other_reason_id]").removeAttr("checked")}};c=A.DowngradeSurvey={init:function(){var T;T="#downgrade-survey-form";return bg(""+T).on("submit",(function(ex){return function(eA){var ez,ey;ey=bg(""+T+" input[name=other_reason_id]:checked").length;ez=bg(""+T+" input[id=downgrade-radio-8]");if(ez.is(":checked")&&ey===0){bg(".downgrade-other-reason .error-message").show();return eA.preventDefault()}}})(this))}};var bM;bM=INLINE_JS.GetSpace=A.GetSpace={_current_space:null,_why_msg:null,_twitter_url:null,offer_highlight_color:"#ffa",init:function(ey,ex,ez){var T;bM._current_space=ey;bM._why_msg=ex;bM._twitter_url=ez;$("space-actions").on("click",".space-action",bM.perform_action);T=C.parse(window.location.href).fragment;if(T){return bM.highlight_offer(T)}},highlight_offer:function(ex){var T,ey;T=bg("#"+ex);ey=T.css("background-color");return T.css("background-color",bM.offer_highlight_color).delay(2000).animate({"background-color":ey}).queue(function(){return T.css("background-color","")})},perform_action:function(ex){var ey,T;T={contact_sales:bM._contact_sales,contact_support:bM._contact_support,teams:bM._teams,upgrade:bM._upgrade,plans:bM._plans,refer:bM._refer,get_started:bM._get_started,fb_link:bM._fb_link,twitter_link:bM._twitter_link,twitter_follow:bM._twitter_follow,why_like:bM._why_like,mailbox_link:bM._mailbox_link};ey=$(ex.target);if(!ey.hasClassName("space-action")){ey=ey.up(".space-action")}return T[ey.id]()},_teams:function(){return window.location.href="/business?tk=dropbox&ag=getspace&ad=v1"},_contact_sales:function(){return window.location.href="mailto:sales@dropbox.com"},_contact_support:function(){return window.location.href="/support"},_plans:function(){return window.location.href="/plans"},_upgrade:function(){return window.location.href="/upgrade"},_refer:function(){return window.location.href="/referrals"},_get_started:function(){return window.location.href="/gs"},_fb_link:function(){return dP.do_auth(function(){bM._refresh_link_bonuses();return bM._completed($("fb_link"))},ck.get_viewer().personal_user.id)},_twitter_link:function(){return cd.do_auth(function(){bM._refresh_link_bonuses();cd.set_is_authed(ck.get_viewer().personal_user.id,true);return bM._completed($("twitter_link"))},ck.get_viewer().personal_user.id)},_twitter_follow:function(){if(cd.is_authed(ck.get_viewer().personal_user.id)){return bM.follow_dropbox()}else{return cd.do_auth(bM.follow_dropbox,ck.get_viewer().personal_user.id)}},_why_like:function(){er.show(dW("Tell us why you love Dropbox"),$("why-i-like-modal"));$("why-i-like-input").focus();return du._track_twitter_chars_left("why-i-like-input",90)},_mailbox_link:function(){return window.location.href="http://www.mailboxapp.com/"},follow_dropbox:function(){if(!cd.is_authed(ck.get_viewer().personal_user.id)){bM._refresh_link_bonuses();cd.set_is_authed(ck.get_viewer().personal_user.id,true)}return cd.follow_dropbox({showWorking:function(){return $("twitter_follow").down(".title").__date(dW("Following Dropbox on Twitter..."))},onFailure:function(){return $("twitter_follow").down(".title").__date(dW("Follow Dropbox on Twitter"))},onSuccess:function(){if($("twitter_link")&&$("twitter_link").visible()){bM._completed($("twitter_link"))}return bM._completed($("twitter_follow"))}},ck.get_viewer().personal_user.id)},submit_why:function(){bM._why_msg=$F("why-i-like-input");return bt.ajax_submit($("why-i-like-form"),false,(function(){er.hide();return bM._completed($("why_like"))}),false,$("why-i-like-submit"))},_completed:function(ex){var T;ex.addClassName("completed");ex.down(".icon-col").__date(b7.make("web","check_36"));bg(ex).css("opacity",0.5).fadeTo(500,1);setTimeout((function(){return bg(ex).css("opacity",1).slideUp().animate({opacity:0},{queue:false,duration:"normal"})}),1500);T=parseInt(ex.down(".space").readAttribute("data-space"),10);bM._current_space+=T;$("current-space").__date(at.format_bytes(bM._current_space));$("current-space").addClassName("updated");return setTimeout((function(){return $("current-space").removeClassName("updated")}),5000)},_refresh_link_bonuses:function(){return new Ajax.DBRequest("/social_recheck")}};var bb;bb=A.Help={toggle_more_help:false,show_os:function(ex,ey,T){ey=$(ey);$$(".os-filter").invoke("removeClassName","selected");ey.addClassName("selected");$$(".help-os-section").invoke("hide");$$(".help-os-"+T).invoke("show");return Event.stop(ex)},vote:function(T,ex){new Ajax.DBRequest("/help/"+T+"/vote/"+ex);bg("#help-vote-cont").fadeOut();return Y.success(dW("Thanks for your feedback!"))}};var dT,di,X,r,cV=function(T,ex){return function(){return T.apply(ex,arguments)}},am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez};di=INLINE_JS.Hosts=A.Hosts={attach_host_listener:function(eA,ey){var ex,ez,eB,T;ex=bg("#"+eA);eB=ex.data("host-ids");ez=ex.data("display-name");T=function(){return new X(eB,ez,ey,null,null).show()};return bg(".unlink-host-link",ex).on("click",T)},edit:function(eB,ey){var ex,eC,eD,eA,ez,T;eD=bg("#host-device-row-"+ey+" .host-item .sprite-text");if(eD.data("editing")==="true"){return false}eD.data("editing","true");eC=eD.text();eD.data("previous",eC);eB=$u.values(eB);eA=bg('').val(eC);T=bg('').val(dW("Save"));T.on("click",function(){return di.doneEditing(eB,ey)});ex=bg('').val(dW("Cancel"));ex.on("click",function(){return di.cancelEditing(ey)});eD.empty();eD.append(eA," ",T," ",ex);ez=bg("input",eD);ez.on("keydown",function(){return di.checkKey(eB,ey)});return ez.focus()},doneEditing:function(ey,ex){var ez,T;ez=bg("#host-device-row-"+ex+" .host-item .sprite-text");T=bg("input",ez).val();return bg.ajax({url:"/account/change_host_name",data:{host_ids:JSON.stringify(ey),name:T},type:"POST"}).success(function(eA){return di.unedit(ez,JSON.parse(eA).display_name)})},cancelEditing:function(T){var ex;ex=bg("#host-device-row-"+T+" .host-item .sprite-text");return di.unedit(ex,ex.data("previous"))},unedit:function(ex,T){ex.data("editing","false");return ex.text(T)},dismiss:function(ey,ex,ez,T,eA){new bg.ajax("/account/dismiss_unlink",{type:"POST",data:{host_id:ey,user_id:ex,team_id:ez},subject_user:eA,success:function(eB){return T.remove()}});return false},checkKey:function(ex,T){return function(ey){ey=ey||window.event;if(ey.keyCode===Event.KEY_RETURN){di.doneEditing(ex,T)}if(ey.keyCode===Event.KEY_ESC){return di.cancelEditing(T)}}},show_device_unlink_modal:function(ez,eA,eC,ey,ex,eE,T){var eD,eB;eD=bg("#unlink-device-modal-"+eE);eB={both:$u.values(ex),personal:[ex[Constants.ROLE_PERSONAL]],work:[ex[Constants.ROLE_WORK]]};er.show(ey,eD[0]);if($u.values(ex).length>1){eD.addClass("show-selector")}return bg("form input[type=submit]",eD).on("click",function(eF){eF.preventDefault();ex=eB[bg(".unlink-select select",eD).val()];bt.add_vars(bg("form",eD)[0],{user_ids:JSON.stringify(ex),app_id:eA,device_id:JSON.stringify(ez),device_name:T});return bg("form",eD).submit()})}};dT=A.DeleteFailuresModal=(function(T){cm(ex,T);function ex(){this.on_show=cV(this.on_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);return ex.__super__.constructor.apply(this,arguments)}ex.prototype.on_confirm_button_click=function(ey){ey.preventDefault();window.location.href="/delete_failures?host_id="+this.host_id;return this.hide()};ex.prototype.on_show=function(ez){var ey;ey=aR("Dropbox couldn't delete %(num_failures)d file from the computer %(host_name)s. You can download the name of this file and the reason why it couldn't be deleted.","Dropbox couldn't delete %(num_failures)d files from the computer %(host_name)s. You can download the names of these files and the reasons why they couldn't be deleted.",this.num_failures).format({host_name:this.name.escapeHTML(),num_failures:this.num_failures});return this.$modal_window.find(".failures_message").html(ey)};return ex})(dw);r=INLINE_JS.show_delete_failures_modal=A.show_delete_failures_modal=function(ey,ex,T){var ez;ez=new dT({element_id:"delete-failures-modal"});ez.host_id=ey;ez.name=ex;ez.num_failures=T;ez.show();return false};X=INLINE_JS.UnlinkHostModal=A.UnlinkHostModal=(function(ex){cm(T,ex);function T(eC,eA,ey,ez,eB){this.host_ids=eC;this.name=eA;this.delete_support_type=ey;this.owner_id=ez;this.team_id=eB;this.on_show=cV(this.on_show,this);this._set_delete_text=cV(this._set_delete_text,this);this.fail_callback=cV(this.fail_callback,this);this.success_callback=cV(this.success_callback,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);T.__super__.constructor.call(this,{element_id:"unlink-host-modal"});this.show_host_selector=$u(this.host_ids).values().length>1}T.prototype.on_confirm_button_click=function(eB){var ez,eA,ey;eB.preventDefault();eA=this.$modal_window.find(".unlink_host_form")[0];ez=$(this.$modal_window.find(".confirm-button")[0]);this.$modal_window.find("[type=button]").attr("disabled","");ey={host_ids:JSON.stringify(this.get_selected_hosts())};return bt.ajax_submit(eA,false,this.success_callback,this.fail_callback,ez,ey)};T.prototype.success_callback=function(){return window.location.reload()};T.prototype.fail_callback=function(){return this.$modal_window.find("[type=button]").removeAttr("disabled")};T.prototype._set_delete_text=function(ey){return this.$modal_window.find(".delete_data_label").text(ey)};T.prototype._get_unlink_select=function(){return this.$modal_window.find(".unlink-select select").val()};T.prototype._set_delete_checkbox=function(){return this.$modal_window.find(".delete_data").prop("checked",true)};T.prototype._clear_delete_checkbox=function(){return this.$modal_window.find(".delete_data").prop("checked",false)};T.prototype.on_show=function(ez){var ey;this._clear_delete_checkbox();if(this.delete_support_type===Constants.DELETE_ON_UNLINK_OLD_CLIENT){this.$modal_window.find(".unlink_host_modal_content").addClass("show_old_client_modal")}else{if(this.delete_support_type===Constants.DELETE_ON_UNLINK_UNSUPPORTED){this.$modal_window.find(".unlink_host_modal_content .unlink_host_form").addClass("hidden")}else{if(this.delete_support_type===Constants.DELETE_ON_UNLINK_SUPPORTED_TEAM_ONLY){this._set_delete_checkbox();this.$modal_window.find(".unlink-choice").change((function(eA){return function(eB){if(eA._get_unlink_select()===Constants.ROLE_PERSONAL){eA._clear_delete_checkbox();return eA.$modal_window.find(".new_client").hide()}else{eA._set_delete_checkbox();return eA.$modal_window.find(".new_client").show()}}})(this));this._set_delete_text(dW("Delete files from %(team_name)s Dropbox the next time this computer comes online.").format({team_name:ck.get_viewer().team_name}))}else{if(this.delete_support_type===Constants.DELETE_ON_UNLINK_SUPPORTED_PERSONAL_ONLY){this._set_delete_checkbox();this.$modal_window.find(".unlink-choice").change((function(eA){return function(eB){if(eA._get_unlink_select()===Constants.ROLE_WORK){eA._clear_delete_checkbox();return eA.$modal_window.find(".new_client").hide()}else{eA._set_delete_checkbox();return eA.$modal_window.find(".new_client").show()}}})(this));this._set_delete_text(dW("Delete files from my personal Dropbox the next time this computer comes online."))}else{if(this.delete_support_type===Constants.DELETE_ON_UNLINK_SUPPORTED){this._set_delete_checkbox();this._set_delete_text(dW("Delete files from these Dropboxes the next time this computer comes online."));this.$modal_window.find(".unlink-choice").change((function(eA){return function(eB){if(eA._get_unlink_select()===Constants.ROLE_PERSONAL){return eA._set_delete_text(dW("Delete files from my personal Dropbox the next time this computer comes online."))}else{if(eA._get_unlink_select()===Constants.ROLE_WORK){return eA._set_delete_text(dW("Delete files from %(team_name)s Dropbox the next time this computer comes online.").format({team_name:ck.get_viewer().team_name}))}else{return eA._set_delete_text(dW("Delete files from these Dropboxes the next time this computer comes online."))}}}})(this))}}}}}if(this.show_host_selector){ey="";this.$modal_window.find(".unlink-select").removeClass("hidden");this.$modal_window.find(".unlink-modal-text").html(dW("Which Dropboxes do you want to unlink from %(host_name)s? Any Dropbox you unlink will immediately stop syncing.").format({host_name:ey}))}this.$modal_window.find("[name=host_id]").attr("value",this.host_id);this.$modal_window.find("[name=team_id]").attr("value",this.team_id);this.$modal_window.find("[name=user_id]").attr("value",this.owner_id);return this.$modal_window.find(".host_name").text(this.name)};T.prototype.get_selected_hosts=function(){var ey;if($u.values(this.host_ids).length===1){return $u.values(this.host_ids)}ey=bg(".unlink-choice").val();if(ey==="both"){return $u.values(this.host_ids)}else{return[this.host_ids[ey]]}};return T})(dw);var d5;d5=A.News={DEFAULT_TAB:"recent-news",init:function(){$("news-home").on("click","#nav a",function(ex,ey){var T;if(ey.hasAttribute("data-div")){ex.preventDefault();T=ey.readAttribute("data-div");return dZ.push_state("/news/"+T)}});return dZ.add_callback("/news",d5.history_change)},change_tab:function(T){var ex;ex=$$("#nav a[data-div="+T+"]").first();if($(ex)){$$(".section").invoke("removeClassName","selected");$$("#nav a").invoke("removeClassName","selected");$(ex).addClassName("selected");return $(T).addClassName("selected")}},history_change:function(T){T=T||d5.DEFAULT_TAB;return d5.change_tab(T)}};var c6;c6=A.Recover={init:function(){var T;T=$("recover-form");return T.observe("submit",this.form_submit.bind(this))},form_submit:function(T){this.clear_error();T.preventDefault();return bt.ajax_submit($("recover-form"),null,this.submit_response.bind(this))},submit_response:function(ex){var T;T=JSON.parse(ex.responseText);if(T.status==="error"){this.show_error(T.msg)}if(T.status==="ok"){this.show_hosts(T)}if(T.status==="redirect"){return window.location.href=T.url}},show_hosts:function(eD){var eA,ey,ez,T,eC,ex,eB;bt.add_vars($("recover-form"),{check_file:"true"});$("filename-to-create").update(eD.filename);ey=$("trusted-hosts");ey.update();eB=eD.hosts;for(eC=0,ex=eB.length;eC0,"Element is missing an id");T.push(eB.observe("click",(function(eC){return this.click(eC)}).bindAsEventListener(ey)))}return T},click:function(T){if(this.options.killEvent){Event.stop(T)}return this.toggle($(T.target))},toggle:function(ex){var eA,T,ez,eB,ey;ey=this.container.down("a.selected");if(ey){eB=$(ey.id+"-content");if(eB){eB.hide()}}this.container.select(".selected").invoke("removeClassName","selected");T=false;if(!ex){ex=this.container.down("a");T=true}ex.addClassName("selected");eA=$(ex.id+"-content");if(eA){eA.show()}if(this.options.onTabChange){this.options.onTabChange(ex,ey)}if(this.options.url_prefix){ez=this.options.url_prefix;if(!T){ez+="/"+ex.id}return dZ.push_state(ez)}}});var dd;dd=A.InviteForm={initialized:false,init:function(){if(this.initialized){return}return bg((function(T){return function(){T.add_auto_completer=new Autocompleter.ContactsTokenizer(ck.get_viewer().get_user_by_role(Constants.ROLE_WORK),"team-invite-new-collab-input","team-invite-new-whobulk","team-invite-hidden-input",{tokens:[",",";"],hide_import_contacts:true,suggestions_disabled:true,contact_filter:function(ex){return ex.excludeTeamMembers().excludeFacebook().excludeGroups().excludeNewStyleGroups().excludeRooms().excludeMe()}});T.add_auto_completer.clearTokens();T.tokenAdd=bg.proxy(T._tokenAdd,T);T.tokenRemove=bg.proxy(T._tokenRemove,T);bg("#team-invite-new-collab-input")[0].on("token:add",T.tokenAdd);bg("#team-invite-new-collab-input")[0].on("token:remove",T.tokenRemove);T.reset_licenses();T.initialized=true;T.setup_tab_support(bg);return bT.init()}})(this))},set_emails:function(T){if(T==null){return}return bg((function(ex){return function(){var eA,eC,eB,ez,ey;ex.init();ey=[];for(eB=0,ez=T.length;eB0){this.total_licenses+=T;this.available_licenses+=T;this.update_license_count();if(__CIRCULAR_DEPENDENCY__.Dashboard!=null){return __CIRCULAR_DEPENDENCY__.Dashboard.add_licenses(T)}}},on_add_licenses_exit:function(ex,T){var ey;if((ey=this.invite_modal)!=null?ey.$modal_window:void 0){this.rebind_modal_submit_autocompleter()}return this.add_total_licenses(T)},reset_modal:function(){var T;T=this.invite_modal.$modal_window;cA.reset(T.find("#team-invite-message")[0]);if(this.add_auto_completer){this.add_auto_completer.clearTokens()}this.reset_modal_licenses();return T.find(".new-collab-input").val("")},on_add_licenses_click:function(ex){var T;ex.preventDefault();if(this.is_trial){if((T=this.invite_modal)!=null){T.hide()}return __CIRCULAR_DEPENDENCY__.add_more_licenses_to_trial()}else{if(this.add_licenses_cb!=null){dp.unregister(__CIRCULAR_DEPENDENCY__.AddLicensesModal.LICENSES_ADDED,this.add_licenses_cb)}this.add_licenses_cb=bg.proxy(this.on_add_licenses_exit,this);dp.register(__CIRCULAR_DEPENDENCY__.AddLicensesModal.LICENSES_ADDED,this.add_licenses_cb);return dp.push(new __CIRCULAR_DEPENDENCY__.AddLicensesModal())}}};var t,cV=function(T,ex){return function(){return T.apply(ex,arguments)}},am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez};t=A.InviteModal=(function(ex){cm(T,ex);function T(ey){this.transition_view_model=ey;this._reset=cV(this._reset,this);this._update_form_pricing_information=cV(this._update_form_pricing_information,this);this._update_remaining_licenses_message=cV(this._update_remaining_licenses_message,this);this._make_transition_info_request=cV(this._make_transition_info_request,this);this._handle_token_change=cV(this._handle_token_change,this);this._licenses_total=cV(this._licenses_total,this);this._licenses_to_add=cV(this._licenses_to_add,this);this.on_hide=cV(this.on_hide,this);this.on_show=cV(this.on_show,this);T.__super__.constructor.call(this,{element_id:"team-invite-wizard",focus:".new-collab-input"});this.inline_add_license=this.transition_view_model!=null;if(this.inline_add_license){this.transition_info_fetcher=new et([ey]);this.probability=Math.random()}this.skip_reset=false}T.prototype.on_confirm_button_click=function(ey){return dh.add_users(ey,this.add_qty)};T.prototype.on_show=function(){var ey;this._reset();ey=bg("#team-invite-wizard .team-invite-add-licenses");ey.on("click",bg.proxy(dd.on_add_licenses_click,dd));bg(window).on("token:changed",this._handle_token_change);if(dd.initialized){dd.update_license_count()}return dp.register(dp.CLEAR,function(){return dd.reset_modal()})};T.prototype.on_hide=function(){return bg(window).off("token:changed",this._handle_token_change)};T.prototype._licenses_to_add=function(){return -1*dd.available_licenses};T.prototype._licenses_total=function(){return dd.total_licenses+this._licenses_to_add()};T.prototype._handle_token_change=function(ez,ey){this._update_remaining_licenses_message(ey.remaining_licenses);if(this.inline_add_license){clearTimeout(this.fetch_transition_timeout_id);return this.fetch_transition_timeout_id=setTimeout((function(eA){return function(){eA._make_transition_info_request();return eA.fetch_transition_timeout_id=null}})(this),100)}};T.prototype._make_transition_info_request=function(){var eA,ez,ey,eB;ez=Math.floor(Math.random()*1000000);this.current_callback_token=ez;eA=this._licenses_to_add();ey=this._licenses_total();eB=(function(eC){return function(eD){return eC._update_form_pricing_information(ez,eA,ey,eD[0])}})(this);if(eA>0){return this.transition_info_fetcher.get(eB,{total_users:this._licenses_total()})}else{return eB(null)}};T.prototype._update_remaining_licenses_message=function(ey){var ez;this.remaining_licenses=ey;ez=this._get_remaining_licenses_message(ey);return this.$modal_window.find("#license-count-message").text(ez)};T.prototype._get_remaining_licenses_message=function(ey){var ez;if(ey<0){ez=dW("You need more licenses for this invitation.")}else{if(ey===0){ez=dW("After this invitation, you'll have no remaining licenses.")}else{ez=aR("After this invitation, you'll have %(count)d remaining license.","After this invitation, you'll have %(count)d remaining licenses.",ey).format({count:ey})}}return ez};T.prototype._update_form_pricing_information=function(eB,eC,ey,eF){var ez,eE,eD,eA;if(eB!==this.current_callback_token){return}if(eF&&eC>0){this.add_qty=eC;ez=this.transition_view_model.state.currency;eD=eF.current_total.amount;eE=es.formatCurrency(eD,ez);eA=es.formatCurrency(eF.recurring_total.amount,ez);bg(".new-amount").text(eE);bg(".add-qty").text(eC);bg(".recurring-amount").text(eA);bg(".total-qty").text(ey);bg(".charges-section").show();bg(".team-invite-buttons .confirm-button").val(dW("Invite and buy"));return bg("#expected_price").val(eD)}else{return this._reset()}};T.prototype._reset=function(){this.add_qty=0;bg(".charges-section").hide();bg("#expected_price").val(0);return bg(".team-invite-buttons .confirm-button").val(dW("Invite to team"))};return T})(dw);var bj,al,ao,N,dC,eh,a8,d3,dh,eq,b2,n,cV=function(T,ex){return function(){return T.apply(ex,arguments)}},am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez};dh=INLINE_JS.Team=A.Team={_use_async_reset:false,team_id:ck.get_viewer().team_id,set_team_id:function(T){this.team_id=T},setup_beta_modal_listeners:function(){var eB,eE,eC,T,eA,ez,eD,ex,ey;eE=bg(".feature-list .enroll-button");T=bg(".feature-list .feedback-button");for(eA=0,eD=eE.length;eA1){return Y.success(dW("Invited %(user_count)d people.").format({user_count:eE.length}))}else{return Y.error(aR("Skipped %(num_skipped)d person who is already a member of the team.","Skipped %(num_skipped)d people who are already members of the team.",eA.length).format({num_skipped:eA.length}))}}}else{return Y.error()}},onFailure:function(eD){var eB,eC;if(eD){if(eD.responseText.indexOf("err:")===0){eB=eD.responseText.substr(4);if(eB.indexOf("{")===0){eC=eB.evalJSON(true);bt.fill_errors(ex,eC)}else{eB=new eu(eB);Y.error(eB)}}else{Y.error()}}bt.remove_loading();return bg("input[type='submit']").prop("disabled",false)},cleanUp:function(){bt.remove_loading();dd.reset_modal();return dd.invite_modal.hide()}})},show_demo_signup_modal:function(ey,ez,eA,ex,eB){var T,eE,eD,eC;this.webinar_key=ey;this.webinar_iso_datetime=ez;this.webinar_date=eA;this.webinar_title=ex;this.tab_url=eB;eC=dW("Register for a webinar on %(start_time)s").format({start_time:this.webinar_date});eE=new N({element_id:"demo-signup-modal",title:eC});eE.show();eE.$modal_window.find("input[name=webinar_key]").attr("value",this.webinar_key);eE.$modal_window.find("input[name=webinar_title]").attr("value",this.webinar_title);eE.$modal_window.find("input[name=Sales_Webinar_Topic__c]").attr("value",this.webinar_title);eE.$modal_window.find("input[name=Sales_webinar_date__c]").attr("value",this.webinar_iso_datetime);eD=eE.$modal_window.find("input[name=retURL]");eD.attr("value",eD.val()+"#"+this.tab_url);T=eE.$modal_window.find("#demo-signup-form")[0];return T.on("submit",eE.on_confirm_button_click)},show_unsuspend_modal:function(ey,T,ex){var ez;ez=new a8({element_id:"dfe-unsuspend-modal",focus:"confirm"});ez.user_name=ey||ex;ez.email=ex;ez.user_id=T;ez.team_id=this.team_id;ez.show();return false},show_remove_or_deactivate_modal:function(ey,eA,T,ex,eB){var ez;ez=new dC({element_id:"dfe-remove-or-deactivate-user-modal",focus:".new-collab-input"});ez.user_name=eA||ex;ez.email=ex;ez.user_id=T;ez.team_id=this.team_id;ez.invited=eB;ez.show();return false},show_remove_modal:function(ey,eA,T,ex,eB){var ez;ez=new eh({element_id:"dfe-remove-user-modal",focus:".new-collab-input"});ez.user_name=eA||ex;ez.email=ex;ez.user_id=T;ez.team_id=this.team_id;ez.invited=eB;ez.show();return false},remove_user:function(ez,eA){var ey,ex,T;alert("in remove_user");Event.stop(ez);ex=bg("input[type=submit]","#remove-user-modal");ex.attr("disabled",1);T=er.vars.user_id;if(eA){ey=true}else{ey=bg("input[name=disable_if_joined]:checked","#remove-user-modal").val()}return new Ajax.DBRequest("/account/team/remove_user",{parameters:{team_id:this.team_id,user_id:T,disable_if_joined:ey},onSuccess:(function(eB){return function(eE){var eD,eF,eC;eD=JSON.parse(eE.responseText);if((eF=window.active_team_member_table)!=null){eF.remove_user(er.vars.user_id)}if((eC=window.removed_team_member_table)!=null){eC.add_users(eD)}eB.decrement_used_licenses();return Y.success(dW("User removed."))}})(this),cleanUp:function(){er.hide();return ex.removeAttr("disabled")}})},show_reinvite_modal:function(ey,ez,T,ex){var eA;cT.fillVal(ex,"reinvite-user-email");cT.fillVal(ez,"reinvite-user-team");eA=dW("Resend invite to '%(email_address)s'").format({email_address:bu.em_snippet(ex,18)});return er.show(eA,$("reinvite-user-modal"),{user_id:T,button:ey})},reinvite_user:function(ex){var T;Event.stop(ex);T=er.vars.user_id;return new Ajax.DBRequest("/account/team/reinvite_user",{parameters:{team_id:this.team_id,user_id:T},onSuccess:function(eB){var ez,eA,ey,eC;Y.success(dW("Invite sent."));if((eC=$("team-member-info"))!=null){eC.update(eB.responseText)}ez=window.active_team_member_table;if(ez){ey=ez.data.users[T];ey.invite_expired=false;eA={};eA[T]=ey;return ez.update_user_data(eA)}},cleanUp:function(){return er.hide()}})},show_user_activity_log_modal:function(T,ey,ez){var ex;ex=bg("#activity-log-modal");ex.find(".activity-log-email").text(ey);ex.find(".activity-log-name").text(ez);ex.find("#activity-log-user-message").show();return er.show(dW("Create activity report"),ex[0],{user_id:T})},show_team_activity_log_modal:function(ex,ey){var T;T=bg("#activity-log-modal");T.find(".activity-log-email").text(ex);T.find(".activity-log-name").text(ey);T.find("#activity-log-team-message").show();return er.show(dW("Create full activity report"),T[0])},generate_activity_log:function(eD){var eB,ez,eC,eA,T,ey,ex;Event.stop(eD);ez=bg("#activity-log-modal");eC=ez.find("input[name='from_date']").val();T=ez.find("input[name='to_date']").val();if(eC>T){Y.error(dW("Your start date is after your end date."));return}eA=this.team_id;ex=er.vars.user_id;ey=new Date().getTimezoneOffset().toString();eB=bg(".activity-report-generator .freshbutton-blue");eB.prop("disabled",true);return new Ajax.DBRequest("/team/events_report/csv",{parameters:{from_date:eC,to_date:T,team_id:eA,user_id:ex,tzoffset:ey},onSuccess:function(eE){return Y.success(dW("Report started. We'll email you when it's ready."))},cleanUp:function(){er.hide();return eB.prop("disabled",false)}})},show_reset_password_modal:function(ex,ey,T){var ez;bg("#reset-password-modal .member-name").text(ey);ez=dW("Reset password for '%(user_name)s'").format({user_name:ey});return er.show(ez,$("reset-password-modal"),{user_id:T,button:ex})},reset_password:function(ex){var T;Event.stop(ex);T=er.vars.user_id;return new Ajax.DBRequest("/account/team/reset_password",{parameters:{team_id:this.team_id,user_id:T},onSuccess:function(ey){return Y.success(dW("User's password reset."))},cleanUp:function(){return er.hide()}})},show_reset_all_passwords_modal:function(){return er.show(dW("Reset all passwords"),$("reset-all-passwords-modal"))},set_async_password_reset:function(T){return this._use_async_reset=T},reset_all_passwords:function(){return new Ajax.DBRequest("/account/team/reset_all_passwords",{parameters:{team_id:this.team_id},job:this._use_async_reset,subject_user:ck.get_viewer().work_user,progress_text:dW("Resetting all passwords..."),onSuccess:function(T){return Y.success(dW("All passwords reset."))},cleanUp:function(){return er.hide()}})},show_admin_status_modal:function(ey,eE,eG,eA,eF,eB){var ex,eC,T,ez,eD;T=eF.strip()||eA;ez=void 0;ex=void 0;eD=void 0;eC=void 0;if(eB){eD=dW("Add admin permissions for '%(person_name)s'").format({person_name:T.escapeHTML()});ez=dW("Are you sure you want to add admin permissions for %(person_name)s?").format({person_name:T.escapeHTML()});ex=dW("Add admin permissions",{comment:"make this user an admin; give them the permissions an admin has"});eC="alert_32"}else{eD=dW("Remove admin privileges from '%(person_name)s'").format({person_name:T.escapeHTML()});ez=dW("Are you sure you want to remove admin permissions from %(person_name)s?").format({person_name:T.escapeHTML()});ex=dW("Remove admin permissions",{comment:"clicking this button completes the action: it removes a person's admin status"});eC="alert_32"}cT.fillVal(eA,"admin-status-email");cT.fillVal(ez,"admin-status-action");cT.fillVal(ex,"admin-status-button-action");return er.show(eD,$("admin-status-modal"),{user_id:eG,button:ey,admin_on:eB})},set_admin_status:function(ex){var T;Event.stop(ex);T=er.vars.user_id;return new Ajax.DBRequest("/account/team/set_admin_status",{parameters:{team_id:this.team_id,user_id:T,on:(er.vars.admin_on?"yes":"no")},onSuccess:function(ez){var eA,ey;eA=(er.vars.admin_on?dW("User's admin status granted."):dW("User's admin status removed."));if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){return __CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}else{if(window.active_team_member_table){ey=JSON.parse(ez.responseText);window.active_team_member_table.update_user_data(ey);return Y.success(eA)}else{if(er.vars.admin_on){return window.location="/team/admin/member?id=%d&msg=granted".format(er.vars.user_id)}else{return window.location="/team/admin/member?id=%d&msg=removed".format(er.vars.user_id)}}}},cleanUp:function(){return er.hide()}})},show_disable_2fa_modal:function(ey,T,ex){bg("#disable-2fa-modal .member-name").text(ex);return er.show(dW("Disable two-step verification"),$("disable-2fa-modal"),{user_id:T,elm:ey})},show_reset_2fa_modal:function(ey,T,ex){bg("#reset-2fa-modal .member-name").text(ex);return er.show(dW("Disable two-step verification"),$("reset-2fa-modal"),{user_id:T,user_name:ex,elm:ey})},reset_2fa:function(){return new Ajax.DBRequest("/account/team/reset_2fa",{parameters:{team_id:this.team_id,user_id:er.vars.user_id},onSuccess:function(ex){var T;bg(".tfa_enabled").replaceWith(dW("Disabled"));T=JSON.parse(ex.responseText);if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){__CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}else{if(window.active_team_member_table){window.active_team_member_table.update_user_data(T)}else{if(__CIRCULAR_DEPENDENCY__.MemberActionsMenu){__CIRCULAR_DEPENDENCY__.MemberActionsMenu.update_container_users(".buttons",T)}}}Y.success(dW("Two-step verification reset for %(user_name)s").format({user_name:er.vars.user_name}));return er.hide()}})},disable_2fa:function(){return new Ajax.DBRequest("/account/team/disable_2fa",{parameters:{team_id:this.team_id,user_id:er.vars.user_id},onSuccess:function(ex){var T;bg(".tfa_enabled").replaceWith(dW("Disabled"));T=JSON.parse(ex.responseText);if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){__CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}else{if(window.active_team_member_table){window.active_team_member_table.update_user_data(T)}else{if(__CIRCULAR_DEPENDENCY__.MemberActionsMenu){__CIRCULAR_DEPENDENCY__.MemberActionsMenu.update_container_users(".buttons",T)}}}Y.success(dW("Two-step verification disabled."));return er.hide()}})},show_sso_preview_email:function(T){return er.show(dW("Email preview"),$(T))},show_sso_sample_email:function(T){return er.show(dW("Sample email"),$(T))},show_user_message_modal:function(ey,ex,T){var ez;cT.fillVal(T,"user-message-email");ez=dW("Send email to '%(user_name)s'").format({user_name:ey});$("user-message").value="";er.show(ez,$("user-message-modal"),{user_name:ey,user_id:ex});return du.focus.defer("user-message")},send_user_message:function(){var ex,T;T=er.vars.user_id;ex=$F("user-message").strip();return new Ajax.DBRequest("/account/team/send_user_message",{parameters:{user_id:T,team_id:this.team_id,message:ex},onSuccess:function(){var ey;ey=er.vars.user_name;Y.success(dW("Message successfully sent to %(user_name)s.").format({user_name:ey}));return er.hide()}})},hide_team_name_change_banner:function(){new Ajax.DBRequest("/account/team/name_change_notice_received",{parameters:{team_id:this.team_id}});bg(".team_name_change_notice").hide();return false},hide_pin_banner:function(){new Ajax.DBRequest("/team/invalidate_pin");return bg(".pin_notice").hide()},hide_pin_banner_with_user_id:function(T,ex){var ey;ey=function(ez){return bg(ex).closest("span").removeClass("on").addClass("off")};if(T===null){return new Ajax.DBRequest("/team/invalidate_pin",{onSuccess:ey})}else{return new Ajax.DBRequest("/team/invalidate_pin",{parameters:{user_id:T},onSuccess:ey})}},get_pin_with_user_id:function(T,ey,ex){var ez;if(ex==null){ex=null}if(ex===null){ex=function(eB,eA){bg(eA).closest("span").find(".pin-value").text(eB.pin+" -");return bg(eA).closest("span").removeClass("off").addClass("on")}}ez=function(eB){var eA;eA=JSON.parse(eB.responseText);return ex(eA,ey)};if(T===null){return new Ajax.DBRequest("/team/generate_pin",{onSuccess:ez})}else{return new Ajax.DBRequest("/team/generate_pin",{parameters:{user_id:T},onSuccess:ez})}},send_team_message:function(ex){var T;Event.stop(ex);T=$F("team-message").strip();if(T){return new Ajax.DBRequest("/account/team/send_team_message",{parameters:{team_id:this.team_id,message:T},onSuccess:function(ey){Y.success(dW("Message successfully sent to team."));return er.hide()}})}},show_security_message_modal:function(){return new eq().show()},send_team_security_message:function(ey){var ex,T;Event.stop(ey);T=$F("team-security-message").strip();ex=$("team-security-message-form");return new Ajax.DBRequest("/account/team/send_team_message",{parameters:ex.serialize(true),onSuccess:function(ez){Y.success(dW("Message successfully sent."));return er.hide()}})},used_licenses:0,total_licenses:0,set_used_licenses:function(T,ex){this.used_licenses=T;return this.total_licenses=ex},decrement_used_licenses:function(){return this.set_used_licenses(this.used_licenses-1,this.total_licenses)},show_migration_link:function(T,ex){$("migration-url").value=ex;er.show(dW("Migration link for '%(email)s'").format({email:bu.em_snippet(T,18)}),$("migrate-url-modal"));return $("migration-url").select()},show_end_session_modal:function(ex,T,ey){a2.hide_all();bg("#end-session-modal .member-name").text(bg("#member-name").text());return er.show(dW("Close web session",{comment:"Log out of your current Dropbox web session"}),$("end-session-modal"),{login_id:ex,user_id:T,elm:ey})},end_session:function(){return new Ajax.DBRequest("/logout_remote_session",{parameters:{remote_login_id:er.vars.login_id,team_id:this.team_id,user_id:er.vars.user_id},onSuccess:function(){er.hide();dh.remove_closest_row(er.vars.elm);return Y.success(dW("Web session closed."))}})},unlink_device:function(T,ez,eD,ex,eE,ey,eA){var eC,eB;a2.hide_all();eC=$("unlink-device-modal-"+ey);eB=dW("Unlink %(device_name)s").format({device_name:eD});return er.show(eB,eC,{app_id:ez,user_id:eE,elm:eA,device_id:T,display_name:eD})},unlink_device_submit:function(){return new Ajax.DBRequest("/account/unlink_team_device",{parameters:{app_id:er.vars.app_id,team_id:this.team_id,user_id:er.vars.user_id,device_id:JSON.stringify(er.vars.device_id)},subject_user:ck.get_viewer().work_user,onSuccess:function(){er.hide();dh.remove_closest_row(er.vars.elm);return Y.success(dW("%(device_name)s unlinked.").format({device_name:er.vars.display_name}))}})},disable_app:function(ex,ey,T,ez){a2.hide_all();bg("#disable-app-modal .app-name").text(ey);bg("#disable-app-modal .member-name").text(bg("#member-name").text());return er.show(dW("Disable '%(app_name)s'?").format({app_name:ey}),$("disable-app-modal"),{app_id:ex,user_id:T,elm:ez})},disable_app_submit:function(){return new Ajax.DBRequest("/api/uninstall_app",{parameters:{app_id:er.vars.app_id,keep_sandbox_files:true,team_id:this.team_id,user_id:er.vars.user_id},subject_user:ck.get_viewer().work_user,onSuccess:function(T){er.hide();dh.remove_closest_row(er.vars.elm);return Y.success(T.responseText)}})},remove_closest_row:function(ez){var ey,ex,T;ey=bg(ez).closest(".team_admin_table_row");ex=bg(ey).closest(".team_admin_table");if(ex.find(".team_admin_table_row").length===1){T=ex.prev(".team_admin_table_title");if(!T.length){T=bg(".team_apps_table_panel")}T.remove();return ex.remove()}else{return ey.remove()}},submit_report_form:function(T){bg(T.target.elements.tzoffset).val(""+new Date().getTimezoneOffset());return true}};al=A.BetaEnrollConfirmationModal=(function(ex){cm(T,ex);function T(ey){this.feature_name=ey;this.on_confirm_button_click=cV(this.on_confirm_button_click,this);T.__super__.constructor.call(this,{element_id:"beta-enroll-confirmation-modal"})}T.prototype.on_confirm_button_click=function(ey){bg("").attr({type:"hidden",name:"feature_name",value:this.feature_name}).appendTo("#beta-enroll-confirmation-modal form");return this.$modal_window.addClass("ajax-loading")};return T})(dw);ao=A.BetaFeedbackModal=(function(ex){cm(T,ex);function T(ey){this.feature_name=ey;this.error=cV(this.error,this);this.success=cV(this.success,this);T.__super__.constructor.call(this,{element_id:"beta-feedback-modal"});this.on_confirm_button_click=(function(ez){return function(eD){var eC,eB,eA;eD.preventDefault();eC=bg(eD.target);eB=eC.closest("form");eA={feature_name:ez.feature_name};return bt.ajax_submit(eB[0],false,ez.success,ez.error,eC[0],eA)}})(this)}T.prototype.success=function(ey){Y.success(dW("Thank you for your feedback."));return this.$modal_window.hide()};T.prototype.error=function(ey){if(ey.status!==200){return Y.error(dW("Failed to submit feedback. Please try again."))}};return T})(dw);N=A.DemoSignupModal=(function(T){cm(ex,T);function ex(){this.on_show=cV(this.on_show,this);this.on_confirm_button_click=cV(this.on_confirm_button_click,this);return ex.__super__.constructor.apply(this,arguments)}ex.prototype.on_confirm_button_click=function(eC){var eK,eH,eD,ey,eF,eA,eJ,eI,ez,eG,eE,eB;eC.preventDefault();eE=$("demo-signup-form");eI=$("1210");eA=bg(eE).find("input[name='first_name']").val();bg(eI).find("input[name='FirstName']").attr("value",eA);eJ=bg(eE).find("input[name='last_name']").val();bg(eI).find("input[name='LastName']").attr("value",eJ);eF=bg(eE).find("input[name='email']").val();bg(eI).find("input[name='Email']").attr("value",eF);eG=bg(eE).find("input[name='phone_number']").val();bg(eI).find("input[name='Phone']").attr("value",eG);eK=bg(eE).find("input[name='company_name']").val();bg(eI).find("input[name='Company']").attr("value",eK);eD=bg(eE).find("select[name='company_size']");eH=eD.find("option:selected").val();bg(eI).find("input[name='Company_size__c']").attr("value",eH);ey=$(this.$modal_window.find(".confirm-button")[0]);eB=(function(eL){return function(eM){eL.$modal_window.hide();return eI.submit()}})(this);ez=bt.collect_form_vars(eE,true);return bt.ajax_submit(eE,false,eB,false,ey,ez,true)};ex.prototype.on_show=function(ey){this.$modal_window.find(".db-modal-content").css({"overflow-y":""});return bT.init()};return ex})(dw);bj=A.AccountTransferBaseModal=(function(ex){cm(T,ex);function T(ey,eA,ez){this.file_action_selector=eA;this.transfer_choice_selector=ez;this._clearInput=cV(this._clearInput,this);this._markInputInvalid=cV(this._markInputInvalid,this);this._markInputValid=cV(this._markInputValid,this);this._tokenRemove=cV(this._tokenRemove,this);this._tokenAdd=cV(this._tokenAdd,this);this._selectChange=cV(this._selectChange,this);this._isTransferSelected=cV(this._isTransferSelected,this);this.handleAjaxFailure=cV(this.handleAjaxFailure,this);T.__super__.constructor.call(this,ey,this.file_action_selector,this.transfer_choice_selector)}T.prototype.on_show=function(){if(this.$modal_window.find("#manage-files-new-collab-input").length===0){return}this.auto_completer=new Autocompleter.TeamTokenizer(ck.get_viewer().get_user_by_role(Constants.ROLE_WORK),"manage-files-new-collab-input","manage-files-new-whobulk","manage-files-hidden-input",{hide_import_contacts:true,suggestions_disabled:true,wrap_name:true,single_token:true,contact_filter:(function(ey){return function(ez){return ez.excludeNonTeam().excludeGroups().excludeNewStyleGroups().excludeRooms().excludeByEmail(ey.email?[ey.email.toLowerCase()]:[])}})(this)});this.tokenAdd=bg.proxy(this._tokenAdd,this);this.tokenRemove=bg.proxy(this._tokenRemove,this);this.$collab_input=this.$modal_window.find("#manage-files-new-collab-input")[0];this.$collab_input.on("token:add",this.tokenAdd);this.$collab_input.on("token:remove",this.tokenRemove);this.$textinput=this.$modal_window.find(".tokenized_autocompleter_container .textinput");this.selectChange=bg.proxy(this._selectChange,this);return this.$modal_window.find(this.file_action_selector).on("change",this.selectChange)};T.prototype.handleAjaxFailure=function(ey){if(ey.status===200&&this._isTransferSelected()){return this._markInputInvalid()}};T.prototype._isTransferSelected=function(){return bg(this.transfer_choice_selector).prop("checked")};T.prototype._selectChange=function(ey){if(this._isTransferSelected()){return this.$textinput.removeClass("unselected")}else{return this.$textinput.addClass("unselected")}};T.prototype._tokenAdd=function(ey){this.$collab_input.hide();if(ey.memo.valid){return this._markInputValid()}else{return this._markInputInvalid()}};T.prototype._tokenRemove=function(ey){this.$collab_input.show();return this._clearInput()};T.prototype._markInputValid=function(){this._clearInput();return this.$textinput.addClass("valid")};T.prototype._markInputInvalid=function(){this._clearInput();return this.$textinput.addClass("invalid")};T.prototype._clearInput=function(){this.$textinput.removeClass("valid");return this.$textinput.removeClass("invalid")};return T})(dw);eq=A.TwoFactorMessageModal=(function(ex){cm(T,ex);function T(){T.__super__.constructor.call(this,{element_id:"team-security-message-modal",focus:"#team-security-message"})}T.prototype.on_confirm_button_click=function(ey){dh.send_team_security_message(ey);return this.hide()};return T})(dw);a8=A.DfeUnsuspendUserModal=(function(T){cm(ex,T);function ex(ey){this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.success_callback=cV(this.success_callback,this);ex.__super__.constructor.call(this,ey)}ex.prototype.before_show=function(){var ey;ex.__super__.before_show.call(this);ey=dW("Un-suspend %(user_name)s").format({user_name:this.user_name});this.$modal_window.find(".db-modal-title-text").text(ey);this.$modal_window.find("[name=user_id]").attr("value",this.user_id);this.$modal_window.find("[name=team_id]").attr("value",this.team_id);this.$modal_window.find("[name=email]").attr("value",this.email);this.$modal_window.find(".unsuspended_name").text(this.user_name);return this.$modal_window.find(".unsuspended_email").text(this.email)};ex.prototype.success_callback=function(ey){var ez;Y.success("User un-suspended");if((ez=__CIRCULAR_DEPENDENCY__.MembersReact)!=null){ez.refresh_member_stats()}return this.hide()};ex.prototype.on_confirm_button_click=function(eA){var ey,ez;eA.preventDefault();ez=this.$modal_window.find(".dfe-unsuspend-modal")[0];ey=$(this.$modal_window.find(".confirm-button")[0]);return bt.ajax_submit(ez,false,this.success_callback,false,ey)};return ex})(dw);dC=A.DfeRemoveOrDeactivateUserModal=(function(ex){cm(T,ex);function T(ey){this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.success_callback=cV(this.success_callback,this);this.on_show=cV(this.on_show,this);this.handle_change_action=cV(this.handle_change_action,this);this.switch_to_uninvite_mode=cV(this.switch_to_uninvite_mode,this);this.switch_to_removal_mode=cV(this.switch_to_removal_mode,this);this.switch_to_deactivation_mode=cV(this.switch_to_deactivation_mode,this);this.show_removal_content=cV(this.show_removal_content,this);this.show_deactivation_content=cV(this.show_deactivation_content,this);this.set_modal_class=cV(this.set_modal_class,this);this.set_form_action_to_remove=cV(this.set_form_action_to_remove,this);this.set_form_action_to_deactivate=cV(this.set_form_action_to_deactivate,this);T.__super__.constructor.call(this,ey,"input[name=transfer_files]","#transfer_files_on")}T.prototype.set_form_action_to_deactivate=function(){return bg(".dfe-remove-or-deactivate-user-modal").attr("action","/account/team/deactivate_user")};T.prototype.set_form_action_to_remove=function(){return bg(".dfe-remove-or-deactivate-user-modal").attr("action","/account/team/remove_user")};T.prototype.set_modal_class=function(eA){var ez,ey;ez="invited suspending deleting";ey=this.$modal_window.find(".dfe-remove-or-deactivate-user-modal");ey.removeClass(ez);return ey.addClass(eA)};T.prototype.show_deactivation_content=function(){return this.set_modal_class("suspending")};T.prototype.show_removal_content=function(){return this.set_modal_class("deleting")};T.prototype.switch_to_deactivation_mode=function(){this.show_deactivation_content();return this.set_form_action_to_deactivate()};T.prototype.switch_to_removal_mode=function(){this.show_removal_content();return this.set_form_action_to_remove()};T.prototype.switch_to_uninvite_mode=function(){this.set_form_action_to_remove();this.set_modal_class("invited");this.$modal_window.find(".transfer_data_on_remove_setting").remove();return this.$modal_window.find(".remote_wipe_setting").remove()};T.prototype.handle_change_action=function(ey){ey.preventDefault();if(bg("#deactivate_option").is(":checked")){return this.switch_to_deactivation_mode()}else{return this.switch_to_removal_mode()}};T.prototype.on_show=function(ey){var ez;T.__super__.on_show.call(this);bg("input[name=deactivate_or_remove").on("change",this.handle_change_action);this.$modal_window.find(".deleted_user_name").text(this.user_name);if(this.invited){ez=dW("Uninvite %(user_name)s").format({user_name:this.user_name});this.switch_to_uninvite_mode()}else{ez=dW("Delete %(user_name)s").format({user_name:this.user_name});bg("#deactivate_option").attr("checked","checked");this.switch_to_deactivation_mode()}this.$modal_window.find(".db-modal-title-text").text(ez);this.$modal_window.find("[name=user_id]").attr("value",this.user_id);return this.$modal_window.find("[name=team_id]").attr("value",this.team_id)};T.prototype.success_callback=function(ey){if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){__CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}if(this.invited){Y.success(dW("User uninvited"))}else{if(bg("#deactivate_option").is(":checked")){Y.success(dW("User suspended"))}else{Y.success(dW("User deleted"))}}return this.hide()};T.prototype.on_confirm_button_click=function(eA){var ey,ez;eA.preventDefault();ez=this.$modal_window.find(".dfe-remove-or-deactivate-user-modal")[0];ey=$(this.$modal_window.find(".confirm-button")[0]);return bt.ajax_submit(ez,false,this.success_callback,this.handleAjaxFailure,ey)};return T})(bj);eh=A.DfeRemoveUserModal=(function(T){cm(ex,T);function ex(ey){this.on_confirm_button_click=cV(this.on_confirm_button_click,this);this.success_callback=cV(this.success_callback,this);this.on_show=cV(this.on_show,this);ex.__super__.constructor.call(this,ey,"input[name=transfer_files]","#transfer_files_on")}ex.prototype.on_show=function(ey){var ez;ex.__super__.on_show.call(this);this.$modal_window.find(".remove_user_name").text(this.user_name);if(this.invited){ez=dW("Uninvite %(user_name)s").format({user_name:this.user_name})}else{ez=dW("Delete %(user_name)s").format({user_name:this.user_name})}this.$modal_window.find(".db-modal-title-text").text(ez);this.$modal_window.find("[name=user_id]").attr("value",this.user_id);this.$modal_window.find("[name=team_id]").attr("value",this.team_id);if(this.invited){this.$modal_window.find(".active_user_remove_setting").remove();return this.$modal_window.find(".dfe-remove-user-modal").addClass("invited")}};ex.prototype.success_callback=function(eA){var ez,eB,ey;ez=JSON.parse(eA.responseText);if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){__CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}else{if((eB=window.active_team_member_table)!=null){eB.remove_user(this.user_id)}if((ey=window.removed_team_member_table)!=null){ey.add_users(ez)}}if(this.invited){Y.success(dW("User uninvited."))}else{Y.success(dW("User removed."))}dh.decrement_used_licenses();return this.hide()};ex.prototype.on_confirm_button_click=function(eA){var ey,ez;eA.preventDefault();ez=this.$modal_window.find(".dfe-remove-user-modal")[0];ey=$(this.$modal_window.find(".confirm-button")[0]);return bt.ajax_submit(ez,false,this.success_callback,this.handleAjaxFailure,ey)};return ex})(bj);d3=A.ManageFilesModal=(function(ex){cm(T,ex);function T(ez,eA,ey){this.source_user_id=ez;this.source_user_name=eA;this.options=ey;this.on_confirm_button_click=cV(this.on_confirm_button_click,this);T.__super__.constructor.call(this,this.options,"input[name=file_action]","#move-files")}T.prototype.get_form=function(){return this.$modal_window.find("form")[0]};T.prototype.on_show=function(){var ey;T.__super__.on_show.call(this);this.$modal_window.find("[name='source_user_id']").attr("value",this.source_user_id);this.$modal_window.find(".source-user-name").text(this.source_user_name);ey=dW("Manage %(team_member)s's files").format({team_member:this.source_user_name});this.$modal_window.find(".db-modal-title-text").text(ey);return this.get_form().on("submit",this.on_confirm_button_click)};T.prototype.on_confirm_button_click=function(eA){var ey,ez,eB;eA.preventDefault();ez=this.get_form();ey=$(this.$modal_window.find(".confirm-button")[0]);eB=(function(eC){return function(eE){var eD;eD=JSON.parse(eE.responseText);if(__CIRCULAR_DEPENDENCY__.MembersReact!=null){__CIRCULAR_DEPENDENCY__.MembersReact.refresh_member_stats()}else{if(window.removed_team_member_table){window.removed_team_member_table.update_user_data(eD)}else{if(__CIRCULAR_DEPENDENCY__.MemberActionsMenu!=null){__CIRCULAR_DEPENDENCY__.MemberActionsMenu.update_container_users(".buttons",eD)}}}if(bg("#move-files").prop("checked")){Y.success(dW("Transfer started",{comment:"This refers to the start of a file transfer from one Dropbox to another"}))}else{Y.success(dW("Permanently deleted files"))}return eC.$modal_window.hide()}})(this);return bt.ajax_submit(ez,false,eB,this.handleAjaxFailure,ey)};return T})(bj);b2=A.show_manage_files_modal=function(T,ex){var ey;ey=new d3(T,ex,{element_id:"manage-files-modal",focus:".new-collab-input"});return ey.show()};n=function(){var T;T=function(ez,ey){var ex,eA;bg(ey).css("display","none");ex=bg(ey).closest("#user_generate_liveops_pin");eA=ex.find(".user_generate_liveops_pin_value");eA.text(ez.pin);bg(ey).addClass("liveops_pin_elem_invisible");return ex.find(".user_generate_liveops_pin_text").removeClass("liveops_pin_elem_invisible")};dh.get_pin_with_user_id(null,this,T);return false};bg("#user_generate_liveops_pin_button").click(n);var M,b,dx,aX,af,bl=[].indexOf||function(ey){for(var ex=0,T=this.length;ex0};eT=function(fa){return $u.isNumber(fa)&&fa%1===0&&fa>=0};cj(eN(eO),"user_id must be a positive integer");eB=function(){var fa;fa=1<=arguments.length?cz.call(arguments,0):[];if(b){return console.log.apply(console,fa)}};e2=90000;eH=8096;eP="user";eE="list";ez=false;e4=1000;eF=5*60*1000;e9=0;eQ=function(){var fa;if(eA===0){fa=0}else{fa=Math.min(e4*Math.pow(2,eA-1),eF)}return Math.max(fa,e9)};e3=null;e1={};e7={};eL=1;e8=false;eC=false;e5=null;eX=false;eY=[];eD=null;T=null;eV=null;eG={};eK=false;eA=0;e6=0;eR=function(fe,fc){var fb,fa,fd;fd=[];for(fb in fc){fa=fc[fb];fb=parseInt(fb,10);cj(eN(fb),"ns_ids must be positive integers: "+fb);cj(eT(fa),"sjids must be nonnegative integers: "+fa);if(fe[fb]!=null){fd.push(fe[fb]=Math.min(fe[fb],fa))}else{fd.push(fe[fb]=fa)}}return fd};ey=function(){var fc,fb,fd,fa;cj((e3!=null)&&!$u.isEmpty(e1),"expected nid and ns_map");fd={host_int:0,trace:window.location.pathname,rev:Constants.SVN_REV};fc=$u.pluck($u.values(e7),"type");if(bl.call(fc,eP)>=0){fd.user_id=eO;fd.nid=e3!=null?e3.replace(/^0+(.)/,"$1"):void 0}if(bl.call(fc,eE)>=0){fd.ns_map=((function(){var fe;fe=[];for(fb in e1){fa=e1[fb];fe.push(""+fb+"_"+fa)}return fe})()).join(",")}if(C.parse(dx).updateQuery(fd).toString().length>eH){delete fd.ns_map}return fd};eJ=function(){var fa;if(!ez){return}fa=eQ();if(fa>0){return T=window.setTimeout(eW,fa)}else{return eW()}};eW=function(){var fa;cj(!e8&&!eC,"connect: invalid state");cj(e3>=0||!$u.isEmpty(e1),"notclient: called connect with nothing to subscribe to");eB("###########################");fa=ey();if((fa.nid==null)&&!fa.ns_map){eB("nothing to subscribe to. skipping notserver connection.");return}eB("connecting to notserver...");e8=true;e6+=1;return e5=bg.ajax(dx,{data:fa,dataType:"json",noDropboxDefaults:true,error:function(){if(eX){eX=false;return}eA+=1;eB("error connecting to notserver. bad rounds="+eA+".");e8=false;return eJ()},success:function(fb){eB("notserver connection closed. response:",fb);e8=false;if(fb.chillout!=null){e9=parseInt(fb.chillout,10)*1000;eB("notserver told us to chill for "+e9+"ms")}else{if(e9>0){eB("setting notserver chillout back to 0ms");e9=0}}if(fb.ret==="punt"){return eJ()}else{cj(fb.ret==="new","unknown notserver ret: "+fb.ret);cj("refresh" in fb,"expected notserver ret:new to have refresh keyword");return eZ(fb.refresh)}}})};eM=function(){if(e5!=null){eX=true;e5.abort();return e5=null}};e0=function(){e9=0;e8=false;eC=false;eM();eY=[];window.clearTimeout(eD);window.clearTimeout(T);eD=null;T=null;eV=null;eG={};eK=false;eA=0;return eJ()};eU=function(){var fa;ez=false;e9=0;e3=null;e1={};e7={};fa=0;eL=1;e8=false;eC=false;e5=null;eX=false;eY=[];window.clearTimeout(eD);window.clearTimeout(T);eD=null;T=null;eV=null;eG={};eK=false;eA=0;return e6=0};eZ=function(ff){var fi,fe,fa,fb,fg,fc,fh,fd;cj(!eC&&!e8,"run_handlers: invalid state");cj(eV===null,"run_handlers: new_nid must start at null");cj($u.isEqual(eG,{}),"run_handlers: new_ns_map must start at {}");cj(!eK,"expected one_or_more_handler_failures=false");eC=true;eB("running handlers...");fb=$u.filter($u.values(e7),function(fk){var fj;return fj=fk.type,bl.call(ff,fj)>=0});cj(!$u.isEmpty(fb),"notserver sent a ping for unsubscribed activity");eY=$u.pluck(fb,"handler_id");for(fc=0,fh=fb.length;fc0){eE=0;eA=T-eD;eC=eA/ex}else{eE=Math.abs(eD/ex);eC=Math.abs(T-eD)/ex}}else{eB=bg("#browse-files");if(!eB.length){return[0,b3.files.length-1]}ez=parseInt(eB.css("padding-top"));eE=eF/ex;eA=T-ez;eC=(eA+eF)/ex}eE=Math.max(Math.floor(eE),0);eC=Math.min(Math.floor(eC),b3.files.length-1);return[eE,eC]},_get_elm_height:function(){var ex,T;if(b3.files.length>=3&&b3.files[1].get_div()){ex=bg(b3.files[1].get_div());T=ex.outerHeight()+parseInt(ex.css("margin-bottom"))+parseInt(ex.css("margin-top"));return T}else{return null}},append_ellipsis:function(T){return dW("%(action_text)s\u2026","web","action which requires further user interaction").format({action_text:T})},_show_blue_sharing_icons:function(){return b3.sharing_icons_experiment_variant&&b3.sharing_icons_experiment_variant==="BLUE_ICONS"},get_shared_folder_icon:function(){if(this._show_blue_sharing_icons()){return"s-folder-blue"}else{return"rainbow_16"}},get_shared_link_icon:function(){if(this._show_blue_sharing_icons()){return"s-link-blue"}else{return"s_link"}}};var a4;a4=A.Sort=(function(){var eC,T,ez,eB,eA,ey,ex;ez=function(eE){var eD;eD=eE?1:-1;return function(eF,eG){return eD*du.sort_by_rank_or_key(eF,eG)}};eB=function(eE){var eD;eD=eE?1:-1;return function(eF,eG){if(eF.bytes>eG.bytes){return eD}else{if(eF.byteseG.fq_path.toLowerCase()?1:-1)}};T=function(eE){var eD;eD=eE?1:-1;return function(eG,eH){var eF;eF=eG.ts===eH.ts?0:eG.ts>eH.ts?1:-1;return eD*eF}};ey=function(eD){return function(eG){var eF,eE;eE=eD(eG);eF=ez(true);return function(eH,eI){if(eH.dir^eI.dir){return(eH.dir?1:0)-(eI.dir?1:0)}else{return eE(eH,eI)||eF(eH,eI)}}}};eA=function(eD){return function(eG){var eE,eF;if(!a4.FOLDERS_FIRST){return eD(eG)}eF=eD(eG);eE=eG?1:-1;return function(eI,eJ){var eH;if(eI.dir^eJ.dir){eH=(eI.dir?0:1)-(eJ.dir?0:1);return eE*eH}else{return eF(eI,eJ)}}}};ex=function(eD){return function(eG){var eE,eF;eF=a4.FILES_BY_NAME(eG);eE=eG?1:-1;return function(eI,eJ){var eH;if(eI.is_deleted^eJ.is_deleted){return(eI.is_deleted?1:0)-(eJ.is_deleted?1:0)}eH=0;if(eD){if(eI.get_category()!==eJ.get_category()){eH=eI.get_category()this.CACHE_TIME){ez.push(eB)}}T=[];for(eA=0,ex=ez.length;eA0?true:false,path_scoped:false,search_type:eF,query_string:T.query};aQ.SearchClientActivityLogger.log("query_started",b3.active_user.id,eB);cj(!T.is_advanced,"expected to be in basic search mode");if(!ey){bg("#web-search-results").html(dW("Searching..."))}bg("#browse").addClass("pending-search");eG={query:T.query};if(this.fulltext_search_enabled){if(ey){eG.start=ey}if(eD){eG.max_results=eD}if(eA){eG.deleted=eA}if(this.scoped_search){eG.fq_path=this.last_fq_path}if(!eC){this.last_fulltext_query=T.query}}if(eC){eG.filename_only=true}eE=false;return new Ajax.DBRequest(ex,{no_watch:true,evalJSON:false,parameters:eG,log_timing:true,onSuccess:(function(eH){return function(eJ){var eK,eI,eM,eL;if(!b3.in_search_mode()){return}eM=eJ.request.parameters.parent_request_id;eK=JSON.parse(eJ.responseText);eL=eK.file_info.length;if(eH.fulltext_search_enabled){if(T.query===eH.last_fulltext_query&&ez>=eH.last_new_search_ts){eH.search_pos=eH.search_pos+eL;if(eH.end_of_active_results){eH.deleted_search_pos=eH.deleted_search_pos+eL}if(eL0){eI=eK.file_info[0]}else{eI=null}eB=eH.create_completion_log_dict(eB,eM,eJ.request.start_time,T,eL,null,eI);return aQ.SearchClientActivityLogger.log("query_completed",b3.active_user.id,eB)}})(this),onFailure:(function(eH){return function(eI){eB=eH.create_completion_log_dict(eB,eI.request.parameters.parent_request_id,eI.request.start_time,T,null,eI.status);return aQ.SearchClientActivityLogger.log("query_failed",b3.active_user.id,eB)}})(this),cleanUp:(function(eH){return function(){if(eE){return eH.load_more_results()}else{return bg("#browse").removeClass("pending-search")}}})(this),subject_user:b3.active_user})},ask_server_advanced:function(){var T,ex;ex=this.get_state();T={firefly:this.fulltext_search_enabled,query_string:ex.query};aQ.SearchClientActivityLogger.log("query_started",b3.active_user.id,T);cj(ex.is_advanced,"expected to be in advanced search mode");cj(!ex.query,"expected advanced search params only");delete ex.is_advanced;$("web-search-results").__date(dW("Searching..."));$("browse").addClassName("pending-search");return new Ajax.DBRequest("/ajax_advanced_search",{no_watch:true,evalJSON:false,parameters:ex,log_timing:true,onSuccess:(function(ey){return function(eA){var ez,eB;if(!b3.in_search_mode()){return}eB=eA.request.parameters.parent_request_id;ey.advanced_results=JSON.parse(eA.responseText);ey.update_results(null,false,eB);if(ey.advanced_results.file_info.length>0){ez=ey.advanced_results.file_info[0]}else{ez=null}T=ey.create_completion_log_dict(T,eA.request.parameters.parent_request_id,eA.request.start_time,ex,ey.advanced_results.file_info.length,null,ez);return aQ.SearchClientActivityLogger.log("query_completed",b3.active_user.id,T)}})(this),onFailure:(function(ey){return function(ez){T=ey.create_completion_log_dict(T,ez.request.parameters.parent_request_id,ez.request.start_time,ex,null,ez.status);return aQ.SearchClientActivityLogger.log("query_failed",b3.active_user.id,T)}})(this),cleanUp:(function(ey){return function(ez){return $("browse").removeClassName("pending-search")}})(this),subject_user:b3.active_user})},attempt_cache_filter:function(){var T,ez,ex,eD,ey,eC,eB,eA;eC=this.get_state().query;eD=this._query_to_regex(eC);ex=function(eE){return eD.match(an.filename(eE.ns_path).toLowerCase())};if(eC.length<=1){return false}for(ey=eB=eA=eC.length-1;eA<=1?eB<=1:eB>=1;ey=eA<=1?++eB:--eB){ez=eC.substr(0,ey).strip();if(ez in this._cache){if(this._cache[ez].file_info.length=this.MAX_RESULTS){ex=ex+"+"}T=aR("%(num_results)s result","%(num_results)s results",ex).format({num_results:ex})}}ey=dW("Search")+" - "+T;if(this.sparky_search_ui_enabled){b3.update_header_status(T);ey=dW("Results for '%(query)s'").format({query:this.get_state().query});if(this.scoped_search){ey=dW("Results for '%(query)s' in '%(path)s'").format({query:this.get_state().query,path:an.filename(this.last_fq_path+"'")})}}bg("#web-search-results").text(ey);if(this.sparky_search_ui_enabled&&this.scoped_search){return bg("#fulltext-search-all-link").show()}},show_advanced:function(){$("browse").addClassName("advanced-search");$("browse-search").hide();$("advanced-search-link").__date(dW("Basic search"));$("advanced-search-box").show();return $("all_terms").focus()},show_basic:function(T){$("browse").removeClassName("advanced-search");$("advanced-search-box").hide();$("advanced-search-link").__date(dW("Advanced search"));if($("browse-search")){$("browse-search").show();if(!T){return $("browse-search-input").focus()}}},toggle_advanced:function(){var T,ex;ex=$("advanced-search-link");ex.toggleClassName("selected");if(ex.hasClassName("selected")){bg("#all_terms").val(this.get_basic_query());return this.show_advanced()}else{T=bg("#all_terms").val();if(T){this.set_basic_query(T);return this.show_basic()}else{return this.exit_search()}}},history_change_handler:function(T,ex){var ey;if(this.fulltext_search_enabled&&(ex!=null)){this.last_state=ex;this.last_state.is_advanced=false}if(!this.last_state){aN.set_path_url(Constants.root_ns,"");return}if(this.state_changed()){this.set_state(this.last_state)}key.setScope(b3.KEY_SCOPE);if(eg.get_selected_files().length){ey=eg.get_selected_files()[0].get_div();return b3.scrollToWithPadding(ey,ey.getHeight()*2)}},clear_searchbox:function(){return this._get_browse_search_input().val("")},_get_browse_search_input:function(){if(this.fulltext_search_enabled){return bg("#browse-search-input input")}else{return bg("#browse-search-input")}}};var dM;dM=A.BrowseKeys={_handlers:{},init:function(){},init_advanced:function(){var ey,T,ex;ex=this.advanced_dict;for(T in ex){ey=ex[T];key(ey.key,b3.KEY_SCOPE,ey.onPress)}this.customize_chart();if(du.is_mac()&&Prototype.Browser.Gecko){return document.observe("keypress",(function(ez){return function(eA){if(eA.charCode===63&&!y.focus_in_input()){return ez.advanced_dict.help.onPress()}}})(this))}},customize_chart:function(){var ez,ex,ey,T;ez=(du.is_mac()?".key-windows":".key-macos");ey=0;ex=void 0;T=[];while(true){ex=$("keys-chart").down(ez,ey++);if(!ex){break}T.push(ex.hide())}return T},toggle_chart:function(){if($("keys-chart").style.display==="none"){return this.show_chart()}else{return this.hide_chart()}},show_chart:function(){var T,ex;T=$("keys-chart");T.style.position="fixed";ex=$("browse-sort");if(bK.fulltext_search_enabled&&b3.in_search_mode()){ex=$("browse-header-wrapper")}else{if(ex.getStyle("display")==="none"){ex=$("browse-root-actions")}}bg(T).clonePosition(bg(ex),{setHeight:false});T.style.top=ex.cumulativeOffset()[1]+ex.getHeight()+"px";T.setOpacity(0.9);return T.show()},hide_chart:function(){return $("keys-chart").hide()},advanced_dict:{rename:{title:dW("Rename selected files",{comment:"'selected' means files that have been highlighted by the user to be acted upon"}),key:"f2",onPress:function(ex,ey){var T;T=eg.get_selected_files();if(T.length){return T.first().edit()}}},"delete":{title:dW("Delete selected files",{comment:"'selected' means files that have been highlighted by the user to be acted upon"}),key:"delete, command+backspace, backspace",onPress:function(ez,eA){var T,ey,ex;Event.stop(ez);if(b3.inside_read_only_shared_folder){Y.warning(dW("You don't have permission to delete files in this folder."))}ex=eg.get_selected_files();if(ex.length===1){T=ex.first();if(T.is_deleted){return c1.show_purge(T.fq_path,T.dir)}else{return c1.show_delete(b3.active_user,T.fq_path,T.dir)}}else{if(ex.length>1){ey=aO.profile_files(ex);if(ey.deleted===ex.length){return c1.show_bulk_purge(ex)}else{if(ey.deleted===0){return c1.show_bulk_delete(b3.active_user,ex)}}}}}},help:{title:dW("Show/hide keyboard shorcuts"),key:"shift+/, "+(key.main_modifier())+"+/",onPress:function(){return dM.toggle_chart()}},close_help:{title:dW("Hide keyboard shorcuts"),key:"escape",onPress:function(){return dM.hide_chart()}},up_dir:{title:dW("Up a folder",{comment:"meaning, go from the current folder to its containing (parent) folder. this is one step up only -- the parent, not the root."}),key:"left",onPress:function(){var T,ex;b3.keyboard_nav=true;if(!b3.reloading){if(b3.inside_dir){if(!b3.containing_ns_path()&&b3.containing_ns_id()!==Constants.root_ns){ex=Constants.root_ns;T=an.normalize(an.parent_dir(b3.containing_fq_path()))}else{ex=b3.containing_ns_id();T=an.normalize(an.parent_dir(b3.containing_ns_path()))}if(b3.containing_ns_path()!==T||b3.containing_ns_id()!==ex){b3.select_fq_paths=[b3.containing_fq_path()];return aN.set_path_url(ex,T)}else{return eg.flicker_selected()}}else{return eg.flicker_selected()}}}},open_file:{title:dW("Open highlighted file"),key:"enter",onPress:function(){var T,ex;ex=eg.get_selected_files();if(ex.length===1){T=ex[0];b3.open_file(T,false)}return false}},open_dir:{title:dW("Open highlighted folder"),key:"right",onPress:function(){var T,ex;b3.keyboard_nav=true;ex=eg.get_selected_files();if(ex.length===1){T=ex[0];if(T.dir){b3.select_index=0;b3.open_folder(T)}else{eg.flicker_selected()}}return false}},undo:{title:dW("Undo recent move/copy/rename/delete"),key:""+(key.main_modifier())+"+z",onPress:function(){Q.perform_undo();return false}},search:{title:dW("Search"),key:"/",onPress:function(){var ex,T;if((ex=__CIRCULAR_DEPENDENCY__.SearchBar)!=null){if((T=ex.getInstancesWithHolderClass("top-search-bar")[0])!=null){T.focus()}}return false}}}};var aa;aa=A.BrowseSharedLink={store_shared_link_info:function(ey,T,ex){if(ey.charAt(0)==="/"){ey=ey.substring(1)}this._shared_link_fq_dir=ey;this._shared_link_file=ex;return this._shared_link_url=T},shared_link_handler:function(T,ex){if(aa._shared_link_url==="/s/"+T){aN.load_browse_view(void 0,encodeURIComponent(aa._shared_link_fq_dir));b3.open_preview(aa._shared_link_file)}else{if(aa._shared_link_url==="/sh/"+T){aN.load_browse_view(void 0,encodeURIComponent(aa._shared_link_fq_dir));if(aa._shared_link_file){b3.open_preview(aa._shared_link_file)}else{ax.init([],{include_delete:true,keep_url:true,filename_in_url:true,enable_sublinks:true,share_button_experiment_variant:b3.lightbox_share_button_experiment_variant})}}else{location.reload()}}return aa.highlight_user()},close_shared_link_view:function(){if(window.location.pathname===this._shared_link_url){return aN.set_path_url(null,"/"+this._shared_link_fq_dir)}},highlight_user:function(){if(b3.active_user.role===Constants.ROLE_WORK){bg("#work-nav-item").addClass("selected");return bg("#personal-nav-item").removeClass("selected")}else{bg("#personal-nav-item").addClass("selected");return bg("#work-nav-item").removeClass("selected")}}};var aN;aN=A.BrowseURL={_DEFAULTS:{d:false,select:false,open_preview:false},_get_helper:function(T){var ex;ex=dZ.deconstruct_url().qargs;if(T in ex){return !!ex[T]}else{cj(T in this._DEFAULTS,"bad query param in BrowseURL");return this._DEFAULTS[T]}},get_del:function(){return this._get_helper("d")},ns_to_fq_path:function(T,ey){var ex;if(T!==b3.active_user.root_ns&&(!(T in b3.ns_id_to_mount_point))){T=b3.active_user.root_ns}if(T===b3.active_user.root_ns){return ey}else{ex=b3.ns_id_to_mount_point[T];return ex+ey}},_make_url:function(T,eB,eC){var eD,eA,ex,ez,ey;if(eC==null){eC={}}if(!T){T=b3.active_user.root_ns}cj(typeof T==="number","expected ns_id as a number");cj(typeof eB==="string","expected explicit ns_path string");eD=this.ns_to_fq_path(T,eB);ez=C({path:ew.get_browse_root(b3.active_user)+eD});ex=dZ.deconstruct_url().qargs;for(eA in eC){ey=eC[eA];if(eA in this._DEFAULTS&&!!ey!==this._DEFAULTS[eA]){ex[eA]=ey}}for(eA in ex){if(!(eA in this._DEFAULTS)){delete ex[eA]}}return dZ.construct_url(String(ez),ex)},set_path_url:function(T,eB,ez){var eA,ey,ex;if(!T){T=b3.active_user.root_ns}else{ey=parseInt(T,10);T=!isNaN(ey)?ey:Constants.root_ns}eB=an.normalize(eB);ex=ez!=null?this._make_url(T,eB,{d:ez?1:0}):this._make_url(T,eB);eA=dZ.deconstruct_url(ex);return dZ.push_state(eA.path,eA.qargs)},set_del_url:function(T){var ey,ez,ex;ex=dZ.deconstruct_url();ey=ex.path;ez=ex.qargs;if(T){ez.d="1"}else{delete ez.d}return dZ.push_state(ey,ez)},_first_load:true,_last_ns_dir:null,_last_ns_id:null,load_browse_view:function(T,ez,ex){var eA,eB,ey;if(ex==null){ex=false}key.setScope(b3.KEY_SCOPE);ez=an.normalize(ez);ey=false;if(!this._first_load){ey=(!b3.inside_dir)||(ez!==this._last_ns_dir)||(T!==this._last_ns_id)||(b3.in_search_mode()&&bK.fulltext_search_enabled)}eA=ex!==b3.deleted_shown;b3.deleted_shown=ex;if(this._first_load||ey||eA){b3.reload(T,ez,true)}bK.show_basic(true);this._first_load=false;this._last_ns_dir=ez;this._last_ns_id=T;if(eg.get_selected_files().length){eB=eg.get_selected_files()[0].get_div();if(eB){return b3.scrollToWithPadding(eB,eB.getHeight()*2)}}},history_change_handler:function(eB,eC){var ey,eA,T,ex,ez;if(b3.growth_browse_experiment_rule==="sharing-on-browse-experiment"&&((ez=b3.growth_browse_experiment_variant)==="INLINE_SHARE"||ez==="BOTH")){b3.reset_browse_exp()}T=eC.ns;ex=eC.d==="1";this.load_browse_view(T,eB,ex);if(eC.preview!=null){eA="/"+C.encode(eC.preview);if(!!eB){eA="/"+eB+eA}ey=b3.find_file(C.decode(eA));if(ey!=null){return b3.open_preview(ey,false,false,true)}else{return dZ.replace_state(ew.get_browse_root(b3.active_user))}}else{if(l.shown()){return l.hide()}}},parse_b2_hash:function(eA){var ey,ex,ez,T,eB;T=eA.split(":");if(T.length!==4){return false}ez=T[0];ey=T[2]==="1";ex=T[3];eB=!ex||du.isNumber(ex);if(!eB){return false}ex=parseInt(ex,10)||Constants.root_ns;return{ns_id:ex,ns_path:ez,deleted:ey}}};var cp;cp=A.BrowseFile=Class.create({initialize:function(ey){var eA,ex,ez,T,eB;eA=b3.inside_dir?cO:bW;ex=an.filename(ey.fq_path);this.icon=ey.icon;this.filename=ex;this.filename_highlights=(ez=ey.filename_highlights)!=null?ez:[];this.caption=bu.em_snippet(ex,eA);this.ns_id=ey.ns_id;this.ns_path=ey.ns_path;this.fq_path=ey.fq_path;this.mount_point=ey.mount_point;this.hash=ey.hash;this.href=ey.href;this.size=ey.size!=="None"?ey.size:"";this.bytes=ey.bytes;this.is_deleted=this.bytes===-1;this.ago=ey.ago;this.ts=ey.ts;this.dir=ey.is_dir?1:0;this.target_ns=ey.target_ns;this.sort_rank=ey.sort_rank||0;this.sort_key=ey.sort_key||[""];this.sjid=ey.sjid;this.tkey=void 0;this.thumbnail_url_tmpl=ey.thumbnail_url_tmpl;this.large_thumbnail_url_tmpl=ey.large_thumbnail_url_tmpl;this.type=ey.type;this.preview_type=ey.preview_type;if(ey.last_modified_fname){this.last_modified_fname=bu.em_snippet(ey.last_modified_fname,cr)}this.htmlified_link=ey.htmlified_link;this.doc_preview_status=ey.doc_preview_status;this.in_root_coll=ey.in_root_coll;this.user_id=ey.user_id;this.fulltext_search=ey.fulltext_search;this.read_only=ey.read_only?true:false;this.is_read_only_mount=ey.is_read_only_mount?true:false;this.request_id=(T=ey.request_id)!=null?T:null;return this.match_type=(eB=ey.match_type)!=null?eB:"UNKNOWN_MATCH"},track_in_browse:function(){if(!(this.to_key() in cp._file_index)){b3.add_file(this);return cp._file_index[this.to_key()]=this}},is_shared_folder:function(){return this.type===bI.SHARED_FOLDER},could_be_shared_folder:function(){var ey,ez,T,ex;ez=b3.public_folder_enabled&&this.fq_path.toLowerCase().startsWith("/public/");ex=b3.public_folder_enabled&&this.fq_path.toLowerCase()==="/public";T=this.target_ns;ey=this.ns_id!==Constants.root_ns;return this.type===bI.FOLDER&&!(ey||T||ez||ex)},is_shared_single_file:function(){var T;T=this.ns_id!==Constants.root_ns;return this.type===bI.FILE&&T},could_be_shared_single_file:function(){var ex,ey,T;ey=b3.public_folder_enabled&&this.fq_path.toLowerCase().startsWith("/public/");T=b3.public_folder_enabled&&this.fq_path.toLowerCase()==="/public";ex=this.ns_id!==Constants.root_ns;return this.type===bI.FILE&&!(ex||ey||T)},is_sandbox:function(){return this.type===bI.SANDBOX},video_transcode_url:function(){var T;cj(this.fq_path,"video_transcode_url: expected a non-root fq_path");if(Constants.transcoder_hls4web){T=C({path:"/playlist"+this.fq_path})}else{T=C({scheme:"https",authority:Constants.LIVE_TRANSCODE_SERVER,path:"/transcode_video/w/"+(this.hash+this.fq_path)})}return T.updateQuery(Constants.UID_PARAM_NAME,b3.active_user.id).toString()},get_div:function(){return $("f_"+(this.to_key()))},rename:function(eB,eD,ez,eA,eC,eE){var ex,eF,T,ey;ex=b3.inside_dir?cO:bW;T=this.fq_path;b3.pre_action_selection=[T];eF=b3.find_file(eB);if(eF){b3.remove_file(eF)}this.filename=an.filename(eB);this.caption=bu.em_snippet(this.filename,ex);this.fq_path=eB;this.ns_path=eD;this.htmlified_link=eE;this.hash=ez;this.sort_key=eA;this.sort_rank=null;this.last_modified_fname=null;if(!this.dir){ey=this.href.split("/");ey[ey.length-1]=du.urlquote(this.filename)+("?w="+ez);this.href=ey.join("/");this.icon=eC}else{this.href="/home"+du.urlquote(eB);if(this.target_ns){b3.ns_id_to_mount_point[this.target_ns]=eB}}if(b3.in_search_mode()&&bK.fulltext_search_enabled){this.filename_highlights=[]}cp._file_index[this.to_key()]=this;b3.update_file_pos(this);return document.fire(av.RENAME,{old_fq_path:T,file:this})},edit:function(){var ey,T,ez,ex,eA;this.editing=true;b3.selectable();eA=(function(eB){return function(eJ){var eD,eC,eG,eL,eI,eF,eM,eK,eH,eE;eE=eJ.responseText.evalJSON(true);cj(eE.new_browse_files.length===1,"No new file data returned.");eG=eE.new_browse_files.first();eL=eG.fq_path;eI=eG.hash;eH=du.decode_sort_key(eG.sort_key);eM=eG.icon;eK=eG.ns_path;eF=eG.htmlified_link;eD=eE.changesets;eC=dW("Rename complete.");Q.notifyWithUndo(eC,eD,c1.do_rollback);eB.rename(eL,eK,eI,eH,eM,eF);eg.set_selected_files([eB]);eB.get_div().smoothScrollIntoView();aO.load_visible_thumbs();return b3.fire_visible_change_callbacks()}})(this);T=C({path:"/cmd/rename"+this.fq_path}).updateQuery(Constants.UID_PARAM_NAME,b3.active_user).toString();ez=bK.fulltext_search_enabled&&b3.in_search_mode()?".filename-col":".filename-col a";ey=new Ajax.InPlaceEditor(this.get_div().down(ez),T,{htmlResponse:false,okControl:false,cancelControl:false,highlightColor:"transparent",highlightEndColor:"transparent",clickToEditText:"",cols:25,ajaxClass:Ajax.DBRequest,submitOnBlur:true,initialText:this.filename,cancelIfSame:true,clickToEdit:false,onComplete:(function(eB){return function(){return eB.editing=false}})(this),onFailure:function(){},savingText:dW("Saving..."),ajaxOptions:{job:true,subject_user:b3.active_user,html_in_error_msg:true,progress_text:dW("Renaming..."),method:"POST",onCreate:Y.clear,onSuccess:eA,onUninitialized:b3.unselectable},callback:(function(eB){return function(eC,eD){return{to_path:eD||"",folder:(eB.dir?"yes":"")}}})(this)});ey.enterEditMode();ex=this.get_div().down(".editor_field");if("selectionEnd" in ex&&this.filename.lastIndexOf(".")>-1){return ex.selectionEnd=this.filename.lastIndexOf(".")}},to_key:function(){return""+this.ns_id+"_"+this.sjid},get_category:function(){var ex,T;if(this.dir){if(b3.inside_dir&&b3.containing_fq_path()===""){if(this.filename.toLowerCase()==="public"&&b3.public_folder_enabled){ex="PUBLIC_FOLDER"}}if(ex==null){if(this.type===bI.FOLDER){ex="FOLDER"}else{if(this.type===bI.PACKAGE){ex="FOLDER"}else{if(this.type===bI.SHARED_FOLDER){ex="SHARED_FOLDER"}else{if(this.type===bI.SANDBOX){ex="SANDBOX"}else{if(this.target_ns){ex="SHARED_FOLDER"}else{ex="FOLDER"}}}}}}}if(ex==null){ex=cp.EXTENSION_TO_CATEGORY[this.get_extension()]||"FILE"}T=this.is_deleted?cp.CATEGORY_TO_DELETED_TRANSLATION[ex]:cp.CATEGORY_TO_TRANSLATION[ex];cj(T,"CATEGORY MISSING FOR "+ex);return T},get_extension:function(){if(this.dir||this.filename.indexOf(".")===-1){return}return an.file_extension(this.filename).toLowerCase()},is_shmodelable:function(){return !this.is_deleted&&b3.is_shmodelable_path(this.fq_path)}});cp._CATEGORIES={IMAGE:"bmp cr2 eps gif ico jpeg jpg nef png psd tif tiff svg svgz",VIDEO:"3gp 3gpp 3gpp2 avi dv flv m2t m4v mkv mov mp4 mpeg mpg mts ts vob wmv",AUDIO:"aif flac m4a m4p mp3 ogg wav wma",DOCUMENT:"cdr csv doc docx docm fla indd keynote numbers otf pages pdf dbxlink ai ppt pptx pptm pps ppsx ppsm ps rtf swf txt wpd xls xlsx xlsm",COMPRESSED_FILE:"7z bz2 gz gzip rar tar zip",CODE:"as as3 c coffee cpp cs css cxx h html html java js less php py rb sass scss sh sql vb xhtml xml",DISK_IMAGE:"dmg iso",EXECUTABLE:"exe",SHORTCUT:"lnk",LINK:"url webloc",FONT:"ttf"};cp.EXTENSION_TO_CATEGORY={};cp.CATEGORY_TO_TRANSLATION={FILE:dW("file"),FOLDER:dW("folder"),SHARED_FOLDER:dW("shared folder"),PUBLIC_FOLDER:dW("folder"),IMAGE:dW("image"),VIDEO:dW("video"),AUDIO:dW("audio"),DOCUMENT:dW("document"),COMPRESSED_FILE:dW("archive"),CODE:dW("code"),DISK_IMAGE:dW("disk image"),EXECUTABLE:dW("executable"),SHORTCUT:dW("shortcut"),LINK:dW("link"),FONT:dW("font"),SANDBOX:dW("app folder")};cp.CATEGORY_TO_DELETED_TRANSLATION={FILE:dW("deleted file"),FOLDER:dW("deleted folder"),SHARED_FOLDER:dW("deleted shared folder"),PUBLIC_FOLDER:dW("deleted folder"),IMAGE:dW("deleted image"),VIDEO:dW("deleted video"),AUDIO:dW("deleted audio"),DOCUMENT:dW("deleted document"),COMPRESSED_FILE:dW("deleted archive"),CODE:dW("deleted code"),DISK_IMAGE:dW("deleted disk image"),EXECUTABLE:dW("deleted executable"),SHORTCUT:dW("deleted shortcut"),LINK:dW("deleted link"),FONT:dW("deleted font"),SANDBOX:dW("deleted app folder")};(function(){var ey,eA,ex,ez,T;ez=cp._CATEGORIES;T=[];for(ey in ez){ex=ez[ey];T.push((function(){var eE,eC,eB,eD;eB=ex.trim().split(" ");eD=[];for(eE=0,eC=eB.length;eE0){T=ex.first();this._log_extras={path:T.fq_path,ns_id:T.ns_id};return this._firefly_log_values={file_nsid:T.ns_id,file_sjid:T.sjid,firefly:bK.fulltext_search_enabled,match_type:T.match_type,position:T.sort_rank,request_id:T.request_id,viewport:"full-view"}}},_get_actions_single:function(eM){var eC,eF,eG,eJ,ey,ez,eO,eD,eI,eA,eB,eK,eL,eH,T,eN,eE,ex;eF=[];if(!eM){return[]}eJ=b3.public_folder_enabled&&eM.fq_path.toLowerCase().startsWith("/public/");eI=b3.public_folder_enabled&&eM.fq_path.toLowerCase()==="/public";eO=eM.target_ns;eG=eM.ns_id!==Constants.root_ns;eB=eM.type===bI.SHARED_FOLDER;eA=eM.type===bI.SANDBOX;eD=eM.type===bI.PACKAGE;ez=eM.in_root_coll;if(eM.is_deleted){eF=eF.concat(["restore"]);eF.push("purge");if(!eM.dir){eF.push("revisions")}}else{eH=(__CONDITIONAL_JS__.UnityFeatures!=null)&&((eE=__CONDITIONAL_JS__.UnityCheckFileCache)!=null?eE.get(eM.ns_id,eM.ns_path):void 0);eK=eH?"open":"download";if(eM.dir){if(eA){eF.push("app_info")}else{if(b3.simple_sharing_enabled){eF.push("share_folder_and_token")}else{if(eB){eF.push("sharing_options")}else{if(!(eG||eO||eJ||eI)){eF.push("share")}}}}if(eM.is_shmodelable()&&!b3.simple_sharing_enabled){eF.push("token_share")}eF.push(eK);if(!eI){eF=eF.concat(["delete","rename","move"]);if(!(eD||eO)){eF.push("copy")}}if(b3.can_use_photos_features){if(b3.can_use_photos_features){eF.push("album_from_folder")}}}else{if(eM.is_shmodelable()){eF.push("token_share")}if(eJ||b3.public_app_token){eF.push("copy_url")}eF.push(eK);eF=eF.concat(["delete","rename","move","copy","revisions"]);if(ez&&b3.can_use_photos_features){eF.push("view_in_photos")}}if(b3.sharing_growth_experiments_variant&&b3.sharing_growth_experiments_variant==="DROPDOWN"&&!b3.simple_sharing_enabled){eL=false;ex=["sharing_options","share","token_share"];for(T=0,eN=ex.length;T-1){eF.splice(ey,1);eL=true}}if(eM.is_shared_folder()||eM.could_be_shared_folder()){eF.unshift("single_entry_share_dropdown_variant_menu")}else{eF.unshift("single_entry_share_dropdown_variant_token_share_only")}}}return eF},_get_actions_multi:function(ey){var T,ex,ez;if(Constants.send_a_copy_enabled){T=["send_copy","download"]}else{T=["download"]}T=T.concat(["delete","move","copy","restore","purge","view_in_photos"]);ex=aO.profile_files(ey);if(ex.deleted>0||ex.public_folder>0){T.removeItem("move");T.removeItem("copy");T.removeItem("delete")}if(ex.shared_folders>0){T.removeItem("copy")}if(ex.deleted>0){T.removeItem("send_copy");T.removeItem("delete");T.removeItem("download")}if(!b3.inside_dir){T.removeItem("download")}if(!(ex.deleted===ey.length&&(ex.shared_folders===0||((ex.shared_folders===(ez=ey.length)&&ez===1))))){T.removeItem("restore");if(ex.deleted!==ey.length){T.removeItem("purge")}}if(ex.in_root_coll!==ey.length||!b3.can_use_photos_features){T.removeItem("view_in_photos")}return T},_show_appropriate_sharing_modals:function(ex,T){var ey;if(false){return dc.createAndShowModal(b3.active_user)}else{if(ex.is_shared_folder()){aQ.ShmodelUILogger.log_with_target_file("sf_options",T,ex);return p.show_shared_folder_options_modal(ex.fq_path,b3.active_user)}else{if(ex.could_be_shared_folder()){aQ.ShmodelUILogger.log_with_target_file("sf_invite",T,ex);return p.show_share_existing_modal(ex.fq_path,b3.active_user)}else{aQ.ShmodelUILogger.log_with_target_file("token_share",T,ex);ey=ex.fq_path;cj(ey,"token_share: expected non-root fq_path");return cW.shmodel(ey,T+"_token_share")}}}},get_disabled_action_names:function(){var T,ey,eA,ex,ez;T=false;ez=this.get_files();for(eA=0,ex=ez.length;eA1){return c1.show_copy_bulk(ex)}}}},move:{icon:"move_16",text:aO.append_ellipsis(dW("Move",{comment:"BUTTON"})),click_handler:function(ey){var T,ex;ex=this.get_files();if(ex.length===1){T=ex.first();return c1.show_move(T.fq_path,T.dir)}else{if(ex.length>1){return c1.show_move_bulk(ex)}}}},rename:{icon:"rename",text:dW("Rename",{comment:"BUTTON"}),click_handler:function(){return this.get_files().first().edit()}},"delete":{icon:"delete_16",text:aO.append_ellipsis(dW("Delete",{comment:"BUTTON"})),click_handler:function(ey){var T,ex;ex=this.get_files();if(ex.length>1){return c1.show_bulk_delete(b3.active_user,ex)}else{if(ex.length===1){T=ex.first();return c1.show_delete(b3.active_user,T.fq_path,T.dir)}}}},global_purge:{icon:"cancel",text:aO.append_ellipsis(dW("Permanently delete folder")),click_handler:function(){return c1.show_purge(b3.containing_fq_path(),true)}},purge:{icon:"cancel",text:aO.append_ellipsis(dW("Permanently delete",{comment:"BUTTON"})),click_handler:function(ey){var T,ex;ex=this.get_files();if(ex.length===1){T=ex.first();return c1.show_purge(T.fq_path,T.dir)}else{return c1.show_bulk_purge(ex)}}},upload:{icon:"upload_16",text:aO.append_ellipsis(dW("Upload")),click_handler:function(T){return c1.show_upload()}},app_info:{icon:"application_double",text:aO.append_ellipsis(dW("Application info")),click_handler:function(T){return window.location.href="/account/security"}},more_actions:{is_dropdown:true,text:dW("More",{comment:"Show more options"}),click_handler:Prototype.emptyFunction},more_global_actions:{text:dW("More actions"),click_handler:function(){bo.show_secondary();return document.body.observe("click",bo.hide_secondary)}},view_in_photos:{icon:"s_photo",text:function(){return dW("View in Photos")},click_handler:function(){var T;T=this.get_files();return c1.do_bulk_photo_view(T)}},album_from_folder:{icon:"create-album",text:function(){return dW("Create album")},click_handler:function(){var ex,T;ex=this.get_files();T=ex.first();return c1.create_album_from_folder(T.fq_path,T.filename)}},open:{icon:"open",text:function(){return dW("Open")},click_handler:function(){var T;T=this.get_files().first();return __CONDITIONAL_JS__.UnityFeatures.open_file(T.ns_id,T.ns_path,T.user_id,__CONDITIONAL_JS__.UnityFeatures.standard_open_file_handler)}},single_entry_share_dropdown_variant_token_share_only:{icon:"s_rainbow",text:aO.append_ellipsis(dW("Share")),click_handler:function(ey,T){var ex;ex=this.get_files().first();aQ.ShmodelUILogger.log_with_target_file("single_entry_share_click",T,ex);return cW.shmodel(ex.fq_path,T)}},single_entry_share_dropdown_variant_menu:{icon:"s_rainbow",text:aO.append_ellipsis(dW("Share")),is_dropdown:true,subactions:["single_entry_share_dropdown_variant_menu_invite_option","single_entry_share_dropdown_variant_menu_token_share_option"],click_handler:function(){},hover_handler:function(ey,T){var ex;ex=this.get_files().first();return aQ.ShmodelUILogger.log_with_target_file("single_entry_share_hover",T,ex)}},single_entry_share_dropdown_variant_menu_invite_option:{icon:"user_add",text:aO.append_ellipsis(dW("Invite people to collaborate")),click_handler:function(eB,T){var ey,ez,eA,ex;ey=this.get_files().first();if(ey.is_shared_folder()){if(ds.get_for_user(b3.active_user).verified_or_show()){aQ.ShmodelUILogger.log_with_target_file("sf_options",T,ey);ez=new cI(b3.active_user,ey.fq_path);return ez.show()}}else{ex=b3.verify_email_after_share_experiment_variant;eA=ex&&ex==="VERIFY_LAST";if(eA){aQ.UserActivityLogger.log("web","email_verify_last_experiment_shown")}else{if(ex){aQ.UserActivityLogger.log("web","email_verify_last_experiment_not_shown")}}if(eA||ds.get_for_user(b3.active_user).verified_or_show()){aQ.ShmodelUILogger.log_with_target_file("sf_invite",T,ey);ez=new bZ(b3.active_user,{folder_name:ey.fq_path,element_id:"invite-to-new-sf-wizard-modal-"+b3.active_user.id,must_check_verified:eA});return ez.show()}}}},single_entry_share_dropdown_variant_menu_token_share_option:{icon:"s_link",text:aO.append_ellipsis(dW("Send link")),click_handler:function(ey,T){var ex;ex=this.get_files().first();aQ.ShmodelUILogger.log_with_target_file("token_share",T,ex);return cW.shmodel(ex.fq_path,T)}}}});ab=A.BrowseActionsContext=Class.create(a,{initialize:function($super,T){$super(T);return this._listen()},_listen:function(){$("context-menu-container").stopObserving("click");$("context-menu-container").stopObserving("contextmenu");bg("#context-menu-container").off("mouseenter");$("context-menu-container").on("click",".action button",this._click.bind(this));$("context-menu-container").on("contextmenu",".action button",this._click.bind(this));bg("#context-menu-container").on("mouseover","li.primary",this._over.bind(this));bg("#context-menu-container").on("mouseout","li.primary",this._out.bind(this));return bg("#context-menu-container").on("mouseenter",".action button",this._enter.bind(this))},_click:function(ez,ex){var ey,T;ey=ex.readAttribute("data-value");this.firefly_logging_helper(ey);T=a.option_dict[ey];aQ.BrowseActionsContextMenuLogger.log(this.get_files(),ey);if(!T.is_dropdown||ex.hasAttribute("submenu-index")){a1.hide()}ez.preventDefault();T.click_handler.call(this,ez,"browse_actions_context");if(ey==="sharing_options"){aQ.SharedFolderActivityLogger.log("web","browse_view_options",b3.active_user,this._log_extra,true)}if(ey==="share"){return aQ.SharedFolderActivityLogger.log("web","browse_view_share_existing",b3.active_user,this._log_extras,true)}},_reset_all_submenus:function(){return bg("#context-menu-container .hover").removeClass("hover")},_reset_submenu:function(T){return bg(T).removeClass("hover")},_enter:function(ez){var ey,T,ex;ey=bg(ez.currentTarget).data("value");cj(ey);T=a.option_dict[ey];cj(T,"Action info is missing for "+ey);return(ex=T.hover_handler)!=null?ex.call(this,ez,"browse_actions_context"):void 0},_over:function(T){if(bg(T.currentTarget).children(".secondary").length){clearTimeout(this.timeoutID);this._reset_all_submenus();return bg(T.currentTarget).addClass("hover")}},_out:function(T){if(bg(T.currentTarget).children(".secondary").length){return this.timeoutID=setTimeout((function(ex){return function(){return ex._reset_submenu(T.currentTarget)}})(this),300)}}});d1=A.BrowseActionsBasic=Class.create(a,{initialize:function($super){var T;T=eg.get_selected_files();$super(T);this._render();return this._listen()},_listen:function(){var T;this.bound_update=this._update.bind(this);this.bound_disable=this._disable.bind(this);this.bound_enable=this._enable.bind(this);this.bound_click=this._click.bind(this);document.observe(eg.UPDATED_EVT,this.bound_update);document.observe(a1.SHOW_EVT,this.bound_disable);document.observe(a1.HIDE_EVT,this.bound_enable);T=$("browse-root-actions");T.stopObserving("click");return T.on("click",".action button",this.bound_click)},unlisten:function(){document.stopObserving(eg.UPDATED_EVT,this.bound_update);document.stopObserving(a1.SHOW_EVT,this.bound_disable);document.stopObserving(a1.HIDE_EVT,this.bound_enable);return $("browse-root-actions").stopObserving("click",this.bound_click)},_update:function(){this._set_files(eg.get_selected_files());return this._render()},_disable:function(){$("browse-root-actions").stopObserving("click");if($("browse-root-actions").down(".secondary")){$("browse-root-actions").down(".secondary").addClassName("disabled")}return $$("#browse-root-actions .action *").invoke("setStyle",{cursor:"default"})},_disable_action:function(ey){var ex,T;T="#browse-root-actions #"+ey+"_action_button";ex=bg(T);ex.addClass("disabled");return ex.click((function(ez){return function(eA){ez.show_disabled_action_warning(ey);return false}})(this))},_enable:function(){$("browse-root-actions").stopObserving("click");$("browse-root-actions").on("click",".action button",this._click.bind(this));if($("browse-root-actions").down(".secondary")){$("browse-root-actions").down(".secondary").removeClassName("disabled")}return $$("#browse-root-actions .action *").invoke("setStyle",{cursor:"pointer"})},_render:function(){var eX,eQ,eS,eI,eU,eY,e0,eP,eR,eL,T,eE,eF,eH,eG,eT,eD,e1,eN,eB,eK,eJ,eM,eO,eC,eA,ey,ex,eV,eZ,eW,ez;eE=this.get_files();eS=this.get_action_names();if(b3.sharing_growth_experiments_variant&&b3.sharing_growth_experiments_variant==="DROPDOWN"&&!b3.simple_sharing_enabled){eJ=["single_entry_share_dropdown_variant_token_share_only","single_entry_share_dropdown_variant_menu"];for(eA=0,eV=eJ.length;eA-1){eS.splice(eG,1);break}}}eX=13.5;eR="";eF="";if(eE.length===1){eR=bu.em_snippet(eE[0].filename,eX);if(!eE[0].dir&&eE[0].bytes>=0){eF=eE[0].size}}else{if(1e0){eO.push(e1)}else{if(eK.length===0){eN=eO.pop();eK.push(eN)}eK.push(e1)}eU-=e0}if(eK.length){eO.push("more_actions")}eI=(function(){var e4,e2,e3;e3=[];for(e4=0,e2=eO.length;e4=0,"anchor_index: "+fa+" "+eM);cj(e7=0,"target_index: "+e7);e9=b3.files.slice(Math.min(fa,e7),Math.max(fa,e7)+1);e8=eH.slice(0);for(fb=0,fe=e9.length;fb0){fe=b3.files.indexOf(eY.last());e7=b3.files.indexOf(eI);if(eI===eY.last()||e7>fe){if(fe>0){e9=[];for(fd=fb=fc=fe-1;fc<=0?fb<=0:fb>=0;fd=fc<=0?++fb:--fb){e8=b3.files[fd];fa=eY.indexOf(e8);eA(e8,eI);if(fa!==-1){e9.push(eY.splice(fa,1))}else{b3.scrollTo(e8.get_div());break}}return e9}}else{eX(eY.last());return b3.scrollTo(eY.last().get_div())}}else{return e2()}};eC=function(fg){var e7,e8,fe,ff,fb,fc,fd,fa,e9;if(typeof J!=="undefined"&&J!==null){J.reset()}eP();if(fg){Event.extend(fg).preventDefault()}if(eY.length>0){ff=b3.files.indexOf(eY.last());e7=b3.files.indexOf(eI);if(eI===eY.last()||e7fa;fe=fd<=fa?++fc:--fc){e8=b3.files[fe];fb=eY.indexOf(e8);eA(e8,eI);if(fb!==-1){e9.push(eY.splice(fb,1))}else{b3.scrollTo(e8.get_div());break}}return e9}else{eX(eY.last());return b3.scrollTo(eY.last().get_div())}}else{return eN()}};e3=function(){if(typeof J!=="undefined"&&J!==null){J.reset()}eO(b3.files);return false};eZ=function(){if(typeof J!=="undefined"&&J!==null){J.reset()}return eO(null,null,null)};eG=function(e7){return eO(b3.find_file(e7.memo.fq_path))};eJ=function(){$$(".file-select").invoke("removeClassName","file-select");return setTimeout(eF,100)};eU=function(e7){return e7.memo.files.each(function(e8){var e9;e9=eY.indexOf(e8[0]);if(e9!==-1){eY.splice(e9,1);return eA(e8[1])}})};eD=function(e7,e8){var e9;if(b3.in_search_mode()&&e7&&e8){e9={file_nsid:e7.ns_id,file_sjid:e7.file_sjid,firefly:bK.fulltext_search_enabled,match_type:e7.match_type,position:e7.sort_rank,request_id:e7.request_id,viewport:"full-view",action_type:e8};return aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,e9)}};eL=function(e8,e7,e9,fb,ff){var fe,fd,fc,fa;fd="file_row_sharing_menu";if(e7){if(ds.get_for_user(e8).verified_or_show()){aQ.ShmodelUILogger.log("sf_options",fd,e9);eD("single_entry_share_button_folder_options");fe=new cI(e8,fb);if(typeof ff==="function"){ff()}return fe.show()}}else{fa=b3.verify_email_after_share_experiment_variant;fc=fa&&fa==="VERIFY_LAST";if(fc){aQ.UserActivityLogger.log("web","email_verify_last_experiment_shown")}else{if(fa){aQ.UserActivityLogger.log("web","email_verify_last_experiment_not_shown")}}if(fc||ds.get_for_user(e8).verified_or_show()){aQ.ShmodelUILogger.log("sf_invite",fd,e9);eD("single_entry_share_button_folder_invite");fe=new bZ(e8,{folder_name:fb,element_id:"invite-to-new-sf-wizard-modal-"+e8.id,must_check_verified:fc});if(typeof ff==="function"){ff()}return fe.show()}}};document.observe(bf.REMOVE,function(e7){return e7.memo.files.each(eX)});document.observe(bf.MOVE,eU);return{UPDATED_EVT:"db:select:updated",LIGHTBOX_EXIT_SELECT_EVT:"db:filepreview:exitselect",init:function(){var e7;document.observe("click",eW);document.observe("mousedown",ez);document.observe("mouseup",e4);document.observe("dragend",e4);document.observe("mouseup",ex);$("browse-files").on("mouseover","li.browse-file",eS);$("browse-files").on("click",".shmodel-file",ey);$("browse-files").on("click",".inline-share-button",e1);$("browse-files").on("click",".more-link",e1);document.observe(eg.UPDATED_EVT,eF);document.observe(eg.UPDATED_EVT,ex);document.observe(b3.RENDER_EVT,eF);document.observe(b3.RENDER_EVT,ex);document.observe(b3.UPDATE_EVT,eO.bind(null,null,null));document.observe(eg.LIGHTBOX_EXIT_SELECT_EVT,eG);e7=key.main_modifier();key("up",b3.KEY_SCOPE,e2);key("down",b3.KEY_SCOPE,eN);key(e7+"+a",b3.KEY_SCOPE,e3);key("escape",b3.KEY_SCOPE,eZ);key("shift+up",b3.KEY_SCOPE,eT);return key("shift+down",b3.KEY_SCOPE,eC)},set_selected_files:function(e7){return eO(e7)},get_selected_files:function(){return eY.slice(0)},get_selected_fq_paths:function(){return eY.map(function(e7){return e7.fq_path})},has_selected_files:function(){return eY.length},is_selected:function(e7){return eY.indexOf(e7)!==-1},is_selecting:function(){return !!eM},deselect_all:eV,set_context_selected:function(e7){return e6(e7)},flicker_selected:eJ,firefly_logging_helper:function(e7,e8){return eD(e7,e8)},show_share_modal_if_email_verified:eL,recipients_click:function(e7){return eB(e7)},link_click:function(e7){return eE(e7)}}})();ar=A.SharingGrowthExperimentsDropdown={open:function(eB,ey,ez,ex,eC,eD,eA){var T;this.fq_path=eB;this.existing_sf=ey;this.button=ez;this.user=ex;this.target_item=eC;this.is_file=eD;this.mount_point=eA;this.$menu=bg("#sharing-growth-experiments-dropdown-menu");T=this.$button&&this.$button.length;if(T){if(this.$button[0]===this.button){this._hide();return}else{this._hide()}}return this._show()},_show:function(){var T,ex;this.$menu.show();this.$button=bg(this.button);this.$button.addClass("pressed");if(b3.growth_browse_experiment_rule==="sharing-on-browse-experiment"&&((ex=b3.growth_browse_experiment_variant)==="INLINE_SHARE"||ex==="BOTH")){this.$button.parent(".sharing-actions").addClass("pressed")}T={offsetLeft:-1*Math.abs(this.$button.outerWidth()-this.$menu.outerWidth())+6,offsetTop:46,setWidth:false,setHeight:false};y.clone_position(this.$menu,this.$button,T);bg("#browse-box").addClass("dropdown-menu-open");if(this.is_file){this._add_share_file_logging("single_file_shared_entry_button_displayed","single_file_unshared_entry_button_displayed")}return this._listen()},_listen:function(){this.$menu.on("click dblclick",function(T){return T.stopPropagation()});bg(document).on("mousedown",bg.proxy(this._click_outside_menu_callback,this));this.$menu.find(".option-to-share-folder").on("click",bg.proxy(this._sf_click,this));return this.$menu.find(".option-to-share-link").on("click",bg.proxy(this._share_link_click,this))},_unlisten:function(){this.$menu.hide().off("click dblclick");bg(document).off("mousedown",this._click_outside_menu_callback);this.$menu.find(".option-to-share-folder").off("click",bg.proxy(this._sf_click,this));return this.$menu.find(".option-to-share-link").off("click",bg.proxy(this._share_link_click,this))},_add_share_file_logging:function(ey,ez){var ex,T;T={path:this.fq_path};ex=this.existing_sf?ey:ez;return aQ.SharedFolderActivityLogger.log("web",ex,this.user,T)},_sf_click:function(ex){var T;if(this.is_file){if(ds.get_for_user(this.user).verified_or_show()){this._add_share_file_logging("single_file_shared_collaboration_clicked","single_file_unshared_collaboration_clicked");if(this.existing_sf){T=new dv(this.user,{folder_name:an.filename(this.mount_point),folder_path:this.mount_point,element_id:"confirm-share-existing-file-wizard-modal"})}else{T=new bZ(this.user,{folder_name:this.fq_path,is_file:true,element_id:"invite-to-new-share-file-wizard-modal-"+this.user.id})}this._hide();return T.show()}}else{return eg.show_share_modal_if_email_verified(this.user,this.existing_sf,this.target_item,this.fq_path,this._hide.bind(this))}},_share_link_click:function(ex){var T;T="file_row_sharing_menu";aQ.ShmodelUILogger.log("token_share",T,this.target_item);this._firefly_logging_helper("single_entry_share_button_folder_link");cW.shmodel(this.fq_path,T);if(this.is_file){this._add_share_file_logging("single_file_shared_link_clicked","single_file_unshared_link_clicked")}return this._hide()},_firefly_logging_helper:function(T){return eg.firefly_logging_helper(b3.find_file(this.fq_path),T)},_clicked:function(T,ex){return T.is(ex.target)||T.has(ex.target).length},_click_outside_menu_callback:function(T){if(!(this._clicked(this.$menu,T)||this._clicked(this.$button,T))){return this._hide()}},_hide:function(T){this._unlisten();bg("#browse-box").removeClass("dropdown-menu-open");this.$button.removeClass("pressed");if(b3.growth_browse_experiment_rule==="sharing-on-browse-experiment"&&b3.growth_browse_experiment_variant===["INLINE_SHARE","BOTH"]){this.$button.parent(".sharing-actions").removeClass("pressed")}return this.$button=null}};aJ=A.SharingGrowthExperimentsAutocomplete={init:function(){return this.autocomplete=new Autocompleter.ContactsTokenizer(b3.active_user,"growth-browse-inline-new-collab-input","growth-browse-inline-new-whobulk","growth-browse-inline-hidden-input",{tokens:[",",";"],include_fb:false,include_team:false,hide_import_contacts:false,suggestions_disabled:true})},recipients_click:function(ex,T){var ey;this.file=ex;this.user=T;this.mode="recipients";this._activate();this.$sharing_actions.find(".get-link").hide();this.$sharing_actions.find(".send-button").show();ey=this._autocomplete_div();this.$sharing_actions.prepend(ey);ey.show();this.autocomplete.dynamically_resize_input();bg(this.autocomplete.element).val("");this.autocomplete.clearTokens();bg(this.autocomplete.get_entry_container()).hide();bg(this.autocomplete.element).focus();return false},link_click:function(ey,ex){var T;this.file=ey;this.user=ex;if(!ds.get_for_user(this.user).verified_or_show(dQ.SHMODAL)){return}T="file_row_sharing_menu";aQ.ShmodelUILogger.log("token_share",T,this.target_item);return cW.shmodel(this.file.fq_path,T)},_activate:function(){this.$sharing_div=bg(this.file.get_div()).find(".sharing");this.$sharing_actions=this.$sharing_div.find(".sharing-actions");this.$sharing_actions.find(".recipients").hide();this.$sharing_div.addClass("pressed");bg("#browse-box").addClass("dropdown-menu-open");return this._listen()},_send:function(){var ex,eC,eD,eF,eI,ez,ey,eA,eE,eH,eB,T,eG;this.sharing_api=new aZ(this.user);this.autocomplete.tokenize_emails_input(true);eF=this.emails=this.autocomplete.getEmails().split(", ");eI=this.file.fq_path;T={emails:eF};eD="";eC="";ex="";eA=this.file.target_ns;ey="";eG="";ex="";ez=false;this._hide();eH=(function(eJ){return function(){return eJ._complete(dW("Sent!"),"success")}})(this);eE=(function(eJ){return function(eO){var eN,eM,eL,eK;eK=eO.responseText.substr(4);if(eK[0]==="{"){eN=JSON.parse(eK);if(eN.emails){eM=eN.emails["message_text"]}if(eN.path){eM=eN.path["message_text"]}}else{eM=eK}if(!eM){eM="Unknown"}eL=dW("Error: %(msg)s").format({msg:eM});return eJ._complete(eL,"error")}})(this);if(!ds.get_for_user(this.user).verified_or_show(dQ.SHMODAL)){return}eB=this.file.read_only||this.file.is_read_only_mount;if(this.file.is_shared_folder()&&!eB){return this.sharing_api.invite_more_to_folder(eA,T,eD,ex,eH,eE)}else{if(this.file.could_be_shared_folder()&&!eB){return this.sharing_api.share_folder(false,eI,T,eD,eC,ey,eG,ex,ez,eH,eE)}else{return this._get_shmodel_link(function(eK){var eJ;eJ=C.parse(eK);return cc.WebRequest({url:"/sm/share",data:{emails:eF,shmodel_path:eJ.path},subject_user:b3.active_user.id,success:eH,error:eE})})}}},_get_shmodel_link:function(T){return cc.WebRequest({url:"/growth/find_or_create_shmodel_link",data:{path:this.file.fq_path},subject_user:b3.active_user.id,dataType:"json",success:(function(ex){return function(ey){if(ey.error!=null){return ex._complete(dW("Error"),"error")}else{return T(ey.shmodel_link)}}})(this),error:(function(ex){return function(){return ex._complete(dW("Error"),"error")}})(this)})},_complete:function(ex,eC){var T,eB,eD,eE,ez,eA,ey;this.$sharing_div.addClass("complete");T=this.$sharing_div.find(".sharers");if(eC==="success"&&this.emails){eA=aR("Sent to %(number)d person","Sent to %(number)d people",this.emails.length).format({number:this.emails.length});Y.success(eA);eB=T.text();if(eB==="--"){eB=""}if(eB.length===""||eB.length+this.emails.join(", ").length<28){eD=[];ey=0;ez=0;while(ezeD.length){eD.push("+"+(this.emails.length-eD.length))}if(eB!==""){eD.push(eB)}eE=eD.join(", ");T.text(eE);b3.update_file_to_sharers(this.file,eE)}}else{if(eC==="error"){Y.error(ex)}}return setTimeout(this._removeComplete,2000)},_removeComplete:function(){return bg("div.sharing.complete").removeClass("complete")},_autocomplete_div:function(){return bg("#browse-inline-autocomplete")},_listen:function(){if(this.mode==="recipients"){this._autocomplete_div().on("click dblclick",function(T){return T.stopPropagation()});this.$sharing_actions.find(".send-button").on("click",bg.proxy(this._send,this))}return bg(document).on("mousedown",bg.proxy(this._click_outside_autocompleter_callback,this))},_unlisten:function(){if(this.mode==="recipients"){this._autocomplete_div().off("click dblclick");this.$sharing_actions.find(".send-button").off("click",bg.proxy(this._send,this))}return bg(document).off("mousedown",this._click_outside_autocompleter_callback)},_click_outside_autocompleter_callback:function(T){if(!(this.$sharing_actions.is(T.target)||bg(T.target).parents(".sharing-actions").length)){return this._hide()}},_hide:function(T){var ex;this._unlisten();bg("#browse-box").removeClass("dropdown-menu-open");this.$sharing_actions.find(".recipients, .get-link").show();this.$sharing_actions.find(".send-button, .link-field").hide();this.$sharing_div.removeClass("pressed");ex=this._autocomplete_div().hide();return bg("#browse-sort").append(ex)}};var x;x=A.DragScroll={_timer:null,_mouse_y:0,_initial_mouse_y:null,_scroll_amount:40,_scroll_window:50,_min_drag_distance:20,_exclude_move_event:null,init:function(T,ex){this._exclude_move_event=T;if(ex!=null){return this._scroll_window=ex}},start:function(){this._initial_mouse_y=null;this._listen();return this._timer=setInterval(this._check_for_scroll.bind(this),100)},end:function(){this._unlisten();return clearInterval(this._timer)},_mousemove:function(ex){var T;if(typeof this._exclude_move_event==="function"?this._exclude_move_event(ex):void 0){return this._mouse_y=0}else{T=ex.pointerY();return this._mouse_y=T-y.scroll_offsets().top}},_listen:function(){document.observe("mousemove",this._mousemove.bind(this));return document.observe("dragover",this._mousemove.bind(this))},_unlisten:function(){document.stopObserving("mousemove",this._mousemove.bind(this));return document.stopObserving("dragover",this._mousemove.bind(this))},_check_for_scroll:function(){var T;if(this._initial_mouse_y===null){this._initial_mouse_y=this._mouse_y}if(Math.abs(this._mouse_y-this._initial_mouse_y)y.viewport_dimensions().height-this._scroll_window){T=this._scroll_amount}}if(T){return y.scroll_to(y.scroll_offsets().left,y.scroll_offsets().top+T)}}};var br;br=A.BrowseDrag={_BODY_DRAG_CLASS:"external_drag",_STATUS_CLASS:"dragging",_STATUS_OFFSET:10,_SELECTION_CONST:"SELECTION",_current_item_key:null,_drag_from_window:false,init:function(){var T;if(!Modernizr.draganddrop){return}this.listen();T=function(ey){var ex;ex=bg(ey.target);return ex.closest("#browse-location").length||ex.attr("id")==="browse-location"};return x.init(T,bg("#browse-header").height())},listen:function(){var T;T=$(document.body);document.observe(b3.UPDATE_EVT,this._update_body_data.bind(this));T.on("dragleave","[dropzone]",this._dropzone_dragleave.bind(this));T.on("dragend",this._body_dragend.bind(this));T.on("dragover","[dropzone]",this._dropzone_dragover.bind(this));if(Prototype.Browser.IE){T.on("dragenter","[dropzone]",this._dropzone_dragover.bind(this));T.on("mousedown",this._ie_start_drags.bind(this));T.on("mouseover","a.filename-link",this._ie_mouseover.bind(this))}T.observe("dragover",this._body_dragover.bind(this));T.observe("dragleave",this._body_dragleave.bind(this));T.observe("dragstart",this._body_dragstart.bind(this));T.observe("mousemove",this._body_mousemove.bind(this));T.on("dragstart","li.browse-file",this._file_dragstart.bind(this));document.observe(eg.UPDATED_EVT,this._build_selected_drag_icon.bind(this));document.observe(b3.RENDER_EVT,this._build_selected_drag_icon.bind(this));T.on("mousedown","li.browse-file",this._build_file_drag_icon.bind(this));return T.on("drop","[dropzone]",this._drop.bind(this))},_file_mousemove:function(ex){var T;if(!window.event||window.event.button!==1){return}T=ex.findElement("[draggable]");if(T&&T!==document&&T.dragDrop){T.dragDrop();return br._ie_end_drags()}},_ie_start_drags:function(T,ex){if(ex.tagName!=="OBJECT"&&$(ex).match("[draggable]")){return $("browse-files").observe("mousemove",this._file_mousemove)}},_ie_end_drags:function(){return $("browse-files").stopObserving("mousemove")},_update_body_data:function(){var ex,T;ex=b3.inside_dir?"copy move":false;T=b3.inside_dir?b3.containing_fq_path():false;$(document.documentElement).writeAttribute("dropzone",ex);return $(document.documentElement).writeAttribute("data-fq_path",T)},_body_dragover:function(ez){var ex,ey,T;ex=this._get_event_browse_files();if(ex.length){return this._update_status_position(ez,ex)}else{if(!this._drag_from_window&&((ey=ez.dataTransfer)!=null?(T=ey.types)!=null?T.contains("Files"):void 0:void 0)){return a3.show_drop_indicators(ez)}}},_body_dragleave:function(ey){var ex,T,ez;T=ey.x||ey.clientX;ez=ey.y||ey.clientY;ex=y.viewport_dimensions();if(!((01){T.addClassName("rotatein")}if(this._is_dragging_selection()){T.addClassName("selection")}return T.addClassName("fadein")}},_add_drop_indicators:function(eA){var eB,ez,ex,ey,T;$(document.body).addClassName(this._STATUS_CLASS);if(!dg.disabled){ey=$$('[dropzone="copy move"]');T=[];for(ez=0,ex=ey.length;ez","|"].map(function(T){return T.charCodeAt(0)}),update:function(){var ey,eB,ex,eA,T,ez;if(!J._listening){J.listen();J._listening=true}ey=[];ez=b3.files;for(eA=0,T=ez.length;eA0&&ez.length>0,"bad input to cmp_codepoints");for(T=ey=0,ex=eA.length;0<=ex?eyex;T=0<=ex?++ey:--ey){if(ez[T]==null){return 1}if(eA[T]!==ez[T]){return(eA[T]eA.length){return -1}else{return 0}},to_codepoint_list:function(ex){var ey,T,eA,ez;ex=ex.toLowerCase();T=[];for(ey=eA=0,ez=ex.length;0<=ez?eAez;ey=0<=ez?++eA:--eA){T.push(ex.charCodeAt(ey))}return T}};var a1;a1=A.ContextMenu={KEY_SCOPE:"context",SHOW_EVT:"db:contextmenu:show",HIDE_EVT:"db:contextmenu:hide",_prev_key_scope:null,listen:function(){bg(document).click(this.hide_on_click);bg(document).on(b3.UPDATE_EVT,this.hide_on_click);return key("esc",this.KEY_SCOPE,(function(T){return function(ex){return a1.hide()}})(this))},unlisten:function(){bg(document).off("click",this.hide_on_click);return bg(document).off(b3.UPDATE_EVT,this.hide_on_click)},hide_on_click:function(T){if(!(T.which===3||bg(T.target).parents("#context-menu").length)){return a1.hide()}},show_for_file:function(T,ez,ey){var eA,ex;b3.keyboard_nav=false;this.hide();eA=cp.from_elem(ey);ex=eg.is_selected(eA)?eg.get_selected_files():(eg.deselect_all(),[eA]);eg.set_context_selected(ex);return this._show(ez,new T(ex))},show_global:function(T,ex){this.hide();return this._show(ex,new T())},show_shmodel:function(eA){var ez,T,ex,ey;ez=["get_original"];this.hide();ex=eA.findElement("img");ey={get_original:{icon:"download",text:dW("Download original"),href:ex.readAttribute("data-original-href")}};T=Class.create({get_action_names:function(){return ez},get_disabled_action_names:function(){return[]},get_action_by_name:function(eB){var eC;eC=ey[eB];eC.name=eB;return eC}});return this._show(eA,new T())},show_for_lightbox:function(eA){var ez,T,ex,ey;ez=["download","view_original"];this.hide();ex=eA.findElement("img");ey={download:{icon:"download",text:dW("Download"),href:C.parse(ex.readAttribute("data-original-href")).updateQuery({dl:1}).toString()},view_original:{icon:"view_original",text:aO.append_ellipsis(dW("View original")),href:ex.readAttribute("data-original-href"),target:"_blank"}};T=Class.create({initialize:function(){return this._listen()},_listen:function(){var eB;eB=$("context-menu-container");eB.stopObserving("click");eB.stopObserving("contextmenu");eB.on("click",".action button",this._click.bind(this));return eB.on("contextmenu",".action button",this._click.bind(this))},_click:function(eF,eC){var eE,eB,eD;eE=eC.readAttribute("data-value");eB=ey[eE];a1.hide();eF.preventDefault();return(eD=eB.click_handler)!=null?eD.call(this,eF):void 0},get_action_names:function(){return ez},get_disabled_action_names:function(){return[]},get_action_by_name:function(eB){var eC;eC=ey[eB];eC.name=eB;return eC}});return this._show(eA,new T())},show_photos:function(eE,eI){var eH,ex,eB,ez,eG,eF,T,ey,eC,eD,eA;this.hide();ez={divider:{type:"divider"},choose_album:{icon:"album_16",text:aO.append_ellipsis(dW("Add %(num_photos)s to album").format({num_photos:eI.length})),click_handler:function(eJ){cg.show_add_to_album_modal(eJ,eI);return h.log_interaction(dK.ADD_TO_OTHER_ALBUM,cE.PCM,{num_photos:eI.length})}},remove:{icon:"album_delete_16",text:dW("Remove %(num_photos)s from album").format({num_photos:eI.length}),click_handler:function(){cg.show_remove_photos_modal(bq.get_current_collection(),eI);return h.log_interaction(dK.REMOVE,cE.PCM,{num_photos:eI.length})}},set_cover:{icon:"album_16",text:dW("Set as cover"),click_handler:function(){bq.get_current_collection().set_cover(eI[0]);return h.log_interaction(dK.SET_AS_COVER,cE.PCM,{num_photos:1})}},edit_timestamp:{text:"Edit timestamp",click_handler:function(){return bq.show_timestamps_modal(eI)}}};if(bq.in_single_collection_view()){eH=["share","choose_album","remove"];if(eI.length===1){eH.unshift("divider");eH.unshift("set_cover")}}else{eH=["share","choose_album"];eH.push("divider");eH.push("delete");if(bq.timestamp_edit_enabled){eG=(function(){var eL,eK,eJ;eJ=[];for(eL=0,eK=eI.length;eLeA.width-ez){$("context-menu").setStyle({left:(eA.width-T-ez)+"px"})}else{$("context-menu").setStyle({left:ey+"px"})}if(eB+ex>eA.height-ez){return $("context-menu").setStyle({top:(eA.height-ex-ez)+"px"})}else{return $("context-menu").setStyle({top:eB+"px"})}},hide:function(){if(!$("context-menu-container").empty()){this.unlisten();eg.set_context_selected([]);$("context-menu-container").__date();if(key.getScope()===this.KEY_SCOPE){key.setScope(this._prev_key_scope)}return document.fire(this.HIDE_EVT)}},disable_action:function(ez,ex){var ey,T;T="#context-menu-container #"+ez+"_button";ey=bg(T);ey.addClass("disabled");return ey.click(function(eA){ex.show_disabled_action_warning(ez);return false})}};var cO,b3,j,cr,bW;cO=A.BROWSE_SNIPPET_LEN=25;bW=A.SEARCH_SNIPPET_LEN=20;cr=A.LAST_MODIFIED_FNAME_SNIPPET=4;b3=INLINE_JS.Browse=A.Browse={KEY_SCOPE:"browse",RENDER_EVT:"db:browse:render",UPDATE_EVT:"db:browse:update",SCROLL_DURATION:0.5,msg:false,files:[],reloading:false,creating_folder:false,first_load:true,last_sort:[a4.FILES_BY_NAME,true],folder_loading_notification:null,folder_loading_timeout:null,keyboard_nav:false,init:function(ex,eC,ez,eB,T,eA,ey){this.browse_actions_ctor=eC;this.global_actions_ctor=ez;this.browse_actions_context_ctor=eB;this.global_actions_context_ctor=T;this.ns_id_to_mount_point=eA;cj(typeof ey==="number","a user_id was not passed into Browse.init",true,[],false);this.active_user=ck.get_viewer().get_user_by_id(ey);__CIRCULAR_DEPENDENCY__.active_user_loaded=true;cj(this.active_user,"No active_user was found in Browse.init",true,[],false);this.unselectable();this.listen();y.viewport_dimensions();if(bC.chrome){this.browser_supports_previews=ex&&du.pdf_plugins().length}else{this.browser_supports_previews=ex}if(ck.get_viewer().is_paired){c3.set_role(this.active_user.role)}this.subscribe_sfj_callbacks={};this.compiled_search_tmpl=eu.tmpl("search_list_item_tmpl");this.add_visible_change_callback((function(eD){return function(){return eD.show_sharing_on_browse_exp()}})(this));return cc.WebRequest({url:C({path:"/flash_detect_log"}),dataType:"json",data:{installed:FlashDetect.installed,major:FlashDetect.major,minor:FlashDetect.minor,revision:FlashDetect.revision,revisionStr:FlashDetect.revisionStr,raw:FlashDetect.raw}})},setup:function(ex,eC){var eB,eA,ez,T,ey;if(eC==null){eC=null}this.ns_id_to_mount_point=ex.ns_id_to_mount_point;this.old_path_to_ns_id=ex.old_path_to_ns_id;this.compiled_tmpl=eu.tmpl("list_item_tmpl");this.render_timeout=null;this.inside_root_folder=ex.containing_fq_path==="";this.inside_dir=ex.inside_dir;this.inside_deleted_dir=ex.inside_deleted_dir;this.inside_shared_folder=ex.inside_shared_folder;this.inside_read_only_shared_folder=ex.inside_read_only_shared_folder;this.inside_sandbox=ex.inside_sandbox;this.public_app_token=ex.public_app_token;this.public_folder_enabled=ex.public_folder_enabled;this.inside_deleted_sandbox=ex.inside_deleted_sandbox;this.inside_deleted_shared_folder=ex.inside_deleted_shared_folder;this.inside_team_folder=ex.inside_team_folder;this.is_read_only=ex.is_read_only;this.ns_map=ex.ns_map;this.contents_cache_key=ex.contents_cache_key;eA="inside_deleted_dir";if(this.inside_deleted_dir){$("browse").addClassName(eA)}else{$("browse").removeClassName(eA)}this.block_hash=ex.block_hash;this.block_hash_param=ex.block_hash_param;if(this.inside_dir){$("advanced-search-box").hide();$("advanced-search-link").removeClassName("selected");this._containing_ns_id=ex.containing_ns_id;this._containing_ns_path=ex.containing_ns_path;this._containing_fq_path=ex.containing_fq_path;this._containing_mount_point=ex.containing_mount_point;this.breadcrumb();ey=[this.browse_actions,this.global_actions];for(ez=0,T=ey.length;ezThis folder is empty Add files using the desktop application or the upload button above.'))}}return this._push_files(ex.file_info,eC)},_push_files:function(ey,eB){var ex,ez,eA,T;if(eB==null){eB=null}for(eA=0,T=ey.length;eA=0;eT=eQ<=0?++eS:--eS){if(eU.memo.files.indexOf(eL.files[eT])===-1){eN=eL.files[eT]}else{break}}eg.deselect_all();eO=eU.memo.files;for(eP=0,eM=eO.length;eP=0){eQ.push(eL.update_file_pos(eV,eT))}else{eQ.push(void 0)}}return eQ}})(this));eH=this.fire_visible_change_callbacks.bind(this);bg(window).on("resize",eH);this._last_visible_change_timeout_id=null;ex=(function(eL){return function(eM){clearTimeout(eL._last_visible_change_timeout_id);return eL._last_visible_change_timeout_id=setTimeout(eH,250)}})(this);return bg(window).on("scroll",ex)},add_subscribe_sfj_callback:function(T){return this.subscribe_sfj_callbacks[this.subsribe_sfj_count]=T},remove_sfj_callback:function(T){return delete this.subscribe_sfj_callbacks[T]},disable_sorting:function(){$("browse-sort").stopObserving("click");return $$("#browse-sort *").invoke("setStyle",{cursor:"default"})},enable_sorting:function(){$("browse-sort").stopObserving("click");$("browse-sort").on("click","#browse-sort a.sortable-column-header",this.sort_handler.bind(this));return $$("#browse-sort *").invoke("setStyle",{cursor:"pointer"})},click:function(ey,eA){var T,ez,ex;ex=$(ey.target);if(ex.match("a.filename-link")||ex.match("img.icon")||ex.up("a.filename-link")){this._click(ey,eA)}if(ex.match("a.parent-dir")){T=cp.from_elem(eA);if(T){ez={file_nsid:T.ns_id,file_sjid:T.sjid,firefly:bK.fulltext_search_enabled,match_type:T.match_type,position:T.sort_rank,request_id:T.request_id,viewport:"full-view",action_type:"click_path_link"};return aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,ez)}}},dblclick:function(T,ex){if($(T.target).match("a")){return}return this._click(T,ex)},open_file:function(ez,T,ex){var eB,ey,eA;if(ex==null){ex=false}ey={mode:"get",file_ext:an.file_extension_for_logging(ez.filename),file_bytes:ez.bytes};eB={file_nsid:ez.ns_id,file_sjid:ez.sjid,firefly:bK.fulltext_search_enabled,match_type:ez.match_type,position:ez.sort_rank,request_id:ez.request_id,viewport:ex?"dropdown-view":"full-view"};if(ez.dir){if(this.in_search_mode()||ex){eB.action_type="folder_open";aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,eB)}if(T){return this.open_folder_in_new_window(ez)}else{return this.open_folder(ez)}}else{if(!T&&!((ez.preview_type==="video")&&Constants.DISABLE_VIDEOS_IN_LIGHTBOX)){if(this.browser_supports_previews||((eA=ez.preview_type)==="photo"||eA==="video")){if(this.in_search_mode()||ex){eB.action_type="file_view";aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,eB)}return this.open_preview(ez,true,ex,ex)}else{if(this.in_search_mode()||ex){eB.action_type="file_view";aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,eB)}aQ.UserActivityLogger.log("web","file_view",ey);return window.open(ez.href,"_blank")}}else{if(this.in_search_mode()||ex){eB.action_type="file_view";aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,eB)}aQ.UserActivityLogger.log("web","file_view",ey);return window.open(ez.href,"_blank")}}},close_preview_callback:function(){bg(document).off("db:filepreview:close",this.close_preview_callback);document.stopObserving(ax.EXIT_SELECT_EVT,this.close_preview_callback);aa.close_shared_link_view();return b3.set_title()},open_preview:function(ex,ez,eA,ey){var T,eC,eB;if(ez==null){ez=false}if(eA==null){eA=false}if(ey==null){ey=false}eC=ex.preview_type==="video"&&Constants.DISABLE_VIDEOS_IN_LIGHTBOX;T=this.browser_supports_previews||((eB=ex.preview_type)==="photo"||eB==="video");if(!eC&&T){aO.filepreview_from_selected("fileclick",ex,!ez,eA,ey);bg(document).on("db:filepreview:close",this.close_preview_callback);return document.observe(ax.EXIT_SELECT_EVT,this.close_preview_callback)}},_click:function(ey,ez){var ex,T;this.keyboard_nav=false;ex=cp.from_elem(ez);if(ex.editing){return}T=(ey.which===2)||(du.is_mac()&&ey.metaKey);b3.open_file(ex,T);ey.preventDefault()},crumb_click:function(ez,T){var ey,ex;this.keyboard_nav=false;ez.preventDefault();ex=T.readAttribute("data-fq_path");ey=this.details_from_fq_path(ex);return aN.set_path_url(ey.ns_id,ey.ns_path)},parent_click:function(eA,ez){var ey,eB,T,ex;this.keyboard_nav=false;eA.preventDefault();ex=ez.readAttribute("data-parent_ns_path");T=parseInt(ez.readAttribute("data-parent_ns_id"),10);aN.set_path_url(T,ex);ey=cp.from_elem(ez);if(ey){eB={file_nsid:ey.ns_id,file_sjid:ey.sjid,firefly:bK.fulltext_search_enabled,match_type:ey.match_type,position:ey.sort_rank,request_id:ey.request_id,viewport:"full-view",action_type:"click_path_link"};return aQ.SearchClientActivityLogger.log("result_action",b3.active_user.id,eB)}},selection_handler:function(){if(eg.get_selected_files().length){return $("browse-box").addClassName("selected")}else{return $("browse-box").removeClassName("selected")}},POST_SCROLL_WAIT:100,_last_scroll_timeout:null,window_scroll:function(){var T,ex,ez,ey;if(bK.fulltext_search_enabled&&this.in_search_mode()&&!bK.end_of_results){ey=aO.get_files_in_view(),ez=ey[0],ex=ey[1];T=this.files.length-(ez+ex);if(T<=50&&!$("browse").hasClassName("pending-search")){bK.load_more_results()}}clearTimeout(this._last_scroll_timeout);return this._last_scroll_timeout=setTimeout(aO.load_visible_thumbs.bind(aO),this.POST_SCROLL_WAIT)},unscoped_search:function(){return bK.search(false)},updateOffset:function(){if(!this.div_parent){return}this._cumulativeOffset=this.div_parent.cumulativeOffset();return this.viewportOffset()},reset_sort:function(){var ex,T;this.last_sort=[a4.FILES_BY_NAME,true];T="#browse-sort a.sortable-column-header";ex=$$(T)[0];du.add_sort_arrow_mouseover(ex,true,T,false);$("kind-sorter-label").__date(cQ.DISPLAY.FILES_BY_KIND);return b7.src(ex.down("img"),"web","arrow-up-gray")},sort_handler:function(eC,eD,ez){var eA,T,eB,ex,eE,ey;eD=$(eD);eD.blur();eA=eD.readAttribute("data-sort");if(ez==null){ez=this.last_sort[0]===a4[eA]?eD.readAttribute("data-ascending")==="false":true}if(cQ.LABELS.indexOf(eA)!==-1){eE=cQ.SORT_FUNCTIONS.indexOf(this.last_sort[0])!==-1;if(eE){eB=(cQ.LABELS.indexOf(eA)+1)%cQ.LABELS.length;eA=cQ.LABELS[eB];T=cQ.DISPLAY[eA];$("kind-sorter-label").__date(T)}eD.writeAttribute("data-sort",eA);ez=cQ.IS_ASC[eA]}else{eD.writeAttribute("data-ascending",(ez?"true":"false"))}ey="#browse-sort a.sortable-column-header";du.add_sort_arrow_mouseover(eD,ez,ey,true);ex=a4[eA];this.sort(ex,ez);if(eC){return eC.stop()}},toggle_deleted:function(){var T;T=!aN.get_del();return aN.set_del_url(T)},new_folder:function(){var ey,ez,eM,eE,ex,eB,eF,eL,T,eA,eH,eK,eG,eJ,eC,eI,eD;if(this.reloading||this.creating_folder){return}this.hide_empty();this.selectable();ez=dW("New folder");ex=[];eD=this.files;for(eC=0,eI=eD.length;eC0){eK=this.files[0].get_div().getLayout().get("margin-box-height");eF=Math.floor(eG.top/eK)}}if(eF>0){this.files[eF].get_div().__sert({after:eJ})}else{$("browse-files").__sert({top:eJ})}T=$$("#browse-files .browse-new-folder .name").first();cj(T!=null,"expected new_folder_name to be defined");eM=this.containing_fq_path();eH=(function(eN){return function(eQ){var eP,eO,eR;eR=eQ.responseText.evalJSON(true);cj(eR.new_browse_files.length===1,"No new file data returned.");eP=an.filename(eR.new_browse_files.first().fq_path);eO=dW("Created folder '%(folder_name)s'");eO=eO.format({folder_name:bu.em_snippet(eP,25)});Y.success(eO);eN.select_fq_paths=[eR.new_browse_files.first().fq_path];return eN.force_reload()}})(this);eA=(function(eN){return function(eP){var eO;eO=$$("#browse-files li.browse-new-folder").first();if(eO){eO.remove()}return eN.creating_folder=false}})(this);eE=new Ajax.InPlaceEditor(T,"/cmd/new"+(du.urlquote(eM)),{htmlResponse:false,okControl:false,cancelControl:false,highlightColor:"transparent",highlightEndColor:"transparent",clickToEditText:"",cols:25,ajaxClass:Ajax.DBRequest,submitOnBlur:true,onFailure:function(){},onComplete:eA,savingText:dW("Creating folder..."),onLeaveEditMode:this.unselectable,ajaxOptions:{method:"POST",onSuccess:eH,subject_user:b3.active_user},callback:(function(eN){return function(eO,eP){eN.creating_folder=true;return{to_path:eP||"",folder:"yes"}}})(this)});return eE.enterEditMode()},open_folder:function(ex){var ez,T,ey;cj(ex.dir,"Only open directories, not files");if(b3.inside_dir&&b3.containing_ns_path()===ex.ns_path&&!(this.in_search_mode()&&bK.fulltext_search_enabled)){return}if(!(eg.get_selected_files().length===1&&eg.get_selected_files().indexOf(ex)===0)){eg.deselect_all();ez=ex.get_div();if(ez){ez.addClassName("file-select")}}clearTimeout(this.folder_loading_timeout);this.folder_loading_timeout=setTimeout((function(eA){return function(){var eB;eB=dW("Loading %(filename)s...");eB=eB.format({filename:bu.em_snippet(ex.filename,50)});return eA.folder_loading_notification=Y.success(eB,60,true)}})(this),1000);if(ex.target_ns){T=ex.target_ns;ey=""}else{T=ex.ns_id;ey=ex.ns_path}if(ex.is_deleted){return aN.set_path_url(T,ey,true)}else{return aN.set_path_url(T,ey)}},open_folder_in_new_window:function(T){return window.open(aN._make_url(T.ns_id,T.ns_path),"_blank")},show_message:function(ey){var ex,T;if((typeof ey)!==(typeof"string")){T=$("browse-files").down(".browse-message");if(T){T.show()}return}this.msg=ey;ex=new Element("div",{"class":"browse-message"});ex.__date(ey);return $("browse-files").__sert(ex)},sort:function(T,ez,ey){var ex;if(!ey&&T===this.last_sort[0]&&ez===this.last_sort[1]){return}this.last_sort=[T,ez];ex=T(ez);this.files.sort(ex);this.smartfill();aO.load_visible_thumbs();return this.fire_visible_change_callbacks()},resort:function(){var ey,T,ex;T=this.last_sort;ex=T[0];ey=T[1];return this.sort(ex,ey,true)},in_search_mode:function(){return $("browse").hasClassName("search")},flex_column:function(){return $("kind-sorter").readAttribute("data-sort")},smartfill:function(){var ex,eA,ey,eB,ez,eD,T,eC;ex=$("browse-files");ez=[];eB=this.in_search_mode();eC=this.files;for(eD=0,T=eC.length;eD=0){eE=eD}eA=this.in_search_mode()&&bK.fulltext_search_enabled?eE:du.bsearch(this.files,eB,ey(eC),true);this.files.splice(eA,0,eB);ez=eB.get_div();T=$("browse-files");if(ez){ez.remove()}if(this.in_search_mode()&&bK.fulltext_search_enabled){ex=this.compiled_search_tmpl({file:eB,Browse:b3,BrowseInterface:ew,Constants:Constants,Emstring:bu,FilePath:an,HTML:eu,Search:__CIRCULAR_DEPENDENCY__.Search,Sprite:b7,Util:du,_:dW})}else{ex=this.compiled_tmpl({file:eB,in_search_mode:this.in_search_mode(),flex_column:this.flex_column(),sharing_growth_experiments_variant:b3.sharing_growth_experiments_variant,share_link_icon_src:aO.get_shared_link_icon(),Browse:b3,Constants:Constants,Emstring:bu,FilePath:an,Sprite:b7,_:dW})}eF=T.childElements();if(eAeQ.length){eQ.push("+"+(eP.length-eQ.length))}if(eQ.length>0){eH.file_to_sharers[eJ.href]=eQ.join(", ")}}return eE()}})(this)})}},update_file_to_sharers:function(ex,T){if(this.file_to_sharers!=null){return this.file_to_sharers[ex.href]=T}},reset_browse_exp:function(){var T;T=bg("#browse-inline-autocomplete");T.hide().off();bg("#browse-sort").append(T);return bg("#browse-box").removeClass("dropdown-menu-open")},reload_fqpath:function(ex,T){return this.reload(null,du.urlquote(ex),T)},force_reload:function(){return this.reload(this.containing_ns_id(),du.urlquote(this.containing_ns_path()),true)},set_title:function(){var T;if(b3.in_search_mode()){bK.set_title();return}if(!b3.inside_dir){return}T=this.containing_fq_path();return document.title=T?an.filename(T)+" - Dropbox":ck.get_viewer().is_paired&&b3.active_user.role===Constants.ROLE_WORK?ck.get_viewer().team_name+" - Dropbox":ck.get_viewer().is_paired&&b3.active_user.role===Constants.ROLE_PERSONAL?dW("Personal")+" - Dropbox":dW("Home")+" - Dropbox"},set_selection_from_fq_paths_or_index:function(eE){var ey,ex,eC,eB,T,ez,eA,eD;T=eE.select_fq_paths;ez=eE.select_index;if(T||ez>-1){ex=[];if(T){for(eA=0,eD=T.length;eA-1){ey=this.files[ez];if(ey){ex.push(ey)}}if(ex.length){eg.set_selected_files(ex);this.scrollToWithPadding(ex.first().get_div(),100)}eE.select_fq_paths=false;return eE.select_index=-1}else{if(!bK.fulltext_search_enabled){return window.scrollTo(0,0)}}},set_selection_from_item_counters:function(){var ex,eD,eA,eF,eB,ez,eE,T,eC,ey;if(this.select_item_counters!=null){eA={};eC=this.select_item_counters;for(eB=0,eE=eC.length;eBey;ex=0<=ey?++ez:--ez){eA=an.normalize(T.slice(0,ex+1).join("/"));eB.push(this.details_from_fq_path(eA))}return eB},_get_root_icon:function(){if(!ck.get_viewer().is_paired){return"glyph"}if(b3.active_user.role===Constants.ROLE_WORK){return"work_icon"}else{if(b3.active_user.role===Constants.ROLE_PERSONAL){return"personal_icon"}}},_get_root_name:function(){return ck.get_root_name(b3.active_user)},_get_max_breadcrumb_width:function(ez){var ex,ey,T;ey=ez?this._DROPDOWN_WIDTH:new bu(this._get_root_name()).length;if(this.use_shorter_breadcrumbs){ex=bg("#browse-rightmenu").width();T=bg("#browse-global-actions-bar").width();return((T-ex)*this._FUDGE_FACTOR/this._PX_TO_EM)-ey}else{return this._MAX_BREADCRUMB_WIDTH-ey}},_PX_TO_EM:16,_FUDGE_FACTOR:0.75,_DROPDOWN_WIDTH:2.625,_MAX_BREADCRUMB_WIDTH:20,_CONNECT_WIDTH:1.64,breadcrumb:function(){var eF,ex,ez,eG,eC,eE,T,eH,eD,ey,eA,eB;ex=this._make_breadcrumbs_data();ey=ex.collect(function(eI){return new bu(eI.fq_path?eI.folder_name:"").length});eD=0;ez=0;cj(ex.length>0,"expected at least one breadcrumb");eH=this._get_max_breadcrumb_width();for(eC=eA=eB=ex.length-1;eB<=0?eA<=0:eA>=0;eC=eB<=0?++eA:--eA){eD+=ey[eC];if(eD>eH){break}ez+=1;eD+=this._CONNECT_WIDTH}eG=ex.slice(0,ex.length-Math.max(1,ez));ex=ex.slice(eG.length,ex.length);if(!eG.length&&ex.length>1){ex.shift()}eE=ex.pop();eF=eu.tmpl("breadcrumb_tmpl",{breadcrumbs:ex,dropdown:eG,containing_fq_path:this.containing_fq_path(),url_root:ew.get_browse_root(b3.active_user),root_name:this._get_root_name(),Sprite:b7});T=eE.folder_name;if(eE.fq_path!==""){T=bu.em_snippet(T,this._get_max_breadcrumb_width(eG.length>1))}$("browse-location").__date(eF);$("browse-location").__sert(" "+T);if(eG.length>1){return this._render_breadcrumbs_dropdown(eG)}},_render_breadcrumbs_dropdown:function(eA){var T,ey,ex,ez;T=$("breadcrumbs-box");eA.reverse();ex=eu.tmpl("breadcrumb_li_tmpl",{breadcrumbs:eA,Sprite:b7,Emstring:bu});$("browse-location").__sert(ex);ey=$("breadcrumb-dropdown");ez=(function(eB){return function(eD){var eC;eD.stopPropagation();ey.show();eC=bg(T);return bg(ey).clonePosition(eC,{setWidth:0,setHeight:0,offsetTop:eC[0].offsetHeight,offsetLeft:parseInt(eC.css("padding-left"),10)})}})(this);T.observe("click",ez);T.observe("dragover",ez);return document.observe("click",(function(eB){return function(){T.removeClassName("down");return ey.hide()}})(this))},viewportOffset:function(){var T,ey,ex;if(!this.files.length){return}if(!this.div_parent){ey=this.files[0].get_div().offsetParent;if(!ey){return}this._viewportOffset={};this.div_parent=$(ey);this._cumulativeOffset=this.div_parent.cumulativeOffset()}T=du.scrollLeft(this.div_parent);ex=du.scrollTop(this.div_parent);if(!this.scrollTop||!this.scrollLeft||this.scrollTop!==ex||this.scrollLeft!==T){this._viewportOffset.top=this._cumulativeOffset.top-ex;this._viewportOffset.left=this._cumulativeOffset.left-T;this.scrollLeft=T;this.scrollTop=ex}return this._viewportOffset},selectable:function(){return du.enableSelection($("browse-files"))},unselectable:function(){return du.disableSelection($("browse-files"))},_header_offset:(function(){var T;T=$("browse-header");return T.getHeight()+T.cumulativeOffset().top}).cached(1000),scrollTo:function(T){return this.scrollToWithPadding(T,3)},scrollToWithPadding:function(ez,eB){var ey,eC,ex,eA,T;if(!ez){return}eA=y.viewport_dimensions();T=y.scroll_offsets();eC=ez.cumulativeOffset().top-T.top;ey=ez.getHeight();ex=this._header_offset();if(eCeA.height){y.scroll_to(0,T.top+eC+ey-eA.height+eB)}}if($("modal-overlay").visible()&&$("modal").getStyle("position")==="absolute"){return er.fix_position()}},_visible_change_callbacks:{},_next_visible_change_callback_id:0,add_visible_change_callback:function(T){this._visible_change_callbacks[this._next_visible_change_callback_id]=T;return this._next_visible_change_callback_id++},remove_visible_change_callback:function(T){return delete this._visible_change_callbacks[T]},fire_visible_change_callbacks:function(){var ey,eC,ez,eB,eA,T,ex;if(!bg.isEmptyObject(this._visible_change_callbacks)){eA=aO.get_files_in_view(),eB=eA[0],ey=eA[1];T=this._visible_change_callbacks;ex=[];for(ez in T){eC=T[ez];ex.push(eC(this.files,this.active_user.id,eB,ey))}return ex}}};j=A.BrowseUpdate=(function(){var T,eD,eC,ez,eB,eA,ey,ex;ey=function(eF){var eG,eH,eE;if(!b3.inside_dir){return}eH=eF.parent_changes;if(eH.change_to_fq_path!=null){if(eH.change_type==="moved"){if(eH.is_changing_view){eG=dW("The folder '%s' has been moved. View");eG=eG.format(eH.old_fq_path.escapeHTML(),du.urlquote(eH.new_fq_path))}else{eG=dW("This folder has been moved")}}else{if(eH.change_type==="renamed"){if(eH.is_changing_view){eG=dW("The folder '%s' has been renamed. View");eG=eG.format(eH.old_fq_path.escapeHTML(),du.urlquote(eH.new_fq_path))}else{eG=dW("This folder has been renamed to '%s'.");eE=eH.change_to_fq_path.split("/");eG=eG.format(eE[eE.length-1].escapeHTML())}}else{eG=dW("The folder '%s' has been deleted.");eG=eG.format(eH.old_fq_path.escapeHTML())}}if(eH.is_changing_view){Y.error(new eu(eG))}else{if(eH.old_fq_path===b3.containing_fq_path()){Y.success(new eu(eG))}}b3.reload_fqpath(eH.change_to_fq_path);return}return eA(eF)};ex=function(eJ){var eF,eM,eL,eE,eO,eK,eH,eN,eI,eG;eM=[];eK=[];if(!b3.in_search_mode()){return}bK.clear_cache();for(eE in b3.ns_id_to_mount_point){if(!(eE in eJ.mount_points)){eJ.mount_points[eE]=null}}eI=eJ.mount_points;for(eE in eI){eL=eI[eE];eE=parseInt(eE,10);eO=b3.ns_id_to_mount_point[eE];if(eL===eO){continue}if(eL){b3.ns_id_to_mount_point[eE]=eL}else{delete b3.ns_id_to_mount_point[eE]}eG=b3.files;for(eH=0,eN=eG.length;eHdA.MODAL_WAIT_MS){T=ex.req.options;dX.show(T.progress_text);T.onProgress=dX.update;if(T.on_modal_shown!=null){T.on_modal_shown()}ex.modaled=true}if(ex.is_async_task){return dA.get_async_task_status(ey)}else{return dA.get_job_status(ey)}},get_job_status:function(T){return new Ajax.DBRequest("/job_status/"+T,{method:"post",subject_user:dA.job_info[T].subject_user,onSuccess:function(ey){var ez,ex;ez=dA.job_info[T];ex=ey.responseText;if(ex.indexOf("err")===0){dA.done(T);if(ez.req.options.onFailure&&!cL.handled(T)){ez.req.options.onFailure(ey)}return}if(ex.indexOf("done")===0){ez.req.options.job=false;if(!cL.peek(T)){new Ajax.Request("/job_results/"+T,{method:"post",parameters:{t:a9.read(Constants.JS_CSRF_COOKIE)},onSuccess:function(eB){if(cL.handled(T)){return}ai.clearWorkingMessage();if(ez.req.options.onSuccess){return ez.req.options.onSuccess(eB)}},onFailure:function(eB){if(cL.handled(T)){return}ai.clearWorkingMessage();if(ez.req.options.onFailure){return ez.req.options.onFailure(eB)}}})}return dA.done(T)}else{try{if(ez.req.options.onProgress){return ez.req.options.onProgress(ey.responseText)}}catch(eA){}}},onFailure:function(ex){var ey;ey=dA.job_info[T];ey.failures++;if(ey.failures>=dA.FAILS_MEAN_FAIL){if(ey.req.options.onFailure){ey.req.options.onFailure(ex,true)}ai.remove(ey.req);return dA.done(T)}}})},get_async_task_status:function(T){return new Ajax.DBRequest("/async_task_status/"+T,{method:"post",subject_user:dA.job_info[T].subject_user,onSuccess:function(ey){var ez,ex;ez=dA.job_info[T];ex=ey.responseText;if(ex.indexOf("done:")===0||ex.indexOf("err:")===0){cL.handled(T);ai.clearWorkingMessage();if(ex.indexOf("done:")===0){ey.responseText=ex.substr(5)}if(ez.req.options.onSuccess){ez.req.options.onSuccess(ey)}if(ez.req.options.onComplete){ez.req.options.onComplete(ey)}return dA.done(T)}else{if(ex.indexOf("async_task_err:")===0){Y.error(new eu(ex.substr(15)));cL.handled(T);ai.clearWorkingMessage();dA.done(T);return b3.force_reload()}else{try{if(ez.req.options.onProgress){return ez.req.options.onProgress(ey.responseText)}}catch(eA){}}}},onFailure:function(ex){var ey;ey=dA.job_info[T];ey.failures++;if(ey.failures>=dA.FAILS_MEAN_FAIL){try{if(ey.req.options.onFailure){ey.req.options.onFailure(ex,true)}}catch(ez){}ai.remove(ey.req);return dA.done(T)}}})},done:function(ex){var T;T=dA.job_info[ex];clearInterval(T.int_id);if(!T.dont_hide){delete dA.job_info[ex];if(!(T.req.async_task_id&&T.req.async_task_id!==ex)){return dX.hide(ex)}}else{return dX.update("1/1")}}};var cR,bz,be,bl=[].indexOf||function(ey){for(var ex=0,T=this.length;ex0){return}bg("#cal_container").hide();this.shown=false;return true};return T})();bz=INLINE_JS.Events=A.Events={ns:null,role:"all",now:Number(new Date()),timestamp:du.start_of_day(new Date(Number(new Date())+60*60*24*1000)),request_in_flight:false,one_day:60*60*24*1000,user_navigated_away:false,init:function(T,eB,eD,ey,eC){var ez,eA,ex;if(eC==null){eC=false}ex=dZ.deconstruct_url();this.first_event_map=T;this.roles=eB;this.rss_data=eD;this.role_has_events=ey;this.for_deleted_files_page=eC;this.role_picker=bg("#role-selector").controller();if(this.roles.length===1){this.role=this.roles[0].role}else{if(ex.qargs.role){this.role=ex.qargs.role;this.role_picker.set_state(this.role)}}this.date_picker=new cR((function(eE){return function(eF){eE.change_date(eF);eE.set_url();return aQ.WebMiscActivityLogger.log("filter_events_date")}})(this));this._init_state();this.role_picker.on_state_change=(function(eE){return function(){eE.role=eE.role_picker.get_state();if(eE.ns&&!$u(eE.valid_roles()).any(function(eF){return eF.ns_ids.contains(eE.ns.ns_id)})){eE.ns=null;aC.set_selected_by_value(bg("#namespace-list")[0],"false")}eE.set_url();return eE.get_more(true)}})(this);bp.set_during_login_callback((function(eE){return function(eG,eF){return window.location.reload()}})(this));bg(window).bind("beforeunload",(function(eE){return function(){eE.user_navigated_away=true;return void 0}})(this));if(bg("#namespace-list-container")[0]){bg("#namespace-list-container")[0].observe("db:change",(function(eE){return function(eF){eE.ns=eE.namespaces[JSON.parse(eF.memo)];eE.set_url();eE.get_more(true);return aQ.WebMiscActivityLogger.log("filter_events_shared_folder")}})(this))}bg(window).on("scroll",(function(eE){return function(){document.body.scrollTop=Math.min(document.body.scrollTop,document.body.scrollHeight-y.viewport_dimensions().height-10);return eE.get_more()}})(this));if(ex.qargs.ns){aC.set_selected_by_value(bg("#namespace-list")[0],ex.qargs.ns);this.ns=this.namespaces[ex.qargs.ns]}if(ex.qargs.date){eA=ex.qargs.date.split("-").map(Number);ez=new Date(eA[2],eA[1]-1,eA[0]);this.date_picker.calendar.selected_date=ez;this.change_date(ez)}this.update_calendar_first_day();return this.get_more()},_init_state:function(){var ex,eA,eD,eB,ez,ey,eC,T;this.namespaces={};eC=$u(this.roles).values();for(eD=0,ez=eC.length;eDthis.latest){this.latest=this.timestamp;this._init_state()}bg("#cur_date_text").text(I.localize(T));return this.get_more(true)},is_scrolled_down:function(){var T,ey,ex;ex=y.scroll_offsets().top;ey=y.viewport_dimensions().height;T=bg("#events").height();return ex+ey+50>=T},get_more:function(ez){var T,ex,ey;if(this.request_in_flight){return}if($u(this.valid_nss()).all(function(eA){return eA.done})){this.render();return}if(!(ez||this.is_scrolled_down())){this.render();return}this.request_in_flight=true;this.render();ex=(function(eA){return function(){return $u(eA.valid_nss()).map(function(eB){return eB.ns_id}).join(",")}})(this);T=Math.min(this.earliest(),this.timestamp/1000,Math.floor(this.now/1000));ey={page_size:25,ns_ids:ex(),timestamp:T};if(this.for_deleted_files_page){ey.for_deleted_files_page=true}return new Ajax.DBRequest("/events/ajax",{method:"POST",parameters:ey,onSuccess:(function(eA){return function(eO){var eM,eC,eP,eE,eN,eK,eJ,eG,eQ,eD,eB,eL,eI,eF,eH;eM=JSON.parse(eO.responseText);eA.request_in_flight=false;eL=eM.events;for(eK=0,eQ=eL.length;eK0){eI=eM.ns_ids;for(eJ=0,eD=eI.length;eJ0;ey={};if(this.ns){ey.ns=this.ns.ns_id}if(this.role!=="all"){ey.role=this.role}if(ez){ey.date=""+(ex.getDate())+"-"+(ex.getMonth()+1)+"-"+(ex.getFullYear())}T=this.for_deleted_files_page?"/deleted_files":"/events";return dZ.push_state(T,ey)},on_preview_open:function(ey){var ex,T;T=ck.get_viewer().get_user_by_id(ey.user_id);if(ey.preview_type==="photo"&&ey.large_thumbnail_url_tmpl){ex={filename:ey.filename,fq_path:ey.fq_path,thumbnail_url_tmpl:ey.large_thumbnail_url_tmpl,original_url:ey.href,ns_id:ey.ns_id,ns_path:ey.ns_path};ax.init([new S(ex)],{start_index:0})}else{bg(document).on("db:filepreview:close",this.on_preview_close);l.show(ey,T,false)}return false},on_preview_close:function(){bg(document).off("db:filepreview:close",this.on_preview_close);return document.title=dW("Recent events - Dropbox")},render:function(){var T,eL,eM,eG,eN,eF,eQ,eK,ey,eE,eI,eD,eJ,ex,eC,eA,ez,eO,eP,eH,eB;if(this.role_has_events[this.role]){this.update_calendar_first_day()}T=$u(this.valid_nss()).map((function(eR){return function(eS){return eS.events}})(this)).flatten();eL=this.earliest();ex=$u(T).sortBy(function(eR){return -eR.timestamp});eG=$u(ex).filter((function(eR){return function(eS){return eS.timestamp>=eL&&eS.timestamp span").text(eI);bg("#event-table").append(eM);if(eE.preview_jsinfo!=null){eF=eM.find("#prev_link");eF.on("click",this.on_preview_open.bind(this,eE.preview_jsinfo))}}bg("#events-container").show();bg("#events-sub-header").show();bg("#events-sub-header").css("visibility","visible");bg("#events-empty-state").hide();bg(".empty-explanation").hide()}else{if(!this.request_in_flight){bg("#events-container").hide();bg("#events-sub-header").hide();bg("#events-empty-state").show();bg(".empty-explanation").show()}}if(!this.request_in_flight){bg("#more-loading").hide()}else{bg("#more-loading").show()}bg("#more-loading").css("marginTop",this.earliest()===Number.MAX_VALUE?"140px":"20px");eH=bg("#namespace-list > li");for(ez=0,eP=eH.length;ez1)}return eT}).call(this),true)>=0;if(!this.request_in_flight){if(eJ){bg("#namespace-list-container").css("visibility","visible");bg("#namespace-list-container").show()}else{bg("#namespace-list-container").hide()}eD=this.rss_data[(eB=this.ns)!=null?eB.ns_id:void 0]||this.rss_data[this.role];if(eD&&this.role_has_events[this.role]){bg("#rss-feed a").attr("data-title",eD.title);bg("#rss_url").val(eD.url);bg("#reset-rss-link").on("click",(function(eR){return function(eS){new Ajax.DBRequest("/reset_rss",{parameters:{ns_id:eD.ns_id},onSuccess:function(){Y.success(dW("RSS feed url successfully reset."));return bC.redirect("/events")}});return false}})(this));bg("#rss_url").focus();bg("#rss-feed").show();return bg("#rss-feed").css("visibility","visible")}else{return bg("#rss-feed").hide()}}},show_rss_modal:function(){var T,ex;er.show(dW("Subscribe to this RSS feed"),bg("#rss-modal")[0]);ex=bg("#rss_url").val();T=q.clipboard_overlay(ex,bg("#real_copy"),function(){Y.success(dW("Link copied to clipboard!"));return er.hide()},bg(".modal-buttons"));return T.css({zIndex:1001})}};var I;I=A.DateUtil={fromSecondsSinceEpochUTC:function(T){var ex;ex=new Date(1970,0,1);ex.setSeconds(T);return ex},applyTimezoneOffset:function(ex,ez){var T,ey;T=parseInt(ez,10);ey=60*(ez-T);ex.setHours(ex.getHours()+T);return ex.setMinutes(ex.getMinutes()+ey)},contextualFormat:function(ex){var ez,eB,T,ey,eA;T=new Date(Date.now());ey=(T.getTime()-ex.getTime())/1000;ez=0;if(ey<8*3600){return bF.ago(ex)}this.applyTimezoneOffset(T,Constants.TIMEZONE_OFFSET);this.applyTimezoneOffset(ex,Constants.TIMEZONE_OFFSET);eA=new Date(Date.now());this.applyTimezoneOffset(eA,Constants.TIMEZONE_OFFSET);eA.setDate(eA.getDate()-1);if(ex.getYear()===T.getYear()&&ex.getMonth()===T.getMonth()&&ex.getDate()===T.getDate()){eB=dW("Today %(time)s");return eB.format({time:I.format(ex,Constants.time_format)})}else{if(ex.getYear()===eA.getYear()&&ex.getMonth()===eA.getMonth()&&ex.getDate()===eA.getDate()){eB=dW("Yesterday %(time)s");return eB.format({time:I.format(ex,Constants.time_format)})}else{return I.format(ex,Constants.datetime_format)}}},toUTCDate:function(T){return new Date(T.getUTCFullYear(),T.getUTCMonth(),T.getUTCDate(),T.getUTCHours(),T.getUTCMinutes(),T.getUTCSeconds(),T.getUTCMilliseconds())},differenceStr:function(ez,eC){var eE,eD,ex,ey,eA,T,eB;eA=(ez.getTime()-eC.getTime())/1000;if(eA<60){return aR("%d sec","%d secs",eA).format(eA)}else{if(eA<3600){ex=parseInt(eA/60,10);return aR("%d min","%d mins",ex).format(ex)}else{if(eA<86400){eD=parseInt(eA/3600,10);return aR("%d hour","%d hours",eD).format(eD)}else{if(eA<2592000){eE=parseInt(eA/(60*60*24),10);return aR("%d day","%d days",eE).format(eE)}else{if(eA<4838400){T=parseInt(eA/(60*60*24*7),10);return aR("%d week","%d weeks",T).format(T)}else{if(eA<31536000){ey=parseInt(eA/(60*60*24*30),10);return aR("%d month","%d months",ey).format(ey)}else{eB=parseInt(eA/(60*60*24*365),10);return aR("%d year","%d years",eB).format(eB)}}}}}}},localize:function(T){cj(Constants.date_format!=null,"Date format missing.");return I.format(T,Constants.date_format)},format:function(T,ex){var ey;cj(typeof ex==="string","Date format requires a format string");ey={yy:(function(ez){return function(){return T.getFullYear().toString().substring(2)}})(this),yyyy:(function(ez){return function(){return T.getFullYear().toString()}})(this),M:(function(ez){return function(){return(T.getMonth()+1).toString()}})(this),MM:(function(ez){return function(){return(T.getMonth()+1).toString().lpad(2)}})(this),d:(function(ez){return function(){return T.getDate().toString()}})(this),dd:(function(ez){return function(){return T.getDate().toString().lpad(2)}})(this),h:(function(ez){return function(){return(T.getHours()%12||12).toString()}})(this),H:(function(ez){return function(){return T.getHours().toString()}})(this),HH:(function(ez){return function(){return T.getHours().toString().lpad(2)}})(this),m:(function(ez){return function(){return T.getMinutes().toString()}})(this),mm:(function(ez){return function(){return T.getMinutes().toString().lpad(2)}})(this),a:(function(ez){return function(){if(T.getHours()>11){return dW("PM",{comment:"PM as in evening"})}else{return dW("AM",{comment:"AM as in morning"})}}})(this)};return ex.replace(/([a-zA-Z]+)/g,function(ez){if(ey[ez]!=null){return ey[ez]()}else{return ez}})}};var eb;eb=INLINE_JS.Timezone=A.Timezone={check_timezone:function(){var T;if(!ck.get_viewer().is_signed_in){return}T=eb.get_current_timezone();if((Constants.auto_timezone_offset==null)||Constants.auto_timezone_offset!==T){return eb.update(T)}},get_current_timezone:function(){var ez,ey,T,ex;ey=new Date();ey.setSeconds(0);ey.setMilliseconds(0);ex=ey.toGMTString();ez=new Date(ex.substring(0,ex.lastIndexOf(" ")));T=(ey-ez)/(1000*60*60);return T},update:function(T){cj(typeof T==="number","Timezone offset was not a number: "+T);return new Ajax.DBRequest("/set_timezone",{parameters:{offset:T},noAutonotify:true})},update_timezones_dropdown:function(ex,ez){var ey,T;if(ez==null){ez=null}T=eb.timezones_by_country[ex];bg("#timezone_id").empty();bg("#timezone_id").append((function(){var eC,eB,eA;eA=[];for(eC=0,eB=T.length;eC'+ey.name+"").prop("selected",ey.id===ez))}return eA})());return du.syncHeight()},auto:function(){var T;T=$F("timezone_auto");if(T){bg("#tz").hide()}else{if(eb.default_country){bg("#timezone_country").val(eb.default_country);eb.update_timezones_dropdown(eb.default_country)}bg("#tz").show()}return du.syncHeight()},load_data:function(ex,T){eb.timezones_by_country=ex;return eb.default_country=T}};var aV,bk;bk=A.CreateApp={init:function(ez,ex){var ey,eA,T;this.accepted_tos_by_uid=ez;this.form=ey=bg("#create-app-form");this.email_verification=null;if(!ck.get_viewer().is_paired){T=ck.get_viewer().get_users()[0];this.select_user(T.id)}eA=(function(eB){return function(eC){var eD;eD=eC.target.name;return ey.find("input[name="+eD+"]").each(function(){bg(this).parents("label").removeClass("active");return ey.removeClass(bg(this).data("next"))})}})(this);ey.find("input[type=radio]").change(function(eB){eA(eB);bg(eB.target).parents("label").addClass("active");return ey.addClass(bg(this).data("next"))});ey.find("input[type=checkbox]").change(function(eB){var eC;if(bg(this).filter("#accept-tos").length){return}bg(eB.target).parents("label").toggleClass("active");eC=ey.find("input[name="+(bg(this).attr("name"))+"]:checked");ey.toggleClass(bg(this).data("next"),eC.length!==0)});ey.find(".role-choice input").change((function(eB){return function(eD){var eC,eE;eC=ey.find(".role-choice input:checked");eE=eC.val();if(!ck.get_viewer().is_uid_signed_in(eE)){eC.prop("checked",false);eA(eD);bp.show_modal({user_id:eE,on_success:function(){return eC.prop("checked",true).trigger("change")}});return false}else{return eB.select_user(eE)}}})(this));ey.find("input:checked").trigger("change");ey.find("input[name=tos_accept]").change((function(eB){return function(eC){return eB.update_submit_enabled()}})(this));ey.find("#send-verify-email, #resend-verify-email").click((function(eB){return function(eC){eB.email_verification.send_email(ex,function(){ey.addClass("verify-email-sent");eB.email_verification.flash_email_sent_notification();return eB.email_verification.ensure_polling(function(){if(!eB.email_verification.user.is_email_verified){return}ey.addClass("email-verified");ey.removeClass("verifiy-email-sent");return eB.update_submit_enabled()})});return false}})(this));return ey.submit(function(eB){ey=bg(eB.target);bt.ajax_submit(ey[0],false,(function(eC){return window.location.href=eC.responseText}));return false})},select_user:function(T){this.email_verification=ds.get_for_user(ck.get_viewer().get_user_by_id(T));this.form.find("#accept-tos-wrapper").toggle(!this.accepted_tos_by_uid[T]);this.form.find("input[name=tos_accept]").prop("checked",false);this.form.removeClass("verify-email-sent");this.form.find("#verify-email-wrapper").toggle(!this.email_verification.user.is_email_verified);this.form.toggleClass("email-verified",this.email_verification.user.is_email_verified);return this.update_submit_enabled()},update_submit_enabled:function(){var ex,T;T=this.email_verification.user;ex=this.accepted_tos_by_uid[T.id]||this.form.find("input[name=tos_accept]").prop("checked");return this.form.find("#create-button").prop("disabled",!ex)}};aV=INLINE_JS.Apps=A.Apps={init_apps:function(){return bg("#show-disabled-apps").click(function(){bg(this).parent().hide();bg("#disabled-apps").show();return false})},init_app_info:function(ex,ey,T){this.user_email=T;bg("#app-info .icon-container").each(function(eA,eB){var ez;ez=bg(eB);return ez.append(Dropbox.createChooseButton({success:function(eC){ez.find(".icon").attr("src",eC[0].thumbnailLink);return ez.find("input[type=hidden]").val(eC[0].link)},linkType:"direct",extensions:["images"]}))});this._hoverable_tmpl=eu.tmpl("hoverable_tmpl");this._webhook_info_row_tmpl=eu.tmpl("webhook_info_row_tmpl");bg("#domain-list").on("click",".img-container",function(ez){aV.remove_domain(ez.currentTarget.parentNode,ex)});bg("#oauth-uri-list").on("click",".img-container",function(ez){aV.remove_oauth_uri(ez.currentTarget.parentNode,ex)});bg("#webhook-list").on("click",".img-container",function(ez){aV.remove_webhook(ez.currentTarget.parentNode,ex)});bg("#webhook-list").on("click",".webhook-actions.enabled .webhook_disable",function(ez){aV.update_webhook_url(ez.currentTarget,ex,false)});bg("#webhook-list").on("click",".webhook-actions.disabled .webhook_enable",function(ez){aV.update_webhook_url(ez.currentTarget,ex,true)});bg("#generate-token-button").on("click",function(ez){aV.generate_access_token(ex)});bg("#delete-app-button").on("click",function(ez){aV.confirm_disable(ey,ex,0)});bg("#webhook_url").on("click change paste focus",function(ez){bg("#webhook-form").removeClass("error")});this.init_app_info_add_redirect_uri();return bg("#oauth2-allow-implicit-grant").on("change",function(ez){return aV.set_oauth2_allow_implicit_grant(ez.currentTarget,ex)})},init_app_info_add_redirect_uri:function(){var T,ex,ey,ez;ex=/^\#?add_redirect_uri=(.*)$/.exec(window.location.hash||"");if(!ex){return}ez=window.decodeURIComponent(ex[1]);T=bg("#oauth-add-uri-form");bg("input[name=oauth_uri]",T).val(ez);ey=bg("#add-redirect-uri-modal")[0];bg("#add-redirect-uri-modal-uri").text(ez);er.show(dW("Add OAuth redirect URI"),ey,{doit:function(){var eA;if(window.history&&window.history.replaceState){eA=window.location.href;eA=eA.substring(0,eA.indexOf("#"));window.history.replaceState({},document.title,eA)}else{window.location.hash=""}er.hide();return aV.submit_new_oauth_uri(bg("#oauth-add-uri-form")[0])}})},init_app_datastores_browse:function(T){this.ds_info=T;if(ck.get_viewer().is_paired){this.role_picker=bg("#role-selector").controller();this.role_picker.on_state_change=this.app_datastores_browse_render.bind(this);return bp.set_during_login_callback((function(ex){return function(ez,ey){return ex.app_datastores_browse_reload_info(function(){return ey()},function(){ey("Error displaying datastores");return window.location.reload()})}})(this))}},app_datastores_browse_reload_info:function(ex,T){bg.ajax({url:"/developers/apps/datastores/info",success:(function(ey){return function(ez){ey.ds_info=ez;ey.app_datastores_browse_render();return typeof ex==="function"?ex():void 0}})(this),error:(function(ey){return function(ez){return typeof T==="function"?T(ez):void 0}})(this)});return false},app_datastores_browse_render:function(){this.app_datastores_browse_render_id("#apps_developed_container");this.app_datastores_browse_render_id("#apps_used_container");return this.app_datastores_browse_render_empty()},app_datastores_browse_render_empty:function(){var ey,ex,T,ez;ex=bg("#no_apps_container").empty();if(bg("#apps_developed_container").children().length!==0||bg("#apps_used_container").children().length!==0){return}ey=bg("
      ").appendTo(ex);switch((ez=this.role_picker)!=null?ez.get_state():void 0){case dq.PERSONAL:case dq.WORK:T=ck.get_viewer().get_user_by_role(this.role_picker.get_state());return ey.append("You don't have any datastores in your "+ck.get_role_title(T)+" Dropbox.");default:return ey.append("You don't have any datastores in your Dropbox.")}},app_datastores_browse_render_id:function(eD){var ex,eC,ez,eB,eA,ey,T;eB=this.app_datastores_browse_get_id_info(eD);eC=bg(eD);eC.empty();ex="";for(ey=0,T=eB.length;ey").appendTo(eC);return eA.html(ex)}},app_datastores_should_render:function(ex){var T;if(this.role_picker!=null){T=ck.get_viewer().get_user_by_id(ex);return this.role_picker.is_role_visible(T.role)}else{return true}},app_datastores_browse_get_id_info:function(T){switch(T){case"#apps_developed_container":return this.ds_info.apps_developed;case"#apps_used_container":return this.ds_info.apps_used;default:return cj(false,"invalid ds group id")}},app_datastores_browse_get_id_header:function(T){switch(T){case"#apps_developed_container":return bg("

      Apps you develop

      ");case"#apps_used_container":return bg("

      Apps you use

      ");default:return cj(false,"invalid ds group id")}},generate_access_token:function(ex){var ez,ey,T;T=this;ez=bg("#generate-token-button");ey=bg("").attr("src","/static/images/icons/ajax-loading-small.gif").css("vertical-align","middle");ez.replaceWith(ey);return bg.ajax({url:"/developers/apps/generate_access_token",type:"POST",data:{app_id:ex},dataType:"json",success:function(eB){var eA;if(eB.status==="ok"){eA=bg("
      ").append(bg("
      ").attr("id","generated-token").addClass("text").css("padding-top",0).text(eB.token));eA.append(bg("
      ").addClass("detail-text").text(eB.warning))}else{if(eB.status==="error"){eA=bg("
      ").addClass("detail-text").addClass("error").text(eB.msg)}}return ey.replaceWith(eA)},error:function(){return Y.error("Unable to complete your request.")}})},confirm_disable:function(ez,ey,ex){var eA,T;eA=(ex?dW("Are you sure you want to disable '%(app_name)s'?"):dW("Are you sure you want to delete '%(app_name)s'?"));cT.fillVal(eA.format({app_name:ez.escapeHTML()}),"app-disable-text");er.show((ex?dW("Confirm disable"):dW("Confirm delete")),$("app-disable-modal"));T="/developers/disable_app/"+ey;$("app-disable-modal").down("form").action=T;return $("disable-app-button").setValue((ex?dW("Disable"):dW("Delete")))},enable_app:function(ex){var T;T="/developers/enable_app/"+ex;return window.location.href=T},show_uninstall:function(eB,eA,ey,ex,ez,T){var eC;if(eB){Event.stop(eB)}er.vars={app_id:ey,user_id:T};eC=bg("#delete-"+ex+"-app-confirm");if(ex==="sandbox"){if(!ez){aV.do_uninstall();return}bg(".app_folder",eC).text(ez)}bg(".app_name",eC).text(eA);er.show(dW("Remove %(app_name)s?").format({app_name:bu.em_snippet(eA,22)}),eC[0],er.vars);return null},do_uninstall:function(){var T;T=er.vars.user_id;new Ajax.DBRequest("/api/uninstall_app",{parameters:{app_id:er.vars.app_id,keep_sandbox_files:$F("keep_sandbox_files")},onSuccess:function(ex){var ey;Y.success(ex.responseText);ey=bg(".apps-"+T);bg("#inst-app-"+er.vars.app_id+"-row",ey).hide().removeClass("active_app");if(bg(".active_app",ey).length===0){ey.hide()}if(bg(".active_app").length===0){bg("#empty-explanation").text(dW("You have no apps linked to your Dropbox."));return bg("#applications-explanation",ey).remove()}},subject_user:T});return er.hide()},enable_users_in_dev:function(T,ex){new Ajax.DBRequest("/developers/enable_users_in_dev/"+T,{onSuccess:function(ey){er.show(dW("Limit raised to %d users").format(ex),$("increased-dev-user-limit-modal"));bg("#users-in-dev-none, #users-in-dev-some").hide();return bg("#users-in-dev-max").show()}});return false},unlink_all_users_in_dev:function(T){er.show(dW("Unlink all users"),$("confirm-unlink-all-users"),{doit:function(){return new Ajax.DBRequest("/developers/unlink_all_users/"+T,{onSuccess:function(ex){bg("#current-app-users-1, #current-app-users-2").text("0");return er.hide()}})}});return false},unlink_all_teams_in_dev:function(T){er.show(dW("Unlink all teams"),$("confirm-unlink-all-teams"),{doit:function(){return bg.ajax({url:"/developers/unlink_all_teams/"+T,type:"POST",success:function(ex){bg("#current-app-teams").text("0");return er.hide()}})}});return false},restore_sandbox:function(ex,ez,T){var eB,ey,eA;eB=bg("#restore-sandbox")[0];er.show(dW("Restore app folder '%(filename)s'").format({filename:bu.em_snippet(an.filename(ez),17)}),eB);eA=bg("#restore-sandbox-form")[0];ey={ns_id:T};ey[Constants.UID_PARAM_NAME]=ex.id;return bt.add_vars(eA,ey)},submit_restore_sandbox:function(ex){var T;T=$("restore-sandbox-form");bt.ajax_submit(T,false,(function(ey){er.hide();Y.success(dW("Restored app folder"));if(ey.responseText.length){return b3.reload_fqpath(ey.responseText)}else{return b3.reload("","",true)}}),false,ex.target);return false},submit_app_info:function(T){var ex;ex=bg(T).find("input[name=name]").val();bt.clear_errors(T);return bt.ajax_submit(T,false,(function(){Y.success("App info updated.");if(ex){return bg("#app-info h1").text(ex)}}))},submit_folder_name:function(T){var ex;ex=bg(T).find("input[name=folder]").val();bt.clear_errors(T);return bt.ajax_submit(T,false,(function(){Y.success("App folder name updated.");bg("#folder-name .text").text(ex);return aV.hide_folder_input()}))},submit_new_webhook:function(ex){var ey,eI,eG,eB,eE,eD,eH,eF,ez,T,eC,eA;eI=bg(ex);eE=bg("#webhook-list");eB=bg("").attr("src","/static/images/icons/ajax-loading-small.gif").css("vertical-align","middle");eG=eI.find("input[name=webhook_url]");ez=function(eK,eJ){if(eJ){eJ.remove()}if(eE.find(".hoverable-url").length===0){eE.addClass("hide-status")}bg("#webhook-form-error").text(eK);return bg("#webhook-form").addClass("error")};eH=eG.val();if(eH===""){ez("Empty URI");return}eF=C.parse(eH);if((eC=eF.scheme)!=="http"&&eC!=="https"){ez("URI scheme must be http or https");return}if(!eF.authority){ez("Improperly formatted URI (typo maybe?)");return}if((eA=eF.authority)==="localhost"||eA==="127.0.0.1"){ez("Webhooks doesn't support localhost as Dropbox can't contact your local server. Please use an internet accessible URI.");return}if(eE.find("tbody").length>=Constants.MAX_WEBHOOKS_PER_APP){ez("You can register a maximum of %d webhook URIs per app.".format(Constants.MAX_WEBHOOKS_PER_APP));return}ey=bg(this._webhook_info_row_tmpl({url:eH,status:"Verifying"}).toHTML());ey.find(".status").append(eB);eE.append(ey);eE.removeClass("hide-status");bg("#webhook-form").removeClass("error");eD=bt.collect_form_vars(ex);eG.val("");T=new Date().getTime();return bg.ajax({url:"/developers/apps/update/add_webhook",type:"POST",dataType:"json",data:eD,success:function(eL){var eJ,eK;if(eL.status==="invalid"){ez(eL.failure_text,ey);return eG.val(eH)}else{eK=new Date().getTime()-T;eJ=Math.max(0,1000-eK);return setTimeout((function(){if(eL.status==="ok"){return ey.find(".status").text("Enabled")}else{if(eL.status==="error"){ey.find("textarea").text(eL.failure_text);ey.find(".status").text(eL.status_text).addClass("error");ey.find(".timestamp").text("Just now");return ey.find(".webhook-failure-info").css("display","")}}}),eJ)}},error:function(){Y.error("Unable to complete your request.");ey.remove();return eG.val(eH)}})},remove_webhook:function(ey,ex){var ez,T;bg("#webhook-form").removeClass("error");T=bg(ey).find(".value").text();ez=bg("").attr("src","/static/images/icons/ajax-loading-small.gif").css("vertical-align","middle");bg(ey).find(".status").text("Removing").removeClass("error").append(ez);return bg.ajax({url:"/developers/apps/update/remove_webhook",type:"POST",data:{app_id:ex,webhook_url:T},dataType:"json",success:function(eC){var eA,eB;eA=ey.parentNode;eB=eA.parentNode;eB.removeChild(eA);if(eB.getElementsByClassName("hoverable-url").length===0){bg(eB).addClass("hide-status")}if(!bg("#webhook_url").val()){return bg("#webhook_url").val(T)}},error:function(){return Y.error("Unable to complete your request.")}})},update_webhook_url:function(eB,ez,ey){var eC,T,eA,eD,ex;ex=bg(eB.parentNode.parentNode).find(".value").text();bg("#webhook-form").removeClass("error");eA=eB.parentNode.parentNode.parentNode;eC=bg("").attr("src","/static/images/icons/ajax-loading-small.gif").css("vertical-align","middle");T=bg(eA).find(".status").text();ey=T==="Disabled";eD=ey?"Enabling":"Disabling";bg(eA).find(".status").text(eD).removeClass("error").append(eC);return bg.ajax({url:"/developers/apps/update/update_webhook_url",type:"POST",data:{app_id:ez,webhook_url:ex,enable:ey},dataType:"json",success:function(eF){var eE;T=bg(eA).find(".status").text();eE=T==="Disabling"?"Disabled":"Enabled";bg(eA).find(".status").text(eE).removeClass("error").removeClass("img");if(T==="Disabling"){return bg(eA).find(".webhook-actions").removeClass("enabled").addClass("disabled")}else{return bg(eA).find(".webhook-actions").removeClass("disabled").addClass("enabled")}},error:function(eE){return Y.error("Unable to complete your request.")}})},set_oauth2_allow_implicit_grant:function(ex,T){return bg.ajax({url:"/developers/apps/update/oauth2_allow_implicit_grant",type:"POST",data:{app_id:T,allow:bg(ex).val()},dataType:"json",success:function(ey){return Y.success("OAuth 2 allow implicit grant updated.")},error:function(){return Y.error("Error updating OAuth 2 allow implicit grant.")}})},submit_new_oauth_uri:function(ex){var T;T=bg(ex).find("input[name=oauth_uri]").val();bt.clear_errors(ex);return bt.ajax_submit(ex,false,(function(){Y.success("OAuth URI added.");aV.add_oauth_uri(T);return bg(ex).find("input[name=oauth_uri]").val("")}))},add_oauth_uri:function(ex){var T;T=bg("#oauth-uri-list");T.append(this._hoverable_tmpl({value:ex}).toHTML());return T.show()},remove_oauth_uri:function(ex,T){var ez,ey;ez=bg(ex).find(".value").text();ey=function(eB){var eA;Y.success("OAuth URI removed.");eA=ex.parentNode;eA.removeChild(ex);if(eA.getElementsByTagName("div").length===0){return eA.hide()}};return bg.ajax({url:"/developers/apps/update/remove_oauth_uri",type:"POST",data:{app_id:T,oauth_uri:ez},dataType:"json",success:ey,error:function(){return Y.error("Unable to complete your request.")}})},submit_new_domain:function(T){var ex;ex=bg(T).find("input[name=domain_name]").val();bt.clear_errors(T);return bt.ajax_submit(T,false,(function(){Y.success("Domain added.");aV.add_domain(ex);return bg(T).find("input[name=domain_name]").val("")}))},add_domain:function(ex){var T;T=bg("#domain-list");T.append(this._hoverable_tmpl({value:ex}).toHTML());return T.show()},remove_domain:function(ex,T){var ez,ey;ez=bg(ex).find(".value").text();ey=function(eB){var eA;Y.success("Domain removed.");eA=ex.parentNode;eA.removeChild(ex);if(eA.getElementsByTagName("div").length===0){return eA.hide()}};return bg.ajax({url:"/developers/apps/update/remove_domain",type:"POST",data:{app_id:T,domain_name:ez},dataType:"json",success:ey,error:function(){return Y.error("Unable to complete your request.")}})},show_need_users_modal:function(T){er.show(dW("Please test this app",{comment:"Error message"}),$("app-need-users-modal"));return false},show_need_teams_modal:function(T){return er.show(dW("Please test this app",{comment:"Error message"}),$("app-need-teams-modal"))},show_name_branding_modal:function(T){er.show(dW("Please rename this app",{comment:"Error message"}),$("app-name-branding-modal"));return false},hide_folder_input:function(){bg("#folder-name").show();return bg("#folder-input").hide()},show_folder_input:function(){bg("#folder-name").hide();bg("#folder-input").show();return bg("#folder-input input[name=folder]").focus()}};var cd,c4;c4=INLINE_JS.twitter_auth_complete=function(T){cj(T!=null,"user_id must be provided");if(cd.onLoginSuccessCallback){cd.onLoginSuccessCallback(T)}else{window.location.reload()}return false};cd=A.Twitter={is_authed:function(T){T=parseInt(T);if(cd._authed_users==null){cd._authed_users={}}return cd._authed_users[T]},set_is_authed:function(T,ex){T=parseInt(T);if(cd._authed_users==null){cd._authed_users={}}return cd._authed_users[T]=ex},get_progress_container:function(){var T;cj(cd.progress_container,"Twitter is missing progress_container");T=$(cd.progress_container);cj(T,"Missing progress_container elm");return T},follow_dropbox:function(ex,T){var ey;cj(T!=null,"user_id must be provided");if(ex.showWorking){ex.showWorking()}ey=function(){if(ex.onFailure){return ex.onFailure()}else{return window.location.reload()}};return new Ajax.DBRequest("/twitter/follow_us",{onSuccess:function(ez){if(!ez.responseText.startsWith("ok")){return ey()}else{if(ex.onSuccess){return ex.onSuccess()}}},onFailure:function(){return ey()},subject_user:T})},do_auth:function(ez,T){var ey,ex;cj(T!=null,"user_id must be provided");ex=C({path:"/twitter/request_token"}).updateQuery(Constants.UID_PARAM_NAME,T).toString();window.open(ex,"twitter_auth","width=800,height=400");ey=function(eA){cd.set_is_authed(eA,true);return typeof ez==="function"?ez(eA):void 0};return cd.onLoginSuccessCallback=ey},show_auth:function(T){if(T){cd.onLoginSuccessCallback=T}return cT.updateFromElm(cd.get_progress_container(),"inline-twitter-auth")},show_posting:function(){if(cd.should_hide_modal()){er.hide()}return cd.get_progress_container().update(cT.fromElm("sharing-progress"))},show_complete:function(ex){var T;T=cd.get_progress_container();T.update(cT.fromElm("sharing-posted"));return cd.show_complete_into(ex,T)},show_complete_into:function(eC,T){var ez,eA,ey,eB,ex;ez="twitter";eB=dW("View tweet");ex=void 0;if(eC.startsWith("ok")){ex="http://www.twitter.com/"}else{ex=eC}eA=T.down("#view-post");eA.href=ex;eA.update(eB);ey=b7.make("web",ez);return eA.__sert({top:ey})},post:function(ez,eB,ey,T){var eA,ex;cj(T!=null,"user_id must be provided");cj(ez,"Twitter message is empty");eA={message:ez,from_referrals:cd.from_referrals,from_getspace:cd.from_getspace};new Ajax.DBRequest("/twitter_post",{parameters:eA,onSuccess:function(eC){var eD,eE;if(eC.responseText==="login"){cd.onLoginSuccessCallback=function(){return cd.post(ez,null,null,T)};eD=cd.custom_show_auth||cd.show_auth;return eD()}else{if(cd.should_hide_modal()){er.hide()}eE=cd.onPostSuccessCallback||cd.show_complete;return eE(eC.responseText)}},subject_user:T});ex=cd.custom_show_posting||cd.show_posting;return ex()},custom_post:function(ex,ey,T){cj(T!=null,"user_id must be provided");if(ey){cd.onPostSuccessCallback=ey}if(!ex){return}cj(ex,"Twitter message doesn't exist");if(!ck.get_viewer().is_signed_in){return window.open("http://www.twitter.com/home?status="+encodeURI(ex))}else{return cd.post(ex,null,null,T)}},get_user_info:function(ex,T){cj(T!=null,"user_id must be provided");return new Ajax.DBRequest("/twitter/user_info",{noAutonotify:1,parameters:{},onSuccess:function(ey){return ex(JSON.parse(ey.responseText))},subject_user:T})},should_hide_modal:function(){if(typeof cd.hide_modal==="undefined"){return true}else{return cd.hide_modal}}};var cS,ej,c2,S,ec,ak,bi,ag,u,dJ,am={}.hasOwnProperty,cm=function(ez,ex){for(var T in ex){if(am.call(ex,T)){ez[T]=ex[T]}}function ey(){this.constructor=ez}ey.prototype=ex.prototype;ez.prototype=new ey();ez.__super__=ex.prototype;return ez},cV=function(T,ex){return function(){return T.apply(ex,arguments)}};c2=A.LightboxPreviewBase=(function(){function T(ex){this.link_hash=ex.link_hash;this.filename=ex.filename;this.fq_path=ex.fq_path;this.thumbnail_url_tmpl=ex.thumbnail_url_tmpl;this.dl_url=ex.dl_url;this.ns_id=ex.ns_id;this.ns_path=ex.ns_path;this.display_time=ex.display_time||null;this.more_actions_item_tmpl=eu.tmpl("lightbox_more_actions_item_tmpl")}T.prototype.shutdown=function(){};T.prototype.preload=function(){};T.prototype.render=function(){};T.prototype.image_size=function(){var ex;ex=document.viewport.getDimensions();return au(ex.width,ex.height)};T.prototype.get_more_actions_above_divider=function(ey){var ez,ex;ex=[];ez=this.more_actions_item_tmpl({_id:"lightbox_download_link",_href:this.dl_url,_ns_id:this.ns_id,_ns_path:this.ns_path,sprite_name:"lightbox_download",item_text:dW("Download"),more_classes:"more-actions-item",Sprite:b7});ex.push(ez);return ex};T.prototype.get_more_actions_below_divider=function(ex){return[]};T.prototype.is_a_timeline_preview=function(){return this instanceof ec||this instanceof cS||this instanceof ak||this instanceof ej};T.prototype.is_an_album_preview=function(){return this instanceof ec||this instanceof ak};T.prototype.is_a_photo_preview=function(){return this instanceof S};T.prototype.is_a_video_preview=function(){return this instanceof bi};T.prototype.get_actions=function(ez){var eB,eD,eE,ey,eC,ex,eA;ey=[];if(!this.is_a_timeline_preview()&&ez.enable_sublinks){if(ez.share_button_experiment_variant==="WHITE_BUTTON"){eE=bg("#lightbox-share-action-base").clone().attr("id","lightbox-share-button");if(this.shmodel_link){eA=(function(eF){return function(eG){aQ.ShmodelUILogger.log("via-shmodel-lightbox");return window.open(C.parse(eF.shmodel_link).updateQuery("m","1"))}})(this)}else{eA=(function(eF){return function(eG){eG.preventDefault();aQ.ShmodelUILogger.log("via-browse-lightbox");return cW.shmodel(eF.fq_path,"browse_lightbox")}})(this)}}else{eE=bg("",{id:"lightbox_share_link","class":"title_bubble black"});eE.html(b7.make("web","link_white"));if(this.is_a_photo_preview()){eE.attr("title",dW("Share link to photo"))}else{if(this.is_a_video_preview()){eE.attr("title",dW("Share link to video"))}else{cj(false,"preview needs to be a photo or video")}}if(this.shmodel_link){eE.attr("href",C.parse(this.shmodel_link).updateQuery("m","1"));eE.attr("target","_blank");eA=(function(eF){return function(eG){return aQ.ShmodelUILogger.log("via-shmodel-lightbox")}})(this)}else{eE.attr("href","#");eA=(function(eF){return function(eG){eG.preventDefault();aQ.ShmodelUILogger.log("via-browse-lightbox");return cW.shmodel(eF.fq_path,"browse_lightbox")}})(this)}}eE.on("click",eA);ey.push(eE[0])}if(ez.include_delete){eC=bq.in_single_collection_view()?dW("Remove"):dW("Delete");if(ez.share_button_experiment_variant==="WHITE_BUTTON"){eB=bg("#lightbox-delete-action-base").clone().attr("id","lightbox-delete-link");eB.find(".sprite-text-inner").text(eC);eB.on("click",(function(eF){eF.preventDefault();return ax.delete_current()}))}else{eB=bg("",{id:"lightbox-delete-button",href:"#","class":"title_bubble black",title:eC});eB.html(b7.make("web","lightbox_delete_16"));eB.on("click",(function(eF){eF.preventDefault();return ax.toggle_delete()}))}ey.push(eB[0])}if(ez.share_button_experiment_variant==="WHITE_BUTTON"){ex=(function(eF){return function(eG){eG.preventDefault();return ax.toggle_more_actions_menu()}})(this);eD=bg("#lightbox-more-actions-base").clone().attr("id","lightbox-more-actions-button").on("click",ex);ey.push(eD[0])}else{cj(ax.more_actions_button!=null,"Lightbox should have a more_actions_button added on init");ey.push(ax.more_actions_button)}return ey};T.prototype.delete_pressed=function(){var ex;ex=dW("Deleting...");if(this.is_a_timeline_preview()){if(bq.in_single_collection_view()){ex=dW("Removing...");bq.get_current_collection().remove_photos([this.photo])}else{bq._delete_photos([this.photo])}}else{document.fire(ax.PHOTO_DELETE_EVT,this)}return Y.success(ex)};T.prototype.set_more_actions_event_handlers=function(ex){};T.prototype.replace_dl_action_with_open_action_if_file_available=function(){var ey,ez,ex,eA;if(__CONDITIONAL_JS__.UnityFeatures==null){return}ex=b3.active_user.id;ez=(function(eB){return function(eC,eF,eD){var eG,eE;eG=bg("#lightbox_download_link");if(!(eG.data("ns-id")===eC&&eG.data("ns-path")===eF)){return}eE=bg(eB.more_actions_item_tmpl({_id:"unity_open_action",_href:"#",_ns_id:eC,_ns_path:eF,sprite_name:"lightbox_open",item_text:dW("Open"),more_classes:"more-actions-item",Sprite:b7}).toHTML());eG.replaceWith(eE);return eE.on("click",function(eH){return __CONDITIONAL_JS__.UnityFeatures.open_file(eC,eF,eD,__CONDITIONAL_JS__.UnityFeatures.standard_open_file_handler)})}})(this);if((eA=__CONDITIONAL_JS__.UnityCheckFileCache)!=null?eA.get(this.ns_id,this.ns_path):void 0){return ez(this.ns_id,this.ns_path,ex)}else{ey=(function(eB){return function(eC){if(eC){return ez(eB.ns_id,eB.ns_path,ex)}}})(this);return __CONDITIONAL_JS__.UnityFeatures.check_file(this.ns_id,this.ns_path,ex,ey)}};return T})();S=INLINE_JS.PhotoPreview=A.PhotoPreview=(function(ex){cm(T,ex);function T(ey){T.__super__.constructor.call(this,ey);this.original_url=String(C.parse(ey.original_url).updateQuery(Constants.UID_PARAM_NAME,b3.active_user));this.shmodel_link=ey.shmodel_link;this.fail_image_src="/static/images/preview_fail.png";if(this.is_gif()){this.thumbnail_url_tmpl=this.original_url}this.loaded=false}T.prototype.show_fail=function(ez){var ey;return ey=bg(ez).find(".lightbox_fail_text").text(dW("Unable to preview this item."))};T.prototype.fallback=function(ez){var ey,eA;ey=$(ez.target);ey.writeAttribute({src:this.fail_image_src,width:128,height:128});eA=ey.up("div.content-item");if(eA){return this.show_fail(eA)}};T.prototype.is_gif=function(){return"gif"===an.file_extension(this.filename).toLowerCase()};T.prototype.preload=function(eA){var ez,eB,ey;ey=C.parse(this.thumbnail_url_tmpl).updateQuery({size:this.image_size()}).toString();if(this.is_gif()){ey=this.thumbnail_url_tmpl}eB=(function(eC){return function(){if(typeof eA==="function"){eA()}return eC.loaded=true}})(this);du.preload_image(ey,this.fallback.bind(this),eB);ez=$(du.preloaded_images[ey]);ez.writeAttribute("data-original-href",this.original_url);ez.writeAttribute("class","thumbnail");return ez};T.prototype.render=function(eD,eA){var eB,ez,eC,ey,eE;if(this.loaded){eA()}ez=this.preload(eA);eE=bg("
      ",{"class":"content-item"}).append(ez);eB=bg("
      ",{"class":"lightbox_fail_text"});eE.append(eB);eC=ez.getAttribute("src").length;ey=ez.getAttribute("src").substring(eC-this.fail_image_src.length,eC);if(ey===this.fail_image_src){this.show_fail(eE)}eD.appendChild(eE[0]);return eE[0]};T.prototype.advance_on_click=true;T.prototype.get_more_actions_above_divider=function(eA){var ez,ey;ey=T.__super__.get_more_actions_above_divider.call(this,eA);ez=this.more_actions_item_tmpl({_id:"view_original",_href:this.original_url,_target:"_blank",sprite_name:"lightbox_view_original",item_text:dW("View original"),more_classes:"more-actions-item",Sprite:b7});ey.push(ez);return ey};return T})(c2);bi=A.VideoPreview=(function(T){cm(ex,T);function ex(ey){this._player_error=cV(this._player_error,this);this._player_ready=cV(this._player_ready,this);ex.__super__.constructor.call(this,ey);this.preview_url=ey.preview_url;this.shmodel_link=ey.shmodel_link;this.thumbnail_div=null;this.metadata_link=ey.metadata_link!=null?ey.metadata_link:void 0;this.metadata=null;this.player=null}ex.prototype.render_error=function(eB){var eD,ez,ey,eA,eC;ez=bg("
      ");ey=bg("",{src:"/static/images/preview_fail.png","class":"video-preview-fail"});eA=bg("
      ",{"class":"video-preview-fail"});if(eB==="needflash"){eA.html(dW('Install Adobe Flash Player to view this video.'))}else{eA.text(dW("Unable to preview this item.",eC="web",eD="preview means showing the item in the same browser window without downloading a copy."))}ez.append(ey,eA);return ez[0]};ex.prototype._player_ready=function(){var ey;ey=function(){bg(".vjs-poster").show();bg(".vjs-big-play-button").show();return bg(".vjs-big-play-button").focus()};return ey.defer()};ex.prototype._onPlay=function(){bg(".vjs-poster").hide();return bg(".vjs-big-play-button").hide()};ex.prototype._onEnded=function(){bg(".vjs-poster").show();bg(".vjs-big-play-button").show();return bg(".vjs-loading-spinner").hide()};ex.prototype._player_error=function(ey){this.shutdown();this.div=this.render_error(ey);return bg("#file-preview-modal .content-item").html(this.div)};ex.prototype.preload=function(){};ex.prototype.render=function(ez,ey){this.div=this.render_video(ez);return this.div};ex.prototype.render_video=function(eE){var ey,eC,eA,ez,eD,eB;eB=new Element("div",{"class":"video-player content-item"});eD=this.image_size().split("x")[0]*0.8;ez=parseInt(eD*0.55,10);eC=false;eA=C.parse(this.thumbnail_url_tmpl).updateQuery({size:this.image_size()}).toString();ey=(function(eF){return function(eG){return eF.metadata=eG}})(this);this.player=a7.embed(eB,{src:this.preview_url,type:Constants.transcoder_hls4web?"application/vnd.apple.mpegurl":"video/flv",width:eD,height:ez,controls:true,preload:"auto",poster:eA,onError:this._player_error,onReady:this._player_ready,metadata:this.metadata,metadata_link:this.metadata_link,metadata_cb:ey});eE.appendChild(eB);bg(".vjs-poster").hide();bg(".vjs-big-play-button").hide();this.player.on("play",this._onPlay);this.player.on("ended",this._onEnded);return eB};ex.prototype.shutdown=function(){var ez,ey;bg(".vjs-big-play-button").blur();if(this.player){try{this.player.trigger("shutdown");if(this.player.techName==="Hls"){if((ey=this.player.tech.sourceBuffer)!=null){ey.abort()}}this.player.dispose()}catch(eA){ez=eA}return this.player=null}};return ex})(c2);ag=function(ey){var T,ex;T=(function(eA){cm(ez,eA);function ez(eB){eB.ns_id=eB.photo.ns_id;eB.ns_path=eB.photo.ns_path;ez.__super__.constructor.call(this,eB);this.photo=eB.photo;a2.set_vertical_space(3);if(bq.in_single_collection_view()){bg("#lightbox-delete-photo").val(dW("Remove"))}else{bg("#lightbox-delete-photo").val(dW("Delete"))}}ez.prototype.get_more_actions_above_divider=function(eD){var eC,eB;eB=ez.__super__.get_more_actions_above_divider.call(this,eD);eC=this.more_actions_item_tmpl({_id:"lightbox_add_to_album",sprite_name:"lightbox_add_to_album",item_text:dW("Add to album"),more_classes:"more-actions-item",Sprite:b7});eB.push(eC);return eB};ez.prototype.toggle_select_button_off=function(eB){if(this.is_a_photo_preview()){eB.attr("title",dW("Select photo"))}else{if(this.is_a_video_preview()){eB.attr("title",dW("Select video"))}}eB.html(b7.make("web","lightbox_unselected"));eB.removeClass("selected");eB.addClass("elbboggiw");return setTimeout((function(){return eB.removeClass("elbboggiw")}),540)};ez.prototype.toggle_select_button_on=function(eB){if(this.is_a_photo_preview()){eB.attr("title",dW("Un-select photo"))}else{if(this.is_a_video_preview()){eB.attr("title",dW("Un-select video"))}}eB.html(b7.make("web","lightbox_selected"));eB.addClass("selected");eB.addClass("wiggobble");return setTimeout((function(){return eB.removeClass("wiggobble")}),540)};ez.prototype.toggle_select=function(eC){var eB;eC.preventDefault();eB=bg("#lightbox-select-button");a2.hide_all();if(ef.contains(this.photo)){ef._remove(this.photo);return this.toggle_select_button_off(eB)}else{ef._add(this.photo);return this.toggle_select_button_on(eB)}};ez.prototype.get_actions=function(eD){var eC,eB,eE;eC=[];eE=bg("",{id:"lightbox_share",href:"#","class":"lightbox-button lightbox-not-important"});ax.update_share_button_text(null,bg(eE));eE.on("click",((function(eF){return function(eH){var eG;eH.preventDefault();eG=ef.get();if(eG.length===0){return dV.show([eF.photo],false)}else{return dV.show(ef.get(),false)}}})(this)));eB=bg("",{id:"lightbox-select-button",href:"#","class":"title_bubble black",title:dW("Select this photo")});if(ef.contains(this.photo)){eB.html(b7.make("web","lightbox_selected"))}else{eB.html(b7.make("web","lightbox_unselected"))}eB.on("click",this.toggle_select.bind(this));eC.push(eE[0]);eC.push(eB[0]);return eC.concat(ez.__super__.get_actions.call(this,eD))};ez.prototype.set_more_actions_event_handlers=function(eB){$("lightbox_add_to_album").observe("click",((function(eC){return function(eD){eD.preventDefault();return cg.show_add_to_album_modal(eD,[eC.photo])}})(this)));$("lightbox_show_in_folder").observe("click",((function(eC){return function(eD){eD.preventDefault();return bq.show_in_folder(eC.photo)}})(this)));return ez.__super__.set_more_actions_event_handlers.call(this,eB)};ez.prototype.get_more_actions_below_divider=function(eD){var eC,eB;eC=[];eB=this.more_actions_item_tmpl({_id:"lightbox_show_in_folder",sprite_name:"lightbox_show_in_folder",item_text:dW("Show in folder"),more_classes:"more-actions-item",Sprite:b7});eC.push(eB);eC=eC.concat(ez.__super__.get_more_actions_below_divider.call(this,eD));return eC};return ez})(ey);ex=(function(eA){cm(ez,eA);function ez(){return ez.__super__.constructor.apply(this,arguments)}ez.prototype.get_more_actions_below_divider=function(eD){var eB,eC;eC=[];eB=this.more_actions_item_tmpl({_id:"lightbox_remove_from_album",sprite_name:"lightbox_remove_from_album",item_text:dW("Remove from album"),more_classes:"more-actions-item",Sprite:b7});eC.push(eB);eC=eC.concat(ez.__super__.get_more_actions_below_divider.call(this,eD));return eC};ez.prototype.set_more_actions_event_handlers=function(eB){$("lightbox_remove_from_album").observe("click",((function(eC){return function(eD){eD.preventDefault();return cg.show_remove_photos_modal(bq.get_current_collection(),[eC.photo])}})(this)));return ez.__super__.set_more_actions_event_handlers.call(this,eB)};return ez})(T);return[T,ex]};u=ag(S),cS=u[0],ec=u[1];dJ=ag(bi),ej=dJ[0],ak=dJ[1];var ax;ax=INLINE_JS.Lightbox=A.Lightbox=(function(){var eQ,eO,fm,fl,e8,eE,ex,eV,e4,fq,fk,eD,e3,ff,eL,fe,e0,e9,fp,eK,e1,eI,fd,fh,eC,fg,eB,eT,fj,eN,e2,eF,eW,fa,eX,e6,ez,eP,T,e5,fi,fo,fc,eM,eS,eA,eR,e7,ey,eG,fb,eY,eZ,eJ,eU,eH,fn;fl=[];eQ=0;e8=false;fm=true;eY=void 0;ex=/^\d+\-\d+\-\d+\s+\d+\.\d+\.\d+/;eE=false;fj=void 0;ff=void 0;e7=-1;ey=null;e9=null;e1=false;T=false;eC=false;eI=null;eK=function(fr){return fr.complete!==false};eA=function(){var fr;if($$("#file-preview-modal .loading-image").length){return}fr=new Element("img",{"class":"loading-image",src:"/static/images/icons/ajax-loader-black.gif"});return $$("#file-preview-modal .preview-content").first().__sert(fr)};e0=function(){return $$("#file-preview-modal .loading-image").invoke("remove")};eX=function(){var fx,fw,ft,fr,fv,fu,fs;fw=$$("#file-preview-modal .content-item").first().down("img.thumbnail");if(!fw||!eK(fw)){return}fr=$$("#file-preview-modal .preview").first().getDimensions();fx=void 0;if(!fw.naturalHeight){fx=fw.getDimensions();fw.naturalHeight=fx.height;fw.naturalWidth=fx.width}else{fx={width:fw.naturalWidth,height:fw.naturalHeight}}ft=fx.width/fr.width;fs=fx.height/fr.height;fu=Math.max(ft,fs);fw.style.visibility="";if(fu<1){fw.style.width="";fw.style.height=""}else{fw.style.width=Math.floor(fx.width/fu)+"px";fw.style.height=Math.floor(fx.height/fu)+"px"}fv=bg("#file-preview-modal .paging-block").position().left-16;return bg("#file-preview-modal .filename").css("max-width",fv)};e3=void 0;fg=function(){var fy,ft,fx,fw,fv,fs,fu,fr;ft=$("file-preview-modal");fw=ft.down(".menu");fx=ft.down(".header");fu=$$(".lightbox-not-important");fr=[];for(fv=0,fs=fu.length;fv1&&(((fu=fC.photo)!=null?fu.item_owner_fname:void 0)!=null)){fG="  ·  ";fG+=dW("Added by %(fname)s").format({fname:bu.em_snippet(fC.photo.item_owner_fname,7)});fI.down(".added-by").__date(new eu(fG));fI.down(".added-by").show()}else{fI.down(".added-by").hide()}fx=eu.tmpl("lightbox_more_actions_item_tmpl");fE=fC.get_more_actions_above_divider(fj);fB=fC.get_more_actions_below_divider(fj);if(fB.length){fE.push(fx({divider:true,Sprite:b7}));fE=fE.concat(fB)}$("lightbox-more-actions-list").__date(fE);fC.set_more_actions_event_handlers(fj);if(bg(fI).data("is-unity-allowed")==="True"&&(__CONDITIONAL_JS__.UnityFeatures!=null)){fC.replace_dl_action_with_open_action_if_file_available()}fA=fC.get_actions(fj);fr=document.createDocumentFragment();for(fs=0,fL=fA.length;fs",{id:"lightbox-click-catcher",style:"position: absolute; width: 100%; height: 100%; top: 0px; left: 0px; z-index: 2;"});fs.appendTo("#file-preview-modal .modal-preview-content");if(bC.msie_version_at_most(10)){fs.css("background","black");fs.fadeTo(0,0)}}fs.off("click");fs.on("click",(function(ft){ft.preventDefault();return fr()}));return fs.show()};eL=function(){return bg("#lightbox-click-catcher").hide()};fq=function(){var fr;fr=bg("#lightbox-more-actions-button");if(fr.hasClass("toggled")){eL();fr.removeClass("toggled");$("lightbox-more-actions-menu").hide();bg(document).trigger("dropdownClosed",[1]);eG();return true}return false};eT=function(){var fr;fr=bg("#lightbox-more-actions-button");if(!fr.hasClass("toggled")){fe();fr.addClass("toggled");a2.hide_all();bg("#lightbox-more-actions-menu").show();bg(document).trigger("dropdownOpened",[1]);fb();return fi(ax.close_more_actions_menu)}};eJ=function(){if(bg("#lightbox-more-actions-button").hasClass("toggled")){return fq()}else{return eT()}};eB=function(fs){var fr;if(e1){T=true;fa()}fq();if(fs){fs.preventDefault()}if(eQ===fl.length-1&&fj.no_wrap){return}if((fr=fl[eQ])!=null){fr.shutdown()}eQ=fp(1);if(eQ===0){e6()}return e5(null,ax.NEXT)};eW=function(fs){var fr;if(e1){T=true;fa()}fq();if(fs){fs.preventDefault()}if(eQ===0&&fj.no_wrap){return}if((fr=fl[eQ])!=null){fr.shutdown()}eQ=fp(-1);return e5(null,ax.PREV)};e4=function(fr){if(fr){fr.preventDefault()}if(fl[eQ].advance_on_click){if(fr.clientXeJ;eQ=0<=eJ?++eO:--eO){eK=new Element("img",{src:"/static/images/page-left.png","class":"page-end-left page-end"});eK.style.left=(28-eQ*5)+"px";eK.style.zIndex=ey-eQ;eR.appendChild(eK)}for(eP=eM=0;0<=eN?eMeN;eP=0<=eN?++eM:--eM){eL=new Element("img",{src:"/static/images/page-right.png","class":"page-end-right page-end"});eL.style.right=(31-eP*5)+"px";eL.style.zIndex=ey-eP;eR.appendChild(eL)}return $("book").appendChild(eR)};T=function(eI){(eI>0?Element.show:Element.hide)("tour-page-back");return(eI+1=ey){return}eB(eI);return dZ.push_state("/tour/"+eI)};eH=function(eJ,eK){var eI;eJ.preventDefault();eI=parseInt(eK.href.split("/").last(),10);eB(eI);return dZ.push_state("/tour/"+eI)};eG=function(){$("tour-page-back").observe("click",eD);$("tour-page-forward").observe("click",eE);key("right",eE);key("left",eD);return $("toc").on("click","a",eH)};eC=function(eJ,eK){var eI;eI=parseInt(eJ,10)||0;return eB(eI)};eF=function(){var eM,eL,eJ,eK,eI;eK=$$(".page-right img");eI=[];for(eL=0,eJ=eK.length;eL%(items)s from your Dropbox?").format({items:cC.file_desc(eE)}),confirm_text:dW("Delete"),cancel_text:dW("Cancel"),confirm_callback:(function(eG){return function(){return eG._delete_photos(eE)}})(this)})},_delete_photos:function(eL){var eH,eF,ez,eI,T,ex,eK,eE,eC,eB,eJ,ey,eD,eA,eG;eL=eL.slice(0);eK=[];for(eC=0,eJ=eL.length;eCbq.NUM_PHOTOS_LONG_RUNNING_DELETES,job_user:ck.get_viewer().photos_user,progress_text:eF,onSuccess:function(eQ){var eO,eR,eP;eR=eQ.responseText.evalJSON();eP=bq.undo_enabled&&(bq._all_photos_timeline!=null);eO=eP?eR.changesets:null;Q.notifyWithUndo(eF,eO,eG);bq.get_timeline().remove_photos(eL);if(eN.length>0){return cg.refresh_album_views(eN)}},subject_user:ck.get_viewer().photos_user})}})(this);return new Ajax.DBRequest("/collections_from_paths",{parameters:{fq_paths:JSON.stringify(eK)},onSuccess:(function(eM){return function(eP){var eO,eN,eQ,eR;eN=JSON.parse(eP.responseText);eQ=[];for(eR in eN){eO=eN[eR];eQ=eQ.concat(eO)}return eE(eQ)}})(this)})},_preview:function(T){return ax.show(T)},_lightbox_delete:function(T){var ex;ex=T.memo.photo;h.log_interaction(dK.DELETE,cE.LIGHTBOX);return this.show_delete_photos_modal([ex])},_lightbox_remove:function(ex){var T;T=ex.memo.photo;this.get_current_collection().remove_photos([T]);return h.log_interaction(dK.REMOVE,cE.LIGHTBOX)},_show_duplicates_modal:function(ex,eM){var eE,eL,eC,eG,eF,ez,eI,ey,eD,eH,T,eK,eA,eJ,eB;eF=ex.duplicates_info.slice(0);eF.push(ex);eF.sort(function(eO,eN){return eN.mtime-eO.mtime});eG=$("cu-duplicate-files");ez=[];for(eA=0,eJ=eF.length;eA=5){eG.addClassName("scroll")}else{eG.removeClassName("scroll")}eB=cC.categorize_files([ex]),eH=eB[0],T=eB[1];if(eH){ey=dW("There are multiple copies of this photo.");eD=dW("Delete all copies of this photo?")}else{ey=dW("There are multiple copies of this video.");eD=dW("Delete all copies of this video?")}if(eM){eI="delete_32";eK=eD;eE=ey+" "+dW("Would you like to delete them all?");$("cu-delete-all-duplicates").show()}else{eI="folder_32";eK=dW("Show in folder");eE=ey+" "+dW("Which folder would you like to view?");$("cu-delete-all-duplicates").hide()}cT.fillVal(eE,"cu-duplicates-desc");return er.show(eK,$("cu-duplicates-modal"),{action:this._delete_photos.curry([ex])})},_show_delete_multiple_duplicates_modal:function(eJ,eE){var eI,eC,eF,ey,ex,eD,eB,eG,T,ez,eH,eA;eF=$("cu-multiple-duplicate-files");ey=[];for(ez=0,eH=eE.length;ez=5){eF.addClassName("scroll")}else{eF.removeClassName("scroll")}eA=cC.categorize_files(eJ),eG=eA[0],T=eA[1];if(eG&&T){ex=dW("Delete %(num_files)s files and all copies?").format({num_files:eJ.length});eD=dW("There are multiple copies of these files in your Dropbox.");eB=dW("Show files with multiple copies")}else{if(eG){ex=dW("Delete %(num_photos)s photos and all copies?").format({num_photos:eJ.length});eD=dW("There are multiple copies of these photos in your Dropbox.");eB=dW("Show photos with multiple copies")}else{ex=dW("Delete %(num_videos)s videos and all copies?").format({num_videos:eJ.length});eD=dW("There are multiple copies of these videos in your Dropbox.");eB=dW("Show videos with multiple copies")}}cT.fillVal(eD,"cu-multiple-duplicates-desc");cT.fillVal(eB,"cu-multiple-duplicates-show");$("cu-multiple-duplicates-modal").removeClassName("show-duplicates");return er.show(ex,$("cu-multiple-duplicates-modal"),{action:this._delete_photos.curry(eJ)})},show_timestamps_modal:function(eB){var ex,ey,ez,T,eA;eB.sort_by_key((function(eC){return eC.time_taken}),true);T=(function(){var eE,eD,eC;eC=[];for(eE=0,eD=eB.length;eEeL;eE=0<=eL?++eM:--eM){eK.push(eH)}return eK})();eD={};for(eF=eG=0,eC=T.length;eGeF.NUM_PHOTOS_LONG_RUNNING_EDIT_TIMESTAMP,job_user:ck.get_viewer().photos_user,onSuccess:function(eS){dX.update("1/3");return eF._scroll_to_photo_after_timestamp_edit(eE[0],eH[0])}})}})(this)})},_preload_file_previews:function(ez){var eF,eD,ey,T,eK,eJ,eG,eE,eH,eC,eB,eI,ex,eA;eH=this.get_timeline().get_photos();if(ez[0]<=ez[ez.length-1]){eE=null;for(eC=0,eI=ez.length;eC=eG;eD<=eG?eH++:eH--){ey.push(eH)}return ey}).apply(this))}else{if(eE.memo.direction===ax.PREV){eF=Math.max(T-this.LIGHTBOX_OFFSET*this.get_timeline().THUMBS_PER_ROW,0);return this._preload_file_previews((function(){ex=[];for(var eH=ez=T-1;ez<=eF?eH<=eF:eH>=eF;ez<=eF?eH++:eH--){ex.push(eH)}return ex}).apply(this))}}},_lightbox_exit:function(T){return key.setScope(this.KEY_SCOPE)},_window_resize:function(){var ey,ex,ez,T;ex=$("cu-view").cumulativeOffset().top+$("photos-list").getLayout().get("margin-top")+$("photos-list").getLayout().get("padding-top");if(bg("#carousel-promo-banner").outerHeight()){ex+=bg("#carousel-promo-banner").outerHeight()-$("cu-view").cumulativeOffset().top}ey=$("cu-view").cumulativeOffset().left+$("photos-list").getLayout().get("margin-left")+$("photos-list").getLayout().get("padding-left");if((ez=this._all_photos_timeline)!=null){ez.update_offsets(ex,ey)}return(T=this._single_collection_timeline)!=null?T.update_offsets(ex,ey):void 0},_history_change_handler:function(eJ,eI){var eE,eF,eG,eB,ez,eC,eH,eD,eA,ey,ex,T;if(this._init_finished){if(er.shown()){er.hide()}}$("photos-nav-item").removeClassName("selected");$$(".sidebar-album.selected").invoke("removeClassName","selected");if((eD=this.get_timeline())!=null){eD.unlisten()}if(eJ==="all_albums"){cg.load_collections(null);this._in_all_collections_view=true;$("cu-view").removeClassName("single-collection");$("cu-view").addClassName("all-collections");if((eA=$("all-albums-sidebar"))!=null){eA.addClassName("selected")}ef.clear();document.title=dW("Albums")+" - Dropbox";cg.restore_all_albums_scroll_position();this._current_collection_gid=null;return}else{this._in_all_collections_view=false;$("cu-view").removeClassName("all-collections")}if(eJ.startsWith("album/")){eE=cg.get_from_url("/photos/"+eJ);ey=$$(".sidebar-album");for(eC=0,eH=ey.length;eC1){eF=dW("%(photo_video_desc)s from %(album_members)s",{comment:'for example: "3 photos and 1 video from Peter, Boris, and Ryan"'}).format({photo_video_desc:cC.album_desc(eE),album_members:du.nice_list(eE.member_fnames)});$("single-collection-share-status").__date(eF)}else{$("single-collection-share-status").__date(dW("Shared"))}}else{$("single-collection-share-status").__date()}$("cu-view").addClassName("single-collection");if(!eE.is_creator){$("cu-view").addClassName("not-collection-creator")}document.title=""+eE.name+" - Dropbox";b8.log_event("show_collection",eE.gid,eE.num_photos,eE.is_anonymous)}else{eE=null;$("cu-view").removeClassName("single-collection");$("photos-nav-item").addClassName("selected");document.title=dW("Photos")+" - Dropbox"}eB=false;if(eE!=null){if(eE.gid!==this._current_collection_gid){eB=true}}else{if(this._all_photos_timeline==null){eB=true}}this._current_collection_gid=eE!=null?eE.gid:null;if(eB){this._refresh_view()}else{this._init_lightbox();this.get_timeline().init_timeline_nav();this.get_timeline().restore_scroll_position();this.get_timeline().listen()}if((this._last_lightbox_photo!=null)&&this.get_timeline().num_photos()){ez=this._last_lightbox_photo.uniqueness_key;this.get_timeline().scroll_to_photo_with_key(ez);if((T=$(ez))!=null){T.addClassName("wiggobble")}setTimeout((function(){return $(ez).removeClassName("wiggobble")}),1000);return this._last_lightbox_photo=null}}};var ay;ay=INLINE_JS.PhotosTour=A.PhotosTour={_frame:0,next:function(){var T;er.show("",bg("#photos-tour-"+(this._frame+1))[0],null,null,700,null,null,false);T=this._frame;h.log_interaction(aP.SHOW_MODAL,"",{frame:T});bg("#modal-x").off("click");bg("#modal-x").on("click",((function(ex){return function(){return h.log_interaction(aP.EXIT_MODAL,"",{frame:T})}})(this)));return this._frame=(this._frame+1)%4},hide:function(T){h.log_interaction(T,"");return er.hide()}};var cC;cC=A.PhotosUtil={categorize_files:function(ex){var ey,T;ey=ex.filter(function(ez){return ez.preview_type==="photo"});T=ex.filter(function(ez){return ez.preview_type==="video"});return[ey.length,T.length]},file_desc:function(eB,ey,T){var ex,eA,ez;if(ey==null){ey=false}if(T==null){T=false}ez=this.categorize_files(eB),ex=ez[0],eA=ez[1];return this._photo_video_desc(ex,eA,ey,T)},album_desc:function(ey,ex,T){if(ex==null){ex=false}if(T==null){T=false}return this._photo_video_desc(ey.num_photos,ey.num_videos,ex,T)},_photo_video_desc:function(ex,eC,ey,T){var ez,eB,eA;eB=aR("%d photo","%d photos",ex,{comment:"This will be used in a phrase such as 'x photos and y videos'"}).format(ex);eA=aR("%d video","%d videos",eC,{comment:"This will be used in a phrase such as 'x photos and y videos'"}).format(eC);if(ex&&eC){if(ey){ez=ex+eC;return aR("%d item","%d items",ez).format(ez)}else{if(T){return new eu(""+eB+"
      "+eA)}else{return dW("%(num_photos)s and %(num_videos)s",{comment:"num_photos and num_videos may be like either '1 photo' or '%d photos'"}).format({num_photos:eB,num_videos:eA})}}}else{if(ex){return eB}else{if(eC){return eA}else{return""}}}}};var ef,bl=[].indexOf||function(ey){for(var ex=0,T=this.length;ex=0},clear:function(){this._selected=[];this._last_selected=null;$$(".cu-thumb.selected").invoke("removeClassName","selected");$("cu-view").removeClassName("photos-selected");$("page-sidebar").removeClassName("photos-selected");ed.hide_all();return document.fire(ef.CHANGE_EVT)},clear_highlighted:function(){this._highlighted=[];this._dehighlighted=[];if(!this._select_highlighted_waiting){$$(".cu-thumb.highlighted").invoke("removeClassName","highlighted");$$(".cu-thumb.dehighlighted").invoke("removeClassName","dehighlighted");this._last_highlight_from_photo=null;return this._last_highlight_to_photo=null}},photo_click:function(ex,T){if(ex.isRightClick()&&!ex.shiftKey){return}if(ex.shiftKey){return this._select_highlighted()}else{if(this.contains(T)){return this._remove(T)}else{return this._add(T)}}},num_selected:function(){return this._selected.length},refresh:function(ez){var eB,eC,ey,eD,eA,ex,T;eD=(function(){var eH,eF,eG,eE;eG=this._selected;eE=[];for(eH=0,eF=eG.length;eH=0){T.push(this._selected[eB]=eC)}else{T.push(void 0)}}return T},inc_num_loading_events_before_select:function(T){if(!this._show_share_after_loading_selected){dX.show(dW("Loading photos..."))}this._show_share_after_loading_selected=T;this._num_pending_events_with_selections++;if(this._num_pending_events_with_selections>this._max_num_pending_events_with_selections){return this._max_num_pending_events_with_selections=this._num_pending_events_with_selections}},dec_num_loading_events_before_select:function(){this._num_pending_events_with_selections--;dX.update(""+(this._max_num_pending_events_with_selections-this._num_pending_events_with_selections)+"/"+this._max_num_pending_events_with_selections);if(this._num_pending_events_with_selections===0){dX.hide();if(this._show_share_after_loading_selected){this._show_share_after_loading_selected=false;if(this.num_selected()>0){return bq._share_selected()}}}},_photo_mouseover:function(T){this._last_mouseover=bq.get_timeline().get_photo_for_thumb_elm($(T.target));if(T.shiftKey){return this._highlight_range(this._last_selected,this._last_mouseover)}else{if(this._drag_select.active){return this._highlight_range(this._drag_select.anchor,this._last_mouseover,true)}}},_photo_mouseout:function(T){if(!this._marquee.active){this.clear_highlighted();return this._last_mouseover=null}},_body_mousedown:function(ez){var T,ex,ey;if(bq.in_all_collections_view()||ez.isRightClick()||this._invalid_mouse_target($(ez.target))){return}a1.hide();ed.hide_all();T=(ey=bq.get_timeline())!=null?ey.get_photo_for_thumb_elm($(ez.target)):void 0;if(T!=null){if(this.contains(T)||!ef.drag_select_enabled){ex=y.scroll_offsets();this._drag_drop.active=true;this._drag_drop.start_x=ez.clientX+ex.left;this._drag_drop.start_y=ez.clientY+ex.top;this._drag_drop.anchor=$(ez.target);this._drag_drop.single_photo=this.contains(T)?null:T;this._build_drag_status(T);this._update_drag_status_position(ez)}else{this._drag_select.active=true;this._drag_select.anchor=T}}else{ex=y.scroll_offsets();if((ez.clientX+ex.left)>=($(document.body).getWidth()-this.SCROLL_BAR_WIDTH)){return}this._marquee.active=true;this._marquee.start_x=ez.clientX+ex.left;this._marquee.start_y=ez.clientY+ex.top;this._marquee.x_max_boundary=-1;this._marquee.y_max_boundary=-1}return x.start()},_body_mousemove:function(ez){var ex,T,eA,ey;ex=y.scroll_offsets();T=ez.clientX+ex.left;eA=ez.clientY+ex.top;if(this._marquee.active){if(!$("marquee").visible()){if(Math.abs(T-this._marquee.start_x)=this._marquee.x_max_boundary||this._marquee.end_x<=this._marquee.x_min_boundary){this._update_marquee_x_bounds(this._marquee.end_x);ey=true}if(this._marquee.end_y>=this._marquee.y_max_boundary||this._marquee.end_y<=this._marquee.y_min_boundary){this._update_marquee_y_bounds(this._marquee.end_y);ey=true}if(ey){return this._update_marquee_highlight(ez,eA,ex,T)}}},_update_marquee_highlight:function(eH,ey,T,eJ){var eF,eG,eD,ex,eC,eB,eI,eE,eA,ez;this.clear_highlighted();ex=[];eG=bq.get_timeline().grid.photo_col_offsets.length;eE=bq.get_timeline().grid.photo_col_offsets.slice(0,eG-1);for(eF=eC=0,eI=eE.length;eC=ey){ex.push(eF)}}ez=[];for(eF=eB=0,eA=bq.get_timeline().events.length();0<=eA?eBeA;eF=0<=eA?++eB:--eB){ez.push(bq.get_timeline().events.valueAtIndex(eF).marquee_highlight(eH,eH+eJ,ex))}return ez},_update_marquee_x_bounds:function(T){var ez,eC,eD,eB,ey,eA,ex;eC=$(document.body).getWidth();if(Tbq.get_timeline().grid.photo_col_offsets.last()){this._marquee.x_min_boundary=bq.get_timeline().grid.photo_col_offsets.last();return this._marquee.x_max_boundary=eC}else{eA=bq.get_timeline().grid.photo_col_offsets;ex=[];for(ez=eB=0,ey=eA.length;eBT){this._marquee.x_min_boundary=bq.get_timeline().grid.photo_col_offsets[ez-1];this._marquee.x_max_boundary=eD;break}else{ex.push(void 0)}}return ex}}},_update_marquee_y_bounds:function(eD){var T,eA,ez,eC,ey,eB,ex;ez=$(document.body).getHeight();if(eDbq.get_timeline().grid.photo_row_offsets.last()){this._marquee.y_min_boundary=bq.get_timeline().grid.photo_row_offsets.last();return this._marquee.y_max_boundary=ez}else{eB=bq.get_timeline().grid.photo_row_offsets;ex=[];for(eA=eC=0,ey=eB.length;eCeD){this._marquee.y_min_boundary=bq.get_timeline().grid.photo_row_offsets[eA-1];this._marquee.y_max_boundary=T;break}else{ex.push(void 0)}}return ex}}},_build_drag_status:function(ez){var ey,T,ex;T=bq.get_timeline().get_thumb_elm_for_photo(ez);ex=T.down("img.thumb-content").cloneNode(false);$("photos-drag-status").down(".thumb").__date(ex);ey=this._drag_drop.single_photo?[this._drag_drop.single_photo]:this._selected;return $("photos-drag-status").down(".count").__date(cC.file_desc(ey,false,true))},_update_drag_status_position:function(T){return $("photos-drag-status").setStyle({left:(T.pointerX()-y.scroll_offsets().left+this.DRAG_STATUS_OFFSET)+"px",top:(T.pointerY()-y.scroll_offsets().top+this.DRAG_STATUS_OFFSET)+"px"})},_highlight_range:function(eI,eH,ey){var eG,T,ez,eD,eF,eE,ex,eB,eC,eA;if(ey==null){ey=false}this.clear_highlighted();this._events_highlighting=[];this._last_highlight_from_photo=eI;this._last_highlight_to_photo=eH;ez=bq.get_timeline().index_of_photo(eI);ex=bq.get_timeline().index_of_photo(eH);eG=!ey&&this.contains(eH)&&!this.contains(eI);eA=[];for(eD=eB=ez;ez<=ex?eB<=ex:eB>=ex;eD=ez<=ex?++eB:--eB){eE=bq.get_timeline().photo_at_index(eD);if(eE.status===F.PLACEHOLDER){if(eE.event!==eF){T=eE.event;if(!T.has_loaded_metadata()){T.on_load_all_metadata=this._highlight_range_incremental.bind(this);T.load_metadata();if(eC=T.unique_id,bl.call(this._events_highlighting,eC)<0){this._events_highlighting.push(T.unique_id)}eA.push(eF=T)}else{eA.push(void 0)}}else{eA.push(void 0)}}else{if(this.contains(eE)){if(eG){eA.push(this._dehighlight(eE))}else{eA.push(void 0)}}else{if(!eG){eA.push(this._highlight(eE))}else{eA.push(void 0)}}}}return eA},_highlight_range_incremental:function(T){var eD,ey,eE,eA,eB,ex,eC,ez;eE=this._last_highlight_from_photo;eC=this._last_highlight_to_photo;if(!((eE!=null)&&(eC!=null))){return}ey=bq.get_timeline().index_of_photo(eE);ex=bq.get_timeline().index_of_photo(eC);for(eA=ez=ey;ey<=ex?ez<=ex:ez>=ex;eA=ey<=ex?++ez:--ez){eB=bq.get_timeline().photo_at_index(eA);if(eB.status!==F.PLACEHOLDER&&!this.contains(eB)&&this._highlighted.indexOf(eB)===-1){this._highlight(eB)}}eD=this._events_highlighting.indexOf(T.unique_id);if(eD>=0){this._events_highlighting.splice(eD,1)}if(this._select_highlighted_waiting){dX.update(""+(this._select_highlighted_waiting-this._events_highlighting.length)+"/"+this._select_highlighted_waiting);if(this._events_highlighting.length===0){return this._select_highlighted()}}},_highlight_list:function(ez){var ey,eA,ex,T;this.clear_highlighted();T=[];for(eA=0,ex=ez.length;eA0){dX.show(dW("Selecting photos..."));this._select_highlighted_waiting=this._events_highlighting.length;return}eB=this._highlighted;for(eC=0,ey=eB.length;eC=0)||(bl.call(ex,"freshbutton-blue")>=0)||(bl.call(ex,"freshbutton-lightblue")>=0)||(bl.call(ex,"freshbutton-blue-on-gray")>=0)||(bl.call(ex,"timeline-elm")>=0)||(ez.up(".no-marquee")!=null)||(ez.up("#context-menu")!=null)||(ez.up(".freshdropdown-menu")!=null)||ez.nodeName==="A"||((ey=ez.tagName.toUpperCase())==="INPUT"||ey==="TEXTAREA"||ey==="SELECT")||er.shown()||((T=$("modal-progress-content"))!=null?T.visible():void 0)||ax.shown},_check_for_single_selection:function(){if(this._selected.length===1){return $("cu-view").addClassName("single-selection")}else{return $("cu-view").removeClassName("single-selection")}}};var cg,bl=[].indexOf||function(ey){for(var ex=0,T=this.length;ex
      '),_collections:[],_gid_to_collection:{},_url_to_collection:{},_collection_list_item_tmpl:null,_albums_sidebar_tmpl:null,_all_collections_loaded:false,_removed_pre_load:[],_all_albums_scroll_position:0,_num_loading_collections:0,init:function(ex,T){this._collections=ex;this._gid_to_collection=ex.dict_by("gid");this._url_to_collection=ex.dict_by("url");this._collection_list_item_tmpl=eu.tmpl("collection_list_item_tmpl");this._albums_sidebar_tmpl=eu.tmpl("albums_sidebar_tmpl");this._all_collections_loaded=false;this._sidebar_collections_loaded=false;this._num_loading_collections=0;this.refresh_album_views();return this._init_collections()},_init_collections:function(){var T;T=dZ.deconstruct_url();if(T.path!=="/photos/all_albums"){return this.load_collections(5)}},load_collections:function(T){if(this._num_loading_collections!==null&&(this._num_loading_collections=0)){eE=new W(eD,false);ex._collections.push(eE);ex._gid_to_collection[eE.gid]=eE;ex._url_to_collection[eE.url]=eE}}if(T===null||ez.length=5){ex._sidebar_collections_loaded=true}return ex.refresh_album_views()}})(this)})}},reload:function(){this._collections=[];this._gid_to_collection={};this._url_to_collection={};this._all_collections_loaded=false;this.refresh_album_views();return this._init_collections()},listen:function(){$("single-collection-title").observe("click",(function(T){return function(ex){if(!bq.get_current_collection().is_creator){return}T.header_rename();return h.log_interaction(dK.RENAME_ALBUM,cE.CLICK_TITLE)}})(this));$(document.body).on("contextmenu",".albums-list-item",this._albums_list_item_contextmenu.bind(this));$(document.body).on("click",".show-collection-target",this._show_collection_click.bind(this));$(document.body).on("click",".collection-shmodel-target",this._collection_shmodel_click.bind(this));$(document.body).on("click",".add-to-album-target",this._add_to_album_click.bind(this));$(document.body).on("mouseover",".add-to-album-drop-target",this._drop_target_mouseover.bind(this));$(document.body).on("mouseup",".add-to-album-drop-target",this._drop_target_mouseup.bind(this));$(document.body).on("mouseout",".add-to-album-drop-target",this._drop_target_mouseout.bind(this));$(document.body).on("click",".create-album-target",this._create_album_click.bind(this));document.observe(a1.HIDE_EVT,(function(){return $$(".albums-list-item.context-selected").invoke("removeClassName","context-selected")}));Event.observe(window,"scroll",this._window_scroll.bind(this));document.observe(W.CREATE_EVT,this._collection_created.bind(this));document.observe(W.ADD_EVT,this._collection_photos_added.bind(this));document.observe(W.REMOVE_EVT,this._collection_photos_removed.bind(this));document.observe(W.UNDO_REMOVE_EVT,this._collection_undid_remove.bind(this));document.observe(W.RENAME_EVT,this._collection_renamed.bind(this));document.observe(W.DELETE_EVT,this._collection_deleted.bind(this));document.observe(W.SHARE_EVT,this._collection_shared.bind(this));document.observe(W.UNSHARE_EVT,this._collection_unshared.bind(this));return document.observe(W.COVER_CHANGE_EVT,this._collection_cover_changed.bind(this))},render_all_albums_view:function(){var eA,ex,ez,T,ey;if(this._collections.length||!this._all_collections_loaded){$("albums-empty").hide()}else{$("albums-empty").show()}ex=[];ey=this._collections;for(ez=0,T=ey.length;ez0){return $("add-to-album-modal-list").__sert(this.LOADING_SPINNER)}},render_albums_sidebar:function(){var eC,eE,eA,eD,eB,ez,ex,T,ey;if(!this._sidebar_collections_loaded){return}if(!this._collections.length){$("albums-sidebar").hide();$("main-nav-bottom").show();return}$("main-nav-bottom").hide();$("albums-sidebar").show();eE=this._albums_sidebar_tmpl({collections:this._collections.slice(0,5),_:dW,Sprite:b7,PhotosCollections:cg});if((eB=$("albums-sidebar"))!=null){eB.__date(eE)}if((ez=$("all-albums-sidebar"))!=null){ez.observe("click",bq.show_all_collections)}if((ex=$("all-albums-sidebar"))!=null){ex.observe("mouseup",(function(eF){return function(eG){var eH;if(!ef._drag_drop.active){return}if(ef._drag_drop.single_photo!=null){eH=[ef._drag_drop.single_photo]}else{eH=ef.get()}eF.show_add_to_album_modal(eG,eH);return h.log_interaction(dK.ADD_TO_OTHER_ALBUM,cE.DROP_TARGET,{num_photos:ef.get().length})}})(this))}if(bq.in_all_collections_view()){return $("all-albums-sidebar").addClassName("selected")}else{if(bq.in_single_collection_view()){T=$$(".sidebar-album");ey=[];for(eA=0,eD=T.length;eAthis.NUM_PHOTOS_LONG_RUNNING_ADDS;Y.success(dW("Adding to album..."));return ey.add_photos(eA,ez,T,ex)},show_remove_photos_modal:function(ez,eB){var ey,T,eA,ex;ex=cC.categorize_files(eB),T=ex[0],eA=ex[1];if(T&&eA){ey=aR("Remove %(file_count)s item?","Remove %(file_count)s items?",eB.length)}else{if(T){ey=aR("Remove %(file_count)s photo?","Remove %(file_count)s photos?",eB.length)}else{ey=aR("Remove %(file_count)s video?","Remove %(file_count)s videos?",eB.length)}}ey=ey.format({file_count:eB.length});cT.fillVal(cC.file_desc(eB),"collection-remove-files");cT.fillVal(ez.name.escapeHTML(),"collection-remove-name");return er.show(ey,cT.fromElm("collection-remove-modal"),{action:(function(eC){return function(){var eD;eB=eB.slice(0);eD=eB.length>eC.NUM_PHOTOS_LONG_RUNNING_REMOVES;return ez.remove_photos(eB,eD)}})(this)})},header_rename:function(){if(bg("#single-collection-title-container").hasClass("editing")){return}bg("#single-collection-title-container").addClass("editing");return bq.get_current_collection().rename($("single-collection-title"))},show_delete_modal:function(ex){var T;cT.fillVal(ex.name.escapeHTML(),"collection-delete-name");T=dW("Delete album?");return er.show(T,cT.fromElm("collection-delete-modal"),{action:function(){if(ex.num_items>this.NUM_PHOTOS_LONG_RUNNING_COLLECTION_DELETES){Y.success(dW("Deleting '%(collection_name)s'...").format({collection_name:ex.name}),100)}return ex["delete"]()}})},show_unshare_modal:function(ex){var T;cT.fillVal(ex.name.escapeHTML(),"collection-unshare-name");T=dW("Unshare album?");return er.show(T,cT.fromElm("collection-unshare-modal"),{action:function(){return ex.unshare()}})},create:function(eE,eD,eI,ex){var ez,eA,ey,eB,eG,eH,eF,T,eC;if(ex==null){ex=false}if(eE){Event.extend(eE).preventDefault();eC=$(eE.target);if(eC.hasClassName("inplaceeditor-form")||(eC.up(".inplaceeditor-form")!=null)){return}if(eC.up("#context-menu")){ez=true}else{if(eC.up(".freshdropdown-menu")){ey=true}}}bq.enable_selection();if(!eI){eI=ef.get()}eB=(function(){var eL,eK,eJ;eJ=[];for(eL=0,eK=eI.length;eLthis.NUM_PHOTOS_LONG_RUNNING_ADDS;eF=(function(eJ){return function(eL){var eO,eM,eK,eN;eM=JSON.parse(eL.responseText);eO=new W(eM);ef.clear();ed.hide_all();a1.hide();er.hide();bq.disable_selection();eN=dW("Created '%(collection_name)s'");eK=eO.name.escapeHTML();eN=eN.format({collection_name:"
      "+eK+""});Y.success(new eu(eN));return eJ.flash_sidebar_album(eO.gid)}})(this);eH=function(){if(!ey){ed.hide_all()}if(!ez){a1.hide()}cg.render_albums_sidebar();return bq.disable_selection()};eA=new Ajax.InPlaceEditor(eD,"/collection_create",{htmlResponse:false,okControl:false,cancelControl:false,highlightColor:"transparent",highlightEndColor:"transparent",clickToEditText:"",cols:11,ajaxClass:Ajax.DBRequest,submitOnBlur:ex,initialText:"",cancelIfSame:true,clickToEdit:false,onCancel:eH,onFailure:function(){},savingText:dW("Creating..."),onLeaveEditMode:bq.disable_selection(),onLeaveHover:function(){},ajaxOptions:{method:"POST",onSuccess:eF,job:eG,job_user:ck.get_viewer().photos_user,progress_text:dW("Creating album...")},callback:function(eJ,eL){var eK;Y.success(dW("Creating album..."));eK={collection_name:eL,item_counters:JSON.stringify(eB)};if(bq.in_single_collection_view()){eK.source_collection_gid=bq.get_current_collection().gid}return eK}});eA.enterEditMode();if(!ex){return eA._controls.editor.observe("blur",eH)}},toggle_more_selected_actions:function(T){if(T){Event.extend(T).preventDefault()}if(!$("more-selected-actions-menu").visible()){return ed.show($("more-selected-actions-menu"),$("more-selected-actions-button"))}},toggle_more_actions:function(T){var ex;if(T){Event.extend(T).preventDefault()}if(!$("more-collection-actions-menu").visible()){if(bq.get_current_collection().share_tkey!=null){$("unshare-album").show()}else{$("unshare-album").hide()}if(bC.msie_version_at_most(10)){ex=bg("#more-collection-actions-menu");if(!ex.parent().is("body")){bg(document.body).append(ex.remove())}}return ed.show($("more-collection-actions-menu"),$("more-collection-actions-button"))}},_collection_created:function(T){var ex;ex=T.memo.collection;if(!ex.is_anonymous){this._collections.unshift(ex)}this._gid_to_collection[ex.gid]=ex;this._url_to_collection[ex.url]=ex;return this.refresh_album_views()},_collection_changed:function(T){this._collections.removeItem(T);this._collections.unshift(T);return this.refresh_album_views()},_collection_photos_added:function(eD){var eC,eA,ez,eE,eF,ey,T,ex,eG,eB;eC=eD.memo.collection;eG=eD.memo.photos;eE=eD.memo.num_items_added;ey=eD.memo.num_photos_added;ex=eD.memo.num_videos_added;if(eD.memo.promote_collection&&eE>0){this._collection_changed(eC)}else{this.refresh_album_views()}if(eG===ef.get()){ef.clear()}if(eE<1){eB=cC.categorize_files(eG),eF=eB[0],T=eB[1];if(eF&&T){ez=aR("That item is already in '%(collection_name)s'","Those items are already in '%(collection_name)s'",eG.length)}else{if(eF){ez=aR("That photo is already in '%(collection_name)s'","Those photos are already in '%(collection_name)s'",eG.length)}else{ez=aR("That video is already in '%(collection_name)s'","Those videos are already in '%(collection_name)s'",eG.length)}}}else{if(ey&&ex){ez=aR("Added item to '%(collection_name)s'","Added items to '%(collection_name)s'",eG.length)}else{if(ey){ez=aR("Added photo to '%(collection_name)s'","Added photos to '%(collection_name)s'",eG.length)}else{ez=aR("Added video to '%(collection_name)s'","Added videos to '%(collection_name)s'",eG.length)}}}eA=eC.name.escapeHTML();ez=ez.format({collection_name:""+eA+""});return Y.success(new eu(ez))},_collection_photos_removed:function(ex){var ey,ez,T;ey=ex.memo.collection;ez=ex.memo.photos;T=bq.undo_enabled?ex.memo.undo_changeset:null;bq.get_timeline().remove_photos(ez);this._collection_changed(ey);return Y.success(dW("Removed %(files_desc)s from '%(collection_name)s'").format({files_desc:cC.file_desc(ez),collection_name:ey.name}),null,null,T,(function(){return ey.undo_remove(T)}))},_collection_undid_remove:function(T){var ex;ex=T.memo.collection;bq.get_timeline().restore_removed_photos();cg.refresh_album_views([ex.gid]);return Y.success(dW("Undo complete"))},_collection_renamed:function(ex){var ey,T;ey=ex.memo.collection;if(((T=bq.get_current_collection())!=null?T.gid:void 0)===ey.gid){bg("#single-collection-title").text(bu.em_snippet(ey.name,this.HEADER_COLLECTION_SNIPPET_LENGTH,1));document.title=""+ey.name+" - Dropbox"}this._collection_changed(ey);return Y.success(dW("Renamed '%(collection_name)s'").format({collection_name:ey.name}))},_collection_deleted:function(ex){var ey,T;ey=ex.memo.collection;this._collections.removeItem(ey);if(!this._all_collections_loaded){this._removed_pre_load.push(ey.gid)}this.refresh_album_views();if(((T=bq.get_current_collection())!=null?T.gid:void 0)===ey.gid){bq.show_all_collections()}delete this._gid_to_collection[ey.gid];delete this._url_to_collection[ey.url];return Y.success(dW("Deleted '%(collection_name)s'").format({collection_name:ey.name}))},_collection_shared:function(ex){var ey,T;ey=ex.memo.collection;this._collection_changed(ey);if(((T=bq.get_current_collection())!=null?T.gid:void 0)===ey.gid){bg("#single-collection-share-status").text(dW("Shared"));return bg("#single-collection-share-status").attr("href",ey.shmodel_url)}},_collection_unshared:function(ex){var ey,T;ey=ex.memo.collection;if(((T=bq.get_current_collection())!=null?T.gid:void 0)===ey.gid){bg("#single-collection-share-status").text("")}return Y.success(dW("Unshared '%(collection_name)s'").format({collection_name:ey.name}))},_collection_cover_changed:function(T){var ey,ex;ey=T.memo.collection;this._collection_changed(ey);ex=dW("Changed cover photo for '%(collection_name)s'");ex=ex.format({collection_name:ey.name.escapeHTML()});return Y.success(ex)},_albums_list_item_contextmenu:function(ex,T){a1.show_photo_collection(ex,this.get(T.readAttribute("data-gid")),T);T.removeClassName("album-flash");return T.addClassName("context-selected")},_show_collection_click:function(ey,T){var ex;ex=$(ey.target);if(ex.hasClassName("inplaceeditor-form")||(ex.up(".inplaceeditor-form")!=null)){return}return bq.show_collection(T.readAttribute("data-gid"))},_collection_shmodel_click:function(ex,T){return this.go_to_link(this.get(T.readAttribute("data-gid")))},_add_to_album_click:function(ex,T){if(ef._context_selected){this.add_photos(this.get(T.readAttribute("data-gid")),ef._context_selected);ef._context_selected=null}else{this.add_photos(this.get(T.readAttribute("data-gid")),ef.get())}delete er.onHide;er.hide();return h.log_interaction(dK.ADD_TO_RECENT_ALBUM,cE.SAH,{num_photos:ef.get().length})},_drop_target_mouseover:function(ex,T){if(ef._drag_drop.active){T.addClassName("hovered");return $("photos-drag-status").addClassName("hovering")}},_drop_target_mouseout:function(ex,T){if(ef._drag_drop.active){T.removeClassName("hovered");return $("photos-drag-status").removeClassName("hovering")}},_drop_target_mouseup:function(ex,T){var ey;if(T.hasClassName("hovered")){T.removeClassName("hovered");$("photos-drag-status").removeClassName("hovering");if(ef._drag_drop.single_photo!=null){ey=[ef._drag_drop.single_photo]}else{ey=ef.get()}if(T.readAttribute("data-gid")!=null){this.add_photos(this.get(T.readAttribute("data-gid")),ey,false)}if(T.identify()==="add-to-album-sidebar-new"){return h.log_interaction(dK.ADD_TO_NEW_ALBUM,cE.DROP_TARGET,{num_photos:ef.get().length})}else{if(T.identify()==="all-albums-sidebar"){return h.log_interaction(dK.ADD_TO_OTHER_ALBUM,cE.DROP_TARGET,{num_photos:ef.get().length})}else{return h.log_interaction(dK.ADD_TO_RECENT_ALBUM,cE.DROP_TARGET,{num_photos:ef.get().length})}}}},_create_album_click:function(T,ex){if(ef._context_selected){this.create(T,ex.down(".collection-name"),ef._context_selected,true);return ef._context_selected=null}else{return this.create(T,ex.down(".collection-name"),ef.get(),true)}},_window_scroll:function(){if(bq.in_all_collections_view()){return this._all_albums_scroll_position=y.scroll_offsets().top}},get_all:function(){return this._collections},get_from_url:function(T){return this._url_to_collection[T]},get:function(T){return this._gid_to_collection[T]},go_to_link:function(T){return window.open(T.shmodel_url,"_blank")},restore_all_albums_scroll_position:function(){if(this._all_albums_scroll_position!=null){return window.scrollTo(0,this._all_albums_scroll_position)}else{return window.scrollTo(0,0)}},two_line_snippet:function(ey,ex){var T,eA,ez;T=bu.em_snippet(ey,ex,1);eA=T.lastIndexOf(" ");if(eA===-1){return T}else{T=T.slice(0,+eA+1||9000000000);ez=bu.em_snippet(ey.slice(eA+1),ex,1);return T+ez}},get_default_album_name:function(){var T;T=dW("Untitled album");return this.increment_collection_name_until_valid(T)},collection_name_in_use:function(ex){var eA,ez,T,ey;ey=this.get_all();for(ez=0,T=ey.length;ez0,"Invalid THUMBS_PER_ROW: "+this.THUMBS_PER_ROW);this.top_offset=ez;this.refresh_row_offsets();this.left_offset=ey;this.grid.photo_col_offsets=[];ex=[];for(eA=eC=0,eB=this.THUMBS_PER_ROW;0<=eB?eC<=eB:eC>=eB;eA=0<=eB?++eC:--eC){ex.push(this.grid.photo_col_offsets.push(this.left_offset+this.THUMB_SIZE*eA))}return ex};T.prototype.refresh_row_offsets=function(){var eE,eB,ez,eD,eA,ey,eC,ex;this.grid.photo_row_offsets=[];eE=this.top_offset;eC=this.events.getValues();for(eD=0,ey=eC.length;eDex;ez=0<=ex?++eA:--eA){eE+=this.THUMB_SIZE;this.grid.photo_row_offsets.push(eE)}}};T.prototype._render_empty_grid=function(){var ey,eB,eA,ex,ez;this.container.__date();ez=this.events.getValues();for(eA=0,ex=ez.length;eA1)){ey.add_html_elements_to(this.container)}}if(this.has_missing_timestamp_bucket()&&this.events.length()>1){eB=bg('
      ').addClass("freshbutton-silver").text(dW("Show photos with missing dates"));return bg(this.container).append(eB)}};T.prototype._render_viewport=function(eA){var ey,eJ,eB,eI,eL,eG,eF,eD,eK,ez,ex,eH,eE,eC;if(eA==null){eA=false}this.start_render_scroll_time=-1;eL=this.get_viewport_info();eJ=[];eH=this.events.getValues();for(eG=0,eK=eH.length;eG=($(document.body).getWidth()-this.TIMELINE_NAV_MOUSE_THRESHOLD)){return $("timeline-nav").addClassName("mouse-active")}else{return $("timeline-nav").removeClassName("mouse-active")}};T.prototype._timeline_elm_click=function(eA,ez){var ex,ey;ey=ez.readAttribute("data-event-id");if(ey){ex=this.events.valueFromKey(ey)}this._update_timeline_position(ex);if(ex.is_missing_timestamp_bucket()){h.log_interaction(bX.MISSING_TIMESTAMPS_VIEW);if(!this.is_missing_timestamp_bucket_shown()){this._show_missing_timestamp_bucket(false)}}return this._scroll_to_event(ex)};T.prototype._scroll_to_event=function(ez,ex){var ey;if(ex==null){ex=false}ey=ez.top_offset-this.top_offset;if(ez&&(y.scroll_offsets().top!==ey)){if(ex){return bg("html, body").animate({scrollTop:ey},200)}else{this._skip_scroll_update=true;return window.scrollTo(y.scroll_offsets().left,ey)}}};T.prototype._window_scroll=function(){var eA,ez,eD,eC,ey,eB,ex;ez=bF.time();a6.clear_all_pending_batches();if(this.start_render_scroll_time===-1||ez-this.start_render_scroll_timeeH){break}eD=ex}}if((eD==null)||eD===this.current_event){return}$$(".timeline-elm.current").invoke("removeClassName","current");ez=$$(".timeline-elm");for(eA=0,ey=ez.length;eAeI){eA=eI;eH=eJ.removed_photos_and_indexes[0].photo}}this.event_remove_info=[];this.init_timeline_nav();if(eH!=null){this.scroll_to_photo_with_key(eH.uniqueness_key)}this.refresh_row_offsets();this._load_visible_photos();return $(document).fire(T.PHOTOS_ADDED_EVT,this)};T.prototype.get_photos=function(){var ey,eB,eA,ex,ez;eB=[];ez=this.events.getValues();for(eA=0,ex=ez.length;eAez){return eA.photos[ez-ex]}else{ex+=eA.photos.length}}return null};T.prototype.get_thumb_elm_for_photo=function(ex){return $(ex.uniqueness_key)};T.prototype.get_photo_for_thumb_elm=function(ex){if(!ex.hasClassName("cu-thumb")){ex=ex.up(".cu-thumb")}if(ex){return this.key_to_photo[ex.identify()]}else{return null}};T.prototype.get_viewport_info=function(){var ex,ey;if(this.scroll_container!=null){ey=this.scroll_container.scrollTop;ex=this.scroll_container.getHeight()}else{ey=y.scroll_offsets().top;ex=y.viewport_dimensions().height}return{top:ey,height:ex,bottom:ey+ex}};T.prototype.scroll_to_photo_with_key=function(ey){var eC,ez,ex,eB,eA;y.scroll_unlock_document();eC=$(ey);if(eC!=null?eC.visible():void 0){du.scroll_to_thumb(eC)}else{ex=this.key_to_photo[ey];ez=ex.event;if(ex.event!=null){eB=Math.floor(ez.photos.indexOf(ex)/this.THUMBS_PER_ROW);eA=this.get_viewport_info().height;y.scroll_to(0,ez.top_offset+this.HEADER_HEIGHT+eB*this.THUMB_SIZE-eA/2)}}return this._load_visible_photos()};T.prototype.restore_scroll_position=function(){y.scroll_unlock_document();if(this.last_scroll_position!=null){window.scrollTo(0,this.last_scroll_position)}else{window.scrollTo(0,0)}if(Prototype.Browser.IE&&Prototype.Browser.IEV<9){return this._load_visible_photos()}};T.prototype.visible_thumbs_loaded=function(){var ey,eA,ex,ez;ez=this.events.getValues();for(eA=0,ex=ez.length;eA0};T.prototype._show_missing_timestamp_bucket=function(ex,eA){var ez,ey;if(ex==null){ex=true}if(eA==null){eA=false}if(!(this.has_missing_timestamp_bucket()&&!this.is_missing_timestamp_bucket_shown())){return}ey=this.events.getValues();ez=ey[ey.length-1];bg("#show-missing-timestamps-button").hide();ez.add_html_elements_to(this.container);if(!eA){if(this.opts.uses_timeline_nav){$("timeline-nav").addClassName("mouse-active")}this._scroll_to_event(ez,ex);this._render_viewport()}return this.init_timeline_nav()};return T})();var cF;cF=A.PhotoEvent=(function(){T.EVENT_MISCOUNT_EVT="db:photoevent:miscount";T.PHOTOS_LOADED_EVT="db:photoevent:photos_loaded";T.prototype.MONTH_PREFIX="m_";T.prototype.COLLECTION_PREFIX="c_";T.prototype.EVENT_PREFIX="e_";T.prototype.MISSING_TIMESTAMP_PREFIX="a_";T.prototype.NUM_LIGHTBOX_PHOTOS_TO_PRELOAD=5;T.prototype.MAX_PHOTOS_PER_METADATA_REQUEST=500;T.timeline;T.unique_id;T.name;T.init_num_photos;T.photos;T.header_html;T.placeholder_html;T.top_offset;T.loading_metadata;T.cursor;T.num_photos_loaded;T.prototype.LOADING_ORDER_NOT_DECIDED=-1;T.prototype.LOADING_ORDER_TOP_DOWN=0;T.prototype.LOADING_ORDER_BOTTOM_UP=1;T.loading_order;T.num_photos_to_load;T.on_load_all_metadata;T.init_sel_items;T.scroll_to_first_sel;T.num_to_select;T.logged_thumbs_arrived;T.timing_metadata_received;T.timing_stopped_scrolling_on_event;T.scroll_count;function T(eF,eC,ey,eD,ex,eB){var eA,eG,ez,eE;this.timeline=eF;this.unique_id=eC;this.name=ey;this.init_num_photos=eD;this.photos=(function(){var eI,eH;eH=[];for(eA=eI=0;0<=eD?eIeD;eA=0<=eD?++eI:--eI){eH.push(new F(this))}return eH}).call(this);this.init_sel_items={};for(ez=0,eE=ex.length;ez"+eD+"")}ey=this.get_content_height();ez=this.photos.length%this.timeline.THUMBS_PER_ROW;eB=ez===0?0:(this.timeline.THUMBS_PER_ROW-ez)*this.timeline.THUMB_SIZE;return this.placeholder_html=new eu('
      \n
      \n
      \n
      \n
      ')};T.prototype.add_html_elements_to=function(ey){var ex;if(this.is_event()){ex=new Element("div",{"class":"photo-event"});ex.__sert(this.header_html);ex.__sert(this.placeholder_html);return ey.__sert(ex)}else{ey.__sert(this.header_html);return ey.__sert(this.placeholder_html)}};T.prototype.remove=function(){$("h-"+this.unique_id).hide();$("p-"+this.unique_id).hide();return this.timeline.events.remove(this.unique_id)};T.prototype.restore=function(){$("h-"+this.unique_id).show();return $("p-"+this.unique_id).show()};T.prototype.add_to_timeline_nav=function(eE){var ex,eC,eF,ey,eG,eB,eA,eD,ez;if(eE==null){eE=false}if(!(this.is_month()||this.is_event()||this.is_missing_timestamp_bucket())){return}ez=this.timeline.get_viewport_info().height;eG=this.timeline.TIMELINE_NAV_ELM_HEIGHT;eB=$(document.body).getHeight();eA=this.top_offset/eB*100;if(this.is_event()){ey=this.name}else{if(this.is_missing_timestamp_bucket()){ey=dW("Missing dates")}else{ey=bF.month_abbr_with_year(this.get_month()-1,this.get_year())}}eF=false;for(eD in this.timeline.grid.side_nav){ex=Math.abs(this.timeline.events.valueFromKey(eD).top_offset-this.top_offset);if(ex/eB*ez");eC.addClass("timeline-elm");eC.attr({"data-event-id":this.unique_id.toString(),id:"timeline-nav-"+this.unique_id});eC.css("top",""+eA+"%");eC.text(ey);bg("#timeline-nav").append(eC)}return this.timeline.grid.side_nav[this.unique_id]=eA}else{if(eC.length){return eC.remove()}}};T.prototype.marquee_highlight=function(ex,eE,eB){var ez,eF,ey,eG,eI,eA,eD,eC,eH;if(this.top_offset>eE||this.top_offset+this.get_height()this.top_offset+this.get_height()){ex-=this.top_offset;eI=Math.ceil(this.photos.length/this.timeline.THUMBS_PER_ROW);if(ex=eI;eG=eA<=eI?++eD:--eD){for(eC=0,eH=eB.length;eC=F.LOADED){ey.status=F.LOADED;this.num_photos_loaded++;this.num_photos_to_load=Math.max(this.num_photos_to_load,this.num_photos_loaded)}}return this._num_photos_changed()};T.prototype.remove_photos=function(eF){var eC,ex,eB,eD,ey,ez,eE,eA;eC=this.timeline.events.indexOfKey(this.unique_id);ey=[];for(ez=0,eE=eF.length;ez-1,"Photo not found in the photos array!");this.photos.splice(eB,1);if(ex.status>=F.LOADED){this.num_photos_loaded--;if((eA=$(ex.uniqueness_key))!=null){eA.remove()}ex.status=F.LOADED}ef._remove(ex);ey.push({photo:ex,index:eB})}this._num_photos_changed();eD={removed_photos_and_indexes:ey};if(this.photos.length===0){eD.removed_event_index=eC}return eD};T.prototype._num_photos_changed=function(){if(this.photos.length===0){return this.remove()}else{return this._update_placeholder_container()}};T.prototype.update_placeholders=function(){if($("p-"+this.unique_id)!=null){this._update_placeholder_container();$("p-top-"+this.unique_id).setStyle({height:""+(this.get_content_height())+"px"});return $("p-bottom-"+this.unique_id).setStyle({height:"0px"})}else{return this._generate_container_html()}};T.prototype._update_placeholder_container=function(){var ey,ex;$("p-"+this.unique_id).setStyle({height:""+(this.get_content_height())+"px"});ex=this.photos.length%this.timeline.THUMBS_PER_ROW;ey=ex!==0?(this.timeline.THUMBS_PER_ROW-ex)*this.timeline.THUMB_SIZE:0;return $("p-cover-"+this.unique_id).setStyle({width:""+ey+"px"})};T.prototype.load_metadata=function(eE){var ez,ey,eD,ex,eB,eC,eA;ex=0;if((!this._is_valid_photo_index(eE))||(this.num_to_select>0)){if(this.loading_order===this.LOADING_ORDER_NOT_DECIDED){this.loading_order=this.LOADING_ORDER_TOP_DOWN}ex=this.photos.length}else{if(this.loading_order===this.LOADING_ORDER_NOT_DECIDED){this.loading_order=eE*2<=this.photos.length?this.LOADING_ORDER_TOP_DOWN:this.LOADING_ORDER_BOTTOM_UP}ex=this._is_loading_from_bottom()?this.photos.length-eE:eE+1}this.num_photos_to_load=Math.max(this.num_photos_to_load,ex);if(this.has_loaded_metadata()||(this.num_photos_loaded>=this.num_photos_to_load)){return}if(this.loading_metadata){return}if(this.load_cached_metadata()){return}this.loading_metadata=true;eB={show_hidden:bq.show_hidden};if(this.cursor!=null){eB.cursor=this.cursor}if(this._is_loading_from_bottom()){eB.chron_order=true}eB.limit=Math.max(this.num_photos_to_load-this.num_photos_loaded,0);if(eB.limit>this.MAX_PHOTOS_PER_METADATA_REQUEST){eB.limit=this.MAX_PHOTOS_PER_METADATA_REQUEST}if(this.is_event()){eC=this.unique_id.split("_");ez=eC[2];ey=eC[1];eB.filters=JSON.stringify({date_begin:ez,date_end:ey},{event_id:this.unique_id})}else{if(this.is_missing_timestamp_bucket()){eB.filters=JSON.stringify({other:true})}else{if(this.is_month()){eA=this.get_year();eD=this.get_month();ez=du.to_iso8601_date(new Date(eA,eD-1,1,0,0,0,0),false,true);ey=du.to_iso8601_date(new Date(eA,eD,1,0,0,0),false,true);eB.filters=JSON.stringify({date_begin:ez,date_end:ey},{year:eA,month:eD})}else{if(this.is_collection()){eB.filters=JSON.stringify({collection_gid:this.get_collection_gid()})}else{cj(false,"invalid photo event id: "+this.unique_id)}}}}return new Ajax.DBRequest("/photos_event_metadata",{parameters:eB,allow_retries:true,onSuccess:(function(eF){return function(eG){var eH;eH=JSON.parse(eG.responseText);eF.timing_metadata_received=bF.time();eF.cursor=eH.cursor;return eF._load_metadata_callback(eH.photos,eH.key_to_duplicates,(eH.more!=null)&&eH.more)}})(this)})};T.prototype.load_metadata_range=function(ey,ex){if(!(this._is_valid_photo_index(ey)&&this._is_valid_photo_index(ex))){this.load_metadata();return}if(this.loading_order===this.LOADING_ORDER_NOT_DECIDED){this.loading_order=ey*2<=this.photos.length?this.LOADING_ORDER_TOP_DOWN:this.LOADING_ORDER_BOTTOM_UP}if(this._is_loading_from_bottom()){return this.load_metadata(ey)}else{return this.load_metadata(ex)}};T.prototype.load_cached_metadata=function(){var ex,ey;if(this.loading_metadata||this._is_loading_from_bottom()||this.num_photos_loaded>0||(((ey=bq.event_metadata_cache)!=null?ey[this.unique_id]:void 0)==null)){return false}ex=bq.event_metadata_cache[this.unique_id];this.cursor=ex.cursor;this._load_metadata_callback(ex.photos,ex.key_to_duplicates,ex.more);return true};T.prototype._load_metadata_callback=function(eJ,eC,eD){var eI,eE,eO,eF,eP,ez,eG,eM,eB,eK,eA,eH,ey,ex,eL,eN;eF=[];eB=[];eH=false;for(eI=ey=0,eL=eJ.length;eythis.num_photos_loaded){eM=this._is_loading_from_bottom()?this.photos.length-this.num_photos_to_load:this.num_photos_to_load-1;return this.load_metadata(eM)}};T.prototype._fix_photo_miscount=function(){var ez,ey,ex;ez=Math.ceil(this.init_num_photos/this.timeline.THUMBS_PER_ROW);ey=this.get_num_rows()-ez;if(typeof h!=="undefined"&&h!==null){h.log("event_miscount",null,null,null,{event_id:this.unique_id,false_count:this.init_num_photos,true_count:this.photos.length,count_delta:this.photos.length-this.init_num_photos})}ex=y.scroll_offsets().top;if(this.top_offset+this.get_height()=eC;ex=eD<=eC?++eB:--eB){ey=this.photos[ex];if((ey==null)||!(ey.status>=F.RENDERED)){return false}}return true};T.prototype._is_loaded=function(ex){var ey,ez;if(this._is_loading_from_bottom()){ez=this.photos.length-this.num_photos_loaded;ey=this.photos.length-1}else{ez=0;ey=this.num_photos_loaded-1}return(ez<=ex&&ex<=ey)};T.prototype._is_loading_from_bottom=function(){return this.loading_order===this.LOADING_ORDER_BOTTOM_UP};T.prototype._is_valid_photo_index=function(ex){return(ex!=null)&&(ex>=0)&&(ex<=this.photos.length-1)};T.prototype.update_photo_divs=function(){var ez,ey,eO,eN,eS,eV,eP,eK,eE,eW,eM,eT,eI,eF,eC,eA,eX,eY,ex,eU,eL,eJ,eH,eD,eB,eG,eR,eQ;if(!this.num_photos_loaded){return}eT=this.timeline.get_viewport_info();if(this.hide_photos_if_not_in_current_viewport(eT)){return}eU=this.get_photo_range_to_render(eT),eO=eU[0],eN=eU[1];cj((eO!=null)&&(eN!=null),"This line is after @hide_photos_if_not_in_ current_viewport, so first_photo_to_render and last_photo_to_render shouldn't be null.");if(!this.has_loaded_metadata()&&((!this._is_loaded(eO))||(!this._is_loaded(eN)))){this.load_metadata_range(eO,eN);if(this._is_loading_from_bottom()){eO=Math.max(eO,this.photos.length-this.num_photos_loaded)}else{eN=Math.min(eN,this.num_photos_loaded-1)}if(eO>eN){return}}eV=Math.floor(eO/this.timeline.THUMBS_PER_ROW);eM=eV*this.timeline.THUMB_SIZE;$("p-top-"+this.unique_id).setStyle({height:eM+"px"});eS=Math.floor((this.photos.length-1)/this.timeline.THUMBS_PER_ROW)-Math.floor(eN/this.timeline.THUMBS_PER_ROW);ey=eS*this.timeline.THUMB_SIZE;$("p-bottom-"+this.unique_id).setStyle({height:ey+"px"});this._hide_photos((function(){eG=[];for(var eZ=0;0<=eO?eZeO;0<=eO?eZ++:eZ--){eG.push(eZ)}return eG}).apply(this));this._hide_photos((function(){eR=[];for(var eZ=eL=eN+1,e0=this.photos.length;eL<=e0?eZe0;eL<=e0?eZ++:eZ--){eR.push(eZ)}return eR}).apply(this));this._show_photos((function(){eQ=[];for(var eZ=eO;eO<=eN?eZ<=eN:eZ>=eN;eO<=eN?eZ++:eZ--){eQ.push(eZ)}return eQ}).apply(this));eH=ef.get();for(eA=0,eX=eH.length;eA=F.RENDERED){eW=$(eK.uniqueness_key);if((eW!=null?eW.down("img"):void 0)!=null){ez.push(eW.down("img"))}}}eP=function(eZ){return eZ.up(".cu-thumb").addClassName("thumb-loaded")};return a6.batch_load_thumbs(ez,this.timeline.THUMBS_BATCH_SIZE,eP,this.log_thumb_load.bind(this))};T.prototype._hide_photos=function(eB){var ez,eA,ey,ex;ex=[];for(eA=0,ey=eB.length;eA=0;eA=eC<=0?++eD:--eD){eE=this.photos[eA];if((eE!=null)&&eE.status>=F.RENDERED){eB=$(eE.uniqueness_key);cj(eB!=null,"photo "+eA+" was marked as rendered, but its thumb elm doesn't exist");ey=eB;break}}}return[ey,ez.thumb_html]}};T.prototype.in_y_range=function(ey,ex){return !(this.top_offset+this.timeline.HEADER_HEIGHT>ex||this.top_offset+this.get_height()ex;ey=eB<=ex?++eC:--eC){this._hide_photo(ey)}}else{for(ey=ez=0,eD=this.num_photos_loaded;0<=eD?ezeD;ey=0<=eD?++ez:--ez){this._hide_photo(ey)}}$("p-top-"+this.unique_id).setStyle({height:this.get_content_height()+"px"});$("p-bottom-"+this.unique_id).setStyle({height:"0px"});return true}return false};T.prototype._blur_range=function(eA,ex,eC){var ez,ey,eB;if(eC==null){eC=this.timeline.get_viewport_info()}eB=cZ.get();if(eB>=0){ey=this.timeline.VIEWPORT_SCALE_OTHER_DIRECTION;ez=this.timeline.VIEWPORT_SCALE_SCROLL_DIRECTION}else{if(eB<0){ey=this.timeline.VIEWPORT_SCALE_SCROLL_DIRECTION;ez=this.timeline.VIEWPORT_SCALE_OTHER_DIRECTION}}eA-=ey*eC.height;ex+=ez*eC.height;return[eA,ex]};T.prototype.get_photo_range_to_render=function(eF,ez){var eD,ey,eC,eE,eB,ex,eA;if(ez==null){ez=true}ex=eF.top;eB=eF.bottom;if(ez){eA=this._blur_range(ex,eB,eF),ex=eA[0],eB=eA[1]}if(!this.in_y_range(ex,eB)){return[null,null]}eE=Math.floor((ex-this.top_offset-this.timeline.HEADER_HEIGHT)/this.timeline.THUMB_SIZE);eD=Math.floor((eB-this.top_offset-this.timeline.HEADER_HEIGHT)/this.timeline.THUMB_SIZE);ey=Math.min(this.photos.length-1,eE*this.timeline.THUMBS_PER_ROW);eC=Math.min(this.photos.length-1,(eD+1)*this.timeline.THUMBS_PER_ROW-1);cj(!isNaN(eC),"Last photo to render should not be NaN. "+("viewport_data.bottom="+eF.bottom+" ")+("viewport_data.height="+eF.height+" ")+("photos.length="+this.photos.length+" ")+("top_offset="+this.top_offset+" ")+("bottom_row_to_render="+eD+" "),true,["photo_event_nan_limit"]);return[Math.max(0,ey),eC]};T.prototype.get_photo_range_to_render_with_blur=function(eA){var ey,eD,ez,eC,eB,ex;eB=this.get_photo_range_to_render(eA,true),eD=eB[0],eC=eB[1];ex=this.get_photo_range_to_render(eA,false),ey=ex[0],ez=ex[1];return[eD,ey,ez,eC]};T.prototype.get_thumb_indexes_to_load=function(eK){var eR,eH,eF,eE,eO,eQ,eN,eP,eL,eB,ez,ey,ex,eM,eD,eC,eA,eJ,eI,eG;eM=this.get_photo_range_to_render_with_blur(eK),eH=eM[0],eR=eM[1],eF=eM[2],eE=eM[3];if(eR==null){eO=(function(){eA=[];for(var eS=eH;eH<=eE?eS<=eE:eS>=eE;eH<=eE?eS++:eS--){eA.push(eS)}return eA}).apply(this);if(this.top_offset>eK.bottom){return eO}else{return eO.reverse()}}eP=(function(){eJ=[];for(var eS=eR;eR<=eF?eS<=eF:eS>=eF;eR<=eF?eS++:eS--){eJ.push(eS)}return eJ}).apply(this);eQ=[];eN=[];if(eH=eH;eD<=eH?eS++:eS--){eI.push(eS)}return eI}).apply(this)}if(eE>eF){eN=(function(){eG=[];for(var eS=eC=eF+1;eC<=eE?eS<=eE:eS>=eE;eC<=eE?eS++:eS--){eG.push(eS)}return eG}).apply(this)}eL=cZ.get();if(eL>=0){return eP.concat(eN).concat(eQ)}else{return eP.concat(eQ).concat(eN)}};T.prototype.log_thumb_load=function(ey,ez){var eB,ex,eA;if(!this.timeline.opts.log_thumb_loading){return}if(this.scroll_count===bq.scroll_count&&!this.logged_thumbs_arrived){if((ey+1)%this.timeline.THUMBS_PER_ROW===0||ey+1===ez){if(this.visible_thumbs_loaded()){ex=this.timeline.get_viewport_info();eB=this.timeline.events.indexOfKey(this.unique_id)===(this.timeline.events.length()-1);if((this.top_offset0){this.fontSize=parseFloat(eG);this.fontSizeType=eL}}this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;if(this.options.scaleMode==="box"){this.dims={height:this.element.offsetHeight,width:this.element.offsetWidth}}if(/^content/.test(this.options.scaleMode)){this.dims={height:this.element.scrollHeight,width:this.element.scrollWidth}}if(!this.dims){this.dims={height:this.options.scaleMode.originalHeight,width:this.options.scaleMode.originalWidth}}this.full_height=this.dims.height;this.full_width=this.dims.width;eK=["border%sWidth","margin%s","padding%s"];for(ey=0,eW=eK.length;ey2)){ey=Math.round(ey)}eC.push(ey)}if(this._supports_alpha){return this.element.setStyle({backgroundColor:"rgba("+(eC.join(", "))+")"})}else{return this.element.setStyle({backgroundColor:"rgb("+(eC.slice(0,3).join(", "))+")"})}}});dD=function(ey){var ez,eC,eB,eA,T,ex,eD,eF,eE;ex=/^rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)$/;T=/^rgba\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3}), ?(\d+?\.?\d*)\)$/;eA=/^#([0-9A-F])([0-9A-F])([0-9A-F])$/i;eC=/^#([0-9A-F])([0-9A-F])([0-9A-F])([0-9A-F])$/i;eB=/^#([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/i;ez=/^#([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])([0-9A-F][0-9A-F])$/i;if(eF=ey.match(ex)){eE=(function(){var eJ,eH,eI,eG;eI=eF.slice(1);eG=[];for(eJ=0,eH=eI.length;eJ1){eE[eD-1]=eE[eD-1]/255}}return eE};var aq;aq=A.ClientDownload=(function(){function T(){}T.prototype.show_download_modal=function(){return new Ajax.DBRequest("/download_modal_view",{onSuccess:function(ex){var ey;ey=bg(" input").prop("checked",true)}})(this),contents:bg("#twofactor-delivery-choice"),onSubmit:(function(eH){return function(eI,eJ,eK){eI.vars.sms=!!(bg("#use-sms")[0].getValue()==="on");if(!eI.vars.sms){return eH.fetch_offline_key(eI,eJ)}else{return eJ.next()}}})(this)};eB={name:"enter_phone_number",enter:(function(eH){return function(eJ){var eK,eI;eH.hide_error();eH._is_offline_setup=false;eH._phone_number=null;eK=$("twofactor-enter-phone");eI=eH.fill_phone_number_for_edit(eK,bg("#twofactor-row-"+eH._user.role+" #twofactor-sms-number").text());return eI.focus()}})(this),contents:bg("#twofactor-enter-phone"),onSubmit:this.submit_phone_number.bind(this)};eD={name:"offline_setup",enter:(function(eH){return function(eI){eH.hide_error();eH._is_offline_setup=true;return eH._phone_number=null}})(this),contents:bg("#twofactor-offline-setup")};ey={name:"confirm_phone",enter:(function(eH){return function(eI){var eJ;eH._invalid_code_count=0;if(eH._is_offline_setup){$("twofactor-enable-confirm").addClassName("offline")}else{eJ=eI.vars.phone_number;cj(eJ,"expected a display_phone argument");$("phone-number-placeholder").__date(eJ);$("twofactor-enable-confirm").removeClassName("offline")}eH.hide_error();$("phone-code").clear().focus();return eH.fill_delivery_choice(eJ)}})(this),onSubmit:this.submit_phone_code.bind(this),contents:bg("#twofactor-enable-confirm")};eG={name:"backup_phone",enter:this.enter_backup_phone_number_shown.bind(this,"back_next"),onSubmit:this.submit_backup_phone_number.bind(this,false,"save_none"),contents:bg("#twofactor-enter-backup-phone")};eA=new e(this.DEFAULT_ENABLE_TITLE,this.LOCK_ICON,[{name:"enable_start",enter:this.hide_error.bind(this),contents:bg("#twofactor-start")},{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.ENABLE_CONFIRM_HREF,(function(eH){return function(eI,eJ){eH.successfully_enabled=false;eI.vars.mode="ENABLE";eI.vars.passed_password=true;return eJ.next()}})(this)),contents:bg("#twofactor-enter-password")},eE,eB,eD,ey,eG,{name:"recovery_code",enter:(function(eH){return function(){eH.fill_backup_phone(eH._backup_phone);return eH.hide_error.bind(eH)}})(this),onSubmit:this.submit_finish.bind(this),contents:bg("#twofactor-recovery")},{name:"congrats_done",enter:this.after_enabled.bind(this),title:dW("Congrats! You've enabled two-step verification!"),contents:bg("#twofactor-done")}],{enable_start:function(){return"password"},password:function(){return"delivery_choice"},delivery_choice:((function(eH){return function(eI){if(eI.vars.sms){return"enter_phone_number"}else{return"offline_setup"}}})(this)),enter_phone_number:function(){return"confirm_phone"},confirm_phone:function(){return"backup_phone"},backup_phone:function(){return"recovery_code"},recovery_code:function(){return"congrats_done"},congrats_done:function(){return"__exit__"},offline_setup:function(){return"confirm_phone"}},{enable_start:function(){return null},password:function(){return null},delivery_choice:function(){return null},enter_phone_number:function(){return"delivery_choice"},offline_setup:function(){return"delivery_choice"},confirm_phone:function(eH){if(eH.vars.sms){return"enter_phone_number"}else{return"offline_setup"}},backup_phone:function(){return"delivery_choice"},recovery_code:function(){return"backup_phone"},congrats_done:function(){return null}},"enable_start",function(){return this.vars.passed_password=false});eA.addExitListener((function(eH){return function(eI){if(eA.vars.passed_password&&eI&&!eH.successfully_enabled){return Y.error(dW("Two-step verification is not enabled"))}}})(this));ez=new e(this.DEFAULT_EDIT_TITLE,this.LOCK_ICON,[{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.EDIT_CONFIRM_HREF,(function(eH){return function(eJ,eK){var eI;eH.successfully_enabled=false;bg(".delivery-choice").removeClass("selected");eI=!bg("#twofactor-row").hasClass("with-sms");bg(eI?"#app-choice":"#sms-choice").addClass("selected");bg("#twofactor-recovery").addClass("edit-mode");eJ.vars.passed_password=true;return eK.next()}})(this)),contents:bg("#twofactor-enter-password")},eE,eB,eD,ey,{name:"backup_phone",enter:this.enter_backup_phone_number_shown.bind(this,"back_save"),onSubmit:this.submit_backup_phone_number.bind(this,false,"save_everything"),contents:bg("#twofactor-enter-backup-phone")}],{password:function(){return"delivery_choice"},delivery_choice:((function(eH){return function(eI){if(eI.vars.sms){return"enter_phone_number"}else{return"offline_setup"}}})(this)),enter_phone_number:function(){return"confirm_phone"},confirm_phone:function(){return"backup_phone"},backup_phone:function(){return"__exit__"},offline_setup:function(){return"confirm_phone"}},{password:function(){return null},delivery_choice:function(){return null},enter_phone_number:function(){return"delivery_choice"},offline_setup:function(){return"delivery_choice"},confirm_phone:function(eH){if(eH.vars.sms){return"enter_phone_number"}else{return"offline_setup"}},backup_phone:function(){return"delivery_choice"}},"password",function(){return this.vars.passed_password=false});ez.addExitListener((function(eH){return function(eI){if(ez.vars.passed_password&&eI&&!eH.successfully_enabled){return Y.error(dW("Two-step verification has not been changed"))}}})(this));T=new e(this.DEFAULT_DISABLE_TITLE,this.LOCK_ICON,[{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.DISABLE_CONFIRM_HREF,(function(eH){return function(eI,eJ){eH.successfully_disabled=false;eI.vars.passed_password=true;return eJ.next()}})(this)),contents:bg("#twofactor-enter-password")},{name:"disable",enter:this.hide_error.bind(this),contents:bg("#twofactor-disable"),onSubmit:this.disable_submit.bind(this)}],{password:function(){return"disable"},disable:function(){return"__exit__"}},{password:function(){return null},disable:function(){return"__cancel__"}},"password",function(){return this.vars.passed_password=false});T.addExitListener((function(eH){return function(eI){if(T.vars.passed_password&&eI&&!eH.successfully_disabled){return Y.error(dW("Two-step verification is still enabled"))}}})(this));eC=new e(this.ADD_BACKUP_TITLE,this.LOCK_ICON,[{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.EDIT_CONFIRM_HREF,(function(eH){return function(eI,eJ){return eJ.next()}})(this)),contents:bg("#twofactor-enter-password")},{name:"backup_phone",enter:this.enter_backup_phone_number_shown.bind(this,"cancel_save"),onSubmit:this.submit_backup_phone_number.bind(this,true,"save_backup_phone"),contents:bg("#twofactor-enter-backup-phone")}],{password:function(){return"backup_phone"},backup_phone:function(){return"__exit__"}},{password:function(){return null},backup_phone:function(){return"__cancel__"}},"password");ex=new e(this.EDIT_BACKUP_TITLE,this.LOCK_ICON,[{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.EDIT_CONFIRM_HREF,(function(eH){return function(eI,eJ){return eJ.next()}})(this)),contents:bg("#twofactor-enter-password")},{name:"backup_phone",enter:this.enter_backup_phone_number_shown.bind(this,"cancel_save"),onSubmit:this.submit_backup_phone_number.bind(this,false,"save_backup_phone"),contents:bg("#twofactor-enter-backup-phone")}],{password:function(){return"backup_phone"},backup_phone:function(){return"__exit__"}},{password:function(){return null},backup_phone:function(){return"__cancel__"}},"password");eF=new e(this.EDIT_RECOVERY_TITLE,this.LOCK_ICON,[{name:"password",enter:this.enter_password_shown.bind(this),onSubmit:this.submit_password.bind(this,this.EDIT_CONFIRM_HREF,(function(eH){return function(eI,eJ){return new Ajax.DBRequest(eH.RECOVERY_CODE_HREF,{parameters:{checkpoint_token:eH._checkpoint_token},onSuccess:function(eK){var eL;eL=eK.responseText.strip();if(eL.startsWith("OK:")){eH.fill_recovery_code(eL.substr(3),"backup-code-div-edit");return eJ.next()}else{switch(eL){case"EXPIRED":return eH.show_error_expired();case"ALREADY_DISABLED":bg("#twofactor-row").removeClass("twofactor-enabled");Y.success(dW("Two-step verification is already disabled. Did you maybe disable it in another window?"));return er.hide()}}},onFailure:eH.show_error500.bind(eH),cleanUp:eH.hide_loading.bind(eH),subject_user:eH._user})}})(this)),contents:bg("#twofactor-enter-password")},{name:"recovery_code",enter:this.hide_error.bind(this),contents:bg("#twofactor-recovery-edit"),onSubmit:(function(eH){return function(eI,eJ){eH._checkpoint_token=null;return eJ.next()}})(this)}],{password:function(){return"recovery_code"},recovery_code:function(){return"__exit__"}},{password:function(){return null},recovery_code:function(){return null}},"password");bg(".enable-twofactor").on("click",(function(eH){return function(eI){return eH.start_flow(eI,eA)}})(this));bg(".disable-twofactor").on("click",(function(eH){return function(eI){return eH.start_flow(eI,T)}})(this));bg(".add-twofactor-backup-link").on("click",(function(eH){return function(eI){return eH.start_flow(eI,eC)}})(this));bg(".edit-twofactor-backup").on("click",(function(eH){return function(eI){return eH.start_flow(eI,ex)}})(this));bg(".edit-twofactor-recovery").on("click",(function(eH){return function(eI){return eH.start_flow(eI,eF)}})(this));bg(".edit-twofactor-sms, .edit-twofactor-offline").on("click",(function(eH){return function(eI){return eH.start_flow(eI,ez)}})(this));bg("#generate-new-recovery-code").on("click",(function(eH){return function(eI){eH.show_loading();return new Ajax.DBRequest(eH.NEW_RECOVERY_CODE_HREF,{parameters:{checkpoint_token:eH._checkpoint_token},onSuccess:function(eJ){var eK;eK=eJ.responseText.strip();if(eK.startsWith("OK:")){return eH.fill_recovery_code(eK.substr(3),"backup-code-div-edit")}else{switch(eK){case"EXPIRED":eF.to_state("password");return eH.show_error_expired();case"ALREADY_DISABLED":$("twofactor-row").removeClassName("twofactor-enabled");Y.success(dW("Two-step verification is disabled. Did you maybe disable it in another window?"));return er.hide()}}},onFailure:eH.show_error500.bind(eH),cleanUp:eH.hide_loading.bind(eH),subject_user:eH._user})}})(this));bg("#twofactor-enter-backup-phone #country-code").on("change",this.reset_phone_field.bind(this));bg("#resend-link").on("click",this.enable_resend_phone_code.bind(this));bg("#twofactor-delivery-choice input").change(function(){bg(".delivery-choice").removeClass("selected");return bg(this).parents(".delivery-choice").addClass("selected")});bg("#show-qr").on("click",(function(eH){return function(eI){bg("#twofactor-offline-setup").addClass("showing-qr");return false}})(this));bg("#hide-qr").on("click",(function(eH){return function(eI){bg("#twofactor-offline-setup").removeClass("showing-qr");return false}})(this));if(window.location.hash==="#backup2fa"&&bg("#twofactor-row").hasClass("allow-autopop")){return this.start_flow(eC)}},start_flow:function(ey,ex){var T;ey.preventDefault();T=bg(ey.target).data("uid");ce.set_user(ck.get_viewer().get_user_by_id(T));this._current_flow=ex;ex.start();return false},connect_login_init:function(){this._container_selector="#twofactor-form";this._error_selector="#twofactor-form .error";return bg("#resend-link").on("click",this.connect_resend_phone_code.bind(this))},resend_phone_code:function(ex){var T;if(this.is_resending()){return}this.show_resending();T="/twofactor_resend";if(bg("#twofactor-confirm").hasClass("backup")){T=C.parse(T).updateQuery({backup:true}).toString()}new Ajax.DBRequest(T,{onSuccess:(function(ey){return function(ez){switch(ez.responseText.strip()){case"OK":ey.hide_error();return ey.notify_resent();case"UNREACHABLE":return ey.show_error_unreachable(true);case"BADCARRIER":return ey.show_error_bad_carrier();case"INVALIDNUMBER":return ey.show_error_invalid_number();case"NOTAMOBILE":return ey.show_error_not_a_mobile();case"RATELIMIT":return Y.error(dW("You've asked for too many SMS messages. Please try again in a few minutes."));case"EXPIRED":return $("twofactor-confirm").submit()}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_resending_with_delay.bind(this)});return false},connect_resend_phone_code:function(T){if(this.is_resending()){return}this.show_resending();new Ajax.DBRequest("/twofactor_resend",{onSuccess:(function(ex){return function(ey){switch(ey.responseText.strip()){case"OK":ex.hide_error();return ex.notify_resent();case"UNREACHABLE":return Y.error(error_unreachable(true));case"BADCARRIER":return Y.error(error_bad_carrier());case"INVALIDNUMBER":return ex.show_error_invalid_number();case"NOTAMOBILE":return Y.error(error_not_a_mobile());case"RATELIMIT":return Y.error(dW("You've asked for too many SMS messages. Please try again in a few minutes."));case"EXPIRED":return $("twofactor-form").submit()}}})(this),onFailure:(function(ex){return function(ey){return Y.error(ex.error500())}})(this),cleanUp:this.hide_resending_with_delay.bind(this)});return false},enable_resend_phone_code:function(T){if(this.is_resending()){return}this.show_resending();new Ajax.DBRequest("/twofactor_resend",{onSuccess:(function(ex){return function(ey){switch(ey.responseText.strip()){case"OK":ex.hide_error();return ex.notify_resent();case"UNREACHABLE":return ex.show_error_unreachable();case"BADCARRIER":return ex.show_error_bad_carrier();case"INVALIDNUMBER":return ex.show_error_invalid_number();case"NOTAMOBILE":return ex.show_error_not_a_mobile();case"RATELIMIT":return Y.error("You've asked for too many SMS messages. Please try again in a few minutes.");case"EXPIRED":ex._current_flow.to_state("password");return ex.show_error_expired()}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_resending_with_delay.bind(this)});return false},DEFAULT_ENABLE_TITLE:dW("Enable two-step verification"),DEFAULT_EDIT_TITLE:dW("Edit two-step verification"),DEFAULT_DISABLE_TITLE:dW("Disable two-step verification"),ADD_BACKUP_TITLE:dW("Add a backup phone number"),EDIT_BACKUP_TITLE:dW("Edit backup phone number"),EDIT_RECOVERY_TITLE:dW("View recovery code"),LOCK_ICON:"lock32",ENABLE_CONFIRM_HREF:"/account/twofactor/confirm_password",DISABLE_CONFIRM_HREF:"/account/twofactor/disable_confirm_password",EDIT_CONFIRM_HREF:"/account/twofactor/edit_confirm_password",RECOVERY_CODE_HREF:"/account/twofactor/get_rescue_code",NEW_RECOVERY_CODE_HREF:"/account/twofactor/new_rescue_code",enter_password_shown:function(){var T;this.hide_error();bg("#twofactor-recovery").removeClass("edit-mode");T=$("twofactor-enter-password");bg("#password",T).val("").focus();return false},submit_password:function(ey,eB,T,ez,eA){var ex;ex=$("password").getValue();if(!ex){this.show_error(dW("Please enter your password"));return}this.show_loading();return new Ajax.DBRequest(ey,{parameters:{password:ex},onSuccess:(function(eC){return function(eD){var eE;eE=eD.responseText.strip();if(eE.startsWith("OK:")){eC._checkpoint_token=eE.substr(3);return eB(T,ez)}else{switch(eE){case"EXPIRED_PASSWORD":return eC.show_error_expired_password();case"INVALID":return eC.show_error(dW("Invalid password"));case"RATELIMIT":return eC.show_error(dW("Too many incorrect passwords. Please try again in a few minutes."));case"ALREADY_ENABLED":$("twofactor-row").addClassName("twofactor-enabled");Y.success(dW("Two-step verification is already enabled. Did you maybe enable it in another window?"));return er.hide();case"ALREADY_DISABLED":$("twofactor-row").removeClassName("twofactor-enabled");Y.success(dW("Two-step verification is already disabled. Did you maybe disable it in another window?"));return er.hide()}}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},fetch_offline_key:function(T,ex){this.show_loading();return new Ajax.DBRequest("/account/twofactor/add_phone",{parameters:{checkpoint_token:this._checkpoint_token,offline:true},onSuccess:(function(ey){return function(ez){var eA;eA=ez.responseText.strip();if(eA.startsWith("OK:")){ey.fill_key(eA.substr(3));return ex.next()}else{switch(eA){case"EXPIRED":T.to_state("password");return ey.show_error_expired()}}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},fill_key:function(ex){var T,ez,ey;ex=ex.replace(new RegExp("=+$"),"");T=ex.toLowerCase().replace(/(.{4})/g,"$1 ");$("secret-div").__date(T);$("qr-div").__date();ey=Constants.IS_PROD?"Dropbox":"DropboxDev";ez={text:"otpauth://totp/"+ey+":"+this._user.email+"?secret="+ex+"&issuer="+ey,width:200,height:200};if(!Modernizr.canvas){ez.render="table"}bg("#qr-div").qrcode(ez);if(!Modernizr.canvas){return bg("#qr-div > table").css("margin","0 auto")}},submit_phone_number:function(ex,ez,eA){var T,ey;T=bg("#twofactor-enter-phone .twofactor-phone-number");if(!T.controller().validate_on_submit()){return}ey=T.val();this.show_loading();return new Ajax.DBRequest("/account/twofactor/add_phone",{parameters:{checkpoint_token:this._checkpoint_token,phone_number:ey},onSuccess:(function(eB){return function(eC){switch(eC.responseText.strip()){case"OK":eB._phone_number=ey;ex.vars.phone_number=ey;return ez.next();case"EXPIRED":ex.to_state("password");return eB.show_error_expired();case"UNREACHABLE":return eB.show_error_unreachable(T);case"BADCARRIER":return eB.show_error_bad_carrier(T);case"INVALIDNUMBER":return eB.show_error_invalid_number(T);case"NOTAMOBILE":return eB.show_error_not_a_mobile(T);case"RATELIMIT":return eB.show_error(dW("You've added too many phone numbers. Please try again in a few minutes."))}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},submit_phone_code:function(T,ex,ez){var ey;ey=$("phone-code").getValue().strip();if(!ey){this.show_error(dW("Please enter the security code"));return}if(ey.search(/^\d{6}$/)===-1){this.show_error(dW("Invalid security code"));return}this.show_loading();return new Ajax.DBRequest("/account/twofactor/confirm_phone",{parameters:{checkpoint_token:this._checkpoint_token,twofactor_code:ey},onSuccess:(function(eA){return function(eB){var eD,eC;eC=eB.responseText.strip();if(eC.startsWith("OK:")){eA.fill_recovery_code(eC.substr(3),"backup-code-div");return ex.next()}else{switch(eC){case"INVALID":eA._invalid_code_count+=1;eD=eA._invalid_code_count<=2?dW("Invalid code"):eA._is_offline_setup?dW("Invalid code. Check the clock on your phone: it must be accurate to the minute."):dW("Invalid code");return eA.show_error(eD);case"EXPIRED":T.to_state("password");return eA.show_error_expired();case"RATELIMIT":return eA.show_error(dW("Too many invalid codes. Try again in a few minutes."))}}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},enter_backup_phone_number_shown:function(ez,ex){var ey,T;this.hide_error();ey=$("twofactor-enter-backup-phone");T=this.fill_phone_number_for_edit(ey,bg("#twofactor-row-"+this._user.role+" #twofactor-backup-number").text());T.focus();if(ez==="back_next"){bg("#twofactor-backup-back-next").show();bg("#twofactor-backup-cancel-save").hide();return bg("#twofactor-backup-back-save").hide()}else{if(ez==="cancel_save"){bg("#twofactor-backup-back-next").hide();bg("#twofactor-backup-cancel-save").show();return bg("#twofactor-backup-back-save").hide()}else{if(ez==="back_save"){bg("#twofactor-backup-back-next").hide();bg("#twofactor-backup-cancel-save").hide();return bg("#twofactor-backup-back-save").show()}}}},submit_backup_phone_number:function(eA,ez,ex,eB,eC){var T,ey;T=bg("#twofactor-enter-backup-phone .twofactor-backup-phone-number");if(!T.controller().validate_on_blur()){return}ey=T.val();if(ey){if(this.is_primary_number(ey)){T.controller().show_error(dW("You can't use your primary phone as your backup",T));return}}else{if(eA){T.controller().show_error(dW("Please enter phone number",T));return}}this._backup_phone=ey;if(ez==="save_backup_phone"){this.save_added_backup_phone(ex,eA,ey)}else{if(ez==="save_everything"){this.submit_finish(ex,eB,eC)}else{if(ez==="save_none"){return eB.next()}}}},is_same_phone_number:function(ex,T){if(!ex||!T){return false}return ex.replace(/\D+/g,"")===T.replace(/\D+/g,"")},is_primary_number:function(T){var ex;ex=bg("#twofactor-row-"+this._user.role);if(this._is_offline_setup){return false}if(this.is_same_phone_number(T,ex.data("primary_phone"))){return true}if(this.is_same_phone_number(T,bg("#twofactor-sms-number",ex).text())){return true}return false},save_added_backup_phone:function(T,ey,ex){this.show_loading();return new Ajax.DBRequest("/account/twofactor/set_backup_phone",{parameters:{checkpoint_token:this._checkpoint_token,backup_phone_number:ex},onSuccess:(function(ez){return function(eA){var eB;switch(eA.responseText.strip()){case"OK":ez.hide_error();eB="#twofactor-row-"+ez._user.role;bg(""+eB+" #twofactor-backup-number").text(ex);bg(eB).toggleClass("with-backup",!!ex);du.syncHeight();if(!ex){Y.success(dW("Backup phone number removed"))}else{if(!ey){Y.success(dW("Backup phone number updated"))}else{Y.success(dW("Backup phone number added"))}}return er.hide();case"EXPIRED":T.to_state("password");return ez.show_error_expired()}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},fill_phone_number_for_edit:function(ez,eB){var eA,ex,ey,T;ex=bg(".sick-input > input",ez);if(!eB){return ex.val("")}T=bg('select[name="country_code"]',ez);eA=/^\+\d+/.exec(eB);eA=eA?eA[0]:"";ey=this.option_for_country_code(T,eA);if(ey!=null){ey.selected=true}ex.val(bg.trim(eB.slice(eA.length)));if(ex.length){ex[0].select()}return ex},option_for_country_code:function(T,ey){var ex;if(ey){ex=bg('option[value="'+ey+'"]',T);if(ex.length>1){ex=ex.filter("[selected]")}if(ex.length){return ex[0]}}return bg("option[selected]",T)[0]},fill_delivery_choice:function(T){bg("#twofactor-delivery-phone-label,#confirm-phone-primary").toggle(!!T);bg("#twofactor-delivery-offline-label").toggle(!T);bg("#confirm-phone-primary-number").text(T);return bg("#twofactor-row-"+this._user.role).data("primary_phone",T)},fill_backup_phone:function(T){bg("#confirm-phone-backup").toggle(!!T);return bg("#confirm-phone-backup-number").text(T)},fill_recovery_code:function(ex,T){ex=ex.toLowerCase().replace(/(.{4})/g,"$1 ");return $(T).__date(ex)},submit_finish:function(T,ex,ey){var ez;this.show_loading();ez={checkpoint_token:this._checkpoint_token};if(this._backup_phone){ez.backup_phone_number=this._backup_phone}return new Ajax.DBRequest("/account/twofactor/enable_finish",{parameters:ez,onSuccess:(function(eA){return function(eB){switch(eB.responseText.strip()){case"OK":eA.successfully_enabled=true;if(T.vars.mode!=="ENABLE"){return eA.after_enabled(T,ex)}else{return ex.next()}break;case"EXPIRED":T.to_state("password");return eA.show_error_expired()}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},after_enabled:function(ex,ey){var T;this._checkpoint_token=null;this.hide_error();T=bg("#twofactor-row-"+this._user.role);T.toggleClass("with-sms",!!this._phone_number);bg("#twofactor-sms-number",T).text(this._phone_number||"");T.toggleClass("with-backup",!!this._backup_phone);bg("#twofactor-backup-number",T).text(this._backup_phone||"");T.addClass("twofactor-enabled");du.syncHeight();if(ex.vars.mode!=="ENABLE"){Y.success(dW("Two-step verification updated"));return ey!=null?ey.next():void 0}},disable_submit:function(T,ex){this.show_loading();return new Ajax.DBRequest("/account/twofactor/disable",{parameters:{checkpoint_token:this._checkpoint_token},onSuccess:(function(ey){return function(eA){var ez;switch(eA.responseText.strip()){case"OK":ey.successfully_disabled=true;ey._checkpoint_token=null;ez=bg("#twofactor-row-"+ey._user.role);ez.removeClass("twofactor-enabled with-sms with-backup");bg("#twofactor-sms-number, #twofactor-backup-number",ez).text("");du.syncHeight();Y.success(dW("Two-step verification is now disabled."));return ex.next();case"EXPIRED":T.to_state("password");return ey.show_error_expired()}}})(this),onFailure:this.show_error500.bind(this),cleanUp:this.hide_loading.bind(this),subject_user:this._user})},show_error:function(ey,T){var ex;if(T){T.controller().show_error(ey);return}ex=$$(this._error_selector);if(ey===this.error_expired_password()||ey===this.error_unreachable(true)){ex.invoke("update",ey)}else{ex.invoke("__date",ey)}return ex.invoke("show")},show_error500:function(){return this.show_error(this.error_500())},show_error_bad_carrier:function(T){return this.show_error(this.error_bad_carrier(),T)},show_error_invalid_number:function(T){return this.show_error(this.error_invalid_number(),T)},show_error_not_a_mobile:function(T){return this.show_error(this.error_not_a_mobile(),T)},show_error_unreachable:function(T,ex){if(ex==null){ex=false}return this.show_error(this.error_unreachable(ex),T)},show_error_expired:function(T){return this.show_error(this.error_expired(),T)},show_error_expired_password:function(T){return this.show_error(this.error_expired_password(),T)},error_500:function(){return dW("Sorry, an error occurred. Please try again later.")},error_bad_carrier:function(){return dW("Unfortunately, your carrier is not supported at this time.")},error_invalid_number:function(){return dW("That is not a valid phone number.")},error_not_a_mobile:function(){return dW("That phone number does not appear to be a valid mobile number.")},error_unreachable:function(T){if(T==null){T=false}if(T){return dW('We couldn\'t reach your phone number. If this has happened before click here.')}else{return dW("We couldn't reach your phone number. Are you sure it's correct?")}},error_expired:function(){return dW("Since it's been a while, please enter your password again.")},error_expired_password:function(){return dW('Your password has expired. Please create a new password here.')},hide_error:function(){return $$(this._error_selector).invoke("__date")},show_loading:function(){this.hide_error();return $$(this._container_selector).invoke("addClassName","loading")},hide_loading:function(){return $$(this._container_selector).invoke("removeClassName","loading")},is_resending:function(){return $$(this._container_selector)[0].hasClassName("resending")},show_resending:function(){return $$(this._container_selector).invoke("addClassName","resending")},hide_resending:function(){return $$(this._container_selector).invoke("removeClassName","resending")},hide_resending_with_delay:function(){return setTimeout(this.hide_resending.bind(this),3000)},notify_resent:function(){return Y.success(dW("We sent you another code. It may take a few minutes to arrive."))},reset_phone_field:function(ex){var T,ey;T=ex.element();ey=bg(".sick-input",T.form);bg("input",ey).val("").focus();return this.fill_example_phone_number(T,ey)},fill_example_phone_number:function(T,ez){var ey,ex;if(typeof phone_helpers!=="undefined"&&phone_helpers!==null){ey=bg(T).val().substr(1);ex=phone_helpers.get_example_mobile_number(ey);return bg("label",ez).text(dW("Example: ")+ex)}},reset_phone_field_and_backup_country:function(ex){var T;this.reset_phone_field(ex);if(bg("#backup-phone-number").val()===""){T=bg("#twofactor-enter-backup-phone #country-code");T.val(ex.element().getValue());return this.fill_example_phone_number(T,bg(".sick-input",T[0].form))}}};var bL;bL=A.PseudoLocalStorage={_store:{},getItem:function(T){return this._store[T]},setItem:function(T,ex){return this._store[T]=ex},removeItem:function(T){return delete this._store[T]},clear:function(){return this._store={}}};var bv;bv=A.FileViewRamsCommon={RAMS_FULLSCREEN_TRANSITION_TIME_MSEC:1000,enter_rams_fullscreen:function(T){T.addClass("rams-fullscreen").data("rams-fullscreen",true);return bg(window).resize()},exit_rams_fullscreen:function(T){T.removeClass("rams-fullscreen").removeData("rams-fullscreen");return bg(window).resize()},is_rams_fullscreen_active:function(ex){var T;T=ex.data("rams-fullscreen");return(T!=null)&&T}};var l;l=__PARENT_SCOPE__.FileViewer=INLINE_JS.FileViewer=A.FileViewer={KEY_SCOPE:"fileviewer",_MODAL_FILEINFO:0,_MODAL_PREVIEW:1,file:null,has_preview:false,preview_locked:false,preview_lock_listener:null,modal_type:this._MODAL_FILEINFO,is_loaded:false,has_key_listener:false,history_length:null,preview_status_timeout_obj:null,preview_status_request:null,_non_fullscreen_vert_overflow:null,hiding:false,active_user:null,in_browse:true,globalPreviewStateModel:new Backbone.Model({state:"closed",file_obj:null}),globalOpenWithWebButtonStateModel:new Backbone.Model({state:"hidden",file_extension:null}),_get_extension:function(ex){var T;T=ex.lastIndexOf(".");return(T===-1?"":ex.substr(T+1))},show:function(ex,T,ey){this.file=ex;this.active_user=T;this.in_browse=ey;if(this.shown()){this.prev_scope=key.getScope();key.setScope(this.KEY_SCOPE);return}this._start_time=Date.now();this.history_length=window.history.length;if(this.file.preview_type==="download"){return window.location.href=this.file.href}else{document.title=this.file.filename;this._render_viewer();return bg("#file-viewer").show().trigger("db:filepreview:open",[this.file])}},shown:function(){return bg("#file-viewer").css("display")!=="none"},set_preview_url:function(ex,T,ez){var eB,eA,ey;eB=C.parse(dZ.get_url());eA=eB.getPath();ey=eB.removeQuery("select").updateQuery({preview:ex.filename}).getQuery();return dZ.push_state(C.encode_parts(eA),ey)},unset_preview_url:function(){var ey,ex,T;ey=C.parse(dZ.get_url());if(ey.getPath().match(/^\/s[h]?\/.+/)||!this.in_browse){return}if(!("preview" in ey.getQuery())){return}ex=ey.getPath();T=ey.removeQuery("select").removeQuery("preview").getQuery();return dZ.push_state(C.encode_parts(ex),T)},render_file_failed:function(){this._hide();this.file=this.last_file;this.file.doc_preview_status=Constants.DOC_PREVIEW_UNAVAILABLE_BAD_FILE;this._render_viewer();bg("#file-viewer").show();return bg("#file-viewer").trigger("preview_failed")},_log_view:function(T,ex){var ey;ey={mode:"file-preview",file_ext:an.file_extension_for_logging(this.file.filename),preview_type:this.file.preview_type,preview_status:this.file.doc_preview_status,time_taken:T,file_bytes:this.file.bytes,is_team:this.active_user.is_team===1,paid:this.active_user.paid===1,in_progress:ex,ns_id:this.file.ns_id,sjid:this.file.sjid,user_id:this.active_user.id};return aQ.UserActivityLogger.log("web","file_view",ey)},_render_viewer:function(){var eC,ex,eF,eG,ez,eI,T,eH,eE,eJ,ey,eA,eD,eB;y.scroll_lock_document();ex=bg("#file-viewer");eC=ex.find(".download-button");eG=C.parse(this.file.href).updateQuery({dl:1}).toString();eD=(function(eK){return function(eR){var eN,eP,eM,eO,eQ,eL;if(eR==null){eR=true}eM=bu.em_snippet(eK.file.filename,35);eN=ex.find(".title-bar .filename");eQ={"class":"icon",alt:eK.file.caption};eO=b7.html("web",eK.file.icon,eQ).toHTML();eP=bg("",{"class":"filename-text"}).text(eM);eN.html(eO).append(eP);ex.addClass("has-preview");if(eK.file.htmlified_link){}else{if(eK.file.preview_type==="excel"){ex.addClass("html-preview");ex.find(".loading").css("z-index","-1")}else{ex.addClass(""+eK.file.preview_type+"-preview")}}if(eR){ex.find(".loading").show()}eC.on("click",function(eS){eS.preventDefault();return window.location.href=eG});if(eK.file.tkey===void 0&&l.active_user.is_email_verified){eL=function(eS){this.file.tkey=eS.tkey;return this._update_title_bar_buttons()};cc.WebRequest({url:"/sm/get_token",type:"POST",data:{path:eK.file.fq_path},dataType:"json",subject_user:eK.active_user.id,success:eL.bind(eK)})}else{eK._update_title_bar_buttons()}eK.modal_type=eK._MODAL_PREVIEW;eK._first_render_completed=false;return eK._listen()}})(this);eI=(function(eK){return function(){ex.removeClass();ex.find(".loading").hide();return eK._unlisten()}})(this);eA=(function(eK){return function(eL,eQ,eO,eN,eM){var eP;if(eL==null){eL=false}if(eQ==null){eQ=true}if(eO==null){eO=false}if(eN==null){eN=false}if(eM==null){eM=true}eK._log_view(Date.now()-eK._start_time,eN);eP=eK._get_extension(eK.file.filename);if(eP==="doc"||eP==="docx"||eP==="ppt"||eP==="pptx"||eP==="xls"||eP==="xlsx"||eP==="pdf"){eK.globalPreviewStateModel.set({state:"open",file_obj:eK.file})}if(!eL){eD(eQ);eK._update_title_bar_buttons()}eK._render_preview(eO,eM);return eK._initial_resize()}})(this);ey=(function(eK){return function(eL){var eM;if(eL==null){eL=false}eK.globalPreviewStateModel.set({state:"closed",file_obj:null});eM=bu.em_snippet(eK.file.filename,20);ex.find(".title-bar .filename").text(eM);ex.addClass("no-preview");ex.find(".file-thumbnail img").attr({src:"/static/images/icons128/"+(an.file_icon(eK.file.filename))+".png"});ex.find(".file-type").text(eM);ex.find(".file-size").text(eK.file.size);ex.find(".file-modified").text(eK.file.ago||"");eC.on("click",function(){return bC.redirect(eG)});eK.modal_type=eK._MODAL_FILEINFO;eK._listen();eK._log_view(Date.now()-eK._start_time,eL);eK._update_title_bar_buttons();return eK._initial_resize()}})(this);ez=this._get_extension(this.file.fq_path);eJ=(this.file.preview_type==="doc"||this.file.preview_type==="excel"||this.file.preview_type==="keynote"||this.file.preview_type==="adobecs")&&(this.file.bytes=5000){eI();return ey(true)}return eK.preview_status_request=bg.ajax(eE,{success:function(eM){if(eK.file){return eK.file.doc_preview_status=parseInt(eM,10)}},complete:function(eM,eN){if(eN==="abort"){return}if(eK.file.doc_preview_status===Constants.DOC_PREVIEW_AVAILABLE){eK.has_preview=true;return eA(true,false,true,true)}else{if(eK.file.doc_preview_status===Constants.DOC_PREVIEW_IN_PROGRESS){return eK.preview_status_timeout_obj=setTimeout(eF,1000)}else{eI();return ey(true)}}},timeout:5000-(eL-eB),subject_user:eK.active_user})}})(this))()},_remove_loading:function(T){if(T==null){T=true}bg("#file-viewer .loading").hide();return this.is_loaded=T},_update_title_bar_buttons:function(){var ey,ex,eC,eK,eB,eO,eD,eE,eA,ez,T,eI,eM,eN,eJ,eL,eP,eG,eH,eF;eB=bg("#file-viewer");ey=eB.find(".download-button");ex=eB.find(".split-button.openwith");eK=ex!=null?ex.find(".main-button"):void 0;eC=ex!=null?ex.find(".more-button"):void 0;eO=dW("Open",{comment:"Open a file natively on the user's computer"});eH=function(){return eB.data("is-unity-allowed")==="True"&&(__CONDITIONAL_JS__.UnityFeatures!=null)};eG=(function(eQ){return function(eS){var eT,eR;return eB.data("is-openwith-allowed")==="True"&&((eT=__CONDITIONAL_JS__.OpenWith)!=null?eT.get_open_handler_for(eS,eQ.active_user):void 0)&&eS.bytes<((eR=__CONDITIONAL_JS__.OpenWith)!=null?eR.MAX_SUPPORTED_FILE_SIZE_B:void 0)}})(this);eM=(function(eQ){return function(){return __CONDITIONAL_JS__.UnityFeatures.open_file(eQ.file.ns_id,eQ.file.ns_path,eQ.file.user_id,__CONDITIONAL_JS__.UnityFeatures.standard_open_file_handler)}})(this);eN=(function(eQ){return function(){var eR,eS;eR=__CONDITIONAL_JS__.OpenWith.get_open_handler_for(eQ.file,eQ.active_user);if(eR){if((eS=__CONDITIONAL_JS__.OpenWithMicrosoftLogger)!=null){eS.log_open_button_pressed(eQ.active_user,an.file_extension(eQ.file.filename).toLowerCase(),eQ.file.ns_id,eQ.file.ns_path)}return bC.redirect(eR.uri)}}})(this);eP=(function(eQ){return function(eS,eR,eW){var eT,eU,eV;if(!eS&&!eR){eJ(false)}else{if(eS&&eR){ez(eO,eQ.file,eM,eN)}else{if(eS){eA(eO,eN)}else{eA(eO,eM)}}}if(!eS&&!eR){eU=false}else{if(eR){eU=false}else{eU=true}}if(!eU&&!eW){eQ._hide_more_button()}else{eQ._show_more_button(eW,eU)}eT=function(eX,eZ,e0,eY){if(eQ._open_button_update_state_timeout){clearTimeout(eQ._open_button_update_state_timeout)}return eQ._open_button_update_state_timeout=setTimeout((function(){eQ.globalOpenWithWebButtonStateModel.set({user_id:eX,state:eZ,file_extension:e0,target_button:eY});return eQ._open_button_update_state_timeout=null}),200)};if(eS){eV=an.file_extension(eQ.file.filename).toLowerCase();if(eR){return eT(eQ.active_user.id,"visible",eV,eC)}else{return eT(eQ.active_user.id,"visible",eV,eK)}}else{return eT(null,"hidden",null,null)}}})(this);eJ=function(eQ){if(ex!=null){ex.toggleClass("shown",eQ)}return ey.toggle(!eQ)};eA=function(eQ,eR){if((ex==null)&&(eK==null)){return}eJ(true);ex.removeClass("split");eK.text(eQ);return eK.off("click").on("click",eR)};ez=(function(eQ){return function(eW,eR,eV,eU){var eT,eS;if((ex==null)&&(eK==null)&&(eC==null)){return}eJ(true);ex.addClass("split");eK.text(eW);eT=eB.find(".openwith-dropdown");eK.off("click").on("click",function(eX){return eV(eX)});eC.off("click").on("click",function(eY){var eX;eX=bg(this).parent().siblings(".openwith-dropdown");if(eX.is(":visible")){return}ed.show(eX,this,null,true);return eY.stopPropagation()});eT.find(".openwith-desktop-link").off("click").on("click",function(eX){eX.preventDefault();return eV(eX)});eS=__CONDITIONAL_JS__.OpenWith.get_open_handler_for(eR,eQ.active_user);eT.each(function(){return b7.src(bg(this).find(".openwith-link .sprite")[0],"web",eS.icon)});eT.find(".openwith-link .sprite-text-inner").text(eS.name);eT.find(".openwith-link").off("click").on("click",function(eX){eX.preventDefault();return eU(eX)});return bg("#file-viewer-container").off("click",ed.hide_all).on("click",ed.hide_all)}})(this);eL=!!eH();eD=!!eG(this.file);eE=!!this.file.tkey;eP(eD,false,eE);if(eL){T=(function(eQ){return function(){return eP(eD,true,eE)}})(this);if((eF=__CONDITIONAL_JS__.UnityCheckFileCache)!=null?eF.get(this.file.ns_id,this.file.ns_path):void 0){return T()}else{eI=(function(eQ){return function(eR){if(eR){return T()}}})(this);return __CONDITIONAL_JS__.UnityFeatures.check_file(this.file.ns_id,this.file.ns_path,this.file.user_id,eI)}}},_show_more_button:function(eC,ex){var eA,eB,ey,ez,T;T=bg("#file-viewer");eA=T.find(".more-options-button");eA.show();ey=T.find(".more-options-dropdown");eA.on("click",(function(eD){return function(eE){if(ey.is(":visible")){return}ed.show(ey,eA,null,true);return eE.stopPropagation()}})(this));bg("#file-viewer-container").on("click",ed.hide_all);ez=ey.find(".remove-link");ez.off("click");if(eC){ez.show();ez.on("click",(function(eD){return function(eE){ed.hide_all();return ad.confirm_remove(eD.file.filename,eD.file.tkey,0,0,0,eD.file.user_id)}})(this))}else{ez.hide()}eB=ey.find(".download-button");return eB.toggle(ex)},_hide_more_button:function(){var ex,T;T=bg("#file-viewer");ex=T.find(".more-options-button");ex.off("click").hide();bg("#file-viewer-container").off("click",ed.hide_all);return T.find(".remove-link").off("click")},_initial_resize:function(){var T;if(this.is_loaded){return}T=function(){return bg("window").trigger("resize")};return setTimeout(T,0)},_get_progressive_url:function(eA,ez){var eB,T,ey,ex;ex=this.active_user;eA=eA.substring(0,3).replace("rtf","doc").replace("pps","ppt");ey=C.parse(ez);T=false;if((eA==="doc"&&ex.progressive_previews_doc)||(eA==="key")||(eA==="keynote")||(eA==="adobecs")){if(!(Constants.PDF_PREVIEW_MODE==="pdf-js")){ey=ey.updateQuery({post_message_on_failure:1})}}else{if(eA==="ppt"&&ex.progressive_previews_ppt){eB="private_progressive_viewer";T=true}else{if(eA==="xls"&&ex.progressive_previews_xls){if(ex.xls_edit){eB="xls/edit"}else{eB="xls/preview"}}}}if(eB){if(T){ey.setAuthority(Constants.WEBSERVER)}else{ey.setAuthority(ey.getAuthority().replace("dl-web","dl-doc"))}ey.setPath(ey.getPath().replace("/get/","/"+eB+"/"))}ey=ey.updateQuery({get_preview:1});return ey},_get_pdf_js_url:function(T){var ex;if(Constants.PDF_PREVIEW_MODE==="pdf-js"){ex=T.toString();T=C.parse(Constants.static_url_pdfjs_viewer);T.setQuery({file:ex})}return T},_preview_is_progressive:function(ex){var T;ex=ex.substring(0,3).replace("rtf","doc").replace("pps","ppt");T=this.active_user;return(ex==="doc"&&T.progressive_previews_doc)||(ex==="ppt"&&T.progressive_previews_ppt)||(ex==="xls"&&T.progressive_previews_xls)||(ex==="key"||ex==="keynote")},_preview_progressive_try:function(T){if(!this._preview_is_progressive(T)){return false}if(this.file.doc_preview_status===Constants.DOC_PREVIEW_IN_PROGRESS){return true}T=T.substring(0,3).replace("rtf","doc").replace("pps","ppt");return this.file.doc_preview_status===Constants.DOC_PREVIEW_UNAVAILABLE_FAILED&&(((T==="ppt")&&this.active_user.progressive_previews_ppt_try_failed)||((T==="doc")&&this.active_user.progressive_previews_doc_try_failed)||((T==="xls")&&this.active_user.progressive_previews_xls_try_failed))||(T==="key")||(T==="keynote")},_set_previews_sandbox_params:function(ex,T){ex=ex.substring(0,3).replace("rtf","doc").replace("pps","ppt");if(ex!=="xls"){return""}else{return null}},_render_preview:function(ey,T){var eB,ez,eA,eD,ex,eC;if(ey==null){ey=false}if(T==null){T=true}if(ey){this._remove_loading(false)}eD=bg("#file-viewer .preview-content-container");if(this.file.htmlified_link){eA=bg("