vendor: 4,756 bytes, lines 1-12
1/*! 2 * Packery PACKAGED v2.0.0 3 * Gapless, draggable grid layouts 4 * 5 * Licensed GPLv3 for open source use 6 * or Packery Commercial License for commercial use 7 * 8 * http://packery.metafizzy.co 9 * Copyright 2016 Metafizzy 10 */ 11 12!function(t,e){"use strict";"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,s,a){function h(t,e,n){var o,s="$()."+i+'("'+e+'")';return t.each(function(t,h){var u=a.data(h,i);if(!u)return void r(i+" not initialized. Cannot call methods, i.e. "+s);var c=u[e];if(!c||"_"==e.charAt(0))return void r(s+" is not a valid method");var d=c.apply(u,n);o=void 0===o?d:o}),void 0!==o?o:t}function u(t,e){t.each(function(t,n){var o=a.data(n,i);o?(o.option(e),o._init()):(o=new s(n,e),a.data(n,i,o))})}a=a||e||t.jQuery,a&&(s.prototype.option||(s.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=o.call(arguments,1);return h(this,t,e)}return u(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var o=Array.prototype.slice,s=t.console,r="undefined"==typeof s?function(){}:function(t){s.error(t)};return n(e||t.jQuery),i}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=-1==t.indexOf("%")&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;u>e;e++){var i=h[e];t[i]=0}return t}function n(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}function o(){if(!c){c=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(e);var o=n(e);s.isBoxSizeOuter=r=200==t(o.width),i.removeChild(e)}}function s(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var s=n(e);if("none"==s.display)return i();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var c=a.isBorderBox="border-box"==s.boxSizing,d=0;u>d;d++){var f=h[d],l=s[f],p=parseFloat(l);a[f]=isNaN(p)?0:p}var m=a.paddingLeft+a.paddingRight,g=a.paddingTop+a.paddingBottom,y=a.marginLeft+a.marginRight,v=a.marginTop+a.marginBottom,_=a.borderLeftWidth+a.borderRightWidth,x=a.borderTopWidth+a.borderBottomWidth,b=c&&r,E=t(s.width);E!==!1&&(a.width=E+(b?0:m+_));var T=t(s.height);return T!==!1&&(a.height=T+(b?0:g+x)),a.innerWidth=a.width-(m+_),a.innerHeight=a.height-(g+x),a.outerWidth=a.width+y,a.outerHeight=a.height+v,a}}var r,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],u=h.length,c=!1;return s}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}(this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||{};return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var s=this._onceEvents&&this._onceEvents[t];o;){var r=s&&s[o];r&&(this.off(t,o),delete s[o]),o.apply(this,e),n+=r?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("desandro-matches-selector/matches-selector",e):"object"==typeof module&&module.exports?module.exports=e():t.matchesSelector=e()}(window,function(){"use strict";var t=function(){var t=Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],i=0;i<e.length;i++){var n=e[i],o=n+"MatchesSelector";if(t[o])return o}}();return function(e,i){return e[t](i)}}),function(t,e){"function"==typeof define&&define.amd?define("fizzy-ui-utils/utils",["de
12sandro-matches-selector/matches-selector"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("desandro-matches-selector")):t.fizzyUIUtils=e(t,t.matchesSelector)}(window,function(t,e){var i={};i.extend=function(t,e){for(var i in e)t[i]=e[i];return t},i.modulo=function(t,e){return(t%e+e)%e},i.makeArray=function(t){var e=[];if(Array.isArray(t))e=t;else if(t&&"number"==typeof t.length)for(var i=0;i<t.length;i++)e.push(t[i]);else e.push(t);return e},i.removeFrom=function(t,e){var i=t.indexOf(e);-1!=i&&t.splice(i,1)},i.getParent=function(t,i){for(;t!=document.body;)if(t=t.parentNode,e(t,i))return t},i.getQueryElement=function(t){return"string"==typeof t?document.querySelector(t):t},i.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},i.filterFindElements=function(t,n){t=i.makeArray(t);var o=[];return t.forEach(function(t){if(t instanceof HTMLElement){if(!n)return void o.push(t);e(t,n)&&o.push(t);for(var i=t.querySelectorAll(n),s=0;s<i.length;s++)o.push(i[s])}}),o},i.debounceMethod=function(t,e,i){var n=t.prototype[e],o=e+"Timeout";t.prototype[e]=function(){var t=this[o];t&&clearTimeout(t);var e=arguments,s=this;this[o]=setTimeout(function(){n.apply(s,e),delete s[o]},i||100)}},i.docReady=function(t){"complete"==document.readyState?t():document.addEventListener("DOMContentLoaded",t)},i.toDashed=function(t){return t.replace(/(.)([A-Z])/g,function(t,e,i){return e+"-"+i}).toLowerCase()};var n=t.console;return i.htmlInit=function(e,o){i.docReady(function(){var s=i.toDashed(o),r="data-"+s,a=document.querySelectorAll("["+r+"]"),h=document.querySelectorAll(".js-"+s),u=i.makeArray(a).concat(i.makeArray(h)),c=r+"-options",d=t.jQuery;u.forEach(function(t){var i,s=t.getAttribute(r)||t.getAttribute(c);try{i=s&&JSON.parse(s)}catch(a){return void(n&&n.error("Error parsing "+r+" on "+t.className+": "+a))}var h=new e(t,i);d&&d.data(t,o,h)})})},i}),function(t,e){"function"==typeof define&&define.amd?define("outlayer/item",["ev-emitter/ev-emitter","get-size/get-size"],e):"object"==typeof module&&module.exports?module.exports=e(require("ev-emitter"),require("get-size")):(t.Outlayer={},t.Outlayer.Item=e(t.EvEmitter,t.getSize))}(window,function(t,e){"use strict";function i(t){for(var e in t)return!1;return e=null,!0}function n(t,e){t&&(this.element=t,this.layout=e,this.position={x:0,y:0},this._create())}function o(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}var s=document.documentElement.style,r="string"==typeof s.transition?"transition":"WebkitTransition",a="string"==typeof s.transform?"transform":"WebkitTransform",h={WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[r],u={transform:a,transition:r,transitionDuration:r+"Duration",transitionProperty:r+"Property"},c=n.prototype=Object.create(t.prototype);c.constructor=n,c._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},c.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},c.getSize=function(){this.size=e(this.element)},c.css=function(t){var e=this.element.style;for(var i in t){var n=u[i]||i;e[n]=t[i]}},c.getPosition=function(){var t=getComputedStyle(this.element),e=this.layout._getOption("originLeft"),i=this.layout._getOption("originTop"),n=t[e?"left":"right"],o=t[i?"top":"bottom"],s=this.layout.size,r=-1!=n.indexOf("%")?parseFloat(n)/100*s.width:parseInt(n,10),a=-1!=o.indexOf("%")?parseFloat(o)/100*s.height:parseInt(o,10);r=isNaN(r)?0:r,a=isNaN(a)?0:a,r-=e?s.paddingLeft:s.paddingRight,a-=i?s.paddingTop:s.paddingBottom,this.position.x=r,this.position.y=a},c.layoutPosition=function(){var t=this.layout.size,e={},i=this.layout._getOption("originLeft"),n=this.layout._getOption("originTop"),o=i?"paddingLeft":"paddingRight",s=i?"left":"right",r=i?"right":"left",a=this.position.x+t[o];e[s]=this.getXValue(a),e[r]="";var h=n?"paddingTop":"paddingBottom",u=n?"top":"bottom",c=n?"bottom":"top",d=this.position.y+t[h];e[u]=this.getYValue(d),e[c]="",this.css(e),this.emitEvent("layout",[this])},c.getXValue=function(t){var e=this.layout._getOption("horizontal");return this.layout.options.percentPosition&&!e?t/this.layout.size.width*100+"%":t+"px"},c.getYValue=function(t){var e=this.layout._getOption("horizontal");return this.layout.options.percentPosition&&e?t/this.layout.size.height*100+"%":t+"px"},c._transitionTo=function(t,e){this.getPosition();var i=this.position.x,n=this.position.y,o=parseInt(t,10),s=parseInt(e,10),r=o===this.position.x&&s===this.position.y;if(this.setPosition(t,e),r&&!this.isTransitioning)return void this.layoutPosition();var a=t-i,h=e-n,u={};u.transform=this.getTranslate(a,h),this.transition({to:u,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},c.getTranslate=function(t,e){var i=this.layout._getOption("originLeft"),n=this.layout._getOption("originTop");return t=i?t:-t,e=n?e:-e,"translate3d("+t+"px, "+e+"px, 0)"},c.goTo=function(t,e){this.setPosition(t,e),this.layoutPosition()},c.moveTo=c._transitionTo,c.setPosition=function(t,e){this.position.x=parseInt(t,10),this.position.y=parseInt(e,10)},c._nonTransition=function(t){this.css(t.to),t.isCleaning&&this._removeStyles(t.to);for(var e in t.onTransitionEnd)t.onTransitionEnd[e].call(this)},c.transition=function(t){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(t);var e=this._transn;for(var i in t.onTransitionEnd)e.onEnd[i]=t.onTransitionEnd[i];for(i in t.to)e.ingProperties[i]=!0,t.isCleaning&&(e.clean[i]=!0);if(t.from){this.css(t.from);var n=this.element.offsetHeight;n=null}this.enableTransition(t.to),this.css(t.to),this.isTransitioning=!0};var d="opacity,"+o(a);c.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:d,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(h,this,!1))},c.onwebkitTransitionEnd=function(t){this.ontransitionend(t)},c.onotransitionend=function(t){this.ontransitionend(t)};var f={"-webkit-transform":"transform"};c.ontransitionend=function(t){if(t.target===this.element){var e=this._transn,n=f[t.propertyName]||t.propertyName;if(delete e.ingProperties[n],i(e.ingProperties)&&this.disableTransition(),n in e.clean&&(this.element.style[t.propertyName]="",delete e.clean[n]),n in e.onEnd){var o=e.onEnd[n];o.call(this),delete e.onEnd[n]}this.emitEvent("transitionEnd",[this])}},c.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(h,this,!1),this.isTransitioning=!1},c._removeStyles=function(t){var e={};for(var i in t)e[i]="";this.css(e)};var l={transitionProperty:"",transitionDuration:""};return c.removeTransitionStyles=function(){this.css(l)},c.removeElem=function(){this.element.parentNode.removeChild(this.element),this.css({display:""}),this.emitEvent("remove",[this])},c.remove=function(){return r&&parseFloat(this.layout.options.transitionDuration)?(this.once("transitionEnd",function(){this.removeElem()}),void this.hide()):void this.removeElem()},c.reveal=function(){delete this.isHidden,this.css({display:""});var t=this.layout.options,e={},i=this.getHideRevealTransitionEndProperty("visibleStyle");e[i]=this.onRevealTransitionEnd,this.transition({from:t.hiddenStyle,to:t.visibleStyle,isCleaning:!0,onTransitionEnd:e})},c.onRevealTransitionEnd=function(){this.isHidden||this.emitEvent("reveal")},c.getHideRevealTransitionEndProperty=function(t){var e=this.layout.options[t];if(e.opacity)return"opacity";for(var i in e)return i},c.hide=function(){this.isHidden=!0,this.css({display:""});var t=this.layout.options,e={},i=this.getHideRevealTransitionEndProperty("hiddenStyle");e[i]=this.onHideTransitionEnd,this.transition({from:t.visibleStyle,to:t.hiddenStyle,isCleaning:!0,onTransitionEnd:e})},c.onHideTransitionEnd=function(){this.isHidden&&(this.css({display:"none"}),this.emitEvent("hide"))},c.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},n}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("outlayer/outlayer",["ev-emitter/ev-emitter","get-size/get-size","fizzy-ui-utils/utils","./item"],function(i,n,o,s){return e(t,i,n,o,s)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter"),require("get-size"),require("fizzy-ui-utils"),require("./item")):t.Outlayer=e(t,t.EvEmitter,t.getSize,t.f
vendor: 4,232 bytes, line 12
12izzyUIUtils,t.Outlayer.Item)}(window,function(t,e,i,n,o){"use strict";function s(t,e){var i=n.getQueryElement(t);if(!i)return void(a&&a.error("Bad element for "+this.constructor.namespace+": "+(i||t)));this.element=i,h&&(this.$element=h(this.element)),this.options=n.extend({},this.constructor.defaults),this.option(e);var o=++c;this.element.outlayerGUID=o,d[o]=this,this._create();var s=this._getOption("initLayout");s&&this.layout()}function r(t){function e(){t.apply(this,arguments)}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e}var a=t.console,h=t.jQuery,u=function(){},c=0,d={};s.namespace="outlayer",s.Item=o,s.defaults={containerStyle:{position:"relative"},initLayout:!0,originLeft:!0,originTop:!0,resize:!0,resizeContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}};var f=s.prototype;return n.extend(f,e.prototype),f.option=function(t){n.extend(this.options,t)},f._getOption=function(t){var e=this.constructor.compatOptions[t];return e&&void 0!==this.options[e]?this.options[e]:this.options[t]},s.compatOptions={initLayout:"isInitLayout",horizontal:"isHorizontal",layoutInstant:"isLayoutInstant",originLeft:"isOriginLeft",originTop:"isOriginTop",resize:"isResizeBound",resizeContainer:"isResizingContainer"},f._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),n.extend(this.element.style,this.options.containerStyle);var t=this._getOption("resize");t&&this.bindResize()},f.reloadItems=function(){this.items=this._itemize(this.element.children)},f._itemize=function(t){for(var e=this._filterFindItemElements(t),i=this.constructor.Item,n=[],o=0;o<e.length;o++){var s=e[o],r=new i(s,this);n.push(r)}return n},f._filterFindItemElements=function(t){return n.filterFindElements(t,this.options.itemSelector)},f.getItemElements=function(){return this.items.map(function(t){return t.element})},f.layout=function(){this._resetLayout(),this._manageStamps();var t=this._getOption("layoutInstant"),e=void 0!==t?t:!this._isLayoutInited;this.layoutItems(this.items,e),this._isLayoutInited=!0},f._init=f.layout,f._resetLayout=function(){this.getSize()},f.getSize=function(){this.size=i(this.element)},f._getMeasurement=function(t,e){var n,o=this.options[t];o?("string"==typeof o?n=this.element.querySelector(o):o instanceof HTMLElement&&(n=o),this[t]=n?i(n)[e]:o):this[t]=0},f.layoutItems=function(t,e){t=this._getItemsForLayout(t),this._layoutItems(t,e),this._postLayout()},f._getItemsForLayout=function(t){return t.filter(function(t){return!t.isIgnored})},f._layoutItems=function(t,e){if(this._emitCompleteOnItems("layout",t),t&&t.length){var i=[];t.forEach(function(t){var n=this._getItemLayoutPosition(t);n.item=t,n.isInstant=e||t.isLayoutInstant,i.push(n)},this),this._processLayoutQueue(i)}},f._getItemLayoutPosition=function(){return{x:0,y:0}},f._processLayoutQueue=function(t){t.forEach(function(t){this._positionItem(t.item,t.x,t.y,t.isInstant)},this)},f._positionItem=function(t,e,i,n){n?t.goTo(e,i):t.moveTo(e,i)},f._postLayout=function(){this.resizeContainer()},f.resizeContainer=function(){var t=this._getOption("resizeContainer");if(t){var e=this._getContainerSize();e&&(this._setContainerMeasure(e.width,!0),this._setContainerMeasure(e.height,!1))}},f._getContainerSize=u,f._setContainerMeasure=function(t,e){if(void 0!==t){var i=this.size;i.isBorderBox&&(t+=e?i.paddingLeft+i.paddingRight+i.borderLeftWidth+i.borderRightWidth:i.paddingBottom+i.paddingTop+i.borderTopWidth+i.borderBottomWidth),t=Math.max(t,0),this.element.style[e?"width":"height"]=t+"px"}},f._emitCompleteOnItems=function(t,e){function i(){o.dispatchEvent(t+"Complete",null,[e])}function n(){r++,r==s&&i()}var o=this,s=e.length;if(!e||!s)return void i();var r=0;e.forEach(function(e){e.once(t,n)})},f.dispatchEvent=function(t,e,i){var n=e?[e].concat(i):i;if(this.emitEvent(t,n),h)if(this.$element=this.$element||h(this.element),e){var o=h.Event(e);o.type=t,this.$element.trigger(o,i)}else this.$element.trigger(t,i)},f.ignore=function(t){var e=this.getItem(t);e&&(e.isIgnored=!0)},f.unignore=function(t){var e=this.getItem(t);e&&delete e.isIgnored},f.stamp=function(t){t=this._find(t),t&&(this.stamps=this.stamps.
vendor: 11,206 bytes, line 12
12concat(t),t.forEach(this.ignore,this))},f.unstamp=function(t){t=this._find(t),t&&t.forEach(function(t){n.removeFrom(this.stamps,t),this.unignore(t)},this)},f._find=function(t){return t?("string"==typeof t&&(t=this.element.querySelectorAll(t)),t=n.makeArray(t)):void 0},f._manageStamps=function(){this.stamps&&this.stamps.length&&(this._getBoundingRect(),this.stamps.forEach(this._manageStamp,this))},f._getBoundingRect=function(){var t=this.element.getBoundingClientRect(),e=this.size;this._boundingRect={left:t.left+e.paddingLeft+e.borderLeftWidth,top:t.top+e.paddingTop+e.borderTopWidth,right:t.right-(e.paddingRight+e.borderRightWidth),bottom:t.bottom-(e.paddingBottom+e.borderBottomWidth)}},f._manageStamp=u,f._getElementOffset=function(t){var e=t.getBoundingClientRect(),n=this._boundingRect,o=i(t),s={left:e.left-n.left-o.marginLeft,top:e.top-n.top-o.marginTop,right:n.right-e.right-o.marginRight,bottom:n.bottom-e.bottom-o.marginBottom};return s},f.handleEvent=n.handleEvent,f.bindResize=function(){t.addEventListener("resize",this),this.isResizeBound=!0},f.unbindResize=function(){t.removeEventListener("resize",this),this.isResizeBound=!1},f.onresize=function(){this.resize()},n.debounceMethod(s,"onresize",100),f.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},f.needsResizeLayout=function(){var t=i(this.element),e=this.size&&t;return e&&t.innerWidth!==this.size.innerWidth},f.addItems=function(t){var e=this._itemize(t);return e.length&&(this.items=this.items.concat(e)),e},f.appended=function(t){var e=this.addItems(t);e.length&&(this.layoutItems(e,!0),this.reveal(e))},f.prepended=function(t){var e=this._itemize(t);if(e.length){var i=this.items.slice(0);this.items=e.concat(i),this._resetLayout(),this._manageStamps(),this.layoutItems(e,!0),this.reveal(e),this.layoutItems(i)}},f.reveal=function(t){this._emitCompleteOnItems("reveal",t),t&&t.length&&t.forEach(function(t){t.reveal()})},f.hide=function(t){this._emitCompleteOnItems("hide",t),t&&t.length&&t.forEach(function(t){t.hide()})},f.revealItemElements=function(t){var e=this.getItems(t);this.reveal(e)},f.hideItemElements=function(t){var e=this.getItems(t);this.hide(e)},f.getItem=function(t){for(var e=0;e<this.items.length;e++){var i=this.items[e];if(i.element==t)return i}},f.getItems=function(t){t=n.makeArray(t);var e=[];return t.forEach(function(t){var i=this.getItem(t);i&&e.push(i)},this),e},f.remove=function(t){var e=this.getItems(t);this._emitCompleteOnItems("remove",e),e&&e.length&&e.forEach(function(t){t.remove(),n.removeFrom(this.items,t)},this)},f.destroy=function(){var t=this.element.style;t.height="",t.position="",t.width="",this.items.forEach(function(t){t.destroy()}),this.unbindResize();var e=this.element.outlayerGUID;delete d[e],delete this.element.outlayerGUID,h&&h.removeData(this.element,this.constructor.namespace)},s.data=function(t){t=n.getQueryElement(t);var e=t&&t.outlayerGUID;return e&&d[e]},s.create=function(t,e){var i=r(s);return i.defaults=n.extend({},s.defaults),n.extend(i.defaults,e),i.compatOptions=n.extend({},s.compatOptions),i.namespace=t,i.data=s.data,i.Item=r(o),n.htmlInit(i,t),h&&h.bridget&&h.bridget(t,i),i},s.Item=o,s}),function(t,e){"function"==typeof define&&define.amd?define("packery/rect",e):"object"==typeof module&&module.exports?module.exports=e():(t.Packery=t.Packery||{},t.Packery.Rect=e())}(window,function(){"use strict";function t(e){for(var i in t.defaults)this[i]=t.defaults[i];for(i in e)this[i]=e[i]}t.defaults={x:0,y:0,width:0,height:0};var e=t.prototype;return e.contains=function(t){var e=t.width||0,i=t.height||0;return this.x<=t.x&&this.y<=t.y&&this.x+this.width>=t.x+e&&this.y+this.height>=t.y+i},e.overlaps=function(t){var e=this.x+this.width,i=this.y+this.height,n=t.x+t.width,o=t.y+t.height;return this.x<n&&e>t.x&&this.y<o&&i>t.y},e.getMaximalFreeRects=function(e){if(!this.overlaps(e))return!1;var i,n=[],o=this.x+this.width,s=this.y+this.height,r=e.x+e.width,a=e.y+e.height;return this.y<e.y&&(i=new t({x:this.x,y:this.y,width:this.width,height:e.y-this.y}),n.push(i)),o>r&&(i=new t({x:r,y:this.y,width:o-r,height:this.height}),n.push(i)),s>a&&(i=new t({x:this.x,y:a,width:this.width,height:s-a}),n.push(i)),this.x<e.x&&(i=new t({x:this.x,y:this.y,width:e.x-this.x,height:this.height}),n.push(i)),n},e.canFit=function(t){return this.width>=t.width&&this.height>=t.height},t}),function(t,e){if("function"==typeof define&&define.amd)define("packery/packer",["./rect"],e);else if("object"==typeof module&&module.exports)module.exports=e(require("./rect"));else{var i=t.Packery=t.Packery||{};i.Packer=e(i.Rect)}}(window,function(t){"use strict";function e(t,e,i){this.width=t||0,this.height=e||0,this.sortDirection=i||"downwardLeftToRight",this.reset()}var i=e.prototype;i.reset=function(){this.spaces=[];var e=new t({x:0,y:0,width:this.width,height:this.height});this.spaces.push(e),this.sorter=n[this.sortDirection]||n.downwardLeftToRight},i.pack=function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e];if(i.canFit(t)){this.placeInSpace(t,i);break}}},i.columnPack=function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e],n=i.x<=t.x&&i.x+i.width>=t.x+t.width&&i.height>=t.height-.01;if(n){t.y=i.y,this.placed(t);break}}},i.rowPack=function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e],n=i.y<=t.y&&i.y+i.height>=t.y+t.height&&i.width>=t.width-.01;if(n){t.x=i.x,this.placed(t);break}}},i.placeInSpace=function(t,e){t.x=e.x,t.y=e.y,this.placed(t)},i.placed=function(t){for(var e=[],i=0;i<this.spaces.length;i++){var n=this.spaces[i],o=n.getMaximalFreeRects(t);o?e.push.apply(e,o):e.push(n)}this.spaces=e,this.mergeSortSpaces()},i.mergeSortSpaces=function(){e.mergeRects(this.spaces),this.spaces.sort(this.sorter)},i.addSpace=function(t){this.spaces.push(t),this.mergeSortSpaces()},e.mergeRects=function(t){var e=0,i=t[e];t:for(;i;){for(var n=0,o=t[e+n];o;){if(o==i)n++;else{if(o.contains(i)){t.splice(e,1),i=t[e];continue t}i.contains(o)?t.splice(e+n,1):n++}o=t[e+n]}e++,i=t[e]}return t};var n={downwardLeftToRight:function(t,e){return t.y-e.y||t.x-e.x},rightwardTopToBottom:function(t,e){return t.x-e.x||t.y-e.y}};return e}),function(t,e){"function"==typeof define&&define.amd?define("packery/item",["outlayer/outlayer","./rect"],e):"object"==typeof module&&module.exports?module.exports=e(require("outlayer"),require("./rect")):t.Packery.Item=e(t.Outlayer,t.Packery.Rect)}(window,function(t,e){"use strict";var i=document.documentElement.style,n="string"==typeof i.transform?"transform":"WebkitTransform",o=function(){t.Item.apply(this,arguments)},s=o.prototype=Object.create(t.Item.prototype),r=s._create;s._create=function(){r.call(this),this.rect=new e};var a=s.moveTo;return s.moveTo=function(t,e){var i=Math.abs(this.position.x-t),n=Math.abs(this.position.y-e),o=this.layout.dragItemCount&&!this.isPlacing&&!this.isTransitioning&&1>i&&1>n;return o?void this.goTo(t,e):void a.apply(this,arguments)},s.enablePlacing=function(){this.removeTransitionStyles(),this.isTransitioning&&n&&(this.element.style[n]="none"),this.isTransitioning=!1,this.getSize(),this.layout._setRectSize(this.element,this.rect),this.isPlacing=!0},s.disablePlacing=function(){this.isPlacing=!1},s.removeElem=function(){this.element.parentNode.removeChild(this.element),this.layout.packer.addSpace(this.rect),this.emitEvent("remove",[this])},s.showDropPlaceholder=function(){var t=this.dropPlaceholder;t||(t=this.dropPlaceholder=document.createElement("div"),t.className="packery-drop-placeholder",t.style.position="absolute"),t.style.width=this.size.width+"px",t.style.height=this.size.height+"px",this.positionDropPlaceholder(),this.layout.element.appendChild(t)},s.positionDropPlaceholder=function(){this.dropPlaceholder.style[n]="translate("+this.rect.x+"px, "+this.rect.y+"px)"},s.hideDropPlaceholder=function(){this.layout.element.removeChild(this.dropPlaceholder)},o}),function(t,e){"function"==typeof define&&define.amd?define(["get-size/get-size","outlayer/outlayer","./rect","./packer","./item"],e):"object"==typeof module&&module.exports?module.exports=e(require("get-size"),require("outlayer"),require("./rect"),require("./packer"),require("./item")):t.Packery=e(t.getSize,t.Outlayer,t.Packery.Rect,t.Packery.Packer,t.Packery.Item)}(window,function(t,e,i,n,o){"use strict";function s(t,e){return t.position.y-e.position.y||t.position.x-e.position.x}function r(t,e){return t.position.x-e.position.x||t.position.y-e.position.y}function a(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}i.prototype.canFit=function(t){return this.width>=t.width-1&&this.height>=t.height-1};var h=e.create("packery");h.Item=o;var u=h.prototype;u._create=function(){e.prototype._create.call(this),this.packer=new n,this.shiftPacker=new n,this.isEnabled=!0,this.dragItemCount=0;var t=this;this.handleDraggabilly={dragStart:function(){t.itemDragStart(this.element)},dragMove:function(){t.itemDragMove(this.element,this.position.x,this.position.y)},dragEnd:function(){t.itemDragEnd(this.element)}},this.handleUIDraggable={start:function(e,i){i&&t.itemDragStart(e.currentTarget)},drag:function(e,i){i&&t.itemDragMove(e.currentTarget,i.position.left,i.position.top)},stop:function(e,i){i&&t.itemDragEnd(e.currentTarget)}}},u._resetLayout=function(){this.getSize(),this._getMeasurements();var t,e,i;this._getOption("horizontal")?(t=1/0,e=this.size.innerHeight+this.gutter,i="rightwardTopToBottom"):(t=this.size.innerWidth+this.gutter,e=1/0,i="downwardLeftToRight"),this.packer.width=this.shiftPacker.width=t,this.packer.height=this.shiftPacker.height=e,this.packer.sortDirection=this.shiftPacker.sortDirection=i,this.packer.reset(),this.maxY=0,this.maxX=0},u._getMeasurements=function(){this._getMeasurement("columnWidth","width"),this._getMeasurement("rowHeight","height"),this._getMeasurement("gutter","width")},u._getItemLayoutPosition=function(t){if(this._setRectSize(t.element,t.rect),this.isShifting||this.dragItemCount>0){var e=this._getPackMethod();this.packer[e](t.rect)}else this.packer.pack(t.rect);return this._setMaxXY(t.rect),t.rect},u.shiftLayout=function(){this.isShifting=!0,this.layout(),delete this.isShifting},u._getPackMethod=function(){return this._getOption("horizontal")?"rowPack":"columnPack"},u._setMaxXY=function(t){this.maxX=Math.max(t.x+t.width,this.maxX),this.maxY=Math.max(t.y+t.height,this.maxY)},u._setRectSize=function(e,i){var n=t(e),o=n.outerWidth,s=n.outerHeight;(o||s)&&(o=this._applyGridGutter(o,this.columnWidth),s=this._applyGridGutter(s,this.rowHeight)),i.width=Math.min(o,this.packer.width),i.height=Math.min(s,this.packer.height)},u._applyGridGutter=function(t,e){if(!e)return t+this.gutter;e+=this.gutter;var i=t%e,n=i&&1>i?"round":"ceil";return t=Math[n](t/e)*e},u._getContainerSize=function(){return this._getOption("horizontal")?{width:this.maxX-this.gutter}:{height:this.maxY-this.gutter}},u._manageStamp=function(t){var e,n=this.getItem(t);if(n&&n.isPlacing)e=n.rect;else{var o=this._getElementOffset(t);e=new i({x:this._getOption("originLeft")?o.left:o.right,y:this._getOption("originTop")?o.top:o.bottom})}this._setRectSize(t,e),this.packer.placed(e),this._setMaxXY(e)},u.sortItemsByPosition=function(){var t=this._getOption("horizontal")?r:s;this.items.sort(t)}
vendor: 4,840 bytes, lines 12-25
12,u.fit=function(t,e,i){var n=this.getItem(t);n&&(this.stamp(n.element),n.enablePlacing(),this.updateShiftTargets(n),e=void 0===e?n.rect.x:e,i=void 0===i?n.rect.y:i,this.shift(n,e,i),this._bindFitEvents(n),n.moveTo(n.rect.x,n.rect.y),this.shiftLayout(),this.unstamp(n.element),this.sortItemsByPosition(),n.disablePlacing())},u._bindFitEvents=function(t){function e(){n++,2==n&&i.dispatchEvent("fitComplete",null,[t])}var i=this,n=0;t.once("layout",e),this.once("layoutComplete",e)},u.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&(this.options.shiftPercentResize?this.resizeShiftPercentLayout():this.layout())},u.needsResizeLayout=function(){var e=t(this.element),i=this._getOption("horizontal")?"innerHeight":"innerWidth";return e[i]!=this.size[i]},u.resizeShiftPercentLayout=function(){var e=this._getItemsForLayout(this.items),i=this._getOption("horizontal"),n=i?"y":"x",o=i?"height":"width",s=i?"rowHeight":"columnWidth",r=i?"innerHeight":"innerWidth",a=this[s];if(a=a&&a+this.gutter){this._getMeasurements();var h=this[s]+this.gutter;e.forEach(function(t){var e=Math.round(t.rect[n]/a);t.rect[n]=e*h})}else{var u=t(this.element)[r]+this.gutter,c=this.packer[o];e.forEach(function(t){t.rect[n]=t.rect[n]/c*u})}this.shiftLayout()},u.itemDragStart=function(t){if(this.isEnabled){this.stamp(t);var e=this.getItem(t);e&&(e.enablePlacing(),e.showDropPlaceholder(),this.dragItemCount++,this.updateShiftTargets(e))}},u.updateShiftTargets=function(t){this.shiftPacker.reset(),this._getBoundingRect();var e=this._getOption("originLeft"),n=this._getOption("originTop");this.stamps.forEach(function(t){var o=this.getItem(t);if(!o||!o.isPlacing){var s=this._getElementOffset(t),r=new i({x:e?s.left:s.right,y:n?s.top:s.bottom});this._setRectSize(t,r),this.shiftPacker.placed(r)}},this);var o=this._getOption("horizontal"),s=o?"rowHeight":"columnWidth",r=o?"height":"width";this.shiftTargetKeys=[],this.shiftTargets=[];var a,h=this[s];if(h=h&&h+this.gutter){var u=Math.ceil(t.rect[r]/h),c=Math.floor((this.shiftPacker[r]+this.gutter)/h);a=(c-u)*h;for(var d=0;c>d;d++)this._addShiftTarget(d*h,0,a)}else a=this.shiftPacker[r]+this.gutter-t.rect[r],this._addShiftTarget(0,0,a);var f=this._getItemsForLayout(this.items),l=this._getPackMethod();f.forEach(function(t){var e=t.rect;this._setRectSize(t.element,e),this.shiftPacker[l](e),this._addShiftTarget(e.x,e.y,a);var i=o?e.x+e.width:e.x,n=o?e.y:e.y+e.height;if(this._addShiftTarget(i,n,a),h)for(var s=Math.round(e[r]/h),u=1;s>u;u++){var c=o?i:e.x+h*u,d=o?e.y+h*u:n;this._addShiftTarget(c,d,a)}},this)},u._addShiftTarget=function(t,e,i){var n=this._getOption("horizontal")?e:t;if(!(0!==n&&n>i)){var o=t+","+e,s=-1!=this.shiftTargetKeys.indexOf(o);s||(this.shiftTargetKeys.push(o),this.shiftTargets.push({x:t,y:e}))}},u.shift=function(t,e,i){var n,o=1/0,s={x:e,y:i};this.shiftTargets.forEach(function(t){var e=a(t,s);o>e&&(n=t,o=e)}),t.rect.x=n.x,t.rect.y=n.y};var c=120;u.itemDragMove=function(t,e,i){function n(){s.shift(o,e,i),o.positionDropPlaceholder(),s.layout()}var o=this.isEnabled&&this.getItem(t);if(o){e-=this.size.paddingLeft,i-=this.size.paddingTop;var s=this,r=new Date;this._itemDragTime&&r-this._itemDragTime<c?(clearTimeout(this.dragTimeout),this.dragTimeout=setTimeout(n,c)):(n(),this._itemDragTime=r)}},u.itemDragEnd=function(t){function e(){n++,2==n&&(i.element.classList.remove("is-positioning-post-drag"),i.hideDropPlaceholder(),o.dispatchEvent("dragItemPositioned",null,[i]))}var i=this.isEnabled&&this.getItem(t);if(i){clearTimeout(this.dragTimeout),i.element.classList.add("is-positioning-post-drag");var n=0,o=this;i.once("layout",e),this.once("layoutComplete",e),i.moveTo(i.rect.x,i.rect.y),this.layout(),this.dragItemCount=Math.max(0,this.dragItemCount-1), 13this.sortItemsByPosition(),i.disablePlacing(),this.unstamp(i.element)}},u.bindDraggabillyEvents=function(t){this._bindDraggabillyEvents(t,"on")},u.unbindDraggabillyEvents=function(t){this._bindDraggabillyEvents(t,"off")},u._bindDraggabillyEvents=function(t,e){var i=this.handleDraggabilly;t[e]("dragStart",i.dragStart),t[e]("dragMove",i.dragMove),t[e]("dragEnd",i.dragEnd)},u.bindUIDraggableEvents=function(t){this._bindUIDraggableEvents(t,"on")},u.unbindUIDraggableEvents=function(t){this._bindUIDraggableEvents(t,"off")},u._bindUIDraggableEvents=function(t,e){var i=this.handleUIDraggable;t[e]("dragstart",i.start)[e]("drag",i.drag)[e]("dragstop",i.stop)};var d=u.destroy;return u.destroy=function(){d.apply(this,arguments),this.isEnabled=!1},h.Rect=i,h.Packer=n,h}); 14 15/** 16 * A Twitter library in JavaScript 17 * 18 * @package codebird 19 * @version 2.5.0 20 * @author Jublo Solutions <[email protected]> 21 * @copyright 2010-2014 Jublo Solutions <[email protected]> 22 * @license http://opensource.org/licenses/GPL-3.0 GNU Public License 3.0 23 * @link https://github.com/jublonet/codebird-php 24 */ 25
26/* jshint curly: true, 27 eqeqeq: true, 28 latedef: true, 29 quotmark: double, 30 undef: true, 31 unused: true, 32 trailing: true, 33 laxbreak: true */ 34/* global window, 35 document, 36 navigator, 37 console, 38 Ti, 39 ActiveXObject, 40 module, 41 define, 42 require */ 43(function (undefined) { 44"use strict"; 45 46/** 47 * Array.indexOf polyfill 48 */ 49if (! Array.prototype.indexOf) { 50 Array.prototype.indexOf = function (obj, start) { 51 for (var i = (start || 0); i < this.length; i++) { 52 if (this[i] === obj) { 53 return i; 54 } 55 } 56 return -1; 57 }; 58} 59 60/** 61 * A Twitter library in JavaScript 62 * 63 * @package codebird 64 * @subpackage codebird-js 65 */ 66/* jshint -W098 */ 67var Codebird = function () { 68/* jshint +W098 */ 69 70 /** 71 * The OAuth consumer key of your registered app 72 */ 73 var _oauth_consumer_key = null; 74 75 /** 76 * The corresponding consumer secret 77 */ 78 var _oauth_consumer_secret = null; 79 80 /** 81 * The app-only bearer token. Used to authorize app-only requests 82 */ 83 var _oauth_bearer_token = null; 84 85 /** 86 * The API endpoint base to use 87 */ 88 var _endpoint_base = "https://api.twitter.com/"; 89 90 /** 91 * The media API endpoint base to use 92 */ 93 var _endpoint_base_media = "https://upload.twitter.com/"; 94 95 /** 96 * The API endpoint to use 97 */ 98 var _endpoint = _endpoint_base + "1.1/"; 99 100 /** 101 * The media API endpoint to use 102 */ 103 var _endpoint_media = _endpoint_base_media + "1.1/"; 104 105 /** 106 * The API endpoint base to use 107 */ 108 var _endpoint_oauth = _endpoint_base; 109 110 /** 111 * API proxy endpoint 112 */ 113 var _endpoint_proxy = "https://api.jublo.net/codebird/"; 114 115 /** 116 * The API endpoint to use for old requests 117 */ 118 var _endpoint_old = _endpoint_base + "1/"; 119 120 /** 121 * Use JSONP for GET requests in IE7-9 122 */ 123 var _use_jsonp = (typeof navigator !== "undefined" 124 && typeof navigator.userAgent !== "undefined" 125 && (navigator.userAgent.indexOf("Trident/4") > -1 126 || navigator.userAgent.indexOf("Trident/5") > -1 127 || navigator.userAgent.indexOf("MSIE 7.0") > -1 128 ) 129 ); 130 131 /** 132 * Whether to access the API via a proxy that is allowed by CORS 133 * Assume that CORS is only necessary in browsers 134 */ 135 var _use_proxy = (typeof navigator !== "undefined" 136 && typeof navigator.userAgent !== "undefined" 137 ); 138 139 /** 140 * The Request or access token. Used to sign requests 141 */ 142 var _oauth_token = null; 143 144 /** 145 * The corresponding request or access token secret 146 */ 147 var _oauth_token_secret = null; 148 149 /** 150 * The current Codebird version 151 */ 152 var _version = "2.5.0"; 153 154 /** 155 * Sets the OAuth consumer key and secret (App key) 156 * 157 * @param string key OAuth consumer key 158 * @param string secret OAuth consumer secret 159 * 160 * @return void 161 */ 162 var setConsumerKey = function (key, secret) { 163 _oauth_consumer_key = key; 164 _oauth_consumer_secret = secret; 165 }; 166 167 /** 168 * Sets the OAuth2 app-only auth bearer token 169 * 170 * @param string token OAuth2 bearer token 171 * 172 * @return void 173 */ 174 var setBearerToken = function (token) { 175 _oauth_bearer_token = token; 176 }; 177 178 /** 179 * Gets the current Codebird version 180 * 181 * @return string The version number 182 */ 183 var getVersion = function () { 184 return _version; 185 }; 186 187 /** 188 * Sets the OAuth request or access token and secret (User key) 189 * 190 * @param string token OAuth request or access token 191 * @param string secret OAuth request or access token secret 192 * 193 * @return void 194 */ 195 var setToken = function (token, secret) { 196 _oauth_token = token; 197 _oauth_token_secret = secret; 198 }; 199 200 /** 201 * Enables or disables CORS proxy 202 * 203 * @param bool use_proxy Whether to use CORS proxy or not 204 * 205 * @return void 206 */ 207 var setUseProxy = function (use_proxy) { 208 _use_proxy = !! use_proxy; 209 }; 210 211 /** 212 * Sets custom CORS proxy server 213 * 214 * @param string proxy Address of proxy server to use 215 * 216 * @return void 217 */ 218 var setProxy = function (proxy) { 219 // add trailing slash if missing 220 if (! proxy.match(/\/$/)) { 221 proxy += "/"; 222 } 223 _endpoint_proxy = proxy; 224 }; 225 226 /** 227 * Parse URL-style parameters into object 228 * 229 * version: 1109.2015 230 * discuss at: http://phpjs.org/functions/parse_str 231 * + original by: Cagri Ekin 232 * + improved by: Michael White (http://getsprink.com) 233 * + tweaked by: Jack 234 * + bugfixed by: Onno Marsman 235 * + reimplemented by: stag019 236 * + bugfixed by: Brett Zamir (http://brett-zamir.me) 237 * + bugfixed by: stag019 238 * - depends on: urldecode 239 * + input by: Dreamer 240 * + bugfixed by: Brett Zamir (http://brett-zamir.me) 241 * % note 1: When no argument is specified, will put variables in global scope. 242 * 243 * @param string str String to parse 244 * @param array array to load data into 245 * 246 * @return object 247 */ 248 var _parse_str = function (str, array) { 249 var glue1 = "=", 250 glue2 = "&", 251 array2 = String(str).replace(/^&?([\s\S]*?)&?$/, "$1").split(glue2), 252 i, j, chr, tmp, key, value, bracket, keys, evalStr, 253 fixStr = function (str) { 254 return decodeURIComponent(str).replace(/([\\"'])/g, "\\$1").replace(/\n/g, "\\n").replace(/\r/g, "\\r"); 255 }; 256 if (! array) { 257 array = this.window; 258 } 259 260 for (i = 0; i < array2.length; i++) { 261 tmp = array2[i].split(glue1); 262 if (tmp.length < 2) { 263 tmp = [tmp, ""]; 264 } 265 key = fixStr(tmp[0]); 266 value = fixStr(tmp[1]); 267 while (key.charAt(0) === " ") { 268 key = key.substr(1); 269 } 270 if (key.indexOf("\0") !== -1) { 271 key = key.substr(0, key.indexOf("\0")); 272 } 273 if (key && key.charAt(0) !== "[") { 274 keys = []; 275 bracket = 0; 276 for (j = 0; j < key.length; j++) { 277 if (key.charAt(j) === "[" && !bracket) { 278 bracket = j + 1; 279 } else if (key.charAt(j) === "]") { 280 if (bracket) { 281 if (!keys.length) { 282 keys.push(key.substr(0, bracket - 1)); 283 } 284 keys.push(key.substr(bracket, j - bracket)); 285 bracket = 0; 286 if (key.charAt(j + 1) !== "[") { 287 break; 288 } 289 } 290 } 291 } 292 if (!keys.length) { 293 keys = [key]; 294 } 295 for (j = 0; j < keys[0].length; j++) {
296 chr = keys[0].charAt(j); 297 if (chr === " " || chr === "." || chr === "[") { 298 keys[0] = keys[0].substr(0, j) + "_" + keys[0].substr(j + 1); 299 } 300 if (chr === "[") { 301 break; 302 } 303 } 304 /* jshint -W061 */ 305 evalStr = "array"; 306 for (j = 0; j < keys.length; j++) { 307 key = keys[j]; 308 if ((key !== "" && key !== " ") || j === 0) { 309 key = "'" + key + "'"; 310 } else { 311 key = eval(evalStr + ".push([]);") - 1; 312 } 313 evalStr += "[" + key + "]"; 314 if (j !== keys.length - 1 && eval("typeof " + evalStr) === "undefined") { 315 eval(evalStr + " = [];"); 316 } 317 } 318 evalStr += " = '" + value + "';\n"; 319 eval(evalStr); 320 /* jshint +W061 */ 321 } 322 } 323 }; 324 325 /** 326 * Main API handler working on any requests you issue 327 * 328 * @param string fn The member function you called 329 * @param array params The parameters you sent along 330 * @param function callback The callback to call with the reply 331 * @param bool app_only_auth Whether to use app-only auth 332 * 333 * @return mixed The API reply encoded in the set return_format 334 */ 335 336 var __call = function (fn, params, callback, app_only_auth) { 337 if (typeof params === "undefined") { 338 params = {}; 339 } 340 if (typeof app_only_auth === "undefined") { 341 app_only_auth = false; 342 } 343 if (typeof callback !== "function" && typeof params === "function") { 344 callback = params; 345 params = {}; 346 if (typeof callback === "boolean") { 347 app_only_auth = callback; 348 } 349 } else if (typeof callback === "undefined") { 350 callback = function () {}; 351 } 352 switch (fn) { 353 case "oauth_authenticate": 354 case "oauth_authorize": 355 return this[fn](params, callback); 356 357 case "oauth2_token": 358 return this[fn](callback); 359 } 360 // reset token when requesting a new token (causes 401 for signature error on 2nd+ requests) 361 if (fn === "oauth_requestToken") { 362 setToken(null, null); 363 } 364 // parse parameters 365 var apiparams = {}; 366 if (typeof params === "object") { 367 apiparams = params; 368 } else { 369 _parse_str(params, apiparams); //TODO 370 } 371 372 // map function name to API method 373 var method = ""; 374 var param, i, j; 375 376 // replace _ by / 377 var path = fn.split("_"); 378 for (i = 0; i < path.length; i++) { 379 if (i > 0) { 380 method += "/"; 381 } 382 method += path[i]; 383 } 384 385 // undo replacement for URL parameters 386 var url_parameters_with_underscore = ["screen_name", "place_id"]; 387 for (i = 0; i < url_parameters_with_underscore.length; i++) { 388 param = url_parameters_with_underscore[i].toUpperCase(); 389 var replacement_was = param.split("_").join("/"); 390 method = method.split(replacement_was).join(param); 391 } 392 393 // replace AA by URL parameters 394 var method_template = method; 395 var match = method.match(/[A-Z_]{2,}/); 396 if (match) { 397 for (i = 0; i < match.length; i++) { 398 param = match[i]; 399 var param_l = param.toLowerCase(); 400 method_template = method_template.split(param).join(":" + param_l); 401 if (typeof apiparams[param_l] === "undefined") { 402 for (j = 0; j < 26; j++) { 403 method_template = method_template.split(String.fromCharCode(65 + j)).join("_" + String.fromCharCode(97 + j)); 404 } 405 console.warn("To call the templated method \"" + method_template + "\", specify the parameter value for \"" + param_l + "\"."); 406 } 407 method = method.split(param).join(apiparams[param_l]); 408 delete apiparams[param_l]; 409 } 410 } 411 412 // replace A-Z by _a-z 413 for (i = 0; i < 26; i++) { 414 method = method.split(String.fromCharCode(65 + i)).join("_" + String.fromCharCode(97 + i)); 415 method_template = method_template.split(String.fromCharCode(65 + i)).join("_" + String.fromCharCode(97 + i)); 416 } 417 418 var httpmethod = _detectMethod(method_template, apiparams); 419 var multipart = _detectMultipart(method_template); 420 var internal = _detectInternal(method_template); 421 422 return _callApi( 423 httpmethod, 424 method, 425 apiparams, 426 multipart, 427 app_only_auth, 428 internal, 429 callback 430 ); 431 }; 432 433 /** 434 * Gets the OAuth authenticate URL for the current request token 435 * 436 * @return string The OAuth authenticate URL 437 */ 438 var oauth_authenticate = function (params, callback) { 439 if (typeof params.force_login === "undefined") { 440 params.force_login = null; 441 } 442 if (typeof params.screen_name === "undefined") { 443 params.screen_name = null; 444 } 445 if (_oauth_token === null) { 446 console.warn("To get the authenticate URL, the OAuth token must be set."); 447 } 448 var url = _endpoint_oauth + "oauth/authenticate?oauth_token=" + _url(_oauth_token); 449 if (params.force_login === true) { 450 url += "?force_login=1"; 451 if (params.screen_name !== null) { 452 url += "&screen_name=" + params.screen_name; 453 } 454 } 455 callback(url); 456 return true; 457 }; 458 459 /** 460 * Gets the OAuth authorize URL for the current request token 461 * 462 * @return string The OAuth authorize URL 463 */ 464 var oauth_authorize = function (params, callback) { 465 if (typeof params.force_login === "undefined") { 466 params.force_login = null; 467 } 468 if (typeof params.screen_name === "undefined") { 469 params.screen_name = null; 470 } 471 if (_oauth_token === null) { 472 console.warn("To get the authorize URL, the OAuth token must be set."); 473 } 474 var url = _endpoint_oauth + "oauth/authorize?oauth_token=" + _url(_oauth_token); 475 if (params.force_login === true) { 476 url += "?force_login=1"; 477 if (params.screen_name !== null) { 478 url += "&screen_name=" + params.screen_name; 479 } 480 } 481 callback(url); 482 return true; 483 }; 484 485 /** 486 * Gets the OAuth bearer token 487 * 488 * @return string The OAuth bearer token 489 */ 490 491 var oauth2_token = function (callback) { 492 if (_oauth_consumer_key === null) { 493 console.warn("To obtain a bearer token, the consumer key must be set."); 494 } 495 496 if (typeof callback === "undefined") { 497 callback = function () {}; 498 } 499 500 var post_fields = "grant_type=client_credentials"; 501 var url = _endpoint_oauth + "oauth2/token"; 502 503 if (_use_proxy) { 504 url = url.replace( 505 _endpoint_base, 506 _endpoint_proxy 507 ); 508 } 509 510 var xml = _getXmlRequestObject(); 511 if (xml === null) { 512 return; 513 } 514 xml.open("POST", url, true); 515 xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 516 xml.setRequestHeader( 517 (_use_proxy ? "X-" : "") + "Authorization", 518 "Basic " + _base64_encode(_oauth_consumer_key + ":" + _oauth_consumer_secret) 519 ); 520 521 xml.onreadystatechange = function () { 522 if (xml.readyState >= 4) { 523 var httpstatus = 12027; 524 try { 525 httpstatus = xml.status; 526 } catch (e) {} 527 var response = ""; 528 try { 529 response = xml.responseText; 530 } catch (e) {} 531 var reply = _parseApiReply(response); 532 reply.httpstatus = httpstatus; 533 if (httpstatus === 200) { 534 setBearerToken(reply.access_token); 535 } 536 callback(reply); 537 } 538 }; 539 xml.send(post_fields); 540 541 }; 542 543 /** 544 * Signing helpers 545 */ 546 547 /** 548 * URL-encodes the given data 549 * 550 * @param mixed data 551 * 552 * @return mixed The encoded data 553 */ 554 var _url = function (data) { 555 if ((/boolean|number|string/).test(typeof data)) { 556 return encodeURIComponent(data).replace(/!/g, "%21").replace(/'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\*/g, "%2A"); 557 } else { 558 return ""; 559 } 560 }; 561 562 /** 563 * Gets the base64-encoded SHA1 hash for the given data 564 * 565 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined 566 * in FIPS PUB 180-1 567 * Based on version 2.1 Copyright Paul Johnston 2000 - 2002. 568 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 569 * Distributed under the BSD License 570 * See http://pajhome.org.uk/crypt/md5 for details. 571 * 572 * @param string data The data to calculate the hash from 573 * 574 * @return string The hash 575 */ 576 var _sha1 = function () { 577 function n(e, b) { 578 e[b >> 5] |= 128 << 24 - b % 32; 579 e[(b + 64 >> 9 << 4) + 15] = b; 580 for (var c = new Array(80), a = 1732584193, d = -271733879, h = -1732584194, 581 k = 271733878, g = -1009589776, p = 0; p < e.length; p += 16) { 582 for (var o = a, q = d, r = h, s = k, t = g, f = 0; 80 > f; f++) { 583 var m; 584 585 if (f < 16) { 586 m = e[p + f]; 587 } else { 588 m = c[f - 3] ^ c[f - 8] ^ c[f - 14] ^ c[f - 16]; 589 m = m << 1 | m >>> 31; 590 } 591 592 c[f] = m; 593 m = l(l(a << 5 | a >>> 27, 20 > f ? d & h | ~d & k : 40 > f ? d ^ 594 h ^ k : 60 > f ? d & h | d & k | h & k : d ^ h ^ k), l( 595 l(g, c[f]), 20 > f ? 1518500249 : 40 > f ? 1859775393 : 596 60 > f ? -1894007588 : -899497514)); 597 g = k; 598 k = h; 599 h = d << 30 | d >>> 2; 600 d = a; 601 a = m; 602 } 603 a = l(a, o); 604 d = l(d, q); 605 h = l(h, r); 606 k = l(k, s); 607 g = l(g, t); 608 } 609 return [a, d, h, k, g]; 610 } 611 612 function l(e, b) { 613 var c = (e & 65535) + (b & 65535); 614 return (e >> 16) + (b >> 16) + (c >> 16) << 16 | c & 65535; 615 } 616 617 function q(e) { 618 for (var b = [], c = (1 << g) - 1, a = 0; a < e.length * g; a += g) { 619 b[a >> 5] |= (e.charCodeAt(a / g) & c) << 24 - a % 32; 620 } 621 return b; 622 } 623 var g = 8; 624 return function (e) { 625 var b = _oauth_consumer_secret + "&" + (null !== _oauth_token_secret ? 626 _oauth_token_secret : ""); 627 if (_oauth_consumer_secret === null) { 628 console.warn("To generate a hash, the consumer secret must be set."); 629 } 630 var c = q(b); 631 if (c.length > 16) { 632 c = n(c, b.length * g); 633 } 634 b = new Array(16); 635 for (var a = new Array(16), d = 0; d < 16; d++) { 636 a[d] = c[d] ^ 909522486; 637 b[d] = c[d] ^ 1549556828; 638 } 639 c = n(a.concat(q(e)), 512 + e.length * g); 640 b = n(b.concat(c), 672); 641 c = ""; 642 for (a = 0; a < 4 * b.length; a += 3) { 643 for (d = (b[a >> 2] >> 8 * (3 - a % 4) & 255) << 16 | (b[a + 1 >> 2] >> 644 8 * (3 - (a + 1) % 4) & 255) << 8 | b[a + 2 >> 2] >> 8 * (3 - 645 (a + 2) % 4) & 255, e = 0; 4 > e; e++) { 646 c = 8 * a + 6 * e > 32 * b.length ? c + "=" : c + 647 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
647+/" 648 .charAt(d >> 6 * (3 - e) & 63); 649 } 650 } 651 return c; 652 }; 653 }(); 654 655 /* 656 * Gets the base64 representation for the given data 657 * 658 * http://phpjs.org 659 * + original by: Tyler Akins (http://rumkin.com) 660 * + improved by: Bayron Guevara 661 * + improved by: Thunder.m 662 * + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 663 * + bugfixed by: Pellentesque Malesuada 664 * + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 665 * + improved by: RafaÅ Kukawski (http://kukawski.pl) 666 * 667 * @param string data The data to calculate the base64 representation from 668 * 669 * @return string The base64 representation 670 */ 671 var _base64_encode = function (a) { 672 var d, e, f, b, g = 0, 673 h = 0, 674 i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 675 c = []; 676 if (!a) { 677 return a; 678 } 679 do { 680 d = a.charCodeAt(g++); 681 e = a.charCodeAt(g++); 682 f = a.charCodeAt(g++); 683 b = d << 16 | e << 8 | f; 684 d = b >> 18 & 63; 685 e = b >> 12 & 63; 686 f = b >> 6 & 63; 687 b &= 63; 688 c[h++] = i.charAt(d) + i.charAt(e) + i.charAt(f) + i.charAt(b); 689 } while (g < a.length); 690 c = c.join(""); 691 a = a.length % 3; 692 return (a ? c.slice(0, a - 3) : c) + "===".slice(a || 3); 693 }; 694 695 /* 696 * Builds a HTTP query string from the given data 697 * 698 * http://phpjs.org 699 * + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 700 * + improved by: Legaev Andrey 701 * + improved by: Michael White (http://getsprink.com) 702 * + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 703 * + improved by: Brett Zamir (http://brett-zamir.me) 704 * + revised by: stag019 705 * + input by: Dreamer 706 * + bugfixed by: Brett Zamir (http://brett-zamir.me) 707 * + bugfixed by: MIO_KODUKI (http://mio-koduki.blogspot.com/) 708 * 709 * @param string data The data to concatenate 710 * 711 * @return string The HTTP query 712 */ 713 var _http_build_query = function (e, f, b) { 714 function g(c, a, d) { 715 var b, e = []; 716 if (a === true) { 717 a = "1"; 718 } else if (a === false) { 719 a = "0"; 720 } 721 if (null !== a) { 722 if (typeof a === "object") { 723 for (b in a) { 724 if (a[b] !== null) { 725 e.push(g(c + "[" + b + "]", a[b], d)); 726 } 727 } 728 return e.join(d); 729 } 730 if (typeof a !== "function") { 731 return _url(c) + "=" + _url(a); 732 } 733 console.warn("There was an error processing for http_build_query()."); 734 } else { 735 return ""; 736 } 737 } 738 var d, c, h = []; 739 if (! b) { 740 b = "&"; 741 } 742 for (c in e) { 743 d = e[c]; 744 if (f && ! isNaN(c)) { 745 c = String(f) + c; 746 } 747 d = g(c, d, b); 748 if (d !== "") { 749 h.push(d); 750 } 751 } 752 return h.join(b); 753 }; 754 755 /** 756 * Generates a (hopefully) unique random string 757 * 758 * @param int optional length The length of the string to generate 759 * 760 * @return string The random string 761 */ 762 var _nonce = function (length) { 763 if (typeof length === "undefined") { 764 length = 8; 765 } 766 if (length < 1) { 767 console.warn("Invalid nonce length."); 768 } 769 var nonce = ""; 770 for (var i = 0; i < length; i++) { 771 var character = Math.floor(Math.random() * 61); 772 nonce += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".substring(character, character + 1); 773 } 774 return nonce; 775 }; 776 777 /** 778 * Sort array elements by key 779 * 780 * @param array input_arr The array to sort 781 * 782 * @return array The sorted keys 783 */ 784 var _ksort = function (input_arr) { 785 var keys = [], sorter, k; 786 787 sorter = function (a, b) { 788 var a_float = parseFloat(a), 789 b_float = parseFloat(b), 790 a_numeric = a_float + "" === a, 791 b_numeric = b_float + "" === b; 792 if (a_numeric && b_numeric) { 793 return a_float > b_float ? 1 : a_float < b_float ? -1 : 0; 794 } else if (a_numeric && !b_numeric) { 795 return 1; 796 } else if (!a_numeric && b_numeric) { 797 return -1; 798 } 799 return a > b ? 1 : a < b ? -1 : 0; 800 }; 801 802 // Make a list of key names 803 for (k in input_arr) { 804 if (input_arr.hasOwnProperty(k)) { 805 keys.push(k); 806 } 807 } 808 keys.sort(sorter); 809 return keys; 810 }; 811 812 /** 813 * Clone objects 814 * 815 * @param object obj The object to clone 816 * 817 * @return object clone The cloned object 818 */ 819 var _clone = function (obj) { 820 var clone = {}; 821 for (var i in obj) { 822 if (typeof(obj[i]) === "object") { 823 clone[i] = _clone(obj[i]); 824 } else { 825 clone[i] = obj[i]; 826 } 827 } 828 return clone; 829 }; 830 831 /** 832 * Generates an OAuth signature 833 * 834 * @param string httpmethod Usually either 'GET' or 'POST' or 'DELETE' 835 * @param string method The API method to call 836 * @param array optional params The API call parameters, associative 837 * @param bool optional append_to_get Whether to append the OAuth params to GET 838 * 839 * @return string Authorization HTTP header 840 */ 841 var _sign = function (httpmethod, method, params, append_to_get) { 842 if (typeof params === "undefined") { 843 params = {}; 844 } 845 if (typeof append_to_get === "undefined") { 846 append_to_get = false;
847 } 848 if (_oauth_consumer_key === null) { 849 console.warn("To generate a signature, the consumer key must be set."); 850 } 851 var sign_params = { 852 consumer_key: _oauth_consumer_key, 853 version: "1.0", 854 timestamp: Math.round(new Date().getTime() / 1000), 855 nonce: _nonce(), 856 signature_method: "HMAC-SHA1" 857 }; 858 var sign_base_params = {}; 859 var value; 860 for (var key in sign_params) { 861 value = sign_params[key]; 862 sign_base_params["oauth_" + key] = _url(value); 863 } 864 if (_oauth_token !== null) { 865 sign_base_params.oauth_token = _url(_oauth_token); 866 } 867 var oauth_params = _clone(sign_base_params); 868 for (key in params) { 869 value = params[key]; 870 sign_base_params[key] = value; 871 } 872 var keys = _ksort(sign_base_params); 873 var sign_base_string = ""; 874 for (var i = 0; i < keys.length; i++) { 875 key = keys[i]; 876 value = sign_base_params[key]; 877 sign_base_string += key + "=" + _url(value) + "&"; 878 } 879 sign_base_string = sign_base_string.substring(0, sign_base_string.length - 1); 880 var signature = _sha1(httpmethod + "&" + _url(method) + "&" + _url(sign_base_string)); 881 882 params = append_to_get ? sign_base_params : oauth_params; 883 params.oauth_signature = signature; 884 keys = _ksort(params); 885 var authorization = ""; 886 if (append_to_get) { 887 for(i = 0; i < keys.length; i++) { 888 key = keys[i]; 889 value = params[key]; 890 authorization += key + "=" + _url(value) + "&"; 891 } 892 return authorization.substring(0, authorization.length - 1); 893 } 894 authorization = "OAuth "; 895 for (i = 0; i < keys.length; i++) { 896 key = keys[i]; 897 value = params[key]; 898 authorization += key + "=\"" + _url(value) + "\", "; 899 } 900 return authorization.substring(0, authorization.length - 2); 901 }; 902 903 /** 904 * Detects HTTP method to use for API call 905 * 906 * @param string method The API method to call 907 * @param array params The parameters to send along 908 * 909 * @return string The HTTP method that should be used 910 */ 911 var _detectMethod = function (method, params) { 912 // multi-HTTP method endpoints 913 switch (method) { 914 case "account/settings": 915 case "account/login_verification_enrollment": 916 case "account/login_verification_request": 917 method = params.length ? method + "__post" : method; 918 break; 919 } 920 921 var httpmethods = {}; 922 httpmethods.GET = [ 923 // Timelines 924 "statuses/mentions_timeline", 925 "statuses/user_timeline", 926 "statuses/home_timeline", 927 "statuses/retweets_of_me", 928 929 // Tweets 930 "statuses/retweets/:id", 931 "statuses/show/:id", 932 "statuses/oembed", 933 "statuses/retweeters/ids", 934 935 // Search 936 "search/tweets", 937 938 // Direct Messages 939 "direct_messages", 940 "direct_messages/sent", 941 "direct_messages/show", 942 943 // Friends & Followers 944 "friendships/no_retweets/ids", 945 "friends/ids", 946 "followers/ids", 947 "friendships/lookup", 948 "friendships/incoming", 949 "friendships/outgoing", 950 "friendships/show", 951 "friends/list", 952 "followers/list", 953 "friendships/lookup", 954 955 // Users 956 "account/settings", 957 "account/verify_credentials", 958 "blocks/list", 959 "blocks/ids", 960 "users/lookup", 961 "users/show", 962 "users/search", 963 "users/contributees", 964 "users/contributors", 965 "users/profile_banner", 966 "mutes/users/ids", 967 "mutes/users/list", 968 969 // Suggested Users 970 "users/suggestions/:slug", 971 "users/suggestions", 972 "users/suggestions/:slug/members", 973 974 // Favorites 975 "favorites/list", 976 977 // Lists 978 "lists/list", 979 "lists/statuses", 980 "lists/memberships", 981 "lists/subscribers", 982 "lists/subscribers/show", 983 "lists/members/show", 984 "lists/members", 985 "lists/show", 986 "lists/subscriptions", 987 "lists/ownerships", 988 989 // Saved searches 990 "saved_searches/list", 991 "saved_searches/show/:id", 992 993 // Places & Geo 994 "geo/id/:place_id", 995 "geo/reverse_geocode", 996 "geo/search", 997 "geo/similar_places", 998 999 // Trends 1000 "trends/place", 1001 "trends/available", 1002 "trends/closest", 1003 1004 // OAuth 1005 "oauth/authenticate", 1006 "oauth/authorize", 1007 1008 // Help 1009 "help/configuration", 1010 "help/languages", 1011 "help/privacy", 1012 "help/tos", 1013 "application/rate_limit_status", 1014 1015 // Tweets 1016 "statuses/lookup", 1017 1018 // Internal 1019 "users/recommendations", 1020 "account/push_destinations/device", 1021 "activity/about_me", 1022 "activity/by_friends", 1023 "statuses/media_timeline", 1024 "timeline/home", 1025 "help/experiments", 1026 "search/typeahead", 1027 "search/universal", 1028 "discover/universal", 1029 "conversation/show", 1030 "statuses/:id/activity/summary", 1031 "account/login_verification_enrollment", 1032 "account/login_verification_request", 1033 "prompts/suggest", 1034 1035 "beta/timelines/custom/list", 1036 "beta/timelines/timeline", 1037 "beta/timelines/custom/show" 1038 ]; 1039 httpmethods.POST = [ 1040 // Tweets 1041 "statuses/destroy/:id", 1042 "statuses/update", 1043 "statuses/retweet/:id", 1044 "statuses/update_with_media", 1045 "media/upload", 1046 1047 // Direct Messages 1048 "direct_messages/destroy", 1049 "direct_messages/new", 1050 1051 // Friends & Followers 1052 "friendships/create", 1053 "friendships/destroy", 1054 "friendships/update", 1055 1056 // Users 1057 "account/settings__post", 1058 "account/update_delivery_device", 1059 "account/update_profile", 1060 "account/update_profile_background_image", 1061 "account/update_profile_colors", 1062 "account/update_profile_image", 1063 "blocks/create", 1064 "blocks/destroy", 1065 "account/update_profile_banner", 1066 "account/remove_profile_banner", 1067 "mutes/users/create", 1068 "mutes/users/destroy", 1069 1070 // Favorites 1071 "favorites/destroy", 1072 "favorites/create", 1073 1074 // Lists 1075 "lists/members/destroy", 1076 "lists/subscribers/create", 1077 "lists/subscribers/destroy", 1078 "lists/members/create_all", 1079 "lists/members/create", 1080 "lists/destroy", 1081 "lists/update", 1082 "lists/create", 1083 "lists/members/destroy_all", 1084 1085 // Saved Searches 1086 "saved_searches/create", 1087 "saved_searches/destroy/:id", 1088 1089 // Spam Reporting 1090 "users/report_spam", 1091 1092 // OAuth 1093 "oauth/access_token", 1094 "oauth/request_token", 1095 "oauth2/token", 1096 "oauth2/invalidate_token", 1097 1098 // Internal 1099 "direct_messages/read", 1100 "account/login_verification_enrollment__post", 1101 "push_destinations/enable_login_verification", 1102 "account/login_verification_request__post", 1103 1104 "beta/timelines/custom/create", 1105 "beta/timelines/custom/update", 1106 "beta/timelines/custom/destroy", 1107 "beta/timelines/custom/add", 1108 "beta/timelines/custom/remove" 1109 ]; 1110 for (var httpmethod in httpmethods) { 1111 if (httpmethods[httpmethod].indexOf(method) > -1) { 1112 return httpmethod; 1113 } 1114 } 1115 console.warn("Can't find HTTP method to use for \"" + method + "\"."); 1116 }; 1117 1118 /** 1119 * Detects if API call should use multipart/form-data 1120 * 1121 * @param string method The API method to call 1122 * 1123 * @return bool Whether the method should be sent as multipart 1124 */ 1125 var _detectMultipart = function (method) { 1126 var multiparts = [ 1127 // Tweets 1128 "statuses/update_with_media", 1129 1130 // Users 1131 "account/update_profile_background_image", 1132 "account/update_profile_image", 1133 "account/update_profile_banner" 1134 ]; 1135 return multiparts.indexOf(method) > -1; 1136 }; 1137 1138 /** 1139 * Build multipart request from upload params 1140 * 1141 * @param string method The API method to call
1142 * @param array params The parameters to send along 1143 * 1144 * @return null|string The built multipart request body 1145 */ 1146 var _buildMultipart = function (method, params) { 1147 // well, files will only work in multipart methods 1148 if (! _detectMultipart(method)) { 1149 return; 1150 } 1151 1152 // only check specific parameters 1153 var possible_methods = [ 1154 // Tweets 1155 "statuses/update_with_media", 1156 // Accounts 1157 "account/update_profile_background_image", 1158 "account/update_profile_image", 1159 "account/update_profile_banner" 1160 ]; 1161 var possible_files = { 1162 // Tweets 1163 "statuses/update_with_media": "media[]", 1164 // Accounts 1165 "account/update_profile_background_image": "image", 1166 "account/update_profile_image": "image", 1167 "account/update_profile_banner": "banner" 1168 }; 1169 // method might have files? 1170 if (possible_methods.indexOf(method) === -1) { 1171 return; 1172 } 1173 1174 // check for filenames 1175 possible_files = possible_files[method].split(" "); 1176 1177 var multipart_border = "--------------------" + _nonce(); 1178 var multipart_request = ""; 1179 for (var key in params) { 1180 multipart_request += 1181 "--" + multipart_border + "\r\n" 1182 + "Content-Disposition: form-data; name=\"" + key + "\""; 1183 if (possible_files.indexOf(key) > -1) { 1184 multipart_request += 1185 "\r\nContent-Transfer-Encoding: base64"; 1186 } 1187 multipart_request += 1188 "\r\n\r\n" + params[key] + "\r\n"; 1189 } 1190 multipart_request += "--" + multipart_border + "--"; 1191 return multipart_request; 1192 }; 1193 1194 /** 1195 * Detects if API call is internal 1196 * 1197 * @param string method The API method to call 1198 * 1199 * @return bool Whether the method is defined in internal API 1200 */ 1201 var _detectInternal = function (method) { 1202 var internals = [ 1203 "users/recommendations" 1204 ]; 1205 return internals.join(" ").indexOf(method) > -1; 1206 }; 1207 1208 /** 1209 * Detects if API call should use media endpoint 1210 * 1211 * @param string method The API method to call 1212 * 1213 * @return bool Whether the method is defined in media API 1214 */ 1215 var _detectMedia = function (method) { 1216 var medias = [ 1217 "media/upload" 1218 ]; 1219 return medias.join(" ").indexOf(method) > -1; 1220 }; 1221 1222 /** 1223 * Detects if API call should use old endpoint 1224 * 1225 * @param string method The API method to call 1226 * 1227 * @return bool Whether the method is defined in old API 1228 */ 1229 var _detectOld = function (method) { 1230 var olds = [ 1231 "account/push_destinations/device" 1232 ]; 1233 return olds.join(" ").indexOf(method) > -1; 1234 }; 1235 1236 /** 1237 * Builds the complete API endpoint url 1238 * 1239 * @param string method The API method to call 1240 * 1241 * @return string The URL to send the request to 1242 */ 1243 var _getEndpoint = function (method) { 1244 var url; 1245 if (method.substring(0, 5) === "oauth") { 1246 url = _endpoint_oauth + method; 1247 } else if (_detectMedia(method)) { 1248 url = _endpoint_media + method + ".json"; 1249 } else if (_detectOld(method)) { 1250 url = _endpoint_old + method + ".json"; 1251 } else { 1252 url = _endpoint + method + ".json"; 1253 } 1254 return url; 1255 }; 1256 1257 /** 1258 * Gets the XML HTTP Request object, trying to load it in various ways 1259 * 1260 * @return object The XMLHttpRequest object instance 1261 */ 1262 var _getXmlRequestObject = function () { 1263 var xml = null; 1264 // first, try the W3-standard object 1265 if (typeof window === "object" 1266 && window 1267 && typeof window.XMLHttpRequest !== "undefined" 1268 ) { 1269 xml = new window.XMLHttpRequest(); 1270 // then, try Titanium framework object 1271 } else if (typeof Ti === "object" 1272 && Ti 1273 && typeof Ti.Network.createHTTPClient !== "undefined" 1274 ) { 1275 xml = Ti.Network.createHTTPClient(); 1276 // are we in an old Internet Explorer? 1277 } else if (typeof ActiveXObject !== "undefined" 1278 ) { 1279 try { 1280 xml = new ActiveXObject("Microsoft.XMLHTTP"); 1281 } catch (e) { 1282 console.error("ActiveXObject object not defined."); 1283 } 1284 // now, consider RequireJS and/or Node.js objects 1285 } else if (typeof require === "function" 1286 && require 1287 ) { 1288 // look for xmlhttprequest module 1289 try { 1290 var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; 1291 xml = new XMLHttpRequest(); 1292 } catch (e1) { 1293 // or maybe the user is using xhr2 1294 try { 1295 var XMLHttpRequest = require("xhr2"); 1296 xml = new XMLHttpRequest(); 1297 } catch (e2) { 1298 console.error("xhr2 object not defined, cancelling."); 1299 } 1300 } 1301 } 1302 return xml; 1303 }; 1304 1305 /** 1306 * Calls the API using cURL 1307 * 1308 * @param string httpmethod The HTTP method to use for making the request 1309 * @param string method The API method to call
1310 * @param array optional params The parameters to send along 1311 * @param bool optional multipart Whether to use multipart/form-data 1312 * @param bool optional app_only_auth Whether to use app-only bearer authentication 1313 * @param bool optional internal Whether to use internal call 1314 * @param function callback The function to call with the API call result 1315 * 1316 * @return mixed The API reply, encoded in the set return_format 1317 */ 1318 1319 var _callApi = function (httpmethod, method, params, multipart, app_only_auth, internal, callback) { 1320 if (typeof params === "undefined") { 1321 params = {}; 1322 } 1323 if (typeof multipart === "undefined") { 1324 multipart = false; 1325 } 1326 if (typeof app_only_auth === "undefined") { 1327 app_only_auth = false; 1328 } 1329 if (typeof callback !== "function") { 1330 callback = function () {}; 1331 } 1332 if (internal) { 1333 params.adc = "phone"; 1334 params.application_id = 333903271; 1335 } 1336 1337 var url = _getEndpoint(method); 1338 var authorization = null; 1339 1340 var xml = _getXmlRequestObject(); 1341 if (xml === null) { 1342 return; 1343 } 1344 var post_fields; 1345 1346 if (httpmethod === "GET") { 1347 var url_with_params = url; 1348 if (JSON.stringify(params) !== "{}") { 1349 url_with_params += "?" + _http_build_query(params); 1350 } 1351 if (! app_only_auth) { 1352 authorization = _sign(httpmethod, url, params); 1353 } 1354 1355 // append auth params to GET url for IE7-9, to send via JSONP 1356 if (_use_jsonp) { 1357 if (JSON.stringify(params) !== "{}") { 1358 url_with_params += "&"; 1359 } else { 1360 url_with_params += "?"; 1361 } 1362 var callback_name = _nonce(); 1363 window[callback_name] = function (reply) { 1364 reply.httpstatus = 200; 1365 1366 var rate = null; 1367 if (typeof xml.getResponseHeader !== "undefined" 1368 && xml.getResponseHeader("x-rate-limit-limit") !== "" 1369 ) { 1370 rate = { 1371 limit: xml.getResponseHeader("x-rate-limit-limit"), 1372 remaining: xml.getResponseHeader("x-rate-limit-remaining"), 1373 reset: xml.getResponseHeader("x-rate-limit-reset") 1374 }; 1375 } 1376 callback(reply, rate); 1377 }; 1378 params.callback = callback_name; 1379 url_with_params = url + "?" + _sign(httpmethod, url, params, true); 1380 var tag = document.createElement("script"); 1381 tag.type = "text/javascript"; 1382 tag.src = url_with_params; 1383 var body = document.getElementsByTagName("body")[0]; 1384 body.appendChild(tag); 1385 return; 1386 1387 } else if (_use_proxy) { 1388 url_with_params = url_with_params.replace( 1389 _endpoint_base, 1390 _endpoint_proxy 1391 ).replace( 1392 _endpoint_base_media, 1393 _endpoint_proxy 1394 ); 1395 } 1396 xml.open(httpmethod, url_with_params, true); 1397 } else { 1398 if (_use_jsonp) { 1399 console.warn("Sending POST requests is not supported for IE7-9."); 1400 return; 1401 } 1402 if (multipart) { 1403 if (! app_only_auth) { 1404 authorization = _sign(httpmethod, url, {}); 1405 } 1406 params = _buildMultipart(method, params); 1407 } else { 1408 if (! app_only_auth) { 1409 authorization = _sign(httpmethod, url, params); 1410 } 1411 params = _http_build_query(params); 1412 } 1413 post_fields = params; 1414 if (_use_proxy || multipart) { // force proxy for multipart base64 1415 url = url.replace( 1416 _endpoint_base, 1417 _endpoint_proxy 1418 ).replace( 1419 _endpoint_base_media, 1420 _endpoint_proxy 1421 ); 1422 } 1423 xml.open(httpmethod, url, true); 1424 if (multipart) { 1425 xml.setRequestHeader("Content-Type", "multipart/form-data; boundary=" 1426 + post_fields.split("\r\n")[0].substring(2)); 1427 } else { 1428 xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 1429 } 1430 } 1431 if (app_only_auth) { 1432 if (_oauth_consumer_key === null 1433 && _oauth_bearer_token === null 1434 ) { 1435 console.warn("To make an app-only auth API request, consumer key or bearer token must be set."); 1436 } 1437 // automatically fetch bearer token, if necessary 1438 if (_oauth_bearer_token === null) { 1439 return oauth2_token(function () { 1440 _callApi(httpmethod, method, params, multipart, app_only_auth, false, callback); 1441 }); 1442 } 1443 authorization = "Bearer " + _oauth_bearer_token; 1444 } 1445 if (authorization !== null) { 1446 xml.setRequestHeader((_use_proxy ? "X-" : "") + "Authorization", authorization); 1447 } 1448 xml.onreadystatechange = function () { 1449 if (xml.readyState >= 4) { 1450 var httpstatus = 12027; 1451 try { 1452 httpstatus = xml.status; 1453 } catch (e) {} 1454 var response = ""; 1455 try { 1456 response = xml.responseText; 1457 } catch (e) {} 1458 var reply = _parseApiReply(response); 1459 reply.httpstatus = httpstatus; 1460 var rate = null; 1461 if (typeof xml.getResponseHeader !== "undefined" 1462 && xml.getResponseHeader("x-rate-limit-limit") !== "" 1463 ) { 1464 rate = { 1465 limit: xml.getResponseHeader("x-rate-limit-limit"), 1466 remaining: xml.getResponseHeader("x-rate-limit-remaining"), 1467 reset: xml.getResponseHeader("x-rate-limit-reset") 1468 }; 1469 } 1470 callback(reply, rate); 1471 } 1472 }; 1473 xml.send(httpmethod === "GET" ? null : post_fields); 1474 return true; 1475 }; 1476 1477 /** 1478 * Parses the API reply to encode it in the set return_format 1479 * 1480 * @param string reply The actual reply, JSON-encoded or URL-encoded 1481 * 1482 * @return array|object The parsed reply 1483 */ 1484 var _parseApiReply = function (reply) { 1485 if (typeof reply !== "string" || reply === "") { 1486 return {}; 1487 } 1488 if (reply === "[]") { 1489 return []; 1490 } 1491 var parsed; 1492 try { 1493 parsed = JSON.parse(reply); 1494 } catch (e) { 1495 parsed = {}; 1496 if (reply.indexOf("<" + "?xml version=\"1.0\" encoding=\"UTF-8\"?" + ">") === 0) { 1497 // we received XML... 1498 // since this only happens for errors, 1499 // don't perform a full decoding 1500 parsed.request = reply.match(/<request>(.*)<\/request>/)[1]; 1501 parsed.error = reply.match(/<error>(.*)<\/error>/)[1]; 1502 } else { 1503 // assume query format 1504 var elements = reply.split("&"); 1505 for (var i = 0; i < elements.length; i++) { 1506 var element = elements[i].split("=", 2); 1507 if (element.length > 1) { 1508 parsed[element[0]] = decodeURIComponent(element[1]); 1509 } else { 1510 parsed[element[0]] = null; 1511 } 1512 } 1513 } 1514 } 1515 return parsed; 1516 }; 1517 1518 return { 1519 setConsumerKey: setConsumerKey, 1520 getVersion: getVersion, 1521 setToken: setToken, 1522 setBearerToken: setBearerToken, 1523 setUseProxy: setUseProxy, 1524 setProxy: setProxy,
1525 __call: __call, 1526 oauth_authenticate: oauth_authenticate, 1527 oauth_authorize: oauth_authorize, 1528 oauth2_token: oauth2_token 1529 }; 1530}; 1531 1532if (typeof module === "object" 1533 && module 1534 && typeof module.exports === "object" 1535) { 1536 // Expose codebird as module.exports in loaders that implement the Node 1537 // module pattern (including browserify). Do not create the global, since 1538 // the user will be storing it themselves locally, and globals are frowned 1539 // upon in the Node module world. 1540 module.exports = Codebird; 1541} else { 1542 // Otherwise expose codebird to the global object as usual 1543 if (typeof window === "object" 1544 && window) { 1545 window.Codebird = Codebird; 1546 } 1547 1548 // Register as a named AMD module, since codebird can be concatenated with other 1549 // files that may use define, but not via a proper concatenation script that 1550 // understands anonymous AMD modules. A named AMD is safest and most robust 1551 // way to register. Lowercase codebird is used because AMD module names are 1552 // derived from file names, and codebird is normally delivered in a lowercase 1553 // file name. Do this after creating the global so that if an AMD module wants 1554 // to call noConflict to hide this version of codebird, it will work. 1555 if (typeof define === "function" && define.amd) { 1556 define("codebird", [], function () { return Codebird; }); 1557 } 1558} 1559 1560})(); 1561// doT.js 1562// 2011, Laura Doktorova, https://github.com/olado/doT 1563// Licensed under the MIT license. 1564 1565(function() { 1566 "use strict"; 1567 1568 var doT = { 1569 version: '1.0.1', 1570 templateSettings: { 1571 evaluate: /\{\{([\s\S]+?(\}?)+)\}\}/g, 1572 interpolate: /\{\{=([\s\S]+?)\}\}/g, 1573 encode: /\{\{!([\s\S]+?)\}\}/g, 1574 use: /\{\{#([\s\S]+?)\}\}/g, 1575 useParams: /(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g, 1576 define: /\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g, 1577 defineParams:/^\s*([\w$]+):([\s\S]+)/, 1578 conditional: /\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g, 1579 iterate: /\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g, 1580 varname: 'it', 1581 strip: true, 1582 append: true, 1583 selfcontained: false 1584 }, 1585 template: undefined, //fn, compile template 1586 compile: undefined //fn, for express 1587 }, global; 1588 1589 if (typeof module !== 'undefined' && module.exports) { 1590 module.exports = doT; 1591 } else if (typeof define === 'function' && define.amd) { 1592 define(function(){return doT;}); 1593 } else { 1594 global = (function(){ return this || (0,eval)('this'); }()); 1595 global.doT = doT; 1596 } 1597 1598 function encodeHTMLSource() { 1599 var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }, 1600 matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g; 1601 return function() { 1602 return this ? this.replace(matchHTML, function(m) {return encodeHTMLRules[m] || m;}) : this; 1603 }; 1604 } 1605 String.prototype.encodeHTML = encodeHTMLSource(); 1606 1607 var startend = { 1608 append: { start: "'+(", end: ")+'", endencode: "||'').toString().encodeHTML()+'" }, 1609 split: { start: "';out+=(", end: ");out+='", endencode: "||'').toString().encodeHTML();out+='"} 1610 }, skip = /$^/; 1611 1612 function resolveDefs(c, block, def) { 1613 return ((typeof block === 'string') ? block : block.toString()) 1614 .replace(c.define || skip, function(m, code, assign, value) { 1615 if (code.indexOf('def.') === 0) { 1616 code = code.substring(4); 1617 } 1618 if (!(code in def)) { 1619 if (assign === ':') { 1620 if (c.defineParams) value.replace(c.defineParams, function(m, param, v) { 1621 def[code] = {arg: param, text: v}; 1622 }); 1623 if (!(code in def)) def[code]= value; 1624 } else { 1625 new Function("def", "def['"+code+"']=" + value)(def); 1626 } 1627 } 1628 return ''; 1629 }) 1630 .replace(c.use || skip, function(m, code) { 1631 if (c.useParams) code = code.replace(c.useParams, function(m, s, d, param) { 1632 if (def[d] && def[d].arg && param) { 1633 var rw = (d+":"+param).replace(/'|\\/g, '_'); 1634 def.__exp = def.__exp || {}; 1635 def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2"); 1636 return s + "def.__exp['"+rw+"']"; 1637 } 1638 }); 1639 var v = new Function("def", "return " + code)(def); 1640 return v ? resolveDefs(c, v, def) : v; 1641 }); 1642 } 1643 1644 function unescape(code) { 1645 return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, ' '); 1646 } 1647 1648 doT.template = function(tmpl, c, def) { 1649 c = c || doT.templateSettings; 1650 var cse = c.append ? startend.append : startend.split, needhtmlencode, sid = 0, indv, 1651 str = (c.use || c.define) ? resolveDefs(c, tmpl, def || {}) : tmpl; 1652 1653 str = ("var out='" + (c.strip ? str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g,' ') 1654 .replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,''): str) 1655 .replace(/'|\\/g, '\\$&') 1656 .replace(c.interpolate || skip, function(m, code) { 1657 return cse.start + unescape(code) + cse.end; 1658 }) 1659 .replace(c.encode || skip, function(m, code) { 1660 needhtmlencode = true; 1661 return cse.start + unescape(code) + cse.endencode; 1662 })
1663 .replace(c.conditional || skip, function(m, elsecase, code) { 1664 return elsecase ? 1665 (code ? "';}else if(" + unescape(code) + "){out+='" : "';}else{out+='") : 1666 (code ? "';if(" + unescape(code) + "){out+='" : "';}out+='"); 1667 }) 1668 .replace(c.iterate || skip, function(m, iterate, vname, iname) { 1669 if (!iterate) return "';} } out+='"; 1670 sid+=1; indv=iname || "i"+sid; iterate=unescape(iterate); 1671 return "';var arr"+sid+"="+iterate+";if(arr"+sid+"){var "+vname+","+indv+"=-1,l"+sid+"=arr"+sid+".length-1;while("+indv+"<l"+sid+"){" 1672 +vname+"=arr"+sid+"["+indv+"+=1];out+='"; 1673 }) 1674 .replace(c.evaluate || skip, function(m, code) { 1675 return "';" + unescape(code) + "out+='"; 1676 }) 1677 + "';return out;") 1678 .replace(/\n/g, '\\n').replace(/\t/g, '\\t').replace(/\r/g, '\\r') 1679 .replace(/(\s|;|\}|^|\{)out\+='';/g, '$1').replace(/\+''/g, '') 1680 .replace(/(\s|;|\}|^|\{)out\+=''\+/g,'$1out+='); 1681 1682 if (needhtmlencode && c.selfcontained) { 1683 str = "String.prototype.encodeHTML=(" + encodeHTMLSource.toString() + "());" + str; 1684 } 1685 try { 1686 return new Function(c.varname, str); 1687 } catch (e) { 1688 if (typeof console !== 'undefined') console.log("Could not create a template function: " + str); 1689 throw e; 1690 } 1691 }; 1692 1693 doT.compile = function(tmpl, def) { 1694 return doT.template(tmpl, null, def); 1695 }; 1696}()); 1697//! moment.js 1698//! version : 2.8.3 1699//! authors : Tim Wood, Iskren Chernev, Moment.js contributors 1700//! license : MIT 1701//! momentjs.com 1702(function(a){function b(a,b,c){switch(arguments.length){case 2:return null!=a?a:b;case 3:return null!=a?a:null!=b?b:c;default:throw new Error("Implement me")}}function c(a,b){return zb.call(a,b)}function d(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function e(a){tb.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+a)}function f(a,b){var c=!0;return m(function(){return c&&(e(a),c=!1),b.apply(this,arguments)},b)}function g(a,b){qc[a]||(e(b),qc[a]=!0)}function h(a,b){return function(c){return p(a.call(this,c),b)}}function i(a,b){return function(c){return this.localeData().ordinal(a.call(this,c),b)}}function j(){}function k(a,b){b!==!1&&F(a),n(this,a),this._d=new Date(+a._d)}function l(a){var b=y(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;this._milliseconds=+k+1e3*j+6e4*i+36e5*h,this._days=+g+7*f,this._months=+e+3*d+12*c,this._data={},this._locale=tb.localeData(),this._bubble()}function m(a,b){for(var d in b)c(b,d)&&(a[d]=b[d]);return c(b,"toString")&&(a.toString=b.toString),c(b,"valueOf")&&(a.valueOf=b.valueOf),a}function n(a,b){var c,d,e;if("undefined"!=typeof b._isAMomentObject&&(a._isAMomentObject=b._isAMomentObject),"undefined"!=typeof b._i&&(a._i=b._i),"undefined"!=typeof b._f&&(a._f=b._f),"undefined"!=typeof b._l&&(a._l=b._l),"undefined"!=typeof b._strict&&(a._strict=b._strict),"undefined"!=typeof b._tzm&&(a._tzm=b._tzm),"undefined"!=typeof b._isUTC&&(a._isUTC=b._isUTC),"undefined"!=typeof b._offset&&(a._offset=b._offset),"undefined"!=typeof b._pf&&(a._pf=b._pf),"undefined"!=typeof b._locale&&(a._locale=b._locale),Ib.length>0)for(c in Ib)d=Ib[c],e=b[d],"undefined"!=typeof e&&(a[d]=e);return a}function o(a){return 0>a?Math.ceil(a):Math.floor(a)}function p(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function q(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function r(a,b){var c;return b=K(b,a),a.isBefore(b)?c=q(a,b):(c=q(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c}function s(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(g(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=tb.duration(c,d),t(this,e,a),this}}function t(a,b,c,d){var e=b._milliseconds,f=b._days,g=b._months;d=null==d?!0:d,e&&a._d.setTime(+a._d+e*c),f&&nb(a,"Date",mb(a,"Date")+f*c),g&&lb(a,mb(a,"Month")+g*c),d&&tb.updateOffset(a,f||g)}function u(a){return"[object Array]"===Object.prototype.toString.call(a)}function v(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function w(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&A(a[d])!==A(b[d]))&&g++;return g+f}function x(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=jc[a]||kc[b]||b}return a}function y(a){var b,d,e={};for(d in a)c(a,d)&&(b=x(d),b&&(e[b]=a[d]));return e}function z(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}tb[b]=function(e,f){var g,h,i=tb._locale[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=tb().utc().set(d,a);return i.call(tb._locale,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function A(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function B(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function C(a,b,c){return hb(tb([a,11,31+b-c]),b,c).week}function D(a){return E(a)?366:365}function E(a){return a%4===0&&a%100!==0||a%400===0}function F(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[Bb]<0||a._a[Bb]>11?Bb:a._a[Cb]<1||a._a[Cb]>B(a._a[Ab],a._a[Bb])?Cb:a._a[Db]<0||a._a[Db]>23?Db:a._a[Eb]<0||a._a[Eb]>59?Eb:a._a[Fb]<0||a._a[Fb]>59?Fb:a._a[Gb]<0||a._a[Gb]>999?Gb:-1,a._pf._overflowDayOfYear&&(Ab>b||b>Cb)&&(b=Cb),a._pf.overflow=b)}
1702function G(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function H(a){return a?a.toLowerCase().replace("_","-"):a}function I(a){for(var b,c,d,e,f=0;f<a.length;){for(e=H(a[f]).split("-"),b=e.length,c=H(a[f+1]),c=c?c.split("-"):null;b>0;){if(d=J(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&w(e,c,!0)>=b-1)break;b--}f++}return null}function J(a){var b=null;if(!Hb[a]&&Jb)try{b=tb.locale(),require("./locale/"+a),tb.locale(b)}catch(c){}return Hb[a]}function K(a,b){return b._isUTC?tb(a).zone(b._offset||0):tb(a).local()}function L(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function M(a){var b,c,d=a.match(Nb);for(b=0,c=d.length;c>b;b++)d[b]=pc[d[b]]?pc[d[b]]:L(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function N(a,b){return a.isValid()?(b=O(b,a.localeData()),lc[b]||(lc[b]=M(b)),lc[b](a)):a.localeData().invalidDate()}function O(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Ob.lastIndex=0;d>=0&&Ob.test(a);)a=a.replace(Ob,c),Ob.lastIndex=0,d-=1;return a}function P(a,b){var c,d=b._strict;switch(a){case"Q":return Zb;case"DDDD":return _b;case"YYYY":case"GGGG":case"gggg":return d?ac:Rb;case"Y":case"G":case"g":return cc;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?bc:Sb;case"S":if(d)return Zb;case"SS":if(d)return $b;case"SSS":if(d)return _b;case"DDD":return Qb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ub;case"a":case"A":return b._locale._meridiemParse;case"X":return Xb;case"Z":case"ZZ":return Vb;case"T":return Wb;case"SSSS":return Tb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?$b:Pb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Pb;case"Do":return Yb;default:return c=new RegExp(Y(X(a.replace("\\","")),"i"))}}function Q(a){a=a||"";var b=a.match(Vb)||[],c=b[b.length-1]||[],d=(c+"").match(hc)||["-",0,0],e=+(60*d[1])+A(d[2]);return"+"===d[0]?-e:e}function R(a,b,c){var d,e=c._a;switch(a){case"Q":null!=b&&(e[Bb]=3*(A(b)-1));break;case"M":case"MM":null!=b&&(e[Bb]=A(b)-1);break;case"MMM":case"MMMM":d=c._locale.monthsParse(b),null!=d?e[Bb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[Cb]=A(b));break;case"Do":null!=b&&(e[Cb]=A(parseInt(b,10)));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=A(b));break;case"YY":e[Ab]=tb.parseTwoDigitYear(b);break;case"YYYY":case"YYYYY":case"YYYYYY":e[Ab]=A(b);break;case"a":case"A":c._isPm=c._locale.isPM(b);break;case"H":case"HH":case"h":case"hh":e[Db]=A(b);break;case"m":case"mm":e[Eb]=A(b);break;case"s":case"ss":e[Fb]=A(b);break;case"S":case"SS":case"SSS":case"SSSS":e[Gb]=A(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=Q(b);break;case"dd":case"ddd":case"dddd":d=c._locale.weekdaysParse(b),null!=d?(c._w=c._w||{},c._w.d=d):c._pf.invalidWeekday=b;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":a=a.substr(0,1);case"gggg":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=A(b));break;case"gg":case"GG":c._w=c._w||{},c._w[a]=tb.parseTwoDigitYear(b)}}function S(a){var c,d,e,f,g,h,i;c=a._w,null!=c.GG||null!=c.W||null!=c.E?(g=1,h=4,d=b(c.GG,a._a[Ab],hb(tb(),1,4).year),e=b(c.W,1),f=b(c.E,1)):(g=a._locale._week.dow,h=a._locale._week.doy,d=b(c.gg,a._a[Ab],hb(tb(),g,h).year),e=b(c.w,1),null!=c.d?(f=c.d,g>f&&++e):f=null!=c.e?c.e+g:g),i=ib(d,e,f,h,g),a._a[Ab]=i.year,a._dayOfYear=i.dayOfYear}function T(a){var c,d,e,f,g=[];if(!a._d){for(e=V(a),a._w&&null==a._a[Cb]&&null==a._a[Bb]&&S(a),a._dayOfYear&&(f=b(a._a[Ab],e[Ab]),a._dayOfYear>D(f)&&(a._pf._overflowDayOfYear=!0),d=db(f,0,a._dayOfYear),a._a[Bb]=d.getUTCMonth(),a._a[Cb]=d.getUTCDate()),c=0;3>c&&null==a._a[c];++c)a._a[c]=g[c]=e[c];for(;7>c;c++)a._a[c]=g[c]=null==a._a[c]?2===c?1:0:a._a[c];a._d=(a._useUTC?db:cb).apply(null,g),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()+a._tzm)}}function U(a){var b;a._d||(b=y(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],T(a))}function V(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function W(a){if(a._f===tb.ISO_8601)return void $(a);a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=""+a._i,h=g.length,i=0;for(d=O(a._f,a._locale).match(Nb)||[],b=0;b<d.length;b++)e=d[b],c=(g.match(P(e,a))||[])[0],c&&(f=g.substr(0,g.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),g=g.slice(g.indexOf(c)+c.length),i+=c.length),pc[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),R(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=h-i,g.length>0&&a._pf.unusedInput.push(g),a._isPm&&a._a[Db]<12&&(a._a[Db]+=12),a._isPm===!1&&12===a._a[Db]&&(a._a[Db]=0),T(a),F(a)}function X(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function Y(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Z(a){var b,c,e,f,g;
1702if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;f<a._f.length;f++)g=0,b=n({},a),null!=a._useUTC&&(b._useUTC=a._useUTC),b._pf=d(),b._f=a._f[f],W(b),G(b)&&(g+=b._pf.charsLeftOver,g+=10*b._pf.unusedTokens.length,b._pf.score=g,(null==e||e>g)&&(e=g,c=b));m(a,c||b)}function $(a){var b,c,d=a._i,e=dc.exec(d);if(e){for(a._pf.iso=!0,b=0,c=fc.length;c>b;b++)if(fc[b][1].exec(d)){a._f=fc[b][0]+(e[6]||" ");break}for(b=0,c=gc.length;c>b;b++)if(gc[b][1].exec(d)){a._f+=gc[b][0];break}d.match(Vb)&&(a._f+="Z"),W(a)}else a._isValid=!1}function _(a){$(a),a._isValid===!1&&(delete a._isValid,tb.createFromInputFallback(a))}function ab(a,b){var c,d=[];for(c=0;c<a.length;++c)d.push(b(a[c],c));return d}function bb(b){var c,d=b._i;d===a?b._d=new Date:v(d)?b._d=new Date(+d):null!==(c=Kb.exec(d))?b._d=new Date(+c[1]):"string"==typeof d?_(b):u(d)?(b._a=ab(d.slice(0),function(a){return parseInt(a,10)}),T(b)):"object"==typeof d?U(b):"number"==typeof d?b._d=new Date(d):tb.createFromInputFallback(b)}function cb(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function db(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function eb(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function fb(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function gb(a,b,c){var d=tb.duration(a).abs(),e=yb(d.as("s")),f=yb(d.as("m")),g=yb(d.as("h")),h=yb(d.as("d")),i=yb(d.as("M")),j=yb(d.as("y")),k=e<mc.s&&["s",e]||1===f&&["m"]||f<mc.m&&["mm",f]||1===g&&["h"]||g<mc.h&&["hh",g]||1===h&&["d"]||h<mc.d&&["dd",h]||1===i&&["M"]||i<mc.M&&["MM",i]||1===j&&["y"]||["yy",j];return k[2]=b,k[3]=+a>0,k[4]=c,fb.apply({},k)}function hb(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=tb(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function ib(a,b,c,d,e){var f,g,h=db(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:D(a-1)+g}}function jb(b){var c=b._i,d=b._f;return b._locale=b._locale||tb.localeData(b._l),null===c||d===a&&""===c?tb.invalid({nullInput:!0}):("string"==typeof c&&(b._i=c=b._locale.preparse(c)),tb.isMoment(c)?new k(c,!0):(d?u(d)?Z(b):W(b):bb(b),new k(b)))}function kb(a,b){var c,d;if(1===b.length&&u(b[0])&&(b=b[0]),!b.length)return tb();for(c=b[0],d=1;d<b.length;++d)b[d][a](c)&&(c=b[d]);return c}function lb(a,b){var c;return"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),B(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function mb(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function nb(a,b,c){return"Month"===b?lb(a,c):a._d["set"+(a._isUTC?"UTC":"")+b](c)}function ob(a,b){return function(c){return null!=c?(nb(this,a,c),tb.updateOffset(this,b),this):mb(this,a)}}function pb(a){return 400*a/146097}function qb(a){return 146097*a/400}function rb(a){tb.duration.fn[a]=function(){return this._data[a]}}function sb(a){"undefined"==typeof ender&&(ub=xb.moment,xb.moment=a?f("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",tb):tb)}for(var tb,ub,vb,wb="2.8.3",xb="undefined"!=typeof global?global:this,yb=Math.round,zb=Object.prototype.hasOwnProperty,Ab=0,Bb=1,Cb=2,Db=3,Eb=4,Fb=5,Gb=6,Hb={},Ib=[],Jb="undefined"!=typeof module&&module.exports,Kb=/^\/?Date\((\-?\d+)/i,Lb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Mb=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Nb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Ob=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,Pb=/\d\d?/,Qb=/\d{1,3}/,Rb=/\d{1,4}/,Sb=/[+\-]?\d{1,6}/,Tb=/\d+/,Ub=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Vb=/Z|[\+\-]\d\d:?\d\d/gi,Wb=/T/i,Xb=/[\+\-]?\d+(\.\d{1,3})?/,Yb=/\d{1,2}/,Zb=/\d/,$b=/\d\d/,_b=/\d{3}/,ac=/\d{4}/,bc=/[+-]?\d{6}/,cc=/[+-]?\d+/,dc=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ec="YYYY-MM-DDTHH:mm:ssZ",fc=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],gc=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],hc=/([\+\-]|\d\d)/gi,ic=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),jc={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},kc={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},lc={},mc={s:45,m:45,h:22,d:26,M:11},nc="DDD w W M D d".split(" "),oc="M D H h m s w W".split(" "),pc={M:function(){return this.month()+1},MMM:function(a){return this.localeData().monthsShort(this,a)},MMMM:function(a){return this.localeData().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.localeData().weekdaysMin(this,a)},ddd:function(a){return this.localeData().weekdaysShort(this,a)},dddd:function(a){return this.localeData().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return p(this.year()%100,2)},YYYY:function(){return p(this.year(),4)},YYYYY:function(){return p(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+p(Math.abs(a),6)},gg:function(){return p(this.weekYear()%100,2)},gggg:function(){return p(this.weekYear(),4)},ggggg:function(){return p(this.weekYear(),5)},GG:function(){return p(this.isoWeekYear()%100,2)},GGGG:function(){return p(this.isoWeekYear(),4)},GGGGG:function(){return p(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return A(this.milliseconds()/100)},SS:function(){return p(A(this.milliseconds()/10),2)},SSS:function(){return p(this.milliseconds(),3)},SSSS:function(){return p(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+p(A(a/60),2)+":"+p(A(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+p(A(a/60),2)+p(A(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},qc={},rc=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];nc.length;)vb=nc.pop(),pc[vb+"o"]=i(pc[vb],vb);for(;oc.length;)vb=oc.pop(),pc[vb+vb]=h(pc[vb],2);pc.DDDD=h(pc.DDD,3),m(j.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=tb.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=tb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return hb(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),tb=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=b,g._f=c,g._l=e,g._strict=f,g._isUTC=!1,g._pf=d(),jb(g)},tb.suppressDeprecationWarnings=!1,tb.createFromInputFallback=f("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i)}),tb.min=function(){var a=[].slice.call(arguments,0);return kb("isBefore",a)},tb.max=function(){var a=[].slice.call(arguments,0);return kb("isAfter",a)},tb.utc=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=b,g._f=c,g._strict=f,g._pf=d(),jb(g).utc()},tb.unix=function(a){return tb(1e3*a)},tb.duration=function(a,b){var d,e,f,g,h=a,i=null;return tb.isDuration(a)?h={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(h={},b?h[b]=a:h.milliseconds=a):(i=Lb.exec(a))?(d="-"===i[1]?-1:1,h={y:0,d:A(i[Cb])*
1702d,h:A(i[Db])*d,m:A(i[Eb])*d,s:A(i[Fb])*d,ms:A(i[Gb])*d}):(i=Mb.exec(a))?(d="-"===i[1]?-1:1,f=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*d},h={y:f(i[2]),M:f(i[3]),d:f(i[4]),h:f(i[5]),m:f(i[6]),s:f(i[7]),w:f(i[8])}):"object"==typeof h&&("from"in h||"to"in h)&&(g=r(tb(h.from),tb(h.to)),h={},h.ms=g.milliseconds,h.M=g.months),e=new l(h),tb.isDuration(a)&&c(a,"_locale")&&(e._locale=a._locale),e},tb.version=wb,tb.defaultFormat=ec,tb.ISO_8601=function(){},tb.momentProperties=Ib,tb.updateOffset=function(){},tb.relativeTimeThreshold=function(b,c){return mc[b]===a?!1:c===a?mc[b]:(mc[b]=c,!0)},tb.lang=f("moment.lang is deprecated. Use moment.locale instead.",function(a,b){return tb.locale(a,b)}),tb.locale=function(a,b){var c;return a&&(c="undefined"!=typeof b?tb.defineLocale(a,b):tb.localeData(a),c&&(tb.duration._locale=tb._locale=c)),tb._locale._abbr},tb.defineLocale=function(a,b){return null!==b?(b.abbr=a,Hb[a]||(Hb[a]=new j),Hb[a].set(b),tb.locale(a),Hb[a]):(delete Hb[a],null)},tb.langData=f("moment.langData is deprecated. Use moment.localeData instead.",function(a){return tb.localeData(a)}),tb.localeData=function(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return tb._locale;if(!u(a)){if(b=J(a))return b;a=[a]}return I(a)},tb.isMoment=function(a){return a instanceof k||null!=a&&c(a,"_isAMomentObject")},tb.isDuration=function(a){return a instanceof l};for(vb=rc.length-1;vb>=0;--vb)z(rc[vb]);tb.normalizeUnits=function(a){return x(a)},tb.invalid=function(a){var b=tb.utc(0/0);return null!=a?m(b._pf,a):b._pf.userInvalidated=!0,b},tb.parseZone=function(){return tb.apply(null,arguments).parseZone()},tb.parseTwoDigitYear=function(a){return A(a)+(A(a)>68?1900:2e3)},m(tb.fn=k.prototype,{clone:function(){return tb(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=tb(this).utc();return 0<a.year()&&a.year()<=9999?N(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):N(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return G(this)},isDSTShifted:function(){return this._a?this.isValid()&&w(this._a,(this._isUTC?tb.utc(this._a):tb(this._a)).toArray())>0:!1},parsingFlags:function(){return m({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(a){return this.zone(0,a)},local:function(a){return this._isUTC&&(this.zone(0,a),this._isUTC=!1,a&&this.add(this._dateTzOffset(),"m")),this},format:function(a){var b=N(this,a||tb.defaultFormat);return this.localeData().postformat(b)},add:s(1,"add"),subtract:s(-1,"subtract"),diff:function(a,b,c){var d,e,f,g=K(a,this),h=6e4*(this.zone()-g.zone());return b=x(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+g.daysInMonth()),e=12*(this.year()-g.year())+(this.month()-g.month()),f=this-tb(this).startOf("month")-(g-tb(g).startOf("month")),f-=6e4*(this.zone()-tb(this).startOf("month").zone()-(g.zone()-tb(g).startOf("month").zone())),e+=f/d,"year"===b&&(e/=12)):(d=this-g,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-h)/864e5:"week"===b?(d-h)/6048e5:d),c?e:o(e)},from:function(a,b){return tb.duration({to:this,from:a}).locale(this.locale()).humanize(!b)},fromNow:function(a){return this.from(tb(),a)},calendar:function(a){var b=a||tb(),c=K(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.localeData().calendar(e,this))},isLeapYear:function(){return E(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=eb(a,this.localeData()),this.add(a-b,"d")):b},month:ob("Month",!0),startOf:function(a){switch(a=x(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this},endOf:function(a){return a=x(a),this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms")},isAfter:function(a,b){return b=x("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+this>+a):+this.clone().startOf(b)>+tb(a).startOf(b)},isBefore:function(a,b){return b=x("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+a>+this):+this.clone().startOf(b)<+tb(a).startOf(b)},isSame:function(a,b){return b=x(b||"millisecond"),"millisecond"===b?(a=tb.isMoment(a)?a:tb(a),+this===+a):+this.clone().startOf(b)===+K(a,this).startOf(b)},min:f("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(a){return a=tb.apply(null,arguments),this>a?this:a}),max:f("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(a){return a=tb.apply(null,arguments),a>this?this:a}),zone:function(a,b){var c,d=this._offset||0;return null==a?this._isUTC?d:this._dateTzOffset():("string"==typeof a&&(a=Q(a)),Math.abs(a)<16&&(a=60*a),!this._isUTC&&b&&(c=this._dateTzOffset()),this._offset=a,this._isUTC=!0,null!=c&&this.subtract(c,"m"),d!==a&&(!b||this._changeInProgress?t(this,tb.duration(d-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,tb.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?tb(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return B(this.year(),this.month())},dayOfYear:function(a){var b=yb((tb(this).startOf("day")-tb(this).startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}
1702,quarter:function(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)},weekYear:function(a){var b=hb(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==a?b:this.add(a-b,"y")},isoWeekYear:function(a){var b=hb(this,1,4).year;return null==a?b:this.add(a-b,"y")},week:function(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")},isoWeek:function(a){var b=hb(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")},weekday:function(a){var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return C(this.year(),1,4)},weeksInYear:function(){var a=this.localeData()._week;return C(this.year(),a.dow,a.doy)},get:function(a){return a=x(a),this[a]()},set:function(a,b){return a=x(a),"function"==typeof this[a]&&this[a](b),this},locale:function(b){var c;return b===a?this._locale._abbr:(c=tb.localeData(b),null!=c&&(this._locale=c),this)},lang:f("moment().lang() is deprecated. Use moment().localeData() instead.",function(b){return b===a?this.localeData():this.locale(b)}),localeData:function(){return this._locale},_dateTzOffset:function(){return 15*Math.round(this._d.getTimezoneOffset()/15)}}),tb.fn.millisecond=tb.fn.milliseconds=ob("Milliseconds",!1),tb.fn.second=tb.fn.seconds=ob("Seconds",!1),tb.fn.minute=tb.fn.minutes=ob("Minutes",!1),tb.fn.hour=tb.fn.hours=ob("Hours",!0),tb.fn.date=ob("Date",!0),tb.fn.dates=f("dates accessor is deprecated. Use date instead.",ob("Date",!0)),tb.fn.year=ob("FullYear",!0),tb.fn.years=f("years accessor is deprecated. Use year instead.",ob("FullYear",!0)),tb.fn.days=tb.fn.day,tb.fn.months=tb.fn.month,tb.fn.weeks=tb.fn.week,tb.fn.isoWeeks=tb.fn.isoWeek,tb.fn.quarters=tb.fn.quarter,tb.fn.toJSON=tb.fn.toISOString,m(tb.duration.fn=l.prototype,{_bubble:function(){var a,b,c,d=this._milliseconds,e=this._days,f=this._months,g=this._data,h=0;g.milliseconds=d%1e3,a=o(d/1e3),g.seconds=a%60,b=o(a/60),g.minutes=b%60,c=o(b/60),g.hours=c%24,e+=o(c/24),h=o(pb(e)),e-=o(qb(h)),f+=o(e/30),e%=30,h+=o(f/12),f%=12,g.days=e,g.months=f,g.years=h},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return o(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*A(this._months/12)},humanize:function(a){var b=gb(this,!a,this.localeData());return a&&(b=this.localeData().pastFuture(+this,b)),this.localeData().postformat(b)},add:function(a,b){var c=tb.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=tb.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=x(a),this[a.toLowerCase()+"s"]()},as:function(a){var b,c;if(a=x(a),"month"===a||"year"===a)return b=this._days+this._milliseconds/864e5,c=this._months+12*pb(b),"month"===a?c:c/12;switch(b=this._days+qb(this._months/12),a){case"week":return b/7+this._milliseconds/6048e5;case"day":return b+this._milliseconds/864e5;case"hour":return 24*b+this._milliseconds/36e5;case"minute":return 24*b*60+this._milliseconds/6e4;case"second":return 24*b*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*b*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+a)}},lang:tb.fn.lang,locale:tb.fn.locale,toIsoString:f("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"},localeData:function(){return this._locale}}),tb.duration.fn.toString=tb.duration.fn.toISOString;for(vb in ic)c(ic,vb)&&rb(vb.toLowerCase());tb.duration.fn.asMilliseconds=function(){return this.as("ms")},tb.duration.fn.asSeconds=function(){return this.as("s")},tb.duration.fn.asMinutes=function(){return this.as("m")},tb.duration.fn.asHours=function(){return this.as("h")},tb.duration.fn.asDays=function(){return this.as("d")},tb.duration.fn.asWeeks=function(){return this.as("weeks")},tb.duration.fn.asMonths=function(){return this.as("M")},tb.duration.fn.asYears=function(){return this.as("y")},tb.locale("en",{ordinal:function(a){var b=a%10,c=1===A(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"; 1703return a+c}}),Jb?module.exports=tb:"function"==typeof define&&define.amd?(define("moment",function(a,b,c){return c.config&&c.config()&&c.config().noGlobal===!0&&(xb.moment=ub),tb}),sb(!0)):sb()}).call(this); 1704 1705if (typeof Object.create !== 'function') { 1706 Object.create = function(obj) { 1707 function F() {} 1708 F.prototype = obj; 1709 return new F(); 1710 }; 1711} 1712 1713(function($, window, document, undefined) { 1714 $.fn.socialfeed = function(_options) { 1715 1716 1717 var defaults = { 1718 plugin_folder: '', // a folder in which the plugin is located (with a
1718slash in the end) 1719 template: 'template.html', // a path to the template file 1720 show_media: false, // show images of attachments if available 1721 media_min_width: 300, 1722 length: 500, // maximum length of post message shown 1723 date_format: 'll' 1724 }; 1725 //--------------------------------------------------------------------------------- 1726 var options = $.extend(defaults, _options), 1727 container = $(this), 1728 template, 1729 social_networks = ['facebook', 'instagram', 'vk', 'google', 'blogspot', 'twitter', 'pinterest', 'rss'], 1730 posts_to_load_count = 0, 1731 loaded_post_count = 0; 1732 // container.empty().css('display', 'block'); 1733 //--------------------------------------------------------------------------------- 1734 1735 //--------------------------------------------------------------------------------- 1736 // This function performs consequent data loading from all of the sources by calling corresponding functions 1737 function calculatePostsToLoadCount() { 1738 social_networks.forEach(function(network) { 1739 if (options[network]) { 1740 if (options[network].accounts) { 1741 posts_to_load_count += options[network].limit * options[network].accounts.length; 1742 1743 } else if (options[network].urls ){ 1744 posts_to_load_count += options[network].limit * options[network].urls.length; 1745 1746 } else { 1747 posts_to_load_count += options[network].limit; 1748 } 1749 } 1750 }); 1751 1752 } 1753 1754 calculatePostsToLoadCount(); 1755 1756 function fireCallback() { 1757 1758 var fire = true; 1759 /*$.each(Object.keys(loaded), function() { 1760 if (loaded[this] > 0) 1761 fire = false; 1762 });*/ 1763 if (fire && options.callback) { 1764 options.callback(); 1765 } 1766 } 1767 1768 var Utility = { 1769 request: function(url, callback) { 1770 $.ajax({ 1771 url: url, 1772 dataType: 'jsonp', 1773 success: callback 1774 }); 1775 }, 1776 get_request: function(url, callback) { 1777 $.get(url, callback, 'json'); 1778 }, 1779 wrapLinks: function(string, social_network) { 1780 var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; 1781 if (social_network === 'google-plus') { 1782 string = string.replace(/(@|#)([a-z0-9_]+['])/ig, Utility.wrapGoogleplusTagTemplate); 1783 } else { 1784 string = string.replace(exp, Utility.wrapLinkTemplate); 1785 } 1786 return string; 1787 }, 1788 wrapLinkTemplate: function(string) { 1789 return '<a target="_blank" href="' + string + '">' + string + '<\/a>'; 1790 }, 1791 wrapGoogleplusTagTemplate: function(string) { 1792 return '<a target="_blank" href="https://plus.google.com/s/' + string + '" >' + string + '<\/a>'; 1793 }, 1794 shorten: function(string) { 1795 string = $.trim(string); 1796 if (string.length > options.length) { 1797 return jQuery.trim(string).substring(0, options.length).split(" ").slice(0, -1).join(" ") + "..."; 1798 } else { 1799 return string; 1800 } 1801 }, 1802 stripHTML: function(string) { 1803 if (typeof string === "undefined" || string === null) { 1804 return ''; 1805 } 1806 return string.replace(/(<([^>]+)>)|nbsp;|\s{2,}|/ig, ""); 1807 } 1808 }; 1809 1810 function SocialFeedPost(social_network, data) { 1811 this.content = data; 1812 this.content.social_network = social_network; 1813 this.content.attachment = (this.content.attachment === undefined) ? '' : this.content.attachment; 1814 this.content.time_ago = data.dt_create.fromNow(); 1815 this.content.date = data.dt_create.format(options.date_format); 1816 this.content.dt_create = this.content.dt_create.valueOf(); 1817 this.content.text = Utility.wrapLinks(Utility.shorten(data.message + ' ' + data.description), data.social_network); 1818 this.content.moderation_passed = (options.moderation) ? options.moderation(this.content) : true; 1819 1820 Feed[social_network].posts.push(this); 1821 } 1822 SocialFeedPost.prototype = { 1823 render: function() { 1824 var rendered_html = Feed.template(this.content); 1825 var data = this.content; 1826 1827 if ($(container).children('[social-feed-id=' + data.id + ']').length !== 0) { 1828 return false;
1829 } 1830 if ($(container).children().length === 0) { 1831 $(container).append(rendered_html); 1832 } else { 1833 var i = 0, 1834 insert_index = -1; 1835 $.each($(container).children(), function() { 1836 if ($(this).attr('dt-create') < data.dt_create) { 1837 insert_index = i; 1838 return false; 1839 } 1840 i++; 1841 }); 1842 $(container).append(rendered_html); 1843 if (insert_index >= 0) { 1844 insert_index++; 1845 var before = $(container).children('div:nth-child(' + insert_index + ')'), 1846 current = $(container).children('div:last-child'); 1847 $(current).insertBefore(before); 1848 } 1849 1850 } 1851 if (options.media_min_width) { 1852 1853 var query = '[social-feed-id=' + data.id + '] img.attachment'; 1854 var image = $(query); 1855 1856 // preload the image 1857 var height, width = ''; 1858 var img = new Image(); 1859 var imgSrc = image.attr("src"); 1860 1861 $(img).load(function() { 1862 1863 if (img.width < options.media_min_width) { 1864 image.hide(); 1865 } 1866 // garbage collect img 1867 delete img; 1868 1869 }).error(function() { 1870 // image couldnt be loaded 1871 image.hide(); 1872 1873 }).attr({ 1874 src: imgSrc 1875 }); 1876 1877 } 1878 1879 loaded_post_count++; 1880 1881 if (loaded_post_count == posts_to_load_count) { 1882 1883 fireCallback(); 1884 1885 $(document).trigger( 'smuzFeedPostsLoaded', [ 'arg' ] ); 1886 } 1887 1888 1889 1890 } 1891 1892 }; 1893 1894 var Feed = { 1895 template: false, 1896 init: function() { 1897 Feed.getTemplate(function() { 1898 social_networks.forEach(function(network) { 1899 if (options[network]) { 1900 if ( options[network].accounts ) { 1901 //loaded[network] = 0; 1902 options[network].accounts.forEach(function(account) { 1903 //loaded[network]++; 1904 Feed[network].getData(account); 1905 }); 1906 1907 } else if ( options[network].urls ) { 1908 options[network].urls.forEach(function(url) { 1909 Feed[network].getData(url); 1910 }); 1911 } else { 1912 Feed[network].getData(); 1913 } 1914 } 1915 }); 1916 }); 1917 }, 1918 getTemplate: function(callback) { 1919 if (Feed.template) 1920 return callback(); 1921 else { 1922 if (options.template_html) { 1923 Feed.template = doT.template(options.template_html); 1924 return callback(); 1925 } else { 1926 $.get(options.template, function(template_html) { 1927 Feed.template = doT.template(template_html); 1928 return callback(); 1929 }); 1930 } 1931 } 1932 }, 1933 twitter: { 1934 posts: [], 1935 loaded: false, 1936 api: 'http://api.tweecool.com/', 1937 1938 getData: function(account) { 1939 if ( ! account ) 1940 return; 1941 var cb = new Codebird(); 1942 cb.setConsumerKey(options.twitter.consumer_key, options.twitter.consumer_secret); 1943 1944 //Allow setting your own proxy with Codebird 1945 if (options.twitter.proxy !== undefined) { 1946 cb.setoxy(options.twitter.proxy); 1947 } 1948 1949 switch (account[0]) { 1950 case '@': 1951 var userid = account.substr(1); 1952 cb.__call( 1953 "statuses_userTimeline", 1954 "id=" + userid + "&count=" + options.twitter.limit, 1955 Feed.twitter.utility.getPosts, 1956 true // this parameter required 1957 ); 1958 break; 1959 case '#': 1960 var hashtag = account.substr(1); 1961 cb.__call( 1962 "search_tweets", 1963 "q=" + hashtag + "&count=" + options.twitter.limit, 1964 function(reply) { 1965 Feed.twitter.utility.getPosts(reply.statuses); 1966 }, 1967 true // this parameter required 1968 ); 1969 break; 1970 default: 1971 } 1972 }, 1973 utility: { 1974 getPosts: function(json) { 1975 if (json) { 1976 $.each(json, function() { 1977 var element = this; 1978 var post = new SocialFeedPost('twitter', Feed.twitter.utility.unifyPostData(element)); 1979 post.render(); 1980 }); 1981 } 1982 }, 1983 unifyPostData: function(element) { 1984 var post = {};
1985 if (element.id) { 1986 post.id = element.id; 1987 //prevent a moment.js console warning due to Twitter's poor date format. 1988 post.dt_create = moment(new Date(element.created_at)); 1989 post.author_link = 'http://twitter.com/' + element.user.screen_name; 1990 post.author_picture = element.user.profile_image_url; 1991 post.post_url = post.author_link + '/status/' + element.id_str; 1992 post.author_name = element.user.name; 1993 post.message = element.text; 1994 post.description = ''; 1995 post.link = 'http://twitter.com/' + element.user.screen_name + '/status/' + element.id_str; 1996 1997 if (options.show_media === true) { 1998 if (element.entities.media && element.entities.media.length > 0) { 1999 var image_url = element.entities.media[0].media_url; 2000 if (image_url) { 2001 post.attachment = '<img class="attachment" src="' + image_url + '" />'; 2002 } 2003 } 2004 } 2005 } 2006 return post; 2007 } 2008 } 2009 }, 2010 facebook: { 2011 posts: [], 2012 graph: 'https://graph.facebook.com/', 2013 loaded: false, 2014 getData: function(account) { 2015 if ( ! account ) return false; 2016 var proceed = function(request_url){ 2017 Utility.request(request_url, Feed.facebook.utility.getPosts); 2018 }; 2019 var fields = '?fields=id,from,message,created_time,story'; 2020 fields += (options.show_media === true)?',picture.width(500),attachments':''; 2021 var request_url, limit = '&limit=' + options.facebook.limit,
2022 query_extention = '&access_token=' + options.facebook.access_token + '&callback=?'; 2023 switch (account[0]) { 2024 case '@': 2025 var username = account.substr(1); 2026 Feed.facebook.utility.getUserId(username, function(userdata) { 2027 if (userdata.id !== '') { 2028 request_url = Feed.facebook.graph + 'v2.4/' + userdata.id + '/posts'+ fields + limit + query_extention; 2029 proceed(request_url); 2030 } 2031 }); 2032 break; 2033 case '!': 2034 var page = account.substr(1); 2035 request_url = Feed.facebook.graph + 'v2.4/' + page + '/feed'+ fields + limit + query_extention; 2036 proceed(request_url); 2037 break; 2038 default: 2039 proceed(request_url); 2040 } 2041 }, 2042 utility: { 2043 getUserId: function(username, callback) {
2044 var query_extention = '&access_token=' + options.facebook.access_token + '&callback=?'; 2045 var url = 'https://graph.facebook.com/' + username + '?' + query_extention; 2046 var result = ''; 2047 $.get(url, callback, 'json'); 2048 }, 2049 prepareAttachment: function(element) { 2050 2051 var image_url = element.picture; 2052 2053 2054 if ( element.attachments.data[0].media ) { 2055 image_url = element.attachments.data[0].media.image.src; 2056 } else { 2057 console.log(element.attachments.data[0].subattachments.data[0].media.image.src); 2058 image_url = element.attachments.data[0].subattachments.data[0].media.image.src; 2059 } 2060 2061 if ( image_url === undefined ) 2062 return; 2063 2064 /* if (image_url.indexOf('_b.') !== -1) { 2065 //do nothing it is already big 2066 } else if (image_url.indexOf('safe_image.php') !== -1) { 2067 image_url = Feed.facebook.utility.getExternalImageURL(image_url, 'url'); 2068 2069 } else if (image_url.indexOf('app_full_proxy.php') !== -1) { 2070 image_url = Feed.facebook.utility.getExternalImageURL(image_url, 'src'); 2071 2072 } else if (element.object_id) { 2073 image_url = Feed.facebook.graph + element.object_id + '/picture/?type=normal'; 2074 }*/ 2075 2076 return '<img class="attachment fb-image-attachment" src="' + image_url + '" />'; 2077 }, 2078 2079 prepareVideoAttachment: function(element) { 2080 2081 return '<div class="fb-video smuzsf-video" data-href="https://www.facebook.com/video.php?v='+ element.object_id +'" data-width="900" data-allowfullscreen="true"></div>'; 2082 }, 2083 getExternalImageURL: function(image_url, parameter) { 2084 image_url = decodeURIComponent(image_url).split(parameter + '=')[1]; 2085 if (image_url.indexOf('fbcdn-sphotos') === -1) { 2086 return image_url.split('&')[0]; 2087 } else { 2088 return image_url; 2089 } 2090 2091 }, 2092 getPosts: function(json) { 2093 //console.log(json['data']); 2094 if (json['data']) { 2095 json['data'].forEach(function(element) { 2096 var post = new SocialFeedPost('facebook', Feed.facebook.utility.unifyPostData(element)); 2097 post.render(); 2098 }); 2099 } 2100 }, 2101 unifyPostData: function(element) { 2102 var post = {}, 2103 text = (element.message) ? element.message : element.story; 2104 2105 post.id = element.id; 2106 post.dt_create = moment(element.created_time); 2107 post.author_link = 'http://facebook.com/' + element.from.id; 2108 post.author_picture = Feed.facebook.graph + element.from.id + '/picture'; 2109 post.author_name = element.from.name; 2110 post.name = element.name || ""; 2111 post.message = (text) ? text : ''; 2112 post.description = (element.description) ? element.description : ''; 2113 post.link = (element.link) ? element.link : 'http://facebook.com/' + element.from.id; 2114 2115 if ( post.link.search( '/videos/' ) !== -1 ) 2116 element.picture = 'video'; 2117 2118 if (options.show_media === true) { 2119 if (element.picture == 'video' ) { 2120 2121 var attachment = Feed.facebook.utility.prepareVideoAttachment(element); 2122 post.attachment = attachment; 2123 } else { 2124 2125 var attachment = Feed.facebook.utility.prepareAttachment(element); 2126 if (attachment) { 2127 post.attachment = attachment; 2128 } 2129 2130 } 2131 } 2132 return post; 2133 } 2134 } 2135 }, 2136 google: { 2137 posts: [], 2138 loaded: false, 2139 api: 'https://www.googleapis.com/plus/v1/', 2140 getData: function(account) { 2141 if ( ! account ) return false;
2142 var request_url; 2143 switch (account[0]) { 2144 case '#': 2145 var hashtag = account.substr(1); 2146 request_url = Feed.google.api + 'activities?query=' + hashtag + '&key=' + options.google.access_token + '&maxResults=' + options.google.limit; 2147 Utility.get_request(request_url, Feed.google.utility.getPosts); 2148 break; 2149 case '@': 2150 var username = account.substr(1); 2151 request_url = Feed.google.api + 'people/' + username + '/activities/public?key=' + options.google.access_token + '&maxResults=' + options.google.limit; 2152 Utility.get_request(request_url, Feed.google.utility.getPosts); 2153 break; 2154 default: 2155 } 2156 }, 2157 utility: { 2158 getPosts: function(json) { 2159 if (json.items) { 2160 $.each(json.items, function(i) { 2161 var post = new SocialFeedPost('google', Feed.google.utility.unifyPostData(json.items[i])); 2162 post.render(); 2163 }); 2164 } 2165 }, 2166 unifyPostData: function(element) { 2167 var post = {}; 2168 2169 post.id = element.id; 2170 post.attachment = ''; 2171 post.description = ''; 2172 post.dt_create = moment(element.published); 2173 post.author_link = element.actor.url; 2174 post.author_picture = element.actor.image.url; 2175 post.author_name = element.actor.displayName; 2176 2177 if (options.show_media === true) { 2178 if (element.object.attachments) { 2179 $.each(element.object.attachments, function() { 2180 var image = ''; 2181 if (this.fullImage) { 2182 image = this.fullImage.url; 2183 } else { 2184 if (this.objectType === 'album') { 2185 if (this.thumbnails && this.thumbnails.length > 0) { 2186 if (this.thumbnails[0].image) { 2187 image = this.thumbnails[0].image.url; 2188 } 2189 } 2190 } 2191 } 2192 post.attachment = '<img class="attachment fb-image-attachment" src="' + image
2192+ '"/>'; 2193 }); 2194 } 2195 } 2196 post.message = element.title; 2197 post.link = element.url; 2198 2199 return post; 2200 } 2201 } 2202 }, 2203 instagram: { 2204 posts: [], 2205 api: 'https://api.instagram.com/v1/', 2206 loaded: false, 2207 username: '', 2208 accessType: function() { 2209 // If we have both the client_id and access_token set in options, 2210 // use access_token for authentication. If client_id is not set 2211 // then use access_token. If neither are set, log an error to console. 2212 if (typeof options.instagram.access_token === 'undefined' && typeof options.instagram.client_id === 'undefined') { 2213 console.log('You need to define a client_id or access_token to authenticate with Instagram\'s API.'); 2214 return undefined; 2215 } 2216 if (options.instagram.access_token) { options.instagram.client_id = undefined; } 2217 options.instagram.access_type = (typeof options.instagram.client_id === 'undefined' ? 'access_token' : 'client_id'); 2218 return options.instagram.access_type; 2219 }, 2220 getData: function(account) { 2221 var url; 2222 if ( ! account ) return false; 2223 // API endpoint URL depends on which authentication type we're using. 2224 if (this.accessType() !== 'undefined') { 2225 var authTokenParams = options.instagram.access_type + '=' + options.instagram[options.instagram.access_type]; 2226 } 2227 2228 switch (account[0]) { 2229 case '@': 2230 var username = account.substr(1); 2231 //url = Feed.instagram.api + 'users/search/?q=' + username + '&' + authTokenParams + '&count=1' + '&callback=?'; 2232 options.instagram.username = username; 2233 2234 url = Feed.instagram.api + 'users/' + username + '/media/recent/?' + authTokenParams + '&count='+ + options.instagram.limit +'&callback=?'; 2235 2236 Utility.request(url, Feed.instagram.utility.getUsers); 2237 break; 2238 case '#': 2239 var hashtag = account.substr(1); 2240 url = Feed.instagram.api + 'tags/' + hashtag + '/media/recent/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 2241 Utility.request(url, Feed.instagram.utility.getImages); 2242 break; 2243 case '&': 2244 var id = account.substr(1); 2245 url = Feed.instagram.api + 'users/' + id + '/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 2246 Utility.request(url, Feed.instagram.utility.getUsers); 2247 default: 2248 } 2249 }, 2250 utility: { 2251 getImages: function(json) { 2252 if (json.data) { 2253 json.data.forEach(function(element) { 2254 2255 var post = new SocialFeedPost('instagram', Feed.instagram.utility.unifyPostData(element)); 2256 post.render(); 2257 }); 2258 } 2259 }, 2260 getUsers: function(json) { 2261 2262 // API endpoint URL depends on which authentication type we're using. 2263 if (options.instagram.access_type !== 'undefined') { 2264 var authTokenParams = options.instagram.access_type + '=' + options.instagram[options.instagram.access_type]; 2265 } 2266 2267 if (!jQuery.isArray(json.data)) json.data = [json.data] 2268 json.data.forEach(function(user) { 2269 var url = Feed.instagram.api + 'users/' + options.instagram.username + '/media/recent/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?'; 2270 Utility.request(url, Feed.instagram.utility.getImages); 2271 }); 2272 }, 2273 unifyPostData: function(element) { 2274 var post = {}; 2275
2276 post.id = element.id; 2277 post.dt_create = moment(element.created_time * 1000); 2278 post.author_link = 'http://instagram.com/' + element.user.username; 2279 post.author_picture = element.user.profile_picture; 2280 post.author_name = element.user.full_name || element.user.username; 2281 post.message = (element.caption && element.caption) ? element.caption.text : ''; 2282 post.description = ''; 2283 post.link = element.link; 2284 2285 2286 if (options.show_media) { 2287 post.attachment = '<img class="attachment" src="' + element.images.standard_resolution.url + '' + '" />'; 2288 2289 } 2290 return post; 2291 } 2292 } 2293 }, 2294 vk: { 2295 posts: [], 2296 loaded: false, 2297 base: 'http://vk.com/', 2298 api: 'https://api.vk.com/method/', 2299 user_json_template: 'https://api.vk.com/method/' + 'users.get?fields=first_name,%20last_name,%20screen_name,%20photo&uid=', 2300 group_json_template: 'https://api.vk.com/method/' + 'groups.getById?fields=first_name,%20last_name,%20screen_name,%20photo&gid=', 2301 getData: function(account) { 2302 var request_url; 2303 2304 switch (account[0]) { 2305 case '@': 2306 var username = account.substr(1); 2307 request_url = Feed.vk.api + 'wall.get?owner_id=' + username + '&filter=' + options.vk.source + '&count=' + options.vk.limit + '&callback=?'; 2308 Utility.get_request(request_url, Feed.vk.utility.getPosts); 2309 break; 2310 case '#': 2311 var hashtag = account.substr(1); 2312 request_url = Feed.vk.api + 'newsfeed.search?q=' + hashtag + '&count=' + options.vk.limit + '&callback=?'; 2313 Utility.get_request(request_url, Feed.vk.utility.getPosts); 2314 break; 2315 default: 2316 } 2317 }, 2318 utility: { 2319 getPosts: function(json) { 2320 if (json.response) { 2321 $.each(json.response, function() { 2322 if (this != parseInt(this) && this.post_type === 'post') { 2323 var owner_id = (this.owner_id) ? this.owner_id : this.from_id, 2324 vk_wall_owner_url = (owner_id > 0) ? (Feed.vk.user_json_template + owner_id + '&callback=?') : (Feed.vk.group_json_template + (-1) * owner_id + '&callback=?'), 2325 element = this; 2326 Utility.get_request(vk_wall_owner_url, function(wall_owner) { 2327 Feed.vk.utility.unifyPostData(wall_owner, element, json); 2328 }); 2329 } 2330 }); 2331 } 2332 }, 2333 unifyPostData: function(wall_owner, element, json) { 2334 var post = {}; 2335 2336 post.id = element.id; 2337 post.dt_create = moment.unix(element.date); 2338 post.description = ' '; 2339 post.message = Utility.stripHTML(element.text); 2340 if (options.show_media) { 2341 if (element.attachment) { 2342 if (element.attachment.type === 'link') 2343 post.attachment = '<img class="attachment" src="' + element.attachment.link.image_src + '" />'; 2344 if (element.attachment.type === 'video') 2345 post.attachment = '<img class="attachment" src="' + element.attachment.video.image_big + '" />'; 2346 if (element.attachment.type === 'photo') 2347 post.attachment = '<img class="attachment" src="' + element.attachment.photo.src_big + '" />'; 2348 } 2349 } 2350 2351 if (element.from_id > 0) { 2352 var vk_user_json = Feed.vk.user_json_template + element.from_id + '&callback=?'; 2353 Utility.get_request(vk_user_json, function(user_json) { 2354 var vk_post = new SocialFeedPost('vk', Feed.vk.utility.getUser(user_json, post, element, json)); 2355 vk_post.render(); 2356 }); 2357 2358 } else { 2359 var vk_group_json = Feed.vk.group_json_template + (-1) * element.from_id + '&callback=?'; 2360 Utility.get_request(vk_group_json, function(user_json) { 2361 var vk_post = new SocialFeedPost('vk', Feed.vk.utility.getGroup(user_json, post, element, json)); 2362 vk_post.render(); 2363 }); 2364 } 2365 }, 2366 getUser: function(user_json, post, element, json) { 2367 post.author_name = user_json.response[0].first_name + ' ' + user_json.response[0].last_name; 2368 post.author_picture = user_json.response[0].photo; 2369 post.author_link = Feed.vk.base + user_json.response[0].screen_name; 2370 post.link = Feed.vk.base + user_json.response[0].screen_name + '?w=wall' + element.from_id + '_' + element.i
2370d; 2371 2372 return post; 2373 }, 2374 getGroup: function(user_json, post, element, json) { 2375 post.author_name = user_json.response[0].name; 2376 post.author_picture = user_json.response[0].photo; 2377 post.author_link = Feed.vk.base + user_json.response[0].screen_name; 2378 post.link = Feed.vk.base + user_json.response[0].screen_name + '?w=wall-' + user_json.response[0].gid + '_' + element.id; 2379 2380 return post; 2381 } 2382 } 2383 }, 2384 blogspot: { 2385 loaded: false, 2386 getData: function(account) { 2387 var url; 2388 2389 switch (account[0]) { 2390 case '@': 2391 var username = account.substr(1); 2392 url = 'http://' + username + '.blogspot.com/feeds/posts/default?alt=json-in-script&callback=?'; 2393 request(url, getPosts); 2394 break; 2395 default: 2396 } 2397 }, 2398 utility: { 2399 getPosts: function(json) { 2400 $.each(json.feed.entry, function() { 2401 var post = {}, 2402 element = this; 2403 post.id = element.id['$t'].replace(/[^a-z0-9]/gi, ''); 2404 post.dt_create = moment((element.published['$t'])); 2405 post.author_link = element.author[0]['uri']['$t']; 2406 post.author_picture = 'http:' + element.author[0]['gd$image']['src']; 2407 post.author_name = element.author[0]['name']['$t']; 2408 post.message = element.title['$t'] + '</br></br>' + stripHTML(element.content['$t']); 2409 post.description = ''; 2410 post.link = element.link.pop().href; 2411 2412 if (options.show_media) { 2413 if (element['media$thumbnail']) { 2414 post.attachment = '<img class="attachment" src="' + element['media$thumbnail']['url'] + '" />'; 2415 } 2416 } 2417 2418 post.render(); 2419 2420 }); 2421 } 2422 } 2423 }, 2424 pinterest: { 2425 posts: [], 2426 loaded: false, 2427 apiv1: 'https://api.pinterest.com/v1/', 2428 2429 getData: function(account) { 2430 var request_url, 2431 limit = 'limit=' + options.pinterest.limit, 2432 fields = 'fields=id,created_at,link,note,creator(url,first_name,last_name,image),image', 2433 query_extention = fields + '&access_token='
2433+ options.pinterest.access_token + '&' + limit + '&callback=?'; 2434 switch (account[0]) { 2435 case '@': 2436 var username = account.substr(1); 2437 if (username === 'me') { 2438 request_url = Feed.pinterest.apiv1 + 'me/pins/?' + query_extention; 2439 } else { 2440 request_url = Feed.pinterest.apiv1 + 'boards/' + username + '/pins?' + query_extention; 2441 } 2442 break; 2443 default: 2444 } 2445 Utility.request(request_url, Feed.pinterest.utility.getPosts); 2446 }, 2447 utility: { 2448 2449 getPosts: function(json) { 2450 json.data.forEach(function(element) { 2451 var post = new SocialFeedPost('pinterest', Feed.pinterest.utility.unifyPostData(element)); 2452 post.render(); 2453 }); 2454 }, 2455 2456 unifyPostData: function(element){ 2457 var post = {}; 2458 2459 post.id = element.id; 2460 post.dt_create= moment(element.created_at); 2461 post.author_link = element.creator.url; 2462 post.author_picture = element.creator.image['60x60' ].url; 2463 post.author_name = element.creator.first_name + element.creator.last_name; 2464 post.message = element.note; 2465 post.description = ''; 2466 post.social_network = 'pinterest'; 2467 post.link = element.link ? element.link : 'https://www.pinterest.com/pin/' + element.id; 2468 if (options.show_media) { 2469 post.attachment = '<img class="attachment" src="' + element.image['original'].url + '" />'; 2470 } 2471 return post; 2472 } 2473 } 2474 }, 2475 rss : { 2476 posts: [], 2477 loaded: false, 2478 api : 'https://query.yahooapis.com/v1/public/yql?q=', 2479 datatype: 'json', 2480 2481 getData: function(url) { 2482 var limit = options.rss.limit, 2483 yql = encodeURIComponent('select entry FROM feednormalizer where url=\'' + url + '\' AND output=\'atom_1.0\' | truncate(count=' + limit + ')' ), 2484 request_url = Feed.rss.api + yql + '&format=json&callback=?'; 2485 2486 Utility.request(request_url, Feed.rss.utility.getPosts, Feed.rss.datatype); 2487 }, 2488 utility: { 2489 2490 getPosts: function(json) { 2491 console.log(json); 2492 if (json.query.count > 0 ){ 2493 $.each(json.query.results.feed, function(index, element) { 2494 var post = new SocialFeedPost('rss', Feed.rss.utility.unifyPostData(index, element)); 2495 post.render(); 2496 }); 2497 } 2498 }, 2499 2500 unifyPostData: function(index, element){ 2501 2502 var item = element; 2503 2504 if ( element.entry !== undefined ){ 2505 item = element.entry; 2506 } 2507 var post = {}; 2508 2509 post.id = '"' + item.id + '"'; 2510 post.dt_create= moment(item.published, 'YYYY-MM-DDTHH:mm:ssZ', 'en'); 2511 2512 post.author_link = ''; 2513 post.author_picture = ''; 2514 post.author_name = ''; 2515 if( item.creator !== undefined ){ 2516 post.author_name = item.creator; 2517 } 2518 post.message = item.title; 2519 post.description = ''; 2520 if( item.summary !== undefined ){ 2521 post.description = Utility.stripHTML(item.summary.content); 2522 } 2523 post.social_network = 'rss'; 2524 post.link = item.link.href; 2525 if (options.show_media && item.thumbnail !== undefined ) { 2526 post.attachment = '<img class="attachment" src="' + item.thumbnail.url + '" />'; 2527 } 2528 return post; 2529 } 2530 } 2531 } 2532 }; 2533 2534 //make the plugin chainable 2535 return this.each(function() { 2536 // Initialization 2537 Feed.init(); 2538 if (options.update_period) { 2539 setInterval(function() { 2540 return Feed.init(); 2541 }, options.update_period); 2542 } 2543 }) 2544 }; 2545 2546})(jQuery); 2547(function($) { 2548 2549$(document).ready(function() { 2550 2551 $.ajaxSetup({ cache: true }); 2552 2553 $.getScript('//connect.facebook.net/en_US/sdk.js', function(){ 2554 2555 FB.init({ 2556 version: 'v2.5', 2557 xfbml: true 2558 }); 2559 }); 2560 2561 2562$('.social-feed-container').each( function() { 2563 2564 var selector = $('#feed'+ $(this).data('id') ); 2565 2566 var ajaxLink = selector.data('ajaxlink'); 2567 2568 var fb_username = selector.data('facebook'); 2569 2570 var tw_username = selector.data('twitter'); 2571 2572 var tw_id = selector.data('twitterid'); 2573 2574 var tw_secret = selector.data('twittersecret'); 2575 2576 var fb_limit = selector.data('fblimit'); 2577 2578 var tw_limit = selector.data('twlimit'); 2579 2580 var insta_limit = selector.data('instalimit'); 2581 2582 var fb_token = selector.data('fbtoken'); 2583 2584 var insta_username = selector.data('instagram'); 2585 2586 var insta_token = selector.data('instagramtoken'); 2587 2588 var layout = selector.data('template'); 2589 2590 var facebook_arr = { limit: 0Â }; 2591 var twitter_arr = { limit: 0 }; 2592 var insta_arr = { limit: 0 }; 2593 2594 var template = '' 2595 2596 if ( layout == 'layout' ) { 2597 2598 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id = "{{=it.id}}"> <div class="uniqcontent"> <a class="pull-left" href="{{=it.author_link}}" target="_blank"> <img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}"> </a> <div class="media-body"> <p> <i class="smuzsf-socialicon fa fa-{{=it.social_network}}"></i> <span class="author-title">{{=it.author_name}}</span> <span class="smuzsf-date muted pull-right"> {{=it.time_ago}}</span> </p> </div><div class="text-wrapper"> <p class="social-feed-text">{{=it.text}} <a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a></p> </div> </div> <div class="media-attachment">{{=it.attachment}}</div> </div>'; 2599 } 2600 if ( layout == 'layout1' ) { 2601 2602 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id = "{{=it.id}}"><div class="uniqcontent"><div class="text-wrapper"><p class="social-feed-text">{{=it.text}}<a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a></p></div><div class="media-attachment">{{=it.attachment}}</div><a class="pull-left" href="{{=it.author_link}}" target="_blank"><img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}"></a><div class="media-body"><p><i class="smuzsf-socialicon fa fa-{{=it.social_network}}"></i><span class="author-title">{{=it.author_name}}</span><br/><span class="smuzsf-date muted "> {{=it.time_ago}}</span></p></div></div></div>'; 2603 } 2604 if ( layout == 'layout2' ) { 2605 2606 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id = "{{=it.id}}"><div class="social-feed-avatar-postition"><a class="pull-left" href="{{=it.author_link}}" target="_blank"><img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}"></a></div><div class="media-body"><p><span class="author-title">{{=it.author_name}}</span><br><span class="smuzsf-date muted "> {{=it.time_ago}}</span></p></div><div class="uniqcontent"><div class="text-wrapper"><p class="social-feed-text">{{=it.text}}<a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a></p></div><hr/></div><i class="smuzsf-socialicon fa fa-{{=it.social_network}}"></i></div>'; 2607 } 2608 if ( layout == 'layout3' ) { 2609 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id = "{{=it.id}}"><div class="uniqcontent"><div class="media-attachment">{{=it.attachment}}</div><div class="text-wrapper"><p class="social-feed-text">{{=it.text}} <a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a></p></div><a class="pull-left" href="{{=it.author_link}}" target="_blank"><img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}"></a><br/>
2609<div class="media-body"><p><span class="author-title">{{=it.author_name}}</span><br><span class="smuzsf-date muted ">Posted {{=it.time_ago}}</span></p></div></div></div>'; 2610 2611} 2612 if ( layout == 'layout4' ) { 2613 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id="{{=it.id}}"><div class="media-attachment social-attachment">{{=it.attachment}}</div><div class="uniqcontent"><div class="text-wrapper"><p class="social-feed-text">{{=it.text}} <a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a></p></div></div><div class="wpsfb-card-footer-{{=it.social_network}}"><a class="pull-left" href="{{=it.author_link}}" target="_blank"><img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}"></a><div class="media-body"><p><span class="author-title">{{=it.author_name}}</span><br><span class="smuzsf-date muted "> {{=it.time_ago}}</span></p></div></div></div>'; 2614 2615} 2616 if ( layout == 'layout5' ) { 2617 template = '<div id="wpsfp-item" class="grid-item social-feed-element {{? !it.moderation_passed}}hidden{{?}}" dt-create="{{=it.dt_create}}" social-feed-id="{{=it.id}}"> <div class="media-attachment">{{=it.attachment}} <div class="wpsfb-card-footer"> <a class="pull-left" href="{{=it.author_link}}" target="_blank" > <img class="smuzsf-authorpic media-object" src="{{=it.author_picture}}" > </a> <div class="media-body"> <p> <span class="author-title">{{=it.author_name}}</span> <br> <span class="smuzsf-date muted "> {{=it.time_ago}}</span> </p> </div> </div> </div> <div class="uniqcontent" > <div class="text-wrapper" > <p class="social-feed-text">{{=it.text}} <a href="{{=it.link}}" target="_blank" class="smuzsf-readlink read-button"> read more</a> </p> </div> </div> </div>'; 2618 2619} 2620 2621 2622 2623 2624 if ( selector.data('isfb') == '1' ) { 2625 facebook_arr = { 2626 accounts: [fb_username], 2627 limit: parseInt( fb_limit ), 2628 access_token: fb_token 2629 }; 2630 } 2631 2632 if ( selector.data('istw') == '1' ) { 2633 twitter_arr = { 2634 accounts: [tw_username], 2635 limit: parseInt( tw_limit ), 2636 consumer_key: tw_id, // make sure to have your app read-only 2637 consumer_secret: tw_secret // make sure to have your app read-only 2638 }; 2639 } 2640 2641 if ( selector.data('isinsta') == '1' ) { 2642 2643 insta_arr = { 2644 accounts: [insta_username], 2645 limit: parseInt( insta_limit ), 2646 client_id: '6fe1728b3e7844a4a0065ee7465166e7', 2647 access_token: insta_token 2648 }; 2649 } 2650 2651 2652 selector.parent().append( '<div class="smfeed-ajax-spinner"><div class="sk-circle"><div class="sk-circle1 sk-child"></div> <div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div></div>' ); 2653 2654 selector.hide(); 2655 2656 selector.socialfeed({ 2657 2658 facebook: facebook_arr, 2659 twitter: twitter_arr, 2660 instagram: insta_arr, 2661 2662 template_html: template, 2663 show_media: true, 2664 length:400, 2665 callback: function() { 2666 2667 setTimeout( function() { 2668 2669 $('.smfeed-ajax-spinner').hide(); 2670 2671 selector.show(); 2672 2673 selector.packery({ 2674 // options... 2675 itemSelector: '.grid-item', 2676 gutter: 10 2677 }); 2678 2679 }, 1000 ); 2680 2681 setTimeout( function() { 2682 2683 2684 selector.packery({ 2685 // options... 2686 itemSelector: '.grid-item', 2687 gutter: 10 2688 }); 2689 2690 }, 4000 ); 2691 2692 window.smuzcallbackWorking = true; 2693 } 2694 2695 }); 2696 2697 2698 2699 setTimeout( function() { 2700 if ( window.smuzcallbackWorking ) 2701 return; 2702 2703 $('.smfeed-ajax-spinner').hide(); 2704 2705 selector.show(); 2706 2707 selector.packery({ 2708 // options... 2709 itemSelector: '.grid-item', 2710 gutter: 10 2711 }); 2712 }, 6000 ); 2713 2714 2715 }); 2716 2717} ); 2718 2719})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.