Return to Snippet

Revision: 10702
at January 9, 2009 22:38 by abie


Updated Code
transitionTo: function(newState, e) {
      transition = "from_" + this.state + "_to_" + newState;
      switch(transition) {
      case 'from_waiting_to_anchoring':
        anchorSelection(e);
        this.state = 'anchoring';
        break;
        
      case 'from_anchoring_to_anchoring':
        break;
        
      case 'from_anchoring_to_drawing':
        resizeSelection(e);
        this.state = 'drawing';
        break;
        
      case 'from_drawing_to_drawing':
        resizeSelection(e);
        break;
        
      case 'from_anchoring_to_choosing':
        checkRectangleSize(e);
        setSelectionValues();
        $('appearance_name').value = '';
        showVisualTagForm();
        this.state = 'choosing';
        break;        

      case 'from_drawing_to_choosing':
        checkRectangleSize(e);
        setSelectionValues();
        $('appearance_name').value = '';
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      case 'from_choosing_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'choosing';
        this.state = 'dragging';
        break;
                
      case 'from_choosing_more_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'choosing_more';
        this.state = 'dragging';
        break;
        
      case 'from_dragging_to_dragging':
        repositionSelection(this.pointerOffset, e);
        break;
        
      case 'from_dragging_to_choosing':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        setSelectionValues();
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      case 'from_dragging_to_choosing_more':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        setSelectionValues();
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      case 'from_dragging_to_adding':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        $('new-person-form').show();
        this.state = 'adding';
        break;
        
      case 'from_choosing_to_getting_more':
        $('searching-indicator').show();
        addMoreRelatives();
        this.state = 'getting_more';
        break;
        
      case 'from_getting_more_to_choosing_more':
        this.state = 'choosing_more';
        break;
        
      case 'from_choosing_more_to_getting_more':
        addMoreRelatives();
        this.state = 'getting_more';
        break;
        
      case 'from_choosing_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_getting_more_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_choosing_more_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_adding_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'adding';
        this.state = 'dragging';
        break;
        
      case 'from_adding_to_choosing_more':
        $('outer-cancel-link').show();
        $('tag-selection-list').show();
        $('new-person-form').hide();
        resetNewPersonForm();
        showVisualTagForm();
        this.state = 'choosing_more';        
        break;
        
      case 'from_adding_to_choosing':
        Kinfo.Appearance.resetNewPersonForm();
        Kinfo.Appearance.reloadPrimaryRelations();
        $('outer-cancel-link').show();
        $('tag-selection-list').show();
        $('new-person-form').hide();
        showVisualTagForm();
        this.state = 'choosing';
        break;
      }
    }

Revision: 10701
at January 9, 2009 22:35 by abie


Initial Code
    transitionTo: function(newState, e) {
      transition = "from_" + this.state + "_to_" + newState;
      switch(transition) {
      case 'from_waiting_to_anchoring':
        anchorSelection(e);
        this.state = 'anchoring';
        break;
        
      case 'from_anchoring_to_anchoring':
        break;
        
      case 'from_anchoring_to_drawing':
        resizeSelection(e);
        this.state = 'drawing';
        break;
        
      case 'from_drawing_to_drawing':
        resizeSelection(e);
        break;
        
      case 'from_anchoring_to_choosing':
        checkRectangleSize(e);
        setSelectionValues();
        $('appearance_name').value = '';
        showVisualTagForm();
        this.state = 'choosing';
        break;        

      case 'from_drawing_to_choosing':
        checkRectangleSize(e);
        setSelectionValues();
        $('appearance_name').value = '';
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      case 'from_choosing_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'choosing';
        this.state = 'dragging';
        break;
                
      case 'from_choosing_more_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'choosing_more';
        this.state = 'dragging';
        break;
        
      case 'from_dragging_to_dragging':
        repositionSelection(this.pointerOffset, e);
        break;
        
      case 'from_dragging_to_choosing':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        setSelectionValues();
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      // TODO: how do we get here?
      case 'from_dragging_to_choosing_more':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        setSelectionValues();
        showVisualTagForm();
        this.state = 'choosing';
        break;
        
      case 'from_dragging_to_adding':
        $('appearance-rectangle').setStyle({ cursor: 'default' });
        $('new-person-form').show();
        this.state = 'adding';
        break;
        
      case 'from_choosing_to_getting_more':
        $('searching-indicator').show();
        addMoreRelatives();
        this.state = 'getting_more';
        break;
        
      case 'from_getting_more_to_choosing_more':
        // TODO: catch up to field, filter list on contents of appearance_name
        this.state = 'choosing_more';
        break;
        
      case 'from_choosing_more_to_getting_more':
        addMoreRelatives();
        this.state = 'getting_more';
        break;
        
      case 'from_choosing_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_getting_more_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_choosing_more_to_adding':
        $('tag-selection-list').hide();
        $('new-person-form').show();
        initNewPersonForm();
        this.state = 'adding';
        break;
        
      case 'from_adding_to_start_dragging':
        $('visual-tag-form').hide();
        this.pointerOffset = pointerRelativeToSelection(e);
        repositionSelection(this.pointerOffset, e);
        this.previousState = 'adding';
        this.state = 'dragging';
        break;
        
      case 'from_adding_to_choosing_more':
        $('outer-cancel-link').show();
        $('tag-selection-list').show();
        $('new-person-form').hide();
        resetNewPersonForm();
        showVisualTagForm();
        this.state = 'choosing_more';        
        break;
        
      case 'from_adding_to_choosing':
        Kinfo.Appearance.resetNewPersonForm();
        Kinfo.Appearance.reloadPrimaryRelations();
        $('outer-cancel-link').show();
        $('tag-selection-list').show();
        $('new-person-form').hide();
        showVisualTagForm();
        this.state = 'choosing';
        break;
      }
    }

Initial URL

                                

Initial Description

                                

Initial Title
Deviant State Machine

Initial Tags
javascript

Initial Language
JavaScript