Permalink
Browse files

Get rid off last todos

  • Loading branch information...
tekool committed Jan 28, 2012
1 parent f374798 commit c586370ee39af9c39c16d44200a30296e6c30d48

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1397,6 +1397,10 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
/*
* We need to hard reset the select component for jQueryMobile to
* refresh its display and set which is its selected element.
+ *
+ * Whatever the documentation says, with jQueryMobile 1.0.1 if we don't
+ * use native select menus (but we don't have placeholders), the pop-up
+ * menu won't work.
*/
var select/*String*/ = '<select id="department"><option></option></select>';
var options/*String*/ = "";
@@ -1419,7 +1423,7 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
container.append(select);
this.department = this.userFormPanel.find("#department").selectmenu();
- this.department.selectmenu('refresh', true);
+ this.department.selectmenu('refresh');
},
/**
@@ -1433,7 +1437,11 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
{
/*
* We need to hard reset the select component for jQueryMobile to
- * refresh its display and set which are its selected elements.
+ * refresh its display and set which is its selected element.
+ *
+ * Whatever the documentation says, with jQueryMobile 1.0.1 if we don't
+ * use native select menus (but we don't have placeholders), the pop-up
+ * menu won't work.
*/
var select/*String*/ = '<select id="roles" multiple="multiple"><option></option></select>';
var options/*String*/ = "";
@@ -1459,7 +1467,7 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
container.append(select);
this.roles = this.userFormPanel.find("#roles").selectmenu();
- this.roles.selectmenu("refresh", true);
+ this.roles.selectmenu("refresh");
this.roles.mousedown(function(){this.fillRoleList( RoleEnum.getComboList() );})
},
View
@@ -18,4 +18,10 @@
#user-form-panel .fieldError .ui-btn
{
background:#FFAAAA;
+}
+
+#user-form-panel input[disabled]
+{
+ background:#CCC;
+ color:#AAA;
}
@@ -152,38 +152,29 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
*/
bindListeners: function()
{
- //jQuery will be able to only remove events attached under this namespace
- var namespace/*String*/ = ".UserForm";
-
var focusEventProxy/*jQueryProxy*/ = jQuery.proxy( this, "field_focusHandler" );
- this.uname.on("focus" + namespace, focusEventProxy );
- this.password.on("focus" + namespace, focusEventProxy );
- this.confirm.on("focus" + namespace, focusEventProxy );
-
- //TODO focus event is not received by the selects
- this.department.on("focus" + namespace, focusEventProxy );
- this.roles.on("focus" + namespace, focusEventProxy );
+ this.uname.on("focus" + UserForm.EVENT_NS, focusEventProxy );
+ this.password.on("focus" + UserForm.EVENT_NS, focusEventProxy );
+ this.confirm.on("focus" + UserForm.EVENT_NS, focusEventProxy );
- this.submitButton.on( "click" + namespace, jQuery.proxy( this, "submitButton_clickHandler" ) );
- this.deleteButton.on( "click" + namespace, jQuery.proxy( this, "deleteButton_clickHandler" ) );
+ this.submitButton.on( "click" + UserForm.EVENT_NS, jQuery.proxy( this, "submitButton_clickHandler" ) );
+ this.deleteButton.on( "click" + UserForm.EVENT_NS, jQuery.proxy( this, "deleteButton_clickHandler" ) );
},
/**
* Unbind events from their listeners.
*/
unbindListeners: function()
{
- //jQuery will only remove events attached under this namespace
- var namespace/*String*/ = ".UserForm";
+ this.uname.off("focus" + UserForm.EVENT_NS );
+ this.password.off("focus" + UserForm.EVENT_NS );
+ this.confirm.off("focus" + UserForm.EVENT_NS );
- this.uname.off("focus" + namespace );
- this.password.off("focus" + namespace );
- this.confirm.off("focus" + namespace );
- this.department.off("focus" + namespace );
- this.roles.off("focus" + namespace );
+ this.department.parent().off("click" + UserForm.EVENT_NS );
+ this.roles.parent().off("click" + UserForm.EVENT_NS );
- this.submitButton.off( "click" + namespace );
- this.deleteButton.off( "click" + namespace );
+ this.submitButton.off( "click" + UserForm.EVENT_NS );
+ this.deleteButton.off( "click" + UserForm.EVENT_NS );
},
/**
@@ -200,8 +191,9 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
* We need to hard reset the select component for jQueryMobile to
* refresh its display and set which is its selected element.
*
- * Whatever the documentation says. With jQueryMobile 1.0 If we don't
- * use native select menus, the pop-up menu won't work.
+ * Whatever the documentation says, with jQueryMobile 1.0.1 if we don't
+ * use native select menus (but we don't have placeholders), the pop-up
+ * menu won't work.
*/
var select/*String*/ = '<select id="department"><option></option></select>';
var options/*String*/ = "";
@@ -225,7 +217,9 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
this.department = this.userFormPanel.find("#department").selectmenu();
this.department.selectmenu('refresh');
- },
+
+ this.department.on("change" + UserForm.EVENT_NS, jQuery.proxy( this, "field_focusHandler" ) );
+},
/**
* Add items from <code>RoleEnum</code> to the corresponding list UI component.
@@ -238,7 +232,11 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
{
/*
* We need to hard reset the select component for jQueryMobile to
- * refresh its display and set which are its selected elements.
+ * refresh its display and set which is its selected element.
+ *
+ * Whatever the documentation says, with jQueryMobile 1.0.1 if we don't
+ * use native select menus (but we don't have placeholders), the pop-up
+ * menu won't work.
*/
var select/*String*/ = '<select id="roles" multiple="multiple"><option></option></select>';
var options/*String*/ = "";
@@ -265,7 +263,7 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
this.roles = this.userFormPanel.find("#roles").selectmenu();
this.roles.selectmenu("refresh");
- this.roles.mousedown(function(){this.fillRoleList( RoleEnum.getComboList() );})
+ this.roles.on("change" + UserForm.EVENT_NS, jQuery.proxy( this, "field_focusHandler" ) );
},
/**
@@ -359,20 +357,17 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
switch(mode)
{
case UserForm.MODE_ADD:
- //We have to hack jQueryMobile a little here
- //TODO Make this works !!!
this.uname.removeAttr("disabled");
- this.uname.removeAttr( "data-theme");
+
+ //We have to hack jQueryMobile a little here
this.submitButton.parent().find(".ui-btn-text").text("Add");
this.deleteButton.parent().hide();
break;
case UserForm.MODE_EDIT:
- //We have to hack jQueryMobile a little here
-
- //TODO Make this works !!!
this.uname.attr( "disabled", "disabled" );
- this.uname.attr( "data-theme", "ui-disabled" );
+
+ //We have to hack jQueryMobile a little here
this.submitButton.parent().find(".ui-btn-text").text("Save");
this.deleteButton.parent().show();
break;
@@ -409,6 +404,15 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
jQuery.mobile.changePage("#UserList");
},
+ /**
+ * Handle focus event on all the required form fields.
+ */
+ field_focusHandler: function( evt )
+ {
+ //Remove error on the selected field.
+ this.setFieldError( evt.target.id, false );
+ },
+
/**
* Display errors associated with form fields and return if at least one
* field is in error.
@@ -546,7 +550,13 @@ var UserForm = Objs("org.puremvc.js.demos.objs.employeeadmin.view.components.Use
return arr;
}
});
-
+
+/**
+ * @const
+ * @private
+ */
+UserForm.EVENT_NS = ".UserForm";
+
/*
* Event names
*/

0 comments on commit c586370

Please sign in to comment.