title: javascript: use variable from one file in other
body: <p>So, I am building a pretty complicated plugin and ran into a snag. (This is how I learn though, so snags are good...) My code looks similar to the following:</p>
  
  <p><strong>Document 1</strong></p>
  
  <pre><code>if( !window.TextEdit ){
    var TextEdit = {"version": "1.0"};
  }
  
  TextEdit.edit = function(context, options) {
      var self = this;
      self.context = context;
  
      self.buttonDef = {
          bold: {
              class: 'bold',
              command: 'bold',
              icon: 'bold',
              type: 'checkbox',
              label: ''
          },
          italic: {
              class: 'italic',
              command: 'italic',
              icon: 'italic',
              type: 'checkbox',
              label: ''
          },
          underline: {
              class: 'underline',
              command: 'underline',
              icon: 'underline',
              type: 'checkbox',
              label: ''
          }
      }
  
      self.init();
  }
  </code></pre>
  
  <p><strong>Document 2</strong></p>
  
  <pre><code>if( !window.TextEdit.imageload ){
    TextEdit.imageload = {"version": "1.0"};
  }
  
  TextEdit.imageload = function() {
      var self = this;
      self.editor = TextEdit;
  
      self.init();
  }
  
  TextEdit.imageload.prototype = {
      init: function() {
          var self = this;
  
          console.log(self.buttonDef);
  
          $('.tdt-btn-addimage').click(function() {
  
  
  
          });
  
  
      },
      create: function() {
  
      },
      destroy: function() {
  
      }   
  }
  
  new TextEdit.imageload();
  </code></pre>
  
  <p>So, using Document 2 I want to access the variable self.buttonDef in Document 1. I am able to access the functions in Document 1 just fine, but not the variables.</p>
  
  <p>What I am looking for is how to make <code>buttonDef</code> a property of <code>TextEdit</code>.</p>