fbpx
วิกิพีเดีย

มอดูล:Navbar/sandbox

คู่มือการใช้งานมอดูล[ดู] [แก้] [ประวัติ] [ล้างแคช]

This is a Lua implementation of {{Navbar}}. It is used in มอดูล:Navbox.

local p = {} local cfg = mw.loadData('มอดูล:Navbar/configuration')  local function get_title_arg(is_collapsible, template)  local title_arg = 1  if is_collapsible then title_arg = 2 end  if template then title_arg = 'template' end  return title_arg end  local function choose_links(template, args)  -- The show table indicates the default displayed items.  -- view, talk, edit, hist, move, watch  -- TODO: Move to configuration.  local show = {true, true, true, false, false, false}  if template then  show[2] = false  show[3] = false  local index = {t = 2, d = 2, e = 3, h = 4, m = 5, w = 6,  talk = 2, edit = 3, hist = 4, move = 5, watch = 6}  -- TODO: Consider removing TableTools dependency.  for _, v in ipairs(require ('มอดูล:TableTools').compressSparseArray(args)) do  local num = index[v]  if num then show[num] = true end  end  end   local remove_edit_link = args.noedit  if remove_edit_link then show[3] = false end   return show  end  local function add_link(link_description, ul, is_mini, font_style)  local l  if link_description.url then  l = {'[', '', ']'}  else  l = {'[[', '|', ']]'}  end  ul:tag('li')  :addClass('nv-' .. link_description.full)  :wikitext(l[1] .. link_description.link .. l[2])  :tag(is_mini and 'abbr' or 'span')  :attr('title', link_description.html_title)  :cssText(font_style)  :wikitext(is_mini and link_description.mini or link_description.full)  :done()  :wikitext(l[3])  :done() end  local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)   local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)  if not title then  error(cfg.invalid_title .. title_text)  end  local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''   -- TODO: Get link_descriptions and show into the configuration module.  -- link_descriptions should be easier...  local link_descriptions = {  { ['mini'] = 'ด', ['full'] = 'ดู', ['html_title'] = 'ดูแม่แบบนี้',  ['link'] = title.fullText, ['url'] = false },  { ['mini'] = 'ค', ['full'] = 'คุย', ['html_title'] = 'อภิปรายแม่แบบนี้',  ['link'] = talkpage, ['url'] = false },  { ['mini'] = 'ก', ['full'] = 'แก้ไข', ['html_title'] = 'แก้ไขแม่แบบนี้',  ['link'] = title:fullUrl('action=edit'), ['url'] = true },  { ['mini'] = 'ป', ['full'] = 'ประวัติ', ['html_title'] = 'ประวัติแม่แบบนี้',  ['link'] = title:fullUrl('action=history'), ['url'] = true },  { ['mini'] = 'ย', ['full'] = 'ย้าย', ['html_title'] = 'ย้ายแม่แบบนี้',  ['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },  { ['mini'] = 'ฝ', ['full'] = 'เฝ้าดู', ['html_title'] = 'เฝ้าดูแม่แบบนี้',  ['link'] = title:fullUrl('action=watch'), ['url'] = true }  }   local ul = mw.html.create('ul')  if has_brackets then  ul:addClass(cfg.classes.brackets)  :cssText(font_style)  end   for i, _ in ipairs(displayed_links) do  if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end  end  return ul:done()  end  function p._navbar(args)   -- TODO: We probably don't need both fontstyle and fontcolor...  local font_style = args.fontstyle  local font_color = args.fontcolor  local is_collapsible = args.collapsible  local is_mini = args.mini  local is_plain = args.plain   local collapsible_class = nil  if is_collapsible then  collapsible_class = cfg.classes.collapsible  if not is_plain then is_mini = 1 end  if font_color then  font_style = (font_style or '') .. '; color: ' .. font_color .. ';'  end  end   local navbar_style = args.style  local div = mw.html.create():tag('div')  div  :addClass(cfg.classes.navbar)  :addClass(cfg.classes.plainlinks)  :addClass(cfg.classes.horizontal_list)  :addClass(collapsible_class) -- we made the determination earlier  :cssText(navbar_style)   if is_mini then div:addClass(cfg.classes.mini) end   local box_text = (args.text or cfg.box_text) .. ' '  -- the concatenated space guarantees the box text is separated  if not (is_mini or is_plain) then  div  :tag('span')  :addClass(cfg.classes.box_text)  :cssText(font_style)  :wikitext(box_text)  end   local template = args.template  local displayed_links = choose_links(template, args)  local has_brackets = args.brackets  local title_arg = get_title_arg(is_collapsible, template)  local title_text = args[title_arg] or (':' .. mw.getCurrentFrame():getParent():getTitle())  local list = make_list(title_text, has_brackets, displayed_links, is_mini, font_style)  div:node(list)   if is_collapsible then  local title_text_class  if is_mini then  title_text_class = cfg.classes.collapsible_title_mini  else  title_text_class = cfg.classes.collapsible_title_full  end  div:done()  :tag('div')  :addClass(title_text_class)  :cssText(font_style)  :wikitext(args[1])  end   return mw.getCurrentFrame():extensionTag{  name = 'templatestyles', args = { src = cfg.templatestyles }  } .. tostring(div:done()) end  function p.navbar(frame)  return p._navbar(require('มอดูล:Arguments').getArgs(frame)) end  return p 

มอด, navbar, sandbox, อหน, ากระบะทรายมอด, ลของ, มอด, navbar, ความแตกต, าง, อการใช, งานมอด, แก, ประว, างแคช, การใช, มอด, ลน, ใน, หน, าการแก, ไขอาจทำให, เก, ดผลกระทบหร, อส, งเกตเห, นได, งน, นก, อนแก, ไขแม, แบบน, งควรทดลองท, กระบะทราย, หร, อหน, าทดสอบ, หร, อพ, นท. nikhuxhnakrabathraymxdulkhxng mxdul Navbar dukhwamaetktang khumuxkarichnganmxdul du aek prawti langaekhch mikarichmxdulniin 106 000 hnakaraekikhxacthaihekidphlkrathbhruxsngektehnid dngnnkxnaekikhaemaebbnicungkhwrthdlxngthikrabathray hruxhnathdsxb hruxphunthiswntwkhxngkhunkxn cnmnicwacaimekidphlesiytamma nxkcaknikhunyngsamarthphudkhuyekiywkbkaraekikhaemaebbidthihnaxphiprayaemaebbniichinkhxkhwamkhxngrabb karepliynaeplngaemaebbnithaihekidkarepliynaeplngtxswntidtxphuichkhxngwikiphiediyinthnthi ephuxhlikeliyngkhwamphidphlad karthakarepliynaeplngid khwrthdlxnginhnayxy sandbox khxngaemaebbkxn hruxxaccathdlxnginhnayxykhxnghnaphuichkhxngkhun oprdaecnginhnaxphipraykxnthakaraekikhaemaebbniichskhriptphasaluxa mxdul Argumentsmxdul TableToolsmxdulniich TemplateStyles mxdul Navbar styles cssThis is a Lua implementation of Navbar It is used in mxdul Navbox khumuxkarichnganthipraktdanbnnidungmacak mxdul Navbar doc aek prawti phuekhiynsamarththakarthdlxngidthikrabathray aek dukhwamaetktang aelachudthdsxb srang khxngmxdulnioprdephimhmwdhmuipthihnayxy doc hnayxykhxngmxdulnilocal p local cfg mw loadData mxdul Navbar configuration local function get title arg is collapsible template local title arg 1 if is collapsible then title arg 2 end if template then title arg template end return title arg end local function choose links template args The show table indicates the default displayed items view talk edit hist move watch TODO Move to configuration local show true true true false false false if template then show 2 false show 3 false local index t 2 d 2 e 3 h 4 m 5 w 6 talk 2 edit 3 hist 4 move 5 watch 6 TODO Consider removing TableTools dependency for v in ipairs require mxdul TableTools compressSparseArray args do local num index v if num then show num true end end end local remove edit link args noedit if remove edit link then show 3 false end return show end local function add link link description ul is mini font style local l if link description url then l else l end ul tag li addClass nv link description full wikitext l 1 link description link l 2 tag is mini and abbr or span attr title link description html title cssText font style wikitext is mini and link description mini or link description full done wikitext l 3 done end local function make list title text has brackets displayed links is mini font style local title mw title new mw text trim title text cfg title namespace if not title then error cfg invalid title title text end local talkpage title talkPageTitle and title talkPageTitle fullText or TODO Get link descriptions and show into the configuration module link descriptions should be easier local link descriptions mini d full du html title duaemaebbni link title fullText url false mini kh full khuy html title xphiprayaemaebbni link talkpage url false mini k full aekikh html title aekikhaemaebbni link title fullUrl action edit url true mini p full prawti html title prawtiaemaebbni link title fullUrl action history url true mini y full yay html title yayaemaebbni link mw title new Special Movepage fullUrl target title fullText url true mini f full efadu html title efaduaemaebbni link title fullUrl action watch url true local ul mw html create ul if has brackets then ul addClass cfg classes brackets cssText font style end for i in ipairs displayed links do if displayed links i then add link link descriptions i ul is mini font style end end return ul done end function p navbar args TODO We probably don t need both fontstyle and fontcolor local font style args fontstyle local font color args fontcolor local is collapsible args collapsible local is mini args mini local is plain args plain local collapsible class nil if is collapsible then collapsible class cfg classes collapsible if not is plain then is mini 1 end if font color then font style font style or color font color end end local navbar style args style local div mw html create tag div div addClass cfg classes navbar addClass cfg classes plainlinks addClass cfg classes horizontal list addClass collapsible class we made the determination earlier cssText navbar style if is mini then div addClass cfg classes mini end local box text args text or cfg box text the concatenated space guarantees the box text is separated if not is mini or is plain then div tag span addClass cfg classes box text cssText font style wikitext box text end local template args template local displayed links choose links template args local has brackets args brackets local title arg get title arg is collapsible template local title text args title arg or mw getCurrentFrame getParent getTitle local list make list title text has brackets displayed links is mini font style div node list if is collapsible then local title text class if is mini then title text class cfg classes collapsible title mini else title text class cfg classes collapsible title full end div done tag div addClass title text class cssText font style wikitext args 1 end return mw getCurrentFrame extensionTag name templatestyles args src cfg templatestyles tostring div done end function p navbar frame return p navbar require mxdul Arguments getArgs frame end return p ekhathungcak https th wikipedia org w index php title mxdul Navbar sandbox amp oldid 9228073, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม