[IMP] Code optimization.

bzr revid: jra@tinyerp.com-20120626134256-b2f1ufa0w40j8ibz
This commit is contained in:
Jiten (OpenERP) 2012-06-26 19:12:56 +05:30
parent f97e3adc43
commit c3006f004e
1 changed files with 16 additions and 51 deletions

View File

@ -44,15 +44,7 @@ openerp.web_linkedin = function(instance) {
} }
}); });
}); });
if(this.view.fields['linkedin_id']){ self.linkedin_icon_color();
if(this.view.datarecord['linkedin_id']){
this.$element.find('#linkedindefault').hide();
this.$element.find('#linkedinrecord').show();
}else{
this.$element.find('#linkedinrecord').hide();
this.$element.find('#linkedindefault').show();
}
}
this.notification = new instance.web.Notification(this); this.notification = new instance.web.Notification(this);
this.notification.appendTo(this.$element); this.notification.appendTo(this.$element);
this.$element.find(".linkedin_icon").click( this.do_load_linkedin ); this.$element.find(".linkedin_icon").click( this.do_load_linkedin );
@ -165,11 +157,6 @@ openerp.web_linkedin = function(instance) {
width : 840, width : 840,
height:500, height:500,
close: function(){ self.dialog.remove();}, close: function(){ self.dialog.remove();},
// buttons:[
// {
// text: _t("Ok"),
// click: function() { $(this).dialog("close"); }
// }]
}); });
this.dialog.parent().find('.ui-dialog-titlebar').append('<button class="close">No Thanks</button>').click(function(){ this.dialog.parent().find('.ui-dialog-titlebar').append('<button class="close">No Thanks</button>').click(function(){
self.dialog.remove(); self.dialog.remove();
@ -237,26 +224,9 @@ openerp.web_linkedin = function(instance) {
} }
this.removeTemplate( 1 ); this.removeTemplate( 1 );
if (this.msg_Counter == 2) { if (this.msg_Counter == 2) {
// dialog box
/*new instance.web.dialog($(QWeb.render("SearchWarning")), {
title: _t("Linkedin Search"),
modal: true,
buttons: [
{text: _t("Ok"), click: function() { $(this).dialog("close"); }}
]
});*/
// notification
this.notification.warn(_t("Linkedin Search"), _t("Record Not Found.")); this.notification.warn(_t("Linkedin Search"), _t("Record Not Found."));
this.$element.find('#loader').hide(); this.$element.find('#loader').hide();
if(this.view.fields['linkedin_id']){ self.linkedin_icon_color();
if(this.view.datarecord['linkedin_id']){
this.$element.find('#linkedindefault').hide();
this.$element.find('#linkedinrecord').show();
}else{
this.$element.find('#linkedinrecord').hide();
this.$element.find('#linkedindefault').show();
}
}
} else { } else {
if (this.resultcontact || this.resultcompany) { if (this.resultcontact || this.resultcompany) {
this.$element.find('#linkedin-field-name').append(QWeb.render( 'Linkedincontact', {'result' : this.resultcontact, 'resultcompany' : this.resultcompany})) ; this.$element.find('#linkedin-field-name').append(QWeb.render( 'Linkedincontact', {'result' : this.resultcontact, 'resultcompany' : this.resultcompany})) ;
@ -264,15 +234,7 @@ openerp.web_linkedin = function(instance) {
} }
if(this.$element.find('#searchresults .search-box ul li')){ if(this.$element.find('#searchresults .search-box ul li')){
this.$element.find('#loader').hide(); this.$element.find('#loader').hide();
if(this.view.fields['linkedin_id']){ self.linkedin_icon_color();
if(this.view.datarecord['linkedin_id']){
this.$element.find('#linkedindefault').hide();
this.$element.find('#linkedinrecord').show();
}else{
this.$element.find('#linkedinrecord').hide();
this.$element.find('#linkedindefault').show();
}
}
} }
this.$element.find('#searchresults .search-box ul li').click( function() { this.$element.find('#searchresults .search-box ul li').click( function() {
self.getdata( this ); self.getdata( this );
@ -662,16 +624,7 @@ openerp.web_linkedin = function(instance) {
field.reload_current_view(); field.reload_current_view();
if (self.t_count == self.o2m_count) { if (self.t_count == self.o2m_count) {
self.$element.find('#loader').hide(); self.$element.find('#loader').hide();
//$('.linkedin_icon').css('display', 'block'); self.linkedin_icon_color();
if(this.view.fields['linkedin_id']){
if(this.view.datarecord['linkedin_id']){
this.$element.find('#linkedindefault').hide();
this.$element.find('#linkedinrecord').show();
}else{
this.$element.find('#linkedinrecord').hide();
this.$element.find('#linkedindefault').show();
}
}
} }
}, },
/* Name of Searched Linkedin Record is valid or Not */ /* Name of Searched Linkedin Record is valid or Not */
@ -681,6 +634,18 @@ openerp.web_linkedin = function(instance) {
} else { } else {
return false; return false;
} }
},
// Linkedin icon color changed to distinguise record based on linkedin or not.
linkedin_icon_color: function(e) {
if(this.view.fields['linkedin_id']){
if(this.view.datarecord['linkedin_id']){
this.$element.find('#linkedindefault').hide();
this.$element.find('#linkedinrecord').show();
}else{
this.$element.find('#linkedinrecord').hide();
this.$element.find('#linkedindefault').show();
}
}
} }
}); });
}; };