MediaWiki:Snow 3D.js

!function(t){!function e(t,n,o){function r(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return r(n?n:e)},u,u.exports,e,t,n,o)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<o.length;a++)r(o[a]);return r}({1:[function(t,e){var n=function{function t{this.num=200,this.speed=1,this.showOnce="",this.disableMouse=!1,this.fadeScroll=!1,this.url="",this.prefix="fly3d",this.direction="down",this.minScale=10,this.maxScale=30,this.closeButton="Hide",this.closeButtonMode="session",this.closeButtonStyles=""}return t};e.exports=n},{}],2:[function(e,n){var o=this.__extends||function(t,e){function n{this.constructor=t}for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);n.prototype=e.prototype,t.prototype=new n},r=e("./core/base-config"),i=e("./config-defaults"),a=new i,s=function(e){function n(n,o){var r=n.value;delete n.value,n.value=r,e.call(this,t.extend({},a,n),o,a)}return o(n,e),n.setDefaults=function{},n}(r.BaseConfig);n.exports=s},{"./config-defaults":1,"./core/base-config":5}],3:[function(e,n,o){var r=this.__extends||function(t,e){function n{this.constructor=t}for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);n.prototype=e.prototype,t.prototype=new n},i=e("./core/a"),a=e("./core/observable"),s=e("./config"),c=e("./engine");window.requestAnimFrame=function{return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}};var u=function(e){function n(n,o){e.call(this),this.isActive=!0,this.mouseX=0,this.mouseY=0;var r=this;r.$el=n;var a=r._config=new s(o,i.bind(r._onConfigChange,r)),u=a.get("prefix");if(a.get("showOnce")){var p=t.cookie(u),f={path:"/"};if("session"!=a.get("showOnce")&&(f.expires=parseInt(a.get("showOnce"),10)||1),t.cookie(u,!0,f),p)return}if(!t.cookie(u+"-hidden")){var l=r.engine=new c(i.bind(r.getXY,r));l.create(n);var h=a.get("url"),d=a.get("images"),g=[];"string"==t.type(d)&&(d=d.split(","));var v=new PxLoader;i.each(d,function(t){v.addImage(h+t),g.push(h+t)}),v.addCompletionListener(function{r.create(g)}),v.start,a.get("fadeScroll")&&t(window).scroll(i.bind(r.onScroll,r)),t(window).resize(i.bind(r.onResize,r)),a.get("disableMouse")||(document.addEventListener("mousemove",i.bind(r.onDocumentMouseMove,r),!1),document.addEventListener("touchstart",i.bind(r.onDocumentTouchStart,r),!1),document.addEventListener("touchmove",i.bind(r.onDocumentTouchMove,r),!1)),r.closeButton}}return r(n,e),n.prototype.closeButton=function{var e=this,n=e._config.get("closeButton"),o=e._config.get("closeButtonMode"),r=e._config.get("closeButtonStyles");if(n&&0!=n){e.closeBtn=t("",{"class":"fly-close-btn",css:{"background-color":"white",cursor:"pointer",position:"fixed",bottom:"0px",left:"0px",padding:"10px 20px","z-index":"10000000"},html:n||"Close"}),r&&e.closeBtn.attr("style",e.closeBtn.attr("style")+"; "+r);var i=e._config.get("prefix");e.closeBtn.click(function{if("once"!=o){var n={path:"/"};"session"!=o&&(n.expires=parseInt(o,10)||1),t.cookie(i+"-hidden",!0,n)}e.destroy}),t("body").append(e.closeBtn)}},n.prototype.onScroll=function{var t=this;t.engine.updateOpacity},n.prototype.create=function(t){var e=this,n=e._config,o=e.engine;o.generateParticles(t,n.get("num"),n.get("speed"),n.get("minScale"),n.get("maxScale"),n.get("direction"));var r=i.bind(o.frame,o),a=function{e.isActive&&(setTimeout(r,0),window.requestAnimFrame(a))};a},n.prototype.onResize=function{var t=this;t.engine.updateSize(t.$el)},n.prototype.getXY=function{var t=this;return[t.mouseX,t.mouseY]},n.prototype.onDocumentMouseMove=function(e){var n=this;n.mouseX=e.clientX-t(window).width/2,n.mouseY=e.clientY-t(window).height/2},n.prototype.onDocumentTouchStart=function(e){var n=this;1==e.touches.length&&(n.mouseX=e.touches[0].pageX-t(window).width/2,n.mouseY=e.touches[0].pageY-t(window).height/2)},n.prototype.onDocumentTouchMove=function(e){var n=this;1==e.touches.length&&(n.mouseX=e.touches[0].pageX-t(window).width/2,n.mouseY=e.touches[0].pageY-t(window).height/2)},n.prototype._onConfigChange=function{},n.prototype.destroy=function{var t=this;t.isActive=!1,t.engine.stop,t.closeBtn.remove},n}(a);o.Controller=u},{"./config":2,"./core/a":4,"./core/observable":6,"./engine":7}],4:[function(t,e){var n={},o=Array.prototype,r=Object.prototype,i=Function.prototype,a=o.slice,s=o.forEach,c=o.indexOf,u=Object.keys,p=i.bind,f=r.toString,l=r.hasOwnProperty,h=String.prototype.trim,d=function(t){return null==t?"\\s":t.source?t.source:"["+m.strEscapeRegExp(t)+"]"},g=0,v=function{},m=function{function t{}return t.has=function(t,e){return l.call(t,e)},t.keys=function(e){if(!t.isObject(e))return[];if(u)return u(e);var n=[];for(var o in e)t.has(e,o)&&n.push(o);return n},t.each=function(e,o,r){if(null==e)return e;if(s&&e.forEach===s)e.forEach(o,r);else if(e.length===+e.length){for(var i=0,a=e.length;a>i;i++)if(o.call(r,e[i],i,e)===n)return}else for(var c=t.keys(e),i=0,u=c.length;u>i;i++)if(o.call(r,e[c[i]],c[i],e)===n)return;return e},t.extend=function(e){for(var n=[],o=1;on?Math.max(0,r+n):n}if(c&&t.indexOf===c)return t.indexOf(e,n);for(r>o;o++)if(t[o]===e)return o;return-1},t.isObject=function(t){return t===Object(t)},t.bind=function(e,n){var o,r;if(p&&e.bind===p)return p.apply(e,a.call(arguments,1));if(!t.isFunction(e))throw new TypeError;return o=a.call(arguments,2),r=function{if(!(this instanceof r))return e.apply(n,o.concat(a.call(arguments)));v.prototype=e.prototype;var t=new v;v.prototype=null;var i=e.apply(t,o.concat(a.call(arguments)));return Object(i)===i?i:t}},t.isFunction=function(t){return"[object Function]"==f.call(t)},t.format=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.replace(/\{\{|\}\}|\{(\d+)\}/g,function(t,n){return"{{"==t?"{":"}}"==t?"}":e[n]})},t.strEscapeRegExp=function(t){return null==t?"":String(t).replace(/([.*+?^=!:${}|[\]\/\\])/g,"\\$1")},t.strTrim=function(t,e){return null==t?"":!e&&h?h.call(t):(e=d(e),String(t).replace(new RegExp("^"+e+"+|"+e+"+$","g"),""))},t.strCamelize=function(e){return t.strTrim(e).replace(/[-_\s]+(.)?/g,function(t,e){return e?e.toUpperCase:""})},t.strCapitalize=function(t){return t=null==t?"":String(t),t.charAt(0).toUpperCase+t.slice(1)},t};e.exports=m},{}],5:[function(e,n,o){var r=this.__extends||function(t,e){function n{this.constructor=t}for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);n.prototype=e.prototype,t.prototype=new n},i=e("./a"),a=e("./observable"),s=function(e){function n(t,n,o){this._data={},this._defaults=o,e.call(this),i.isFunction(n)&&this.on("change",n),i.isObject(t)&&this.update(t)}return r(n,e),n.prototype.update=function(t,e){var n=this;i.isObject(t)&&i.each(t,function(t,o){return n.set(o,t,e)})},n.prototype.get=function(t){var e=i.strCapitalize(i.strCamelize(t)),n="get"+e;return i.isFunction(this[t])?this._data[t](this):i.isFunction(this[n])?this._data[n](this):this._data[t]},n.prototype.set=function(e,n,o){var r=i.strCapitalize(i.strCamelize(e)),a="set"+r,s=this._data[e];i.isFunction(this[a])?this._data[a](n):("boolean"==t.type(this._defaults[e])&&(n="true"===String(n)),"number"==t.type(this._defaults[e])&&(n=parseFloat(n)),"string"==t.type(this._defaults[e])&&(n=String(n)),this._data[e]=n),(s!==n&&(!o||!o.silence)||o&&o.force)&&this.trigger("change",[this,e,n,s,o])},n.prototype.toggle=function(t){this.set(t,!this.get(t))},n}(a);o.BaseConfig=s},{"./a":4,"./observable":6}],6:[function(e,n){var o=e("./a"),r=function{function e{}return e.prototype.on=function(e){var n=this,r=function(e,o,r){r&&(o=_.bind(o,r)),t(n).on(e,o)};return o.isObject(e)?o.each(e,function(t,n){"scope"!=n&&r(n,t,e.scope)}):r.apply(n,arguments),this},e.prototype.one=function(e,n,o){return o&&(n=_.bind(n,o)),t(this).one(e,n),this},e.prototype.off=function(e){return t(this).off(e),this},e.prototype.trigger=function(e,n){return t(this).trigger(e,n),this},e.prototype.only=function(t,e,n){return this.off(t),this.on(t,e,n),this},e};n.exports=r},{"./a":4}],7:[function(e,n){function o(t,e){return t+Math.floor(Math.random*(e-t+1))}var r=this.__extends||function(t,e){function n{this.constructor=t}for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);n.prototype=e.prototype,t.prototype=new n},i=e("./core/a"),a=e("./core/observable"),s=e("./particle"),c=function(e){function n(t){e.call(this),this.disabled=!1;var n=this;n.positionReader=t}return r(n,e),n.prototype.create=function(e){var n=this;n.camera=new THREE.PerspectiveCamera(75,1,1,5e3),n.camera.position.z=1e3,n.scene=new THREE.Scene,n.scene.add(n.camera),n.renderer=WebGLDetector.webgl?new THREE.WebGLRenderer({alpha:!0,antialias:!0}):new THREE.CanvasRenderer({alpha:!0,overdraw:!0}),n.updateSize(e),n.container=t(" ",{css:{position:"fixed",left:"0px",top:"0px",right:"0px",bottom:"0px",pointerEvents:"none",zIndex:9999999},html:n.renderer.domElement}),e.append(n.container)},n.prototype.stop=function{var t=this;t.renderer.clear,t.container.remove},n.prototype.updateOpacity=function{var e=t(window).height,n=t(window).scrollTop,o=(e-n)/e;0==o?(this.disabled=!0,this.container.hide):(this.disabled=!1,this.container.show),this.container.animate({opacity:o},150)},n.prototype.updateSize=function(e){var n=this,o=e.width,r=e.height;e.is("body")&&(o=t(window).width,r=t(window).height),n.renderer.setSize(o,r),n.camera.aspect=o/r,n.camera.updateProjectionMatrix},n.prototype.generateParticles=function(t,e,n,r,i,a){var c=this;c.particles=[];for(var u=0;e>=u;u++){var p=o(0,t.length-1);THREE.ImageUtils.loadTexture(t[p],null,function(t){var e=new THREE.SpriteMaterial({map:t,color:16777215,transparent:!0}),u=new s(e,n,a);u.position.x=o(-1e3,1e3),u.position.y=o(-1e3,1e3),u.position.z=o(200,1e3),u.scale.x=u.scale.y=o(r,i),c.scene.add(u),c.particles.push(u)})}},n.prototype.resetPosition=function(t){var e=this,n=e.camera.position.z,o=function(t){return t>n&&(t-=2*n),-1*n>t&&(t+=2*n),t};t.position.x=o(t.position.x),t.position.y=o(t.position.y),t.position.z=o(t.position.z)},n.prototype.frame=function{if(!this.disabled){var t=this,e=t.positionReader;i.each(t.particles,function(e){e.position.add(e.velocity),t.resetPosition(e)}),t.camera.position.x+=.15*(-e[0]-t.camera.position.x),t.camera.position.y+=.15*(e[1]-t.camera.position.y),t.camera.lookAt(t.scene.position),t.renderer.render(t.scene,t.camera)}},n}(a);n.exports=c},{"./core/a":4,"./core/observable":6,"./particle":9}],8:[function(e){var n=e("./controller"),o=function{var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents},r=function{return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?!0:!1},i=function(e){var i=this;if(o&&(!e||e.enableMobile||!r))return this.each(function{var o=t(i),r=e.prefix||"fly3d",a=o.data(r);a&&a.destroy;var s=new n.Controller(o,e||{});o.data(r,s)})};t.fn.snow3d=i,t.fn.fly3d=i},{"./controller":3}],9:[function(t,e){function n(t,e){return Math.random*(e-t)+t}var o=this.__extends||function(t,e){function n{this.constructor=t}for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);n.prototype=e.prototype,t.prototype=new n},r=Math.PI/180,i=function(t){function e(e,o,r){t.call(this,e);var i=this;i.velocity="up"==r?new THREE.Vector3(0,3*o,0):new THREE.Vector3(0,-3*o,0),i.rotateXY(n(-65,65),n(0,270)),i.gravity=new THREE.Vector3(0,0,0),i.drag=1}return o(e,t),e.prototype.rotateXY=function(t,e){var n,o,i,a,s,c=this,u=c.velocity,p=t*r,f=e*r;a=Math.cos(p),s=Math.sin(p),o=u.y*a+u.z*s,i=u.y*-s+u.z*a,u.y=o,u.z=i,a=Math.cos(f),s=Math.sin(f),n=u.x*a+u.z*s,i=u.x*-s+u.z*a,u.x=n,u.z=i},e}(THREE.Sprite);e.exports=i},{}]},{},[8])}(jQuery);