Created
          December 27, 2011 17:22 
        
      - 
      
- 
        Save ppcano/1524446 to your computer and use it in GitHub Desktop. 
    Modal View Controller First Attempt
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Luh.Ui = {}; | |
| Luh.Ui.ControlledView = Em.Mixin.create({ | |
| didInsertElement: function() { | |
| set(this, 'isInsertedElement', true); | |
| } | |
| }); | |
| Luh.Ui.ViewController = SC.Object.extend({ | |
| view: null, | |
| _didInsertElement: function() { | |
| this.didInsertElement(); | |
| }.observes('view.isInsertedElement'), | |
| // didInsertElement will be called when the ControlledView is inserted | |
| didInsertElement: function() { | |
| } | |
| }); | |
| Luh.Ui.ModalViewController = Luh.Ui.ViewController.extend({ | |
| position: null, | |
| width: null, | |
| defaultHidden: true, | |
| didInsertElement: function() { | |
| if (!this.view) { | |
| throw Error('set view property ( binding or ... )'); | |
| } | |
| this.width = $(window).width(); | |
| if ( this.defaultHidden ) { | |
| set(this.view, 'isVisible', false); | |
| var id = get( this.view, 'elementId'); | |
| var position = this.width; | |
| var that = this; | |
| move('#'+id) | |
| .x(position) | |
| .end(function(){ | |
| set(that.view, 'isVisible', true); | |
| set(that, 'position', position); | |
| }); | |
| } | |
| }, | |
| toogle: function() { | |
| var id = get( this.view, 'elementId'); | |
| var position = get(this, 'position'); | |
| position = ( position !== 0 ) ? 0 : this.width; | |
| move('#'+id) | |
| .x(position) | |
| .duration('1s') | |
| .end(); | |
| set(this, 'position', position); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment