Index: trunk/extensions/VisualEditor/modules/es/views/es.ListItemView.js |
— | — | @@ -12,6 +12,7 @@ |
13 | 13 | |
14 | 14 | // Properties |
15 | 15 | this.$icon = $( '<div class="es-listItemView-icon"></div>' ).prependTo( this.$ ); |
| 16 | + this.currentStylesHash = null; |
16 | 17 | |
17 | 18 | // DOM Changes |
18 | 19 | this.$.addClass( 'es-listItemView' ); |
— | — | @@ -26,20 +27,24 @@ |
27 | 28 | /* Methods */ |
28 | 29 | |
29 | 30 | es.ListItemView.prototype.setClasses = function() { |
30 | | - var classes = this.$.attr( 'class' ), |
31 | | - styles = this.model.getElementAttribute( 'styles' ); |
32 | | - this.$ |
33 | | - // Remove any existing level classes |
34 | | - .attr( |
35 | | - 'class', |
36 | | - classes |
37 | | - .replace( / ?es-listItemView-level[0-9]+/, '' ) |
38 | | - .replace( / ?es-listItemView-(bullet|number)/, '' ) |
39 | | - ) |
40 | | - // Set the list style class from the style on top of the stack |
41 | | - .addClass( 'es-listItemView-' + styles[styles.length - 1] ) |
42 | | - // Set the list level class from the length of the stack |
43 | | - .addClass( 'es-listItemView-level' + ( styles.length - 1 ) ); |
| 31 | + var styles = this.model.getElementAttribute( 'styles' ), |
| 32 | + stylesHash = styles.join( '|' ); |
| 33 | + if ( this.currentStylesHash !== stylesHash ) { |
| 34 | + this.currentStylesHash = stylesHash; |
| 35 | + var classes = this.$.attr( 'class' ); |
| 36 | + this.$ |
| 37 | + // Remove any existing level classes |
| 38 | + .attr( |
| 39 | + 'class', |
| 40 | + classes |
| 41 | + .replace( / ?es-listItemView-level[0-9]+/, '' ) |
| 42 | + .replace( / ?es-listItemView-(bullet|number)/, '' ) |
| 43 | + ) |
| 44 | + // Set the list style class from the style on top of the stack |
| 45 | + .addClass( 'es-listItemView-' + styles[styles.length - 1] ) |
| 46 | + // Set the list level class from the length of the stack |
| 47 | + .addClass( 'es-listItemView-level' + ( styles.length - 1 ) ); |
| 48 | + } |
44 | 49 | }; |
45 | 50 | |
46 | 51 | es.ListItemView.prototype.setNumber = function( number ) { |
Index: trunk/extensions/VisualEditor/modules/es/views/es.HeadingView.js |
— | — | @@ -10,6 +10,9 @@ |
11 | 11 | // Inheritance |
12 | 12 | es.DocumentViewLeafNode.call( this, model ); |
13 | 13 | |
| 14 | + // Properties |
| 15 | + this.currentLevelHash = null; |
| 16 | + |
14 | 17 | // DOM Changes |
15 | 18 | this.$.addClass( 'es-headingView' ); |
16 | 19 | |
— | — | @@ -23,13 +26,16 @@ |
24 | 27 | /* Methods */ |
25 | 28 | |
26 | 29 | es.HeadingView.prototype.setClasses = function() { |
27 | | - var classes = this.$.attr( 'class' ), |
28 | | - level = this.model.getElementAttribute( 'level' ); |
29 | | - this.$ |
30 | | - // Remove any existing level classes |
31 | | - .attr( 'class', classes.replace( / ?es-headingView-level[0-9]+/, '' ) ) |
32 | | - // Add a new level class |
33 | | - .addClass( 'es-headingView-level' + level ); |
| 30 | + var level = this.model.getElementAttribute( 'level' ); |
| 31 | + if ( level !== this.currentLevelHash ) { |
| 32 | + this.currentLevelHash = level; |
| 33 | + var classes = this.$.attr( 'class' ); |
| 34 | + this.$ |
| 35 | + // Remove any existing level classes |
| 36 | + .attr( 'class', classes.replace( / ?es-headingView-level[0-9]+/, '' ) ) |
| 37 | + // Add a new level class |
| 38 | + .addClass( 'es-headingView-level' + level ); |
| 39 | + } |
34 | 40 | }; |
35 | 41 | |
36 | 42 | /* Registration */ |