var PluginEditor = function(){};

PluginEditor.Init = function(){
    Event.AddById("btnAddPlugin", "click", PluginEditor.AddPlugin);
    Event.AddByClass("removePlugin", "click" , PluginEditor.RemovePlugin);
};

/***
 * Add A Plugin
 */
PluginEditor.AddPlugin = function(e){

    e.preventDefault();
    
     Dialog.open('', {"title": Dashboard.GetCode("PluginEditor.AddPlugin"),
     "app": "EeApp",
     "class": "DialogEeApp",
     "method": "AddPluginApp",
     "params": "Cms",
     "type" : "right"
     });
};

/***
  * Remove plugin to the shop 
  * @returns {undefined}
  */
PluginEditor.RemovePlugin = function(e){
     
    Animation.Confirm(Language.GetCode("Cms.ConfirmRemovePlugin"), function(){
        let container = e.srcElement.parentNode;
        
        let  data = "Class=EeApp&Methode=RemovePluginApp&App=EeApp";
             data += "&pluginId="+e.srcElement.id;
             
        Request.Post("Ajax.php", data).then(data => {
            container.parentNode.removeChild(container);
        });
    });
};

