Skip to content

Commit d36c3c8

Browse files
committed
Update code docs
1 parent f91cf18 commit d36c3c8

3 files changed

Lines changed: 23 additions & 20 deletions

File tree

docs/components_JROverhang.bs.html

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,33 @@
3434

3535
sub currentUserChanged()
3636
m.user.text = m.top.currentUser
37+
m.userImage = m.top.findNode("userImage")
38+
if not isValid(m.userPoster)
39+
m.userPoster = createUserPoster() ' save node to memory for faster load time
40+
end if
3741

3842
if m.top.currentUser = ""
39-
' remove the user image node if it exists
40-
userImage = m.userGroup.findNode("userImage")
41-
if isValid(userImage)
42-
m.userGroup.removeChild(userImage)
43+
' no user logged in, remove image if it exists
44+
if isValid(m.userImage)
45+
m.userGroup.removeChild(m.userImage)
46+
m.userImage = invalid
4347
end if
44-
' remove cached user image if it exists
45-
m.userImage = invalid
46-
else
47-
' cache the user image node if needed
48-
if not isValid(m.userImage)
49-
m.userImage = createUserImage()
48+
else if not isValid(m.userImage)
49+
' user logged in but no image, add it
50+
m.userImage = m.userPoster
51+
if m.userImage.tag = ""
52+
m.userGroup.itemSpacings = 9 ' default image is padded
53+
else
54+
m.userGroup.itemSpacings = 15
5055
end if
51-
' add the user image node to the overhang
56+
5257
m.userGroup.insertChild(m.userImage, 0)
5358
end if
5459
end sub
5560

56-
function createUserImage() as object
61+
function createUserPoster() as object
62+
userImage = createObject("roSGNode", "Poster")
63+
5764
imgParams = {
5865
maxHeight: 36,
5966
maxWidth: 36,
@@ -62,28 +69,24 @@
6269
imgTag = m.global.session.user.primaryImageTag
6370
if isValid(imgTag) and imgTag <> ""
6471
imgParams.tag = imgTag
72+
userImage.tag = imgTag
6573
end if
6674

67-
userImage = createObject("roSGNode", "Poster")
6875
userImage.id = "userImage"
6976
userImage.width = "36"
7077
userImage.height = "36"
7178

72-
if isValid(imgTag) and imgTag <> ""
79+
if isValid(imgTag)
7380
' reset defaults
74-
m.userGroup.itemSpacings = 15
7581
userImage.blendColor = "0xFFFFFFFF"
7682

7783
if m.global.session.server.url <> ""
7884
userImage.uri = buildURL(Substitute("/Users/{0}/Images/Primary", m.global.session.user.id), imgParams)
7985
else
8086
print "ERROR: No server URL set, cannot load user image"
8187
end if
82-
8388
else
84-
m.userGroup.itemSpacings = 9 ' account for default image padding
8589
userImage.blendColor = m.global.constants.colors.text_secondary
86-
8790
userImage.uri = "pkg:/images/icons/person_36px.png"
8891
end if
8992

docs/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/module-JROverhang.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)