UI
Discussion posts and replies are publicly visible
I am not sure whether anyone here has the time to analyze 675 lines of code!
I think you will get more feedback when you make it easier for us.
Posts for help should include:
1) what you want to accomplish / what you want the user experience to be (in simple terms first, then more complex details if needed)
2) what you've tried (simple then complex)
3) specifically what isn't working / what isn't meeting your expectations, along with other mitigations you may have already tried. screenshots if needed, and mockups if the screenshots don't convey the ultimate design experience very well...
At least 2/3 of the above details are missing, and as Stefan mentioned nobody really has time to fully parse your code especially when there isn't really any information about what may or may not already be meeting your expectations.