Skip to content

Instantly share code, notes, and snippets.

@3emad
Created August 22, 2012 01:05
Show Gist options
  • Save 3emad/3421090 to your computer and use it in GitHub Desktop.
Save 3emad/3421090 to your computer and use it in GitHub Desktop.
UX indicator class for child of form
// UX indicator Main class
var UX = function (wrapperId){
this.wrapperId = wrapperId;
this.type = form;
this.type.parent = this;
this.indicator = '<div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div>';
this.errorWrapper = '<div class="alert alert-error" />';
}
UX.prototype.initInidcator = function(id){
if($('.progress').length == 0){
$(id,this.wrapperId).after(this.indicator);
this.indicatorId = id;
}
this.type.initInidcator();
};
UX.prototype.error = function (error,id){
if(typeof id == 'undefined')
id = this.wrapperId;
if($('.alert').length == 0)
$(id,this.wrapperId).after(this.errorWrapper)
this.type.error(error);
}
UX.prototype.complete = function (){
this.type.complete();
}
// child object instance for drived from UX class
var form = {
initInidcator: function(){
$('.progress',this.parent.wrapperId).show();
$(this.parent.indicatorId,this.parent.wrapperId).hide();
},
error: function(error){
$('.alert',this.parent.wrapperId).html(error);
$('.progress',this.parent.wrapperId).hide();
$(this.parent.indicatorId,this.parent.wrapperId).show();
},
complete: function(){
$('.alert',this.parent.wrapperId).remove();
$('.progress',this.parent.wrapperId).remove();
$(this.parent.indicatorId,this.parent.wrapperId).show();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment