Quantcast

Rework to use LoadWith

Adrian L Lange [09-01-12 - 14:31]
Rework to use LoadWith
Filename
Collie.lua
Collie.toc
diff --git a/Collie.lua b/Collie.lua
index 6c9ab27..a12ab8e 100644
--- a/Collie.lua
+++ b/Collie.lua
@@ -1,7 +1,22 @@
 local filter = ''
 local filterTable = {}

-local function Update()
+local Search = CreateFrame('EditBox', 'MountSearch', MountJournal, 'SearchBoxTemplate')
+Search:SetSize(145, 20)
+Search:SetPoint('LEFT', MountJournal.MountCount, 'RIGHT', 15, 0)
+Search:SetMaxLetters(40)
+Search:SetScript('OnTextChanged', function(self)
+	local text = self:GetText()
+	if(text == SEARCH) then
+		filter = ''
+	else
+		filter = text
+	end
+
+	MountJournal_UpdateMountList()
+end)
+
+function MountJournal_UpdateMountList()
 	local scroll = MountJournal.ListScrollFrame
 	local offset = HybridScrollFrame_GetOffset(scroll)
 	local mounts = GetNumCompanions('MOUNT')
@@ -77,28 +92,4 @@ local function Update()
 	MountJournal.MountCount.Count:SetText(mounts)
 end

-local function OnTextChanged(self)
-	local text = self:GetText()
-	if(text == SEARCH) then
-		filter = ''
-	else
-		filter = text
-	end
-
-	Update()
-end
-
-local Handler = CreateFrame('Frame')
-Handler:RegisterEvent('ADDON_LOADED')
-Handler:SetScript('OnEvent', function(self, event, name)
-	if(name == 'Blizzard_PetJournal') then
-		local Search = CreateFrame('EditBox', 'MountSearch', MountJournal, 'SearchBoxTemplate')
-		Search:SetSize(145, 20)
-		Search:SetPoint('LEFT', MountJournal.MountCount, 'RIGHT', 15, 0)
-		Search:SetMaxLetters(40)
-		Search:SetScript('OnTextChanged', OnTextChanged)
-
-		MountJournal.ListScrollFrame.update = Update
-		MountJournal_UpdateMountList = Update
-	end
-end)
\ No newline at end of file
+MountJournal.ListScrollFrame.update = MountJournal_UpdateMountList
diff --git a/Collie.toc b/Collie.toc
index 1ac6bc3..df3ee26 100644
--- a/Collie.toc
+++ b/Collie.toc
@@ -3,5 +3,7 @@
 ## Version: Alpha
 ## Title: Collie
 ## Notes: Mount list search function
+## LoadOnDemand: 1
+## LoadWith: Blizzard_PetJournal

 Collie.lua