/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; } }