Database changes have finished applying - please report any issues you're (still) seeing to support@shoutwiki.com.
Module:Navbar
From Eureka Wiki
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Navbar/doc
1 local p = {}
2
3 local getArgs
4
5 function p._navbar(args)
6 local titleArg = 1
7
8 if args.collapsible then
9 titleArg = 2
10 if not args.plain then
11 args.mini = 1
12 end
13 if args.fontcolor then
14 args.fontstyle = 'color:' .. args.fontcolor .. ';'
15 end
16 args.style = 'float:left; text-align:left'
17 end
18
19 local titleText = args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
20 local title = mw.title.new(mw.text.trim(titleText), 'Template');
21
22 if not title then
23 error('Invalid title ' .. titleText)
24 end
25
26 local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or '';
27
28 local div = mw.html.create():tag('div')
29 div
30 :addClass('plainlinks')
31 :addClass('hlist')
32 :addClass('navbar')
33 :cssText(args.style)
34
35 if args.mini then div:addClass('mini') end
36
37 if not (args.mini or args.plain) then
38 div
39 :tag('span')
40 :css('word-spacing', 0)
41 :cssText(args.fontstyle)
42 :wikitext(args.text or 'This box:')
43 :wikitext(' ')
44 end
45
46 if args.brackets then
47 div
48 :tag('span')
49 :css('margin-right', '-0.125em')
50 :cssText(args.fontstyle)
51 :wikitext('[ ')
52 end
53
54 local ul = div:tag('ul');
55
56 ul
57 :tag('li')
58 :addClass('nv-view')
59 :wikitext('[[' .. title.fullText .. '|')
60 :tag(args.mini and 'abbr' or 'span')
61 :attr('title', 'View this template')
62 :cssText(args.fontstyle)
63 :wikitext(args.mini and 'v' or 'view')
64 :done()
65 :wikitext(']]')
66 :done()
67 :tag('li')
68 :addClass('nv-talk')
69 :wikitext('[[' .. talkpage .. '|')
70 :tag(args.mini and 'abbr' or 'span')
71 :attr('title', 'Discuss this template')
72 :cssText(args.fontstyle)
73 :wikitext(args.mini and 't' or 'talk')
74 :done()
75 :wikitext(']]');
76
77 if not args.noedit then
78 ul
79 :tag('li')
80 :addClass('nv-edit')
81 :wikitext('[' .. title:fullUrl('action=edit') .. ' ')
82 :tag(args.mini and 'abbr' or 'span')
83 :attr('title', 'Edit this template')
84 :cssText(args.fontstyle)
85 :wikitext(args.mini and 'e' or 'edit')
86 :done()
87 :wikitext(']');
88 end
89
90 if args.brackets then
91 div
92 :tag('span')
93 :css('margin-left', '-0.125em')
94 :cssText(args.fontstyle)
95 :wikitext(' ]')
96 end
97
98 if args.collapsible then
99 div
100 :done()
101 :tag('div')
102 :css('font-size', '114%')
103 :css('margin', args.mini and '0 4em' or '0 7em')
104 :cssText(args.fontstyle)
105 :wikitext(args[1])
106 end
107
108 return tostring(div:done())
109 end
110
111 function p.navbar(frame)
112 if not getArgs then
113 getArgs = require('Module:Arguments').getArgs
114 end
115 return p._navbar(getArgs(frame))
116 end
117
118 return p