-- ----------------------------- --
--                               --
--  Elkano's bags_and_merchants  --
--                               --
--          version 2.0          --
--                               --
-- ----------------------------- --

bags_and_merchants = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0")

function bags_and_merchants:OnEnable()
	self:RegisterEvent("AUCTION_HOUSE_SHOW", "ShowBags")
	self:RegisterEvent("AUCTION_HOUSE_CLOSED", "CloseBags")
	self:RegisterEvent("BANKFRAME_OPENED", "ShowBags")
	self:RegisterEvent("BANKFRAME_CLOSED", "CloseBags")
	self:RegisterEvent("MAIL_SHOW", "ShowBags")
	self:RegisterEvent("MAIL_CLOSED", "CloseBags")
	self:RegisterEvent("MERCHANT_SHOW", "ShowBags")
	self:RegisterEvent("MERCHANT_CLOSED", "CloseBags")
	self:RegisterEvent("TRADE_SHOW", "ShowBags")
	self:RegisterEvent("TRADE_CLOSED", "CloseBags")
end

function bags_and_merchants:ShowBags()
	OpenAllBags(true)
end

function bags_and_merchants:CloseBags()
	ContainerFrame1.backpackWasOpen = nil
	CloseAllBags()
end
