r100907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100906‎ | r100907 | r100908 >
Date:23:38, 26 October 2011
Author:inez
Status:deferred
Tags:
Comment:
First round of integrating synth with hype. New demo already works and renders simple paragraphs. A lot of bugs in hype killed.
Modified paths:
  • /trunk/parsers/wikidom/demos/hype (added) (history)
  • /trunk/parsers/wikidom/demos/hype/es.js (added) (history)
  • /trunk/parsers/wikidom/demos/hype/index.html (added) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.DocumentModelNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.ViewNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/models/es.SurfaceModel.js (added) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.ContentView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.DocumentView.js (added) (history)
  • /trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js (added) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/models/es.SurfaceModel.js
@@ -0,0 +1,7 @@
 2+es.SurfaceModel = function( doc) {
 3+ this.doc = doc;
 4+};
 5+
 6+es.SurfaceModel.prototype.getDocument = function() {
 7+ return this.doc;
 8+};
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/hype/bases/es.ViewNode.js
@@ -40,7 +40,7 @@
4141
4242 // Append existing model children
4343 for ( var i = 0; i < model.length; i++ ) {
44 - node.onPush( model[i] );
 44+ node.onAfterPush( model[i] );
4545 }
4646
4747 // Observe and mimic changes on model
@@ -57,7 +57,7 @@
5858 return node;
5959 };
6060
61 -es.ViewNode.onAfterPush = function( childModel ) {
 61+es.ViewNode.prototype.onAfterPush = function( childModel ) {
6262 var childView = childModel.createView();
6363 this.emit( 'beforePush', childView );
6464 childView.attach( this );
@@ -68,7 +68,7 @@
6969 this.emit( 'update' );
7070 };
7171
72 -es.ViewNode.onAfterUnshift = function( childModel ) {
 72+es.ViewNode.prototype.onAfterUnshift = function( childModel ) {
7373 var childView = childModel.createView();
7474 this.emit( 'beforeUnshift', childView );
7575 childView.attach( this );
@@ -79,7 +79,7 @@
8080 this.emit( 'update' );
8181 };
8282
83 -es.ViewNode.onAfterPop = function() {
 83+es.ViewNode.prototype.onAfterPop = function() {
8484 this.emit( 'beforePop' );
8585 var childView = this.pop();
8686 childView.detach();
@@ -89,7 +89,7 @@
9090 this.emit( 'update' );
9191 };
9292
93 -es.ViewNode.onAfterShift = function() {
 93+es.ViewNode.prototype.onAfterShift = function() {
9494 this.emit( 'beforeShift' );
9595 var childView = this.shift();
9696 childView.detach();
@@ -99,7 +99,7 @@
100100 this.emit( 'update' );
101101 };
102102
103 -es.ViewNode.onAfterSplice = function( index, howmany ) {
 103+es.ViewNode.prototype.onAfterSplice = function( index, howmany ) {
104104 var args = Array.prototype.slice( arguments, 0 );
105105 this.emit.apply( ['beforeSplice'].concat( args ) );
106106 this.$.children()
@@ -113,7 +113,7 @@
114114 this.emit( 'update' );
115115 };
116116
117 -es.ViewNode.onAfterSort = function() {
 117+es.ViewNode.prototype.onAfterSort = function() {
118118 this.emit( 'beforeSort' );
119119 for ( var i = 0; i < this.model.length; i++ ) {
120120 for ( var j = 0; j < this.length; j++ ) {
@@ -129,7 +129,7 @@
130130 this.emit( 'update' );
131131 };
132132
133 -es.ViewNode.onAfterReverse = function() {
 133+es.ViewNode.prototype.onAfterReverse = function() {
134134 this.emit( 'beforeReverse' );
135135 this.reverse();
136136 this.$.children().each( function() {
Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentModelNode.js
@@ -98,7 +98,7 @@
9999 * @param {Integer} adjustment Amount to adjust content length by
100100 * @throws Invalid adjustment error if resulting length is less than 0
101101 */
102 -es.DocumentModelNode.prototype.adjustContentLength = function( adjustment ) {
 102+es.DocumentModelNode.prototype.adjustContentLength = function( adjustment, quiet ) {
103103 this.contentLength += adjustment;
104104 // Make sure the adjustment was sane
105105 if ( this.contentLength < 0 ) {
@@ -108,8 +108,11 @@
109109 throw 'Invalid adjustment error. Content length can not be less than 0.';
110110 }
111111 if ( this.parent ) {
112 - this.parent.adjustContentLength( adjustment );
 112+ this.parent.adjustContentLength( adjustment, true );
113113 }
 114+ if ( !quiet ) {
 115+ this.emit( 'update' );
 116+ }
114117 };
115118
116119 /**
Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js
@@ -0,0 +1,12 @@
 2+es.SurfaceView = function( $container, model ) {
 3+ this.$ = $container.addClass( 'editSurface' );
 4+ this.$window = $( window );
 5+ this.model = model;
 6+
 7+ // Initialize document view
 8+ this.documentView = new es.DocumentView( this.model.getDocument(), this );
 9+ this.$.append( this.documentView.$ );
 10+
 11+ // First render
 12+ this.documentView.renderContent();
 13+};
\ No newline at end of file
Index: trunk/parsers/wikidom/lib/hype/views/es.ContentView.js
@@ -23,6 +23,7 @@
2424 * @property {Object} renderState
2525 */
2626 es.ContentView = function( $container, model ) {
 27+ es.EventEmitter.call( this );
2728 this.$ = $container;
2829 this.model = model;
2930 this.boundaries = [];
Index: trunk/parsers/wikidom/lib/hype/views/es.DocumentView.js
@@ -0,0 +1,6 @@
 2+es.DocumentView = function( documentModel, surfaceView ) {
 3+ var node = $.extend( new es.DocumentViewBranchNode( documentModel ), this );
 4+ node.$.addClass( 'editSurface-document' );
 5+ node.surfaceView = surfaceView;
 6+ return node;
 7+};
\ No newline at end of file
Index: trunk/parsers/wikidom/demos/hype/es.js
@@ -0,0 +1,22 @@
 2+$(document).ready( function() {
 3+ window.wikiDom = {
 4+ 'type': 'document',
 5+ 'children': [
 6+ {
 7+ 'type': 'paragraph',
 8+ 'content': { 'text': 'Test 1' }
 9+ },
 10+ {
 11+ 'type': 'paragraph',
 12+ 'content': { 'text': 'Test 22' }
 13+ },
 14+ {
 15+ 'type': 'paragraph',
 16+ 'content': { 'text': 'Test 333' }
 17+ }
 18+ ]
 19+ };
 20+ window.doc = es.DocumentModel.newFromPlainObject( window.wikiDom );
 21+ window.surfaceModel = new es.SurfaceModel( window.doc );
 22+ window.surfaceView = new es.SurfaceView( $( '#es-editor' ), window.surfaceModel );
 23+} );
Index: trunk/parsers/wikidom/demos/hype/index.html
@@ -0,0 +1,41 @@
 2+<!DOCTYPE html>
 3+
 4+<html>
 5+ <head>
 6+ <title>EditSurface Demo</title>
 7+ </head>
 8+ <body>
 9+ <div id="es-editor">
 10+
 11+ </div>
 12+
 13+ <!-- EditSurface -->
 14+ <script src="../../lib/jquery.js"></script>
 15+ <script src="../../lib/hype/es.js"></script>
 16+ <script src="../../lib/hype/es.Range.js"></script>
 17+ <script src="../../lib/hype/es.Transaction.js"></script>
 18+
 19+ <!-- Bases -->
 20+ <script src="../../lib/hype/bases/es.EventEmitter.js"></script>
 21+ <script src="../../lib/hype/bases/es.ModelNode.js"></script>
 22+ <script src="../../lib/hype/bases/es.ViewNode.js"></script>
 23+ <script src="../../lib/hype/bases/es.DocumentNode.js"></script>
 24+ <script src="../../lib/hype/bases/es.DocumentModelNode.js"></script>
 25+ <script src="../../lib/hype/bases/es.DocumentViewBranchNode.js"></script>
 26+ <script src="../../lib/hype/bases/es.DocumentViewLeafNode.js"></script>
 27+
 28+ <!-- Models -->
 29+ <script src="../../lib/hype/models/es.SurfaceModel.js"></script>
 30+ <script src="../../lib/hype/models/es.DocumentModel.js"></script>
 31+ <script src="../../lib/hype/models/es.ParagraphModel.js"></script>
 32+
 33+ <!-- Views -->
 34+ <script src="../../lib/hype/views/es.SurfaceView.js"></script>
 35+ <script src="../../lib/hype/views/es.ContentView.js"></script>
 36+ <script src="../../lib/hype/views/es.DocumentView.js"></script>
 37+ <script src="../../lib/hype/views/es.ParagraphView.js"></script>
 38+
 39+ <!-- Demo -->
 40+ <script src="es.js"></script>
 41+ </body>
 42+</html>
\ No newline at end of file
Property changes on: trunk/parsers/wikidom/demos/hype/index.html
___________________________________________________________________
Added: svn:mime-type
143 + text/plain

Status & tagging log