mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-03 14:34:08 +02:00
Update edit-design plugin with modal event handling
This commit is contained in:
parent
6e4153911a
commit
e1a6328d09
@ -1,7 +1,6 @@
|
|||||||
enabled(){
|
enabled(){
|
||||||
// elements & data
|
// elements & data
|
||||||
this.css = window.TDPF_createCustomStyle(this);
|
this.css = null;
|
||||||
|
|
||||||
this.htmlModal = null;
|
this.htmlModal = null;
|
||||||
this.config = null;
|
this.config = null;
|
||||||
|
|
||||||
@ -81,8 +80,33 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
// modal dialog setup
|
// modal dialog setup
|
||||||
|
var me = this;
|
||||||
|
|
||||||
var customDesignModal = TD.components.BaseModal.extend(function(){
|
var customDesignModal = TD.components.BaseModal.extend(function(){
|
||||||
this.setAndShowContainer($("#td-design-plugin-modal"), false);
|
let modal = $("#td-design-plugin-modal");
|
||||||
|
this.setAndShowContainer(modal, false);
|
||||||
|
|
||||||
|
modal.find("[data-td-key]").each(function(){
|
||||||
|
let item = $(this);
|
||||||
|
let key = item.attr("data-td-key");
|
||||||
|
let value = item.attr("data-td-value");
|
||||||
|
|
||||||
|
if (value == me.config[key]){
|
||||||
|
item.addClass("selected");
|
||||||
|
}
|
||||||
|
|
||||||
|
item.click(function(){ console.profile("aaa");
|
||||||
|
modal.find("[data-td-key='"+key+"']").removeClass("selected");
|
||||||
|
item.addClass("selected");
|
||||||
|
|
||||||
|
me.config[key] = value;
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
me.saveConfig();
|
||||||
|
me.reinjectAll();
|
||||||
|
}, 1); // delays the slight lag caused by saving and reinjection
|
||||||
|
});
|
||||||
|
});
|
||||||
}).methods({
|
}).methods({
|
||||||
_render: () => $(this.htmlModal),
|
_render: () => $(this.htmlModal),
|
||||||
destroy: function(){
|
destroy: function(){
|
||||||
@ -96,9 +120,11 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.resetDesign = function(){
|
this.resetDesign = function(){
|
||||||
for(let index = this.css.element.cssRules.length; index >= 0; index--){
|
if (this.css){
|
||||||
this.css.element.deleteRule(index);
|
this.css.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.css = window.TDPF_createCustomStyle(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.reinjectAll = function(){
|
this.reinjectAll = function(){
|
||||||
@ -115,9 +141,12 @@ ready(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
disabled(){
|
disabled(){
|
||||||
this.css.remove();
|
|
||||||
this.resetLayout();
|
this.resetLayout();
|
||||||
|
|
||||||
|
if (this.css){
|
||||||
|
this.css.remove();
|
||||||
|
}
|
||||||
|
|
||||||
$("[data-action='settings-menu']").off("click", this.onSettingsMenuClickedEvent);
|
$("[data-action='settings-menu']").off("click", this.onSettingsMenuClickedEvent);
|
||||||
$("#td-design-plugin-modal").remove();
|
$("#td-design-plugin-modal").remove();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user