local E, L, V, P, G = unpack(ElvUI);
local mPlugin = "mMediaTag"
local mMT = E:GetModule(mPlugin);
local DT = E:GetModule("DataTexts");
local addon, ns = ...

--Lua functions
local format = format

--Variables
local mText = format("Dock %s", ENCOUNTER_JOURNAL)
local mTextName = "mEncounterJournal"

local function mDockCheckFrame()
	return ( EncounterJournal and EncounterJournal:IsShown() )
end

function mMT:CheckFrameEncounterJournal(self)
	mMT:DockTimerCheck(self, mDockCheckFrame())
end

local function OnEnter(self)
	mMT:mOnEnter(self, ENCOUNTER_JOURNAL)
end

local function OnEvent(self, event, ...)
	mMT:mOnEvent(self, nil, nil, nil, mDockCheckFrame(), E.db[mPlugin].mDock.textures.encounter.path, "CheckFrameEncounterJournal")
end

local function OnLeave(self)
	mMT:mOnLeave(self, mDockCheckFrame())
end

local function OnClick(self)
	if mMT:mCheckCombat() then
		mMT:mClick(self, "CheckFrameEncounterJournal")
		ToggleEncounterJournal()
	end
end

DT:RegisterDatatext(mTextName, nil, nil, OnEvent, nil, OnClick, OnEnter, OnLeave, mText, nil)