regluit/static/js/widgets.js

4 lines
106 KiB
JavaScript
Raw Normal View History

2014-11-07 19:27:49 +00:00
!function(){function provide(t,e){e(function(e){modules[t]=e})}function using(){for(var t,e=Array.prototype.slice.call(arguments,0,-1),i=0,n=[],r=arguments[arguments.length-1];t=e[i];i++){if(!modules[t])throw"[TWITTER] Module dependency missing: "+t;n.push(modules[t])}r&&r.apply(window,n)}var modules={};provide("util/util",function(t){function e(t){return t&&String(t).toLowerCase().indexOf("[native code]")>-1}function i(t){return f(arguments,function(e){r(e,function(e,i){t[e]=i})}),t}function n(t){return r(t,function(e,i){u(i)&&(n(i),l(i)&&delete t[e]),(void 0===i||null===i||""===i)&&delete t[e]}),t}function r(t,e){for(var i in t)(!t.hasOwnProperty||t.hasOwnProperty(i))&&e(i,t[i]);return t}function o(t){return{}.toString.call(t).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function s(t,e){return t==o(e)}function a(t,e,i){return i=i||[],function(){var n=w(arguments,function(t){return t});return t.apply(e,i.concat(n))}}function u(t){return t===Object(t)}function l(t){if(!u(t))return!1;if(Object.keys)return!Object.keys(t).length;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function c(t,e){window.setTimeout(function(){t.call(e||null)},0)}function d(t){return Array.prototype.slice.call(t)}var h=function(){var t=Array.prototype.indexOf;return e(t)?function(e,i){return e?t.apply(e,[i]):-1}:function(t,e){if(!t)return-1;for(var i=0,n=t.length;n>i;i++)if(e==t[i])return i;return-1}}(),f=function(){var t=Array.prototype.forEach;return e(t)?function(e,i){e&&i&&t.apply(e,[i])}:function(t,e){if(t&&e)for(var i=0,n=t.length;n>i;i++)e(t[i],i)}}(),m=function(){var t=Array.prototype.filter;return e(t)?function(e,i){return e?i?t.apply(e,[i]):e:null}:function(t,e){if(!t)return null;if(!e)return t;for(var i=[],n=0,r=t.length;r>n;n++)e(t[n])&&i.push(t[n]);return i}}(),w=function(){var t=Array.prototype.map;return e(t)?function(e,i){return e?i?t.apply(e,[i]):e:null}:function(t,e){if(!t)return null;if(!e)return t;for(var i=[],n=0,r=t.length;r>n;n++)i.push(e(t[n]));return i}}(),p=function(){var t=Array.prototype.reduce;return e(t)?function(e,i,n){return e?i?t.apply(e,[i,n]):n:null}:function(t,e,i){if(!t)return null;if(!e)return i;for(var n=i,r=0,o=t.length;o>r;r++)n=e(n,t[r],r,t);return n}}(),g=function(){var t=String.prototype.trim;return e(t)?function(e){return e&&t.apply(e)}:function(t){return t&&t.replace(/(^\s+|\s+$)/g,"")}}(),v=e(Object.create)?Object.create:function(t){function e(){}return e.prototype=t,new e};t({aug:i,async:c,compact:n,forIn:r,forEach:f,filter:m,map:w,reduce:p,trim:g,indexOf:h,isNative:e,isObject:u,isEmptyObject:l,createObject:v,bind:a,toType:o,isType:s,toRealArray:d})}),provide("util/typevalidator",function(t){using("util/util",function(e){function i(t){return void 0!==t&&null!==t&&""!==t}function n(t){return o(t)&&t%1===0}function r(t){return o(t)&&!n(t)}function o(t){return i(t)&&!isNaN(t)}function s(t){return i(t)&&"array"==e.toType(t)}function a(t){if(!i(t))return!1;switch(t){case"on":case"ON":case"true":case"TRUE":return!0;case"off":case"OFF":case"false":case"FALSE":return!1;default:return!!t}}function u(t){return o(t)?t:void 0}function l(t){return r(t)?t:void 0}function c(t){return n(t)?t:void 0}t({hasValue:i,isInt:n,isFloat:r,isNumber:o,isArray:s,asInt:c,asFloat:l,asNumber:u,asBoolean:a})})}),provide("tfw/util/globals",function(t){using("util/typevalidator",function(e){function i(){var t,e,i=document.getElementsByTagName("meta"),n=0;for(o={};t=i[n];n++)/^twitter:/.test(t.name)&&(e=t.name.replace(/^twitter:/,""),o[e]=t.content)}function n(t){return o[t]}function r(t){return e.asBoolean(t)&&(o.dnt=!0),e.asBoolean(o.dnt)}var o;i(),t({init:i,val:n,dnt:r})})}),provide("util/logger",function(t){using("util/util",function(e){function i(){u("info",e.toRealArray(arguments))}function n(){u("warn",e.toRealArray(arguments))}function r(){u("error",e.toRealArray(arguments))}function o(t){d&&(c[t]=a())}function s(t){var e;d&&(c[t]?(e=a(),i("_twitter",t,e-c[t])):r("timeEnd() called before time() for id: ",t))}function a(){return window.performance&&+window.performance.now()||+new Date}function u(t,e){if(window[l]&&window[l]
c.aug(f.prototype,{setLanguage:function(t){var e;return t||(t=this.params().lang||this.dataAttr("lang")||p(this.srcEl)),(t=t&&t.toLowerCase())?x[t]?this.lang=t:(e=t.replace(/[\-_].*/,""),x[e]?this.lang=e:void(this.lang="en")):this.lang="en"},_:function(t,e){var i=this.lang;return e=e||{},i&&x.hasOwnProperty(i)||(i=this.lang="en"),t=x[i]&&x[i][t]||t,this.ringo(t,e,/%\{([\w_]+)\}/g)},ringo:function(t,e,i){return i=i||/\{\{([\w_]+)\}\}/g,t.replace(i,function(t,i){return void 0!==e[i]?e[i]:t})},makeIframeSource:function(){if(this.iframeSource){var t=u.encode(this.widgetUrlParams());return[twttr.widgets.config.assetUrl(),this.ringo(this.iframeSource,{lang:this.lang}),"#",t].join("")}},add:function(t){b[this.id]=t},create:function(t,e,i){var n,r=this;return i[T]=!0,n=o(c.aug({id:this.id,src:t,"class":this.classAttr.join(" ")},i),e,this.targetEl&&this.targetEl.ownerDocument),this.srcEl?this.layout(function(){return r.srcEl.parentNode.replaceChild(n,r.srcEl),r.completeResolver.fulfill(n),n}):this.targetEl?this.layout(function(){return r.targetEl.appendChild(n),r.completeResolver.fulfill(n),n}):a.reject("Did not append widget")},params:function(){var t,e;return this.srcOb?e=this.srcOb:(t=this.srcEl&&this.srcEl.href&&this.srcEl.href.split("?")[1],e=t?u.decode(t):{}),this.params=function(){return e},e},widgetUrlParams:function(){return{}},dataAttr:function(t){return this.srcEl&&this.srcEl.getAttribute("data-"+t)},attr:function(t){return this.srcEl&&this.srcEl.getAttribute(t)},layout:function(t){return _.enqueue(t)},styles:{base:[["font","normal normal normal 11px/18px 'Helvetica Neue', Arial, sans-serif"],["margin","0"],["padding","0"],["whiteSpace","nowrap"]],button:[["fontWeight","bold"],["textShadow","0 1px 0 rgba(255,255,255,.5)"]],large:[["fontSize","13px"],["lineHeight","26px"]],vbubble:[["fontSize","16px"]]},width:function(){throw new Error(name+" not implemented")},height:function(){return"m"==this.size?20:28},minWidth:function(){},maxWidth:function(){},minHeight:function(){},maxHeight:function(){},dimensions:function(){function t(t){switch(typeof t){case"string":return t;case"undefined":return;default:return t+"px"}}var e={width:this.width(),height:this.height()};return this.minWidth()&&(e["min-width"]=this.minWidth()),this.maxWidth()&&(e["max-width"]=this.maxWidth()),this.minHeight()&&(e["min-height"]=this.minHeight()),this.maxHeight()&&(e["max-height"]=this.maxHeight()),c.forIn(e,function(i,n){e[i]=t(n)}),e},generateId:function(){return this.srcEl&&this.srcEl.id||"twitter-widget-"+v++},completed:function(){return this.completePromise}}),f.afterLoad=function(t){y.push(t)},f.doLayout=function(){_.exec()},f.doLayoutAsync=function(){_.delayedExec()},f.init=function(t){g=t},f.reset=function(){b={}},f.find=function(t){return t&&b[t]?b[t].element:null},f.embed=function(t){var i=g.widgets,n=[],r=[],o=[];l.isArray(t)||(t=[t||document]),h.time("sandboxes"),c.forEach(t,function(t){c.forIn(i,function(i,r){var s,a;i.match(/\./)?(s=i.split("."),a=e.all(s[1],t,s[0])):a=t.getElementsByTagName(i),c.forEach(a,function(t){var e;t.getAttribute(T)||(t.setAttribute(T,"true"),e=new r(t),n.push(e),o.push(e.sandboxCreated))})})}),a.every.apply(null,o).then(function(){h.timeEnd("sandboxes")}),f.doLayout(),c.forEach(n,function(t){r.push(t.completed()),t.render(g)}),a.every.apply(null,r).then(function(t){t=c.filter(t,function(t){return t}),t.length&&(twttr.events.trigger("loaded",{widgets:t}),h.timeEnd("load"))}).then(c.bind(f.trackRender,null,[n])),f.doLayoutAsync(),w()},f.trackRender=function(t){i.endAndTrack("render","widgets-js-load","page",{widget_origin:n.url()},m(t))},window.setInterval(function(){f.doLayout()},500),t(f)})}),provide("util/events",function(t){using("util/util",function(e){var i={bind:function(t,e){return this._handlers=this._handlers||{},this._handlers[t]=this._handlers[t]||[],this._handlers[t].push(e)},unbind:function(t,i){if(this._handlers[t])if(i){var n=e.indexOf(this._handlers[t],i);n>=0&&this._handlers[t].splice(n,1)}else this._handlers[t]=[]},trigger:function(t,i){var n=this._handlers&&this._handlers[t];i=i||{},i.type=
return(t||this.width)-(n+i)},addSiteStyles:function(){var t=g.bind(function(t){return("dark"==this.theme?".thm-dark ":"")+t},this),e=[];return this.headingStyle&&e.push(g.map(N,t).join(",")+"{"+this.headingStyle+"}"),this.linkColor&&(e.push(g.map(A,t).join(",")+"{color:"+this.linkColor+"}"),e.push(g.map(E,t).join(",")+"{background-color:"+this.linkColor+"}")),this.borderColor&&e.push(g.map(I,t).concat("dark"==this.theme?[".thm-dark.customisable-border"]:[]).join(",")+"{border-color:"+this.borderColor+"}"),e.length?this.sandbox.appendCss(e.join("")):void 0},setNarrow:function(){var t=this.narrow;return this.narrow=this.width<this.dimensions.NARROW_WIDTH,t!=this.narrow?this.layout(g.bind(function(){return u.toggle(this.element,"var-narrow",this.narrow)},this)):m.fulfill(this.narrow)},bindIntentHandlers:function(){function t(t){var i=l.ancestor(".tweet",this,n),r=g.aug({},e.baseScribeData(),{item_ids:[],item_details:e.extractTweetScribeDetails(i)});g.forIn(r.item_details,function(t){r.item_ids.push(t)}),s.scribeInteraction(t,r,!0,e.dnt)}var e=this,n=this.element;c.delegate(n,"click","A",t),c.delegate(n,"click","BUTTON",t),c.delegate(n,"click",".profile",function(){e.addUrlParams(this)}),c.delegate(n,"click",".follow-button",function(t){var n;t.altKey||t.metaKey||t.shiftKey||f.ios()||f.android()||p.asBoolean(this.getAttribute("data-age-gate"))||(n=w.intentForFollowURL(this.href,!0),n&&(i.open(n,e.sandbox.element()),c.preventDefault(t)))}),c.delegate(n,"click",".web-intent",function(t){e.addUrlParams(this),t.altKey||t.metaKey||t.shiftKey||(i.open(this.href,e.sandbox.element()),c.preventDefault(t))})},baseScribeData:function(){return{}},extractTweetScribeDetails:function(t){var e,i,n={};return t?(e=t.getAttribute("data-tweet-id"),i=t.getAttribute("data-rendered-tweet-id")||e,i==e?n[i]={item_type:S.TWEET}:e&&(n[i]={item_type:S.RETWEET,target_type:S.TWEET,target_id:e}),n):n},constrainMedia:function(t,e){return o.constrainMedia(t||this.element,e||this.contentWidth(),this.fullBleedPhoto,this.layout)},collapseRegions:function(){g.forEach(l.all("collapsible-container",this.element),g.bind(function(t){var e,i,n=t.children,r=n.length&&t.offsetWidth,o=n.length&&g.map(n,function(t){return t.offsetWidth}),s=n.length;if(n.length)for(;s>0;){if(s--,e=g.reduce(o,y,0),!r||!e)return;if(r>e)return;i=n[s].getAttribute("data-collapsed-class"),i&&(u.add(this.element,i),o[s]=n[s].offsetWidth)}},this))}}),b.VALID_UNIT=/^([0-9]+)( ?px)?$/,b.VALID_COLOR=/^(#(?:[0-9a-f]{3}|[0-9a-f]{6}))$/i,v(),t(b)})}),provide("tfw/widget/timeline",function(t){using("tfw/widget/base","tfw/widget/syndicatedbase","util/datetime","util/promise","anim/transition","performance/perf-timers","tfw/util/article","tfw/util/data","tfw/util/media","tfw/util/tracking","tfw/util/params","util/css","util/env","util/throttle","util/twitter","util/querystring","util/typevalidator","util/util","dom/delegate","dom/classname","dom/get",function(e,i,n,r,o,s,a,u,l,c,d,h,f,m,w,p,g,v,b,y,_){function T(t){if(t){var e,n,r,o,s,a,u,l;i.apply(this,[t]),e=this.params(),n=(e.chrome||this.dataAttr("chrome")||"").split(" "),this.preview=e.previewParams,this.widgetId=e.widgetId||this.dataAttr("widget-id"),this.instanceId=++H,this.cursors={maxPosition:0,minPosition:0},this.override=(o=e.screenName||this.dataAttr("screen-name"))||(s=e.userId||this.dataAttr("user-id"))?{overrideType:"user",overrideId:s,overrideName:o,withReplies:g.asBoolean(e.showReplies||this.dataAttr("show-replies"))?"true":"false"}:(o=e.favoritesScreenName||this.dataAttr("favorites-screen-name"))||(s=e.favoritesUserId||this.dataAttr("favorites-user-id"))?{overrideType:"favorites",overrideId:s,overrideName:o}:((o=e.listOwnerScreenName||this.dataAttr("list-owner-screen-name"))||(s=e.listOwnerId||this.dataAttr("list-owner-id")))&&((a=e.listId||this.dataAttr("list-id"))||(u=e.listSlug||this.dataAttr("list-slug")))?{overrideType:"list",overrideOwnerId:s,overrideOwnerName:o,overrideId:a,overrideName:u}:(l=e.customTimelineId||this.dataAttr("custom-timeline-id"))?{overrideType:"custom",overrideId:l}:{},this.tweetLimit=g.asInt(e.tweetLimit||th
}var c=document.title,d=location.href,h=["vertical","horizontal","none"],f=[,"never","publisher-first","publisher-only","author-first","author-only"];l.prototype=new e,n.aug(l.prototype,{iframeSource:"/widgets/tweet_button.d58098f8a7f0ff5a206e7f15442a6b30.{{lang}}.html",widgetUrlParams:function(){return n.compact({text:this.text,url:this.url,via:this.via,related:this.related,count:this.count,lang:this.lang,counturl:this.counturl,searchlink:this.searchlink,placeid:this.placeid,original_referer:location.href,id:this.id,size:this.size,type:this.type,screen_name:this.screen_name,share_with_retweet:this.shareWithRetweet,button_hashtag:this.button_hashtag,hashtags:this.hashtags,align:this.align,partner:this.partner,dnt:this.dnt,_:+new Date})},height:function(){return"vertical"==this.count?62:"m"==this.size?20:28},width:function(){var t={ver:8,cnt:14,btn:24,xlcnt:18,xlbtn:38},e="vertical"==this.count,i="hashtag"==this.type&&this.button_hashtag?"Tweet %{hashtag}":"mention"==this.type&&this.screen_name?"Tweet to %{name}":"Tweet",r=this._(i,{name:"@"+this.screen_name,hashtag:"#"+this.button_hashtag}),o=this._("K"),s=this._("100K+"),a=(e?"8888":"88888")+o,l=0,c=0,d=0,h=0,f=this.styles.base,m=f;return~n.indexOf(["ja","ko"],this.lang)?a+=this._("10k unit"):a=a.length>s.length?a:s,e?(m=f.concat(this.styles.vbubble),h=t.ver,d=t.btn):"l"==this.size?(f=m=f.concat(this.styles.large),d=t.xlbtn,h=t.xlcnt):(d=t.btn,h=t.cnt),"none"!=this.count&&(c=u(a,"",m).width+h),l=u(r,"",f.concat(this.styles.button)).width+d,e?l>c?l:c:this.calculatedWidth=l+c},render:function(t,e){var i,r=this.makeIframeSource();return this.count&&this.classAttr.push("twitter-count-"+this.count),i=this.create(r,this.dimensions(),{title:this._("Twitter Tweet Button")}).then(n.bind(function(t){return this.element=t},this)),e&&i.then(e),i}}),t(l)})}),provide("tfw/factories",function(t){using("util/util","util/promise","util/twitter","tfw/widget/base","tfw/widget/tweetbutton","tfw/widget/follow","tfw/widget/embed","tfw/widget/timeline",function(e,i,n,r,o,s,a,u){function l(t,n,o,s){return t=t||[],o=o||{},function(){var a,u,l,c,d=Array.prototype.slice.apply(arguments,[0,t.length]),h=Array.prototype.slice.apply(arguments,[t.length]);return e.forEach(h,function(t){return t?1===t.nodeType?void(l=t):e.isType("function",t)?void(a=t):void(e.isType("object",t)&&(u=t)):void 0}),d.length!=t.length||0===h.length?(a&&e.async(function(){a(!1)}),i.reject("Not enough parameters")):l?(u=e.aug(u||{},o),u.targetEl=l,e.forEach(t,function(t){u[t]=d.shift()}),c=new n(u),r.doLayout(),c.render(twttr.widgets.config),s&&s(),a&&c.completed().then(a,function(){a(!1)}),c.completed()):(a&&e.async(function(){a(!1)}),i.reject("No target specified"))}}function c(t){var i;t.linkColor=t.linkColor||t.previewParams.link_color,t.theme=t.theme||t.previewParams.theme,t.height=t.height||t.previewParams.height,i=new u(t),this.render=e.bind(i.render,i),this.completed=e.bind(i.completed,i)}var d=l(["url"],o,{type:"share"}),h=l(["hashtag"],o,{type:"hashtag"}),f=l(["screenName"],o,{type:"mention"}),m=l(["screenName"],s),w=l(["tweetId"],a,{},a.fetchAndRender),p=l(["widgetId"],u),g=l(["previewParams"],c),v={createShareButton:d,createMentionButton:f,createHashtagButton:h,createFollowButton:m,createTweet:w,createTweetEmbed:w,createTimeline:p};n.isTwitterURL(window.location.href)&&(v.createTimelinePreview=g),t(v)})}),!function(){window.twttr=window.twttr||{},twttr.host=twttr.host||"platform.twitter.com",using("util/domready","util/env","util/logger","performance/perf-timers",function(t,e,i,n){function r(t){return!t&&/^http\:$/.test(window.location.protocol)||twttr.ignoreSSL?"http":"https"}if(n.start("widgets-js-load"),!e.ie6()){if(twttr.widgets&&twttr.widgets.loaded)return twttr.widgets.load(),!1;if(twttr.init)return!1;twttr.init=!0,twttr._e=twttr._e||[],twttr.ready=twttr.ready||function(t){twttr.widgets&&twttr.widgets.loaded?t(twttr):twttr._e.push(t)},twttr.ignoreSSL=twttr.ignoreSSL||!1;var o=[];twttr.events={bind:function(t,e){return o.push([t,e])}},t(function(){using("tfw/widget/base","tfw/widget/follow","tfw/widget/tweet