Quantcast
Channel: Zimbra :: Forums - Zimlets
Viewing all articles
Browse latest Browse all 171

Why is my button disabled at creation time ?

$
0
0
Hi.

My zimlet creates a button both in the message composer toolbar and in the contact editor toolbar. First is created properly, second is created but is disabled. Am I doing something wrong ?

Code:

// Création de variables globales pour jouer avec dans firebug
// application, toolbar, controller et viewID
// préfixé d'un D pour débug.

Dapplication = null;
Dtoolbar    = null;
Dcontroller  = null;
DviewID      = null;

// Création d'une nouvelle propriété initialisée à false.
SugarBee.addContactButtonCreated = false;
SugarBee.addMailButtonCreated = false;

SugarBee.prototype.initializeToolbar = function(app, toolbar, controller, viewID){
    Dapplication = app;
    Dtoolbar    = toolbar;
    Dcontroller  = controller;
    DviewID      = viewID;

    if (!SugarBee.addMailButtonCreated && viewID.indexOf(ZmId.VIEW_COMPOSE) >= 0){
        this._createMailButton(toolbar,controller);
    }

    else if (!SugarBee.addContactButtonCreated && viewID == ZmId.VIEW_CONTACT){
        this._createContactButton(toolbar,controller);
    }
};

SugarBee.prototype._createMailButton = function (toolbar,controller){

    var args = {
        text    : "Envoi+copie sugar",
        tooltip : "Envoi l'e-mail et crée une copie dans SugarCRM",
        image  : "plus",
        index  : 1
    };
   
    var bouton = toolbar.createOp("SugarBeeAddMail",args);
    toolbar.addOp("SugarBeeAddMail",1);
    bouton.addSelectionListener(new AjxListener(this._displayMessage,controller));
    SugarBee.addMailbuttonCreated = true;
};

// The debug (D) ev global variable, will be set right below
Dev = null;
Dcontroller2 = null;
SugarBee.prototype._displayMessage = function(controller,ev){
    Dev = ev;
    Dcontroller2=controller;
    var mail_content = controller.getMsg().getBodyContent();
    //mail_content = mail_content.replace(/\n/g,"<br/>");
    this.dialog.showInfo("Votre message : <br/>"+ mail_content);

};
   
SugarBee.prototype._createContactButton = function (toolbar,controller){
    console.debug("createContactButton appel&eactue;e");
    var args = {
        text    : "Enreg.+copie sugar",
        tooltip : "Enregistre le contact localement et dans SugarCRM",
        image  : "plus",
        index  : 1
    };

    var bouton = toolbar.createOp("SugarBeeAddContact",args);
    toolbar.addOp("SugarBeeAddContact",1);
    bouton.addSelectionListener(new AjxListener(this._displayContact));
    SugarBee.addContactButtonCreated = true;
   
};
   
SugarBee.prototype._displayContact = function(ev){
    this.dialog.showInfo("Nouveau contact ajouté;.");
};


Viewing all articles
Browse latest Browse all 171

Trending Articles