(function(app) {
  'use strict';

  var jCore = require('jcore');
  var helper = app.helper || require('../helper.js');
  var dom = app.dom || require('../dom.js');

  var SidebarToggleButton = helper.inherits(function(props) {
    SidebarToggleButton.super_.call(this);

    this.type = this.prop(SidebarToggleButton.TYPE_COLLAPSE);
    this.disabled = this.prop(false);
    this.element = this.prop(props.element);
    this.cache = this.prop({});

    this.collapser = props.collapser;
    this.expander = props.expander;
  }, jCore.Component);

  SidebarToggleButton.prototype.redraw = function() {
    var cache = this.cache();

    var type = this.type();
    if (type !== cache.type) {
      dom.data(this.element(), 'type', type);
      cache.type = type;
    }

    var disabled = this.disabled();
    if (disabled !== cache.disabled) {
      dom.disabled(this.element(), disabled);
      cache.disabled = disabled;
    }
  };

  SidebarToggleButton.TYPE_COLLAPSE = 'collapse';
  SidebarToggleButton.TYPE_EXPAND = 'expand';

  var ContentHeader = helper.inherits(function(props) {
    ContentHeader.super_.call(this);

    this.element = this.prop(props.element);

    this.sidebarToggleButton = this.prop(new SidebarToggleButton({
      element: this.sidebarToggleButtonElement(),
      collapser: props.sidebarCollapser,
      expander: props.sidebarExpander
    }));
  }, jCore.Component);

  ContentHeader.prototype.sidebarToggleButtonElement = function() {
    return dom.child(this.element(), 0);
  };

  ContentHeader.prototype.redraw = function() {
    this.sidebarToggleButton().redraw();
  };

  if (typeof module !== 'undefined' && module.exports)
    module.exports = ContentHeader;
  else
    app.ContentHeader = ContentHeader;
})(this.app || (this.app = {}));

@@ -603,34 +603,117 @@
     
-var cache = this.cache();%0A
+this.redrawType();%0A    this.redrawDisabled();%0A  %7D;%0A%0A  SidebarToggleButton.prototype.redrawType = function() %7B
 %0A   
@@ -733,24 +733,55 @@
 his.type();%0A
+    var cache = this.cache();%0A%0A
     if (type
@@ -781,17 +781,17 @@
 f (type 
-!
+=
 == cache
@@ -796,21 +796,32 @@
 he.type)
- %7B
 %0A  
+    return;%0A%0A
     dom.
@@ -856,26 +856,24 @@
  type);%0A    
-  
 cache.type =
@@ -881,20 +881,81 @@
 type;%0A  
-  %7D%0A
+%7D;%0A%0A  SidebarToggleButton.prototype.redrawDisabled = function() %7B
 %0A    var
@@ -979,24 +979,55 @@
 disabled();%0A
+    var cache = this.cache();%0A%0A
     if (disa
@@ -1031,17 +1031,17 @@
 isabled 
-!
+=
 == cache
@@ -1050,21 +1050,32 @@
 isabled)
- %7B
 %0A  
+    return;%0A%0A
     dom.
@@ -1114,18 +1114,16 @@
 d);%0A    
-  
 cache.di
@@ -1145,14 +1145,8 @@
 ed;%0A
-    %7D%0A
   %7D;

Refactor code for updating sidebar-toggle-button