http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96706

Revision: 96706
Author:   inez
Date:     2011-09-09 23:51:44 +0000 (Fri, 09 Sep 2011)
Log Message:
-----------
Make ordered list works

Modified Paths:
--------------
    trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
    trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js

Modified: trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js     
2011-09-09 23:43:12 UTC (rev 96705)
+++ trunk/parsers/wikidom/lib/synth/models/es.ListBlockItemModel.js     
2011-09-09 23:51:44 UTC (rev 96706)
@@ -12,6 +12,9 @@
        es.ModelContainerItem.call( this, 'list' );
        this.content = content || null;
        this.styles = styles || ['bullet'];
+       this.on( 'update', function() {
+               console.log("u111p");
+       } );
 };
 
 /* Methods */
@@ -23,6 +26,18 @@
        return new es.ListBlockItemView( this );
 };
 
+es.ListBlockItemModel.prototype.getLevel = function() {
+       return this.styles.length - 1;
+};
+
+es.ListBlockItemModel.prototype.getStyle = function() {
+       if ( typeof level === 'undefined') {
+               return this.styles[this.styles.length - 1];
+       } else {
+               return this.styles[level];
+       }
+};
+
 /**
  * Gets the length of all content.
  * 

Modified: trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js
===================================================================
--- trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js   2011-09-09 
23:43:12 UTC (rev 96705)
+++ trunk/parsers/wikidom/lib/synth/views/es.ListBlockView.js   2011-09-09 
23:51:44 UTC (rev 96706)
@@ -4,6 +4,10 @@
 es.ListBlockView = function( model ) {
        es.ViewContainer.call( this, model, 'list' );
        es.BlockView.call( this, model, 'list' );
+       var view = this;
+       this.on( 'update', function() {
+               view.enumerate();
+       } );
 };
 
 /**
@@ -15,6 +19,22 @@
        }
 };
 
+es.ListBlockView.prototype.enumerate = function() {
+       var itemLevel,
+               levels = [];
+
+       for ( var i = 0; i < this.views.length; i++ ) {
+               itemLevel = this.views[i].model.getLevel();
+               levels = levels.slice(0, itemLevel + 1);
+               if ( this.views[i].model.getStyle() === 'number' ) {
+                       if ( !levels[itemLevel] ) {
+                               levels[itemLevel] = 0;
+                       }
+                       this.views[i].setNumber( ++levels[itemLevel] );
+               }
+       }
+};
+
 /**
  * Gets offset within content of position.
  */


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to