Skip to content

Commit

Permalink
#166 create joist demo for testing Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Aug 19, 2015
1 parent cee413a commit 4c143a8
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 0 deletions.
3 changes: 3 additions & 0 deletions joist-strings_en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"joist.name": {
"value": "joist demo"
},
"done": {
"value": "Done"
},
Expand Down
37 changes: 37 additions & 0 deletions joist_en.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<!-- Copyright 2002-2015, University of Colorado Boulder -->
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">

<title>Joist Demo</title>

<!-- Third-party libraries -->
<script src="../sherpa/lib/jquery-2.1.0.js"></script>
<script src='../sherpa/lib/lodash-2.4.1.js'></script>
<script type="text/javascript" src="../sherpa/lib/FileSaver-b8054a2.js"></script>

<!-- PhET common code that must be loaded pre-RequireJS -->
<script type="text/javascript" src="../assert/js/assert.js"></script>
<script type="text/javascript" src="../chipper/js/initialize-globals.js"></script>

<!-- Simulation -->
<script data-main="js/joist-config.js" src="../sherpa/lib/require-2.1.11.js"></script>

</head>

<body>
</body>
</html>
66 changes: 66 additions & 0 deletions js/demo/DialogsDemoView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2002-2015, University of Colorado Boulder

/**
* View for demonstrating dialogs.
*
* @author Chris Malley (PixelZoom, Inc.)
*/
define( function( require ) {
'use strict';

// modules
var Dialog = require( 'JOIST/Dialog' );
var inherit = require( 'PHET_CORE/inherit' );
var PhetFont = require( 'SCENERY_PHET/PhetFont' );
var RectangularPushButton = require( 'SUN/buttons/RectangularPushButton' );
var ScreenView = require( 'JOIST/ScreenView' );
var Text = require( 'SCENERY/nodes/Text' );

// constants
var BUTTON_FONT = new PhetFont( { size: 20 } );

/**
* @constructor
*/
function DialogsDemoView() {

ScreenView.call( this );

var modalDialogButton = new RectangularPushButton( {
content: new Text( 'modal dialog', { font: BUTTON_FONT } ),
listener: function() {
createDialog( true ).show();
},
left: this.layoutBounds.left + 100,
top: this.layoutBounds.top + 100
} );
this.addChild( modalDialogButton );

var nonModalDialogButton = new RectangularPushButton( {
content: new Text( 'non-modal dialog', { font: BUTTON_FONT } ),
listener: function() {
createDialog( false ).show();
},
left: modalDialogButton.right + 20,
top: modalDialogButton.top
} );
this.addChild( nonModalDialogButton );
}

/**
* Creates a model or non-modal dialog
* @param {boolean} modal
* @returns {Dialog}
*/
var createDialog = function( modal ) {
var contentNode = new Text( modal ? 'modal dialog' : 'non-modal dialog', {
font: new PhetFont( 20 )
} );
return new Dialog( contentNode, {
modal: modal,
hasCloseButton: !modal
} );
};

return inherit( ScreenView, DialogsDemoView );
} );
34 changes: 34 additions & 0 deletions js/joist-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2002-2015, University of Colorado Boulder

// RequireJS configuration file for Joist demo.
require.config( {
deps: [ 'joist-main' ],

paths: {

// third party libs
text: '../../sherpa/lib/text-2.0.12',

// plugins
image: '../../chipper/js/requirejs-plugins/image',
mipmap: '../../chipper/js/requirejs-plugins/mipmap',
string: '../../chipper/js/requirejs-plugins/string',

// PhET libs, uppercase names to identify them in require.js imports
AXON: '../../axon/js',
BRAND: '../../brand/' + phet.chipper.brand + '/js',
DOT: '../../dot/js',
JOIST: '../../joist/js',
KITE: '../../kite/js',
PHETCOMMON: '../../phetcommon/js',
REPOSITORY: '..',
PHET_CORE: '../../phet-core/js',
SCENERY: '../../scenery/js',
SCENERY_PHET: '../../scenery-phet/js',
SHERPA: '../../sherpa',
SUN: '../../sun/js'
},

// optional cache buster to make browser refresh load all included scripts, can be disabled with ?cacheBuster=false
urlArgs: phet.chipper.getCacheBusterArgs()
} );
45 changes: 45 additions & 0 deletions js/joist-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2002-2015, University of Colorado Boulder

/**
* Main file for the Joist demo.
*
* @author Chris Malley (PixelZoom, Inc.)
*/
define( function( require ) {
'use strict';

// modules
var DialogsDemoView = require( 'JOIST/demo/DialogsDemoView' );
var Rectangle = require( 'SCENERY/nodes/Rectangle' );
var Screen = require( 'JOIST/Screen' );
var Sim = require( 'JOIST/Sim' );
var SimLauncher = require( 'JOIST/SimLauncher' );

// strings
var title = require( 'string!JOIST/joist.name' );

var screens = [
new Screen( 'Dialogs',
new Rectangle( 0, 0, Screen.HOME_SCREEN_ICON_SIZE.width, Screen.HOME_SCREEN_ICON_SIZE.height, { fill: 'white' } ),
function() { return {}; },
function( model ) { return new DialogsDemoView(); },
{ backgroundColor: 'white' }
),
new Screen( 'Dialogs 2',
new Rectangle( 0, 0, Screen.HOME_SCREEN_ICON_SIZE.width, Screen.HOME_SCREEN_ICON_SIZE.height, { fill: 'white' } ),
function() { return {}; },
function( model ) { return new DialogsDemoView(); },
{ backgroundColor: 'white' }
)
];

var options = {
credits: {
leadDesign: 'PhET'
}
};

SimLauncher.launch( function() {
new Sim( title, screens, options ).start();
} );
} );
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"grunt-contrib-jshint": "~0.6.4",
"uglify-js": "~2.4.0",
"requirejs": "~2.1.8"
},
"phet": {
"requirejsNamespace": "JOIST",
"simTitleStringKey": "JOIST/joist.name"
}
}

0 comments on commit 4c143a8

Please sign in to comment.