From e2bba8d9e159f36adcccec207b3996bc75c0dc77 Mon Sep 17 00:00:00 2001 From: chylex <info@chylex.com> Date: Sun, 4 Sep 2016 04:36:01 +0200 Subject: [PATCH] Update reply-account plugin to use default config and swap event order when enabled late --- Resources/Plugins/reply-account/browser.js | 20 ++++++++++++++++--- ...ation.js => user.configuration.default.js} | 10 ++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) rename Resources/Plugins/reply-account/{user.configuration.js => user.configuration.default.js} (92%) diff --git a/Resources/Plugins/reply-account/browser.js b/Resources/Plugins/reply-account/browser.js index 0a183070..d66869dd 100644 --- a/Resources/Plugins/reply-account/browser.js +++ b/Resources/Plugins/reply-account/browser.js @@ -1,7 +1,7 @@ enabled(){ - var configuration = {}; + var configuration = { defaultAccount: "" }; - window.TDPF_loadConfigurationFile(this, "user.configuration.js", obj => configuration = obj); + window.TDPF_loadConfigurationFile(this, "user.configuration.js", "user.configuration.default.js", obj => configuration = obj); this.uiInlineComposeTweetEvent = function(e, data){ var account = null; @@ -45,7 +45,21 @@ enabled(){ } ready(){ - $(document).on("uiInlineComposeTweet", this.uiInlineComposeTweetEvent); + var events = $._data(document, "events"); + + if ("uiInlineComposeTweet" in events){ + $(document).on("uiInlineComposeTweet", this.uiInlineComposeTweetEvent); + + var handlers = events["uiInlineComposeTweet"]; + var oldHandler = handlers[0]; + var newHandler = handlers[1]; + + handlers[0] = newHandler; + handlers[1] = oldHandler; + } + else{ + $(document).on("uiInlineComposeTweet", this.uiInlineComposeTweetEvent); + } } disabled(){ diff --git a/Resources/Plugins/reply-account/user.configuration.js b/Resources/Plugins/reply-account/user.configuration.default.js similarity index 92% rename from Resources/Plugins/reply-account/user.configuration.js rename to Resources/Plugins/reply-account/user.configuration.default.js index 2ddcc9a5..9a3c2dc4 100644 --- a/Resources/Plugins/reply-account/user.configuration.js +++ b/Resources/Plugins/reply-account/user.configuration.default.js @@ -1,4 +1,14 @@ { + /* + * WARNING + * ------- + * + * Make sure you are editing 'user.configuration.js'. + * This file is automatically generated first time the plugin is enabled. + * Do not edit the default configuration file, as it will be replaced with each update. + * + */ + /* * Simple way of configuring the plugin * ------------------------------------