From 1f09e7ad23f1f3982f44e9b2c9a1e6d08da7f825 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Sat, 28 Jul 2012 09:57:16 -0600 Subject: [PATCH 1/3] Modify Javascript to improve page loading times 1. Add template category 'end' that places content right before final tag 2. Move most Javascript from tpl files into one cacheable file, theme.js 3. Load scripts at end of the HTML document instead of in the header 4. Minify several Javascript files Note that the second and third things were only done for Frost and Frost Mobile. Doing it for every theme means going through every .tpl for every theme and rearranging the Javascript, which is tedious. --- boot.php | 7 + include/conversation.php | 18 +- index.php | 6 + js/acl.min.js | 1 + js/ajaxupload.min.js | 6 + js/country.min.js | 11 + js/fk.autocomplete.min.js | 5 + js/jquery.htmlstream.min.js | 6 + js/main.min.js | 1 + js/webtoolkit.base64.min.js | 6 + library/jquery_ac/friendica.complete.min.js | 10 + mod/contacts.php | 30 +- mod/editpost.php | 10 +- mod/events.php | 3 + mod/message.php | 43 +- mod/photos.php | 46 +- mod/profile_photo.php | 1 + mod/profiles.php | 7 +- mod/settings.php | 33 +- mod/wallmessage.php | 59 +- view/admin_aside.tpl | 2 +- view/contact_end.tpl | 0 view/contacts-end.tpl | 0 view/contacts-head.tpl | 17 + view/cropend.tpl | 0 view/end.tpl | 0 view/event_end.tpl | 0 view/jot-end.tpl | 0 view/message-end.tpl | 0 view/message-head.tpl | 17 + view/msg-end.tpl | 0 view/photo_edit_head.tpl | 11 + view/photos_head.tpl | 26 + view/photos_upload.tpl | 4 +- view/profed_end.tpl | 0 view/profed_head.tpl | 2 + view/settings-end.tpl | 0 view/settings-head.tpl | 25 + view/settings_display_end.tpl | 0 view/theme/frost-mobile/TODO | 6 + view/theme/frost-mobile/acl_selector.tpl | 22 + view/theme/frost-mobile/admin_aside.tpl | 11 - view/theme/frost-mobile/admin_site.tpl | 37 +- view/theme/frost-mobile/comment_item.tpl | 4 +- view/theme/frost-mobile/contact_edit.tpl | 88 ++ view/theme/frost-mobile/contact_head.tpl | 30 - view/theme/frost-mobile/contacts-end.tpl | 4 + view/theme/frost-mobile/contacts-head.tpl | 5 + view/theme/frost-mobile/cropbody.tpl | 27 + view/theme/frost-mobile/cropend.tpl | 4 + view/theme/frost-mobile/crophead.tpl | 1 + view/theme/frost-mobile/default.php | 1 + view/theme/frost-mobile/end.tpl | 19 + view/theme/frost-mobile/event_end.tpl | 4 + view/theme/frost-mobile/event_head.tpl | 135 +-- view/theme/frost-mobile/field_checkbox.tpl | 6 + view/theme/frost-mobile/field_themeselect.tpl | 9 + view/theme/frost-mobile/head.tpl | 86 +- view/theme/frost-mobile/jot-end.tpl | 5 + view/theme/frost-mobile/jot-header.tpl | 219 +--- view/theme/frost-mobile/jot.tpl | 2 +- view/theme/frost-mobile/js/acl.js | 78 +- view/theme/frost-mobile/js/acl.min.js | 1 + .../frost-mobile/js/fk.autocomplete.min.js | 5 + view/theme/frost-mobile/js/main.js | 332 +++--- view/theme/frost-mobile/js/main.min.js | 1 + view/theme/frost-mobile/js/theme.js | 657 ++++++++++- view/theme/frost-mobile/js/theme.js.old | 121 -- view/theme/frost-mobile/js/theme.min.js | 1 + view/theme/frost-mobile/login.tpl | 2 +- view/theme/frost-mobile/message-end.tpl | 4 + view/theme/frost-mobile/message-head.tpl | 0 view/theme/frost-mobile/msg-header.tpl | 98 +- view/theme/frost-mobile/oembed_video.tpl | 4 + view/theme/frost-mobile/photo_edit_head.tpl | 7 + view/theme/frost-mobile/photos_head.tpl | 5 + view/theme/frost-mobile/photos_upload.tpl | 13 +- view/theme/frost-mobile/profed_end.tpl | 8 + view/theme/frost-mobile/profed_head.tpl | 37 +- view/theme/frost-mobile/profile_edit.tpl | 2 +- view/theme/frost-mobile/settings-head.tpl | 5 + .../frost-mobile/settings_display_end.tpl | 2 + view/theme/frost-mobile/style.css | 39 +- view/theme/frost-mobile/theme.php | 2 + view/theme/frost-mobile/wallmsg-end.tpl | 5 + view/theme/frost-mobile/wallmsg-header.tpl | 82 +- view/theme/frost/acl_selector.tpl | 22 + view/theme/frost/admin_aside.tpl | 11 - view/theme/frost/admin_site.tpl | 56 + view/theme/frost/comment_item.tpl | 4 +- view/theme/frost/contact_end.tpl | 6 + view/theme/frost/contact_head.tpl | 0 view/theme/frost/contacts-end.tpl | 4 + view/theme/frost/contacts-head.tpl | 5 + view/theme/frost/conversation.tpl | 4 +- view/theme/frost/cropbody.tpl | 27 + view/theme/frost/cropend.tpl | 4 + view/theme/frost/crophead.tpl | 1 + view/theme/frost/default.php | 1 + view/theme/frost/end.tpl | 19 + view/theme/frost/event_end.tpl | 7 + view/theme/frost/event_head.tpl | 6 + view/theme/frost/field_themeselect.tpl | 9 + view/theme/frost/head.tpl | 90 +- view/theme/frost/jot-end.tpl | 5 + view/theme/frost/jot-header.tpl | 324 +----- view/theme/frost/jot.tpl | 85 ++ view/theme/frost/js/acl.js | 258 +++++ view/theme/frost/js/acl.min.js | 1 + view/theme/frost/js/fk.autocomplete.js | 194 ++++ view/theme/frost/js/fk.autocomplete.min.js | 5 + view/theme/frost/js/main.js | 322 +++--- view/theme/frost/js/main.min.js | 1 + view/theme/frost/js/theme.js | 1014 +++++++++++++++-- view/theme/frost/js/theme.min.js | 1 + view/theme/frost/login.tpl | 2 +- view/theme/frost/message-end.tpl | 4 + view/theme/frost/message-head.tpl | 0 view/theme/frost/msg-end.tpl | 9 + view/theme/frost/msg-header.tpl | 9 + view/theme/frost/photo_edit_head.tpl | 7 + view/theme/frost/photos_head.tpl | 5 + view/theme/frost/photos_upload.tpl | 9 +- view/theme/frost/profed_end.tpl | 9 + view/theme/frost/profed_head.tpl | 5 + view/theme/frost/profile_edit.tpl | 2 +- view/theme/frost/settings-head.tpl | 5 + view/theme/frost/settings_display_end.tpl | 2 + view/theme/frost/theme.php | 3 +- view/theme/frost/wallmsg-end.tpl | 5 + view/theme/frost/wallmsg-header.tpl | 6 + view/wallmsg-end.tpl | 0 132 files changed, 3300 insertions(+), 1917 deletions(-) create mode 100644 js/acl.min.js create mode 100644 js/ajaxupload.min.js create mode 100644 js/country.min.js create mode 100644 js/fk.autocomplete.min.js create mode 100644 js/jquery.htmlstream.min.js create mode 100644 js/main.min.js create mode 100644 js/webtoolkit.base64.min.js create mode 100644 library/jquery_ac/friendica.complete.min.js create mode 100644 view/contact_end.tpl create mode 100644 view/contacts-end.tpl create mode 100644 view/contacts-head.tpl create mode 100644 view/cropend.tpl create mode 100644 view/end.tpl create mode 100644 view/event_end.tpl create mode 100644 view/jot-end.tpl create mode 100644 view/message-end.tpl create mode 100644 view/message-head.tpl create mode 100644 view/msg-end.tpl create mode 100644 view/photo_edit_head.tpl create mode 100644 view/photos_head.tpl create mode 100644 view/profed_end.tpl create mode 100644 view/settings-end.tpl create mode 100644 view/settings-head.tpl create mode 100644 view/settings_display_end.tpl create mode 100644 view/theme/frost-mobile/acl_selector.tpl create mode 100644 view/theme/frost-mobile/contact_edit.tpl create mode 100644 view/theme/frost-mobile/contacts-end.tpl create mode 100644 view/theme/frost-mobile/contacts-head.tpl create mode 100644 view/theme/frost-mobile/cropbody.tpl create mode 100644 view/theme/frost-mobile/cropend.tpl create mode 100644 view/theme/frost-mobile/crophead.tpl create mode 100644 view/theme/frost-mobile/end.tpl create mode 100644 view/theme/frost-mobile/event_end.tpl create mode 100644 view/theme/frost-mobile/field_checkbox.tpl create mode 100644 view/theme/frost-mobile/field_themeselect.tpl create mode 100644 view/theme/frost-mobile/jot-end.tpl create mode 100644 view/theme/frost-mobile/js/acl.min.js create mode 100644 view/theme/frost-mobile/js/fk.autocomplete.min.js create mode 100644 view/theme/frost-mobile/js/main.min.js delete mode 100644 view/theme/frost-mobile/js/theme.js.old create mode 100644 view/theme/frost-mobile/js/theme.min.js create mode 100644 view/theme/frost-mobile/message-end.tpl create mode 100644 view/theme/frost-mobile/message-head.tpl create mode 100755 view/theme/frost-mobile/oembed_video.tpl create mode 100644 view/theme/frost-mobile/photo_edit_head.tpl create mode 100644 view/theme/frost-mobile/photos_head.tpl create mode 100644 view/theme/frost-mobile/profed_end.tpl create mode 100644 view/theme/frost-mobile/settings-head.tpl create mode 100644 view/theme/frost-mobile/settings_display_end.tpl create mode 100644 view/theme/frost-mobile/wallmsg-end.tpl create mode 100644 view/theme/frost/acl_selector.tpl create mode 100644 view/theme/frost/admin_site.tpl create mode 100644 view/theme/frost/contact_end.tpl create mode 100644 view/theme/frost/contact_head.tpl create mode 100644 view/theme/frost/contacts-end.tpl create mode 100644 view/theme/frost/contacts-head.tpl create mode 100644 view/theme/frost/cropbody.tpl create mode 100644 view/theme/frost/cropend.tpl create mode 100644 view/theme/frost/crophead.tpl create mode 100644 view/theme/frost/end.tpl create mode 100644 view/theme/frost/event_end.tpl create mode 100644 view/theme/frost/event_head.tpl create mode 100644 view/theme/frost/field_themeselect.tpl create mode 100644 view/theme/frost/jot-end.tpl create mode 100644 view/theme/frost/jot.tpl create mode 100644 view/theme/frost/js/acl.js create mode 100644 view/theme/frost/js/acl.min.js create mode 100644 view/theme/frost/js/fk.autocomplete.js create mode 100644 view/theme/frost/js/fk.autocomplete.min.js create mode 100644 view/theme/frost/js/main.min.js create mode 100644 view/theme/frost/js/theme.min.js create mode 100644 view/theme/frost/message-end.tpl create mode 100644 view/theme/frost/message-head.tpl create mode 100644 view/theme/frost/msg-end.tpl create mode 100644 view/theme/frost/msg-header.tpl create mode 100644 view/theme/frost/photo_edit_head.tpl create mode 100644 view/theme/frost/photos_head.tpl create mode 100644 view/theme/frost/profed_end.tpl create mode 100644 view/theme/frost/profed_head.tpl create mode 100644 view/theme/frost/settings-head.tpl create mode 100644 view/theme/frost/settings_display_end.tpl create mode 100644 view/theme/frost/wallmsg-end.tpl create mode 100644 view/theme/frost/wallmsg-header.tpl create mode 100644 view/wallmsg-end.tpl diff --git a/boot.php b/boot.php index 0de2b0afcf..34cc4093a8 100644 --- a/boot.php +++ b/boot.php @@ -573,6 +573,13 @@ if(! class_exists('App')) { )); } + function init_page_end() { + $tpl = get_markup_template('end.tpl'); + $this->page['end'] = replace_macros($tpl,array( + '$baseurl' => $this->get_baseurl() // FIXME for z_path!!!! + )); + } + function set_curl_code($code) { $this->curl_code = $code; } diff --git a/include/conversation.php b/include/conversation.php index 4a9142bb20..6a2b2ae633 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1055,7 +1055,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $plaintext = true; $tpl = get_markup_template('jot-header.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array( '$newpost' => 'true', '$baseurl' => $a->get_baseurl(true), @@ -1072,6 +1071,23 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { )); + $tpl = get_markup_template('jot-end.tpl'); + $a->page['end'] .= replace_macros($tpl, array( + '$newpost' => 'true', + '$baseurl' => $a->get_baseurl(true), + '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$geotag' => $geotag, + '$nickname' => $x['nickname'], + '$ispublic' => t('Visible to everybody'), + '$linkurl' => t('Please enter a link URL:'), + '$vidurl' => t("Please enter a video link/URL:"), + '$audurl' => t("Please enter an audio link/URL:"), + '$term' => t('Tag term:'), + '$fileas' => t('Save to Folder:'), + '$whereareu' => t('Where are you right now?') + )); + + $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; diff --git a/index.php b/index.php index 61f3562b58..c9b7f34d72 100644 --- a/index.php +++ b/index.php @@ -118,6 +118,12 @@ if(! x($_SESSION,'authenticated')) $a->init_pagehead(); +/** + * Build the page ending -- this is stuff that goes right before + * the closing tag + */ + +$a->init_page_end(); if(! x($_SESSION,'sysmsg')) diff --git a/js/acl.min.js b/js/acl.min.js new file mode 100644 index 0000000000..74904a02c0 --- /dev/null +++ b/js/acl.min.js @@ -0,0 +1 @@ +function ACL(e,t){that=this,that.url=e,that.kp_timer=null,t==undefined&&(t=[]),that.allow_cid=t[0]||[],that.allow_gid=t[1]||[],that.deny_cid=t[2]||[],that.deny_gid=t[3]||[],that.group_uids=[],that.nw=4,that.list_content=$("#acl-list-content"),that.item_tpl=unescape($(".acl-list-item[rel=acl-template]").html()),that.showall=$("#acl-showall"),t.length==0&&that.showall.addClass("selected"),that.showall.click(that.on_showall),$(".acl-button-show").live("click",that.on_button_show),$(".acl-button-hide").live("click",that.on_button_hide),$("#acl-search").keypress(that.on_search),$("#acl-wrapper").parents("form").submit(that.on_submit),that.get(0,100)}ACL.prototype.on_submit=function(){aclfileds=$("#acl-fields").html(""),$(that.allow_gid).each(function(e,t){aclfileds.append("")}),$(that.allow_cid).each(function(e,t){aclfileds.append("")}),$(that.deny_gid).each(function(e,t){aclfileds.append("")}),$(that.deny_cid).each(function(e,t){aclfileds.append("")})},ACL.prototype.search=function(){var e=$("#acl-search").val();that.list_content.html(""),that.get(0,100,e)},ACL.prototype.on_search=function(e){that.kp_timer&&clearTimeout(that.kp_timer),that.kp_timer=setTimeout(that.search,1e3)},ACL.prototype.on_showall=function(e){return e.preventDefault(),e.stopPropagation(),that.showall.hasClass("selected")?!1:(that.showall.addClass("selected"),that.allow_cid=[],that.allow_gid=[],that.deny_cid=[],that.deny_gid=[],that.update_view(),!1)},ACL.prototype.on_button_show=function(e){return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),that.set_allow($(this).parent().attr("id")),!1},ACL.prototype.on_button_hide=function(e){return e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),that.set_deny($(this).parent().attr("id")),!1},ACL.prototype.set_allow=function(e){type=e[0],id=parseInt(e.substr(1));switch(type){case"g":that.allow_gid.indexOf(id)<0?that.allow_gid.push(id):that.allow_gid.remove(id),that.deny_gid.indexOf(id)>=0&&that.deny_gid.remove(id);break;case"c":that.allow_cid.indexOf(id)<0?that.allow_cid.push(id):that.allow_cid.remove(id),that.deny_cid.indexOf(id)>=0&&that.deny_cid.remove(id)}that.update_view()},ACL.prototype.set_deny=function(e){type=e[0],id=parseInt(e.substr(1));switch(type){case"g":that.deny_gid.indexOf(id)<0?that.deny_gid.push(id):that.deny_gid.remove(id),that.allow_gid.indexOf(id)>=0&&that.allow_gid.remove(id);break;case"c":that.deny_cid.indexOf(id)<0?that.deny_cid.push(id):that.deny_cid.remove(id),that.allow_cid.indexOf(id)>=0&&that.allow_cid.remove(id)}that.update_view()},ACL.prototype.update_view=function(){that.allow_gid.length==0&&that.allow_cid.length==0&&that.deny_gid.length==0&&that.deny_cid.length==0?(that.showall.addClass("selected"),$("#jot-perms-icon").removeClass("lock").addClass("unlock"),$("#jot-public").show(),$(".profile-jot-net input").attr("disabled",!1),typeof editor!="undefined"&&editor!=0&&$("#profile-jot-desc").html(ispublic)):(that.showall.removeClass("selected"),$("#jot-perms-icon").removeClass("unlock").addClass("lock"),$("#jot-public").hide(),$(".profile-jot-net input").attr("disabled","disabled"),$("#profile-jot-desc").html(" ")),$("#acl-list-content .acl-list-item").each(function(){$(this).removeClass("groupshow grouphide")}),$("#acl-list-content .acl-list-item").each(function(){itemid=$(this).attr("id"),type=itemid[0],id=parseInt(itemid.substr(1)),btshow=$(this).children(".acl-button-show").removeClass("selected"),bthide=$(this).children(".acl-button-hide").removeClass("selected");switch(type){case"g":var e="";that.allow_gid.indexOf(id)>=0&&(btshow.addClass("selected"),bthide.removeClass("selected"),e="groupshow"),that.deny_gid.indexOf(id)>=0&&(btshow.removeClass("selected"),bthide.addClass("selected"),e="grouphide"),$(that.group_uids[id]).each(function(t,n){e=="grouphide"&&$("#c"+n).removeClass("groupshow");if(e!=""){var r=$("#c"+n).attr("class");if(r==undefined)return!0;var i=r.indexOf("grouphide");i==-1&&$("#c"+n).addClass(e)}});break;case"c":that.allow_cid.indexOf(id)>=0&&(btshow.addClass("selected"),bthide.removeClass("selected")),that.deny_cid.indexOf(id)>=0&&(btshow.removeClass("selected"),bthide.addClass("selected"))}})},ACL.prototype.get=function(e,t,n){var r={start:e,count:t,search:n};$.ajax({type:"POST",url:that.url,data:r,dataType:"json",success:that.populate})},ACL.prototype.populate=function(e){var t=Math.ceil(e.tot/that.nw)*42;that.list_content.height(t),$(e.items).each(function(){html="
"+that.item_tpl+"
",html=html.format(this.photo,this.name,this.type,this.id,"",this.network,this.link),this.uids!=undefined&&(that.group_uids[this.id]=this.uids),that.list_content.append(html)}),that.update_view()}; \ No newline at end of file diff --git a/js/ajaxupload.min.js b/js/ajaxupload.min.js new file mode 100644 index 0000000000..246f2bdb2c --- /dev/null +++ b/js/ajaxupload.min.js @@ -0,0 +1,6 @@ +/** + * AJAX Upload ( http://valums.com/ajax-upload/ ) + * Copyright (c) Andris Valums + * Licensed under the MIT license ( http://valums.com/mit-license/ ) + * Thanks to Gary Haran, David Mark, Corey Burns and others for contributions. + */(function(){function log(){typeof console!="undefined"&&typeof console.log=="function"&&(Array.prototype.unshift.call(arguments,"[Ajax Upload]"),console.log(Array.prototype.join.call(arguments," ")))}function addEvent(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else{if(!e.attachEvent)throw new Error("not supported or DOM not loaded");e.attachEvent("on"+t,function(){n.call(e)})}}function addResizeEvent(e){var t;addEvent(window,"resize",function(){t&&clearTimeout(t),t=setTimeout(e,100)})}function getBox(e){var t,n,r,i,s=getOffset(e);return t=s.left,r=s.top,n=t+e.offsetWidth,i=r+e.offsetHeight,{left:t,right:n,top:r,bottom:i}}function addStyles(e,t){for(var n in t)t.hasOwnProperty(n)&&(e.style[n]=t[n])}function copyLayout(e,t){var n=getBox(e);addStyles(t,{position:"absolute",left:n.left+"px",top:n.top+"px",width:e.offsetWidth+"px",height:e.offsetHeight+"px"}),t.title=e.title}function fileFromPath(e){return e.replace(/.*(\/|\\)/,"")}function getExt(e){return-1!==e.indexOf(".")?e.replace(/.*[.]/,""):""}function hasClass(e,t){var n=new RegExp("\\b"+t+"\\b");return n.test(e.className)}function addClass(e,t){hasClass(e,t)||(e.className+=" "+t)}function removeClass(e,t){var n=new RegExp("\\b"+t+"\\b");e.className=e.className.replace(n,"")}function removeNode(e){e.parentNode.removeChild(e)}if(document.documentElement.getBoundingClientRect)var getOffset=function(e){var t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.body,i=n.documentElement,s=i.clientTop||r.clientTop||0,o=i.clientLeft||r.clientLeft||0,u=1;if(r.getBoundingClientRect){var a=r.getBoundingClientRect();u=(a.right-a.left)/r.clientWidth}u>1&&(s=0,o=0);var f=t.top/u+(window.pageYOffset||i&&i.scrollTop/u||r.scrollTop/u)-s,l=t.left/u+(window.pageXOffset||i&&i.scrollLeft/u||r.scrollLeft/u)-o;return{top:f,left:l}};else var getOffset=function(e){var t=0,n=0;do t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent;while(e);return{left:n,top:t}};var toElement=function(){var e=document.createElement("div");return function(t){e.innerHTML=t;var n=e.firstChild;return e.removeChild(n)}}(),getUID=function(){var e=0;return function(){return"ValumsAjaxUpload"+e++}}();window.AjaxUpload=function(e,t){this._settings={action:"upload.php",name:"userfile",data:{},autoSubmit:!0,responseType:!1,hoverClass:"hover",focusClass:"focus",disabledClass:"disabled",onChange:function(e,t){},onSubmit:function(e,t){},onComplete:function(e,t){}};for(var n in t)t.hasOwnProperty(n)&&(this._settings[n]=t[n]);e.jquery?e=e[0]:typeof e=="string"&&(/^#.*/.test(e)&&(e=e.slice(1)),e=document.getElementById(e));if(!e||e.nodeType!==1)throw new Error("Please make sure that you're passing a valid element");e.nodeName.toUpperCase()=="A"&&addEvent(e,"click",function(e){e&&e.preventDefault?e.preventDefault():window.event&&(window.event.returnValue=!1)}),this._button=e,this._input=null,this._disabled=!1,this.enable(),this._rerouteClicks()},AjaxUpload.prototype={setData:function(e){this._settings.data=e},disable:function(){addClass(this._button,this._settings.disabledClass),this._disabled=!0;var e=this._button.nodeName.toUpperCase();(e=="INPUT"||e=="BUTTON")&&this._button.setAttribute("disabled","disabled"),this._input&&(this._input.parentNode.style.visibility="hidden")},enable:function(){removeClass(this._button,this._settings.disabledClass),this._button.removeAttribute("disabled"),this._disabled=!1},_createInput:function(){var e=this,t=document.createElement("input");t.setAttribute("type","file"),t.setAttribute("name",this._settings.name),addStyles(t,{position:"absolute",right:0,margin:0,padding:0,fontSize:"480px",fontFamily:"sans-serif",cursor:"pointer"});var n=document.createElement("div");addStyles(n,{display:"block",position:"absolute",overflow:"hidden",margin:0,padding:0,opacity:0,direction:"ltr",zIndex:2147483583,cursor:"pointer"});if(n.style.opacity!=="0"){if(typeof n.filters=="undefined")throw new Error("Opacity not supported by the browser");n.style.filter="alpha(opacity=0)"}addEvent(t,"change",function(){if(!t||t.value==="")return;var n=fileFromPath(t.value);if(!1===e._settings.onChange.call(e,n,getExt(n))){e._clearInput();return}e._settings.autoSubmit&&e.submit()}),addEvent(t,"mouseover",function(){addClass(e._button,e._settings.hoverClass)}),addEvent(t,"mouseout",function(){removeClass(e._button,e._settings.hoverClass),removeClass(e._button,e._settings.focusClass),t.parentNode.style.visibility="hidden"}),addEvent(t,"focus",function(){addClass(e._button,e._settings.focusClass)}),addEvent(t,"blur",function(){removeClass(e._button,e._settings.focusClass)}),n.appendChild(t),document.body.appendChild(n),this._input=t},_clearInput:function(){if(!this._input)return;removeNode(this._input.parentNode),this._input=null,this._createInput(),removeClass(this._button,this._settings.hoverClass),removeClass(this._button,this._settings.focusClass)},_rerouteClicks:function(){var e=this;addEvent(e._button,"mouseover",function(){if(e._disabled)return;e._input||e._createInput();var t=e._input.parentNode;copyLayout(e._button,t),t.style.visibility="visible"})},_createIframe:function(){var e=getUID(),t=toElement('