mediawiki-extensions-Visual.../demos/ve/index.php.template

84 lines
1.9 KiB
Plaintext
Raw Normal View History

<?php
/**
* VisualEditor standalone demo
*
* @file
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
// Find all .html files in the pages directory
$path = __DIR__ . '/pages';
$pages = glob( $path . '/*.html' );
$page = current( $pages );
// If the ?page= parameter is set, and that page exists, load it
if ( isset( $_GET['page'] ) && in_array( $path . '/' . $_GET['page'] . '.html', $pages ) ) {
$page = $path . '/' . $_GET['page'] . '.html';
}
$html = file_get_contents( $page );
// TODO: get rid of the PHP-based loading system and make the demo purely HTML+JS
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>VisualEditor Standalone Demo</title>
<!-- STYLES -->
<!-- demo styles -->
<link rel="stylesheet" href="demo.css">
</head>
<body>
<ul class="ve-demo-docs">
<?php
foreach ( $pages as $page ): ?>
<li>
<a href="./?page=<?php echo basename( $page, '.html' ); ?>">
<?php echo basename( $page, '.html' ); ?>
</a>
</li>
<?php
endforeach;
?>
</ul>
<div class="ve-demo-editor"></div>
<div class="ve-demo-utilities">
<p>
<div class="ve-demo-utilities-commands"></div>
</p>
<table id="ve-dump" class="ve-demo-dump">
<thead>
<th>Linear model</th>
<th>View tree</th>
<th>Model tree</th>
</thead>
<tbody>
<tr>
<td width="30%" id="ve-linear-model-dump"></td>
<td id="ve-view-tree-dump" style="vertical-align: top;"></td>
<td id="ve-model-tree-dump" style="vertical-align: top;"></td>
</tr>
</tbody>
</table>
</div>
<!-- SCRIPTS -->
<!-- demo scripts -->
<script>
$( function () {
new ve.init.sa.Target(
$( '.ve-demo-editor' ),
ve.createDocumentFromHtml( <?php echo json_encode( $html ); ?> )
);
$( '.ve-ce-documentNode' ).focus();
} );
</script>
<script src="demo.js"></script>
</body>
</html>