if not IsAddOnLoaded("JPack") then return end

local left, right = "asc", "desc"
if not Bagnon_Ex.Asc then
	left, right = right, left
end

if JPackFrame_Slash then
	Bagnon_Ex.JPackClick = function()
		JPackFrame_Slash(arg1 == "LeftButton" and left or right)
	end
elseif pack then
	Bagnon_Ex.JPackClick = pack
else
	UIErrorsFrame:AddMessage("|cff7fff7fBagnon_Ex|r: JPack可能已被修改。")
	return
end

function Bagnon_Ex:CreateJPackButton(frame)
	local button = CreateFrame("Button", nil, frame)

	local text = button:CreateFontString()
	text:SetAllPoints(button)
	text:SetJustifyH('CENTER')
	text:SetFontObject('GameFontNormal')
	button:SetFontString(text)
	button:SetHighlightTextColor(1, 1, 1)
	button:SetTextColor(1, 0.82, 0)
	button:RegisterForClicks("LeftButtonUp", "RightButtonUp")

	button:SetWidth(self.Width); button:SetHeight(26)
	button:SetText(self.ClearBag)
	button:SetScript("OnClick", self.JPackClick)

	return button
end
