2013-12-14 23:04:08 +00:00
|
|
|
<?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>
|
2013-12-18 04:33:22 +00:00
|
|
|
<meta charset="utf-8">
|
2013-12-14 23:04:08 +00:00
|
|
|
<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
|
2013-12-18 04:33:22 +00:00
|
|
|
endforeach;
|
|
|
|
?>
|
2013-12-14 23:04:08 +00:00
|
|
|
</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>
|
|
|
|
|
2013-12-18 04:33:22 +00:00
|
|
|
<!-- SCRIPTS -->
|
2013-12-14 23:04:08 +00:00
|
|
|
|
2013-12-18 04:33:22 +00:00
|
|
|
<!-- demo scripts -->
|
|
|
|
<script>
|
|
|
|
$( function () {
|
|
|
|
new ve.init.sa.Target(
|
|
|
|
$( '.ve-demo-editor' ),
|
|
|
|
ve.createDocumentFromHtml( <?php echo json_encode( $html ); ?> )
|
2013-12-14 23:04:08 +00:00
|
|
|
);
|
2013-12-18 04:33:22 +00:00
|
|
|
$( '.ve-ce-documentNode' ).focus();
|
2013-12-14 23:04:08 +00:00
|
|
|
} );
|
|
|
|
</script>
|
2013-12-18 04:33:22 +00:00
|
|
|
<script src="demo.js"></script>
|
2013-12-14 23:04:08 +00:00
|
|
|
</body>
|
|
|
|
</html>
|