Advertisement
patrickc

Untitled

Jul 29th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function VilloRegisterAssistant() {
  2.     /* this is the creator function for your scene assistant object. It will be passed all the
  3.        additional parameters (after the scene name) that were passed to pushScene. The reference
  4.        to the scene controller (this.controller) has not be established yet, so any initialization
  5.        that needs the scene controller should be done in the setup function below. */
  6. }
  7.  
  8. VilloRegisterAssistant.prototype.setup = function() {
  9.     /* this function is for setup tasks that have to happen when the scene is first created */
  10.        
  11.     /* use Mojo.View.render to render view templates and add them to the scene, if needed */
  12.    
  13.     /* setup widgets here */
  14.     this.controller.setupWidget("theUsername",
  15.         this.attributes = {
  16.             hintText: $L(""),
  17.             multiline: false,
  18.             enterSubmits: false,
  19.             autoFocus: true
  20.         },
  21.         this.theusername =  {  
  22.             value: "",
  23.             disabled: false
  24.         }
  25.     ); 
  26.     this.controller.setupWidget("thePassword",
  27.         this.attributes = {
  28.             hintText: $L(""),
  29.             multiline: false,
  30.             enterSubmits: false,
  31.             autoFocus: false
  32.         },
  33.         this.thepassword =  {  
  34.             value: "",
  35.             disabled: false
  36.         }
  37.     ); 
  38.     this.controller.setupWidget("confirmThePassword",
  39.         this.attributes = {
  40.             hintText: $L(""),
  41.             multiline: false,
  42.             enterSubmits: false,
  43.             autoFocus: false
  44.         },
  45.         this.thepasswordconfirm =  {   
  46.             value: "",
  47.             disabled: false
  48.         }
  49.     ); 
  50.     this.controller.setupWidget("theEmail",
  51.         this.attributes = {
  52.             hintText: $L(""),
  53.             multiline: false,
  54.             enterSubmits: false,
  55.             autoFocus: false
  56.         },
  57.         this.theemail =  { 
  58.             value: "",
  59.             disabled: false
  60.         }
  61.     ); 
  62.     this.controller.setupWidget("register",
  63.          this.attributes = {
  64.              },
  65.          this.model = {
  66.              label : "Register",
  67.              disabled: false
  68.          }
  69.      );
  70.    
  71.     /* add event handlers to listen to events from widgets */
  72.         Mojo.Event.listen(this.controller.get("register"),Mojo.Event.tap, this.villoRegister.bindAsEventListener(this));
  73.  
  74. };
  75.  
  76. VilloRegisterAssistant.prototype.activate = function(event) {
  77.     /* put in event handlers here that should only be in effect when this scene is active. For
  78.        example, key handlers that are observing the document */
  79. };
  80.  
  81. VilloRegisterAssistant.prototype.deactivate = function(event) {
  82.     /* remove any event handlers you added in activate and do any other cleanup that should happen before
  83.        this scene is popped or another scene is pushed on top */
  84. };
  85.  
  86. VilloRegisterAssistant.prototype.cleanup = function(event) {
  87.     /* this function should do any cleanup needed before the scene is destroyed as
  88.        a result of being popped off the scene stack */
  89. };
  90.  
  91. VilloRegisterAssistant.prototype.villoRegister = function() {
  92. villo.user.register({
  93.         username: this.theusername.value,
  94.         password: this.thepassword.value,
  95.         password_confirm: this.thepasswordconfirm.value,
  96.         email: this.theemail.value,
  97.     }, this.userLogin.bind(this));};
  98.  
  99. VilloRegisterAssistant.prototype.userLogin = function(sof){
  100.     if(sof === 0){
  101.         this.controller.stageController.swapScene("villo");
  102.     }else{
  103.         Mojo.Controller.errorDialog("Error Registering!");
  104.     }
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement