Socket
Socket
Sign inDemoInstall

phaser-input

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phaser-input - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

1

build/phaser-input.d.ts

@@ -6,2 +6,3 @@ declare module Fabrique {

placeHolder?: string;
fillAlpha?: number;
width?: number;

@@ -8,0 +9,0 @@ height?: number;

@@ -0,1 +1,10 @@

/*!
* phaser-input - version 0.0.4
* Adds input boxes to Phaser like CanvasInput, but also works for WebGL.
*
* OrangeGames
* Build at 10-02-2016
* Released under MIT License
*/
var __extends = (this && this.__extends) || function (d, b) {

@@ -63,2 +72,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var borderColor = (inputOptions.borderColor) ? parseInt(inputOptions.borderColor.slice(1), 16) : 0x959595;
var alpha = (inputOptions.fillAlpha !== undefined) ? inputOptions.fillAlpha : 1;
var height = inputOptions.height || 14;

@@ -73,4 +83,4 @@ if (inputOptions.font) {

this.box = new Phaser.Graphics(this.game, 0, 0);
this.box.beginFill(bgColor, 1)
.lineStyle(inputOptions.borderWidth || 1, borderColor, 1)
this.box.beginFill(bgColor, alpha)
.lineStyle(inputOptions.borderWidth || 1, borderColor, alpha)
.drawRoundedRect(0, 0, width, height, inputOptions.borderRadius || 3);

@@ -77,0 +87,0 @@ this.addChild(this.box);

5

build/phaser-input.min.js
/*!
* phaser-input - version 1.0.0
* phaser-input - version 0.0.4
* Adds input boxes to Phaser like CanvasInput, but also works for WebGL.
*
* OrangeGames
* Build at 08-02-2016
* Build at 10-02-2016
* Released under MIT License
*/
var __extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},Fabrique;!function(a){!function(a){a[a.text=0]="text",a[a.password=1]="password"}(a.InputType||(a.InputType={}));var b=a.InputType,c=function(a){function c(c,d,e,f){a.call(this,c,d,e),this.placeHolder=null,this.box=null,this.focus=!1,this.type=b.text,this.value="",this.id="phaser-input-"+(1e4*Math.random()|0).toString(),this.blink=!0,this.cnt=0,this.padding=f.padding||0,this.createBox(f),f.placeHolder&&f.placeHolder.length>0&&(this.placeHolder=new Phaser.Text(c,this.padding,this.padding,f.placeHolder,{font:f.font||"14px Arial",fontWeight:f.fontWeight||"normal",fill:f.placeHolderColor||"#bfbebd"}),this.addChild(this.placeHolder)),this.cursor=new Phaser.Text(c,this.padding,this.padding-2,"|",{font:f.font||"14px Arial",fontWeight:f.fontWeight||"normal",fill:f.fill||"#000000"}),this.cursor.visible=!1,this.addChild(this.cursor),this.text=new Phaser.Text(c,this.padding,this.padding,"",{font:f.font||"14px Arial",fontWeight:f.fontWeight||"normal",fill:f.placeHolderColor||"#000000"}),this.addChild(this.text),f.type&&(this.type=f.type),this.inputEnabled=!0,this.input.useHandCursor=!0,this.game.input.onDown.add(this.checkDown,this)}return __extends(c,a),c.prototype.createBox=function(a){var b=a.backgroundColor?parseInt(a.backgroundColor.slice(1),16):16777215,c=a.borderColor?parseInt(a.borderColor.slice(1),16):9803157,d=void 0!==a.fillAlpha?a.fillAlpha:1,e=a.height||14;a.font&&(e=Math.max(parseInt(a.font.substr(0,a.font.indexOf("px")),10),e)),e=2*this.padding+e;var f=a.width||150;f=2*this.padding+f,this.box=new Phaser.Graphics(this.game,0,0),this.box.beginFill(b,d).lineStyle(a.borderWidth||1,c,d).drawRoundedRect(0,0,f,e,a.borderRadius||3),this.addChild(this.box)},c.prototype.checkDown=function(a){this.input.checkPointerOver(a)?(this.focus=!0,this.placeHolder.visible=!1,this.createDomElement()):this.focus===!0&&this.endFocus()},c.prototype.createDomElement=function(){var a=this,c=document.getElementById(this.id),d=!1;null===c&&(c=document.createElement("input"),d=!0),c.id=this.id,c.style.position="absolute",c.style.top=(-100).toString()+"px",c.style.left=(-100).toString()+"px",c.value=this.value,this.type===b.password?c.type="password":c.type="text",d&&document.body.appendChild(c),setTimeout(function(){c.focus()},10),this.callback=function(){return a.keyListener()},document.addEventListener("keyup",this.callback)},c.prototype.removeDomElement=function(){var a=document.getElementById(this.id);document.body.removeChild(a),document.removeEventListener("keyup",this.callback)},c.prototype.update=function(){if(this.focus){if(30!==this.cnt)return this.cnt++;this.cursor.visible=this.blink,this.blink=!this.blink,this.cnt=0}},c.prototype.endFocus=function(){this.focus=!1,0===this.value.length&&(this.placeHolder.visible=!0),this.cursor.visible=!1,this.removeDomElement()},c.prototype.updateText=function(){var a="";if(this.type===b.password)for(var c=0;c<this.value.length;c++)a+="*";else a=this.value;this.text.setText(a),this.cursor.x=this.text.width+this.padding},c.prototype.keyListener=function(){this.value=document.getElementById(this.id).value,this.updateText()},c}(Phaser.Sprite);a.InputField=c}(Fabrique||(Fabrique={}));var Fabrique;!function(a){var b;!function(b){var c=function(b){function c(a,c){b.call(this,a,c),this.addInputFieldFactory()}return __extends(c,b),c.prototype.addInputFieldFactory=function(){Phaser.GameObjectFactory.prototype.inputField=function(b,c,d,e){void 0===e&&(e=this.world);var f=new a.InputField(this.game,b,c,d);return e.add(f)},Phaser.GameObjectCreator.prototype.inputField=function(b,c,d){return new a.InputField(this.game,b,c,d)}},c}(Phaser.Plugin);b.InputField=c}(b=a.Plugins||(a.Plugins={}))}(Fabrique||(Fabrique={}));
{
"name": "phaser-input",
"author": "OrangeGames",
"version": "0.0.3",
"version": "0.0.4",
"description": "Adds input boxes to Phaser like CanvasInput, but also works for WebGL.",

@@ -6,0 +6,0 @@ "contributors": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc