//- Navbar mixins
mixin nav_bare(name, style)
	- var style = (typeof style === 'undefined') ? "default" : style
	nav( role="navigation", class=["navbar", "navbar-" + style] )
		.navbar-header
			a.navbar-brand(href="#")= name

		ul.nav.navbar-nav
			block

mixin nav_main(name, id, style)
	- var style = (typeof style === 'undefined') ? "default" : style
	nav( role="navigation", class=["navbar", "navbar-" + style] )
		.container-fluid
			.navbar-header
				button.navbar-toggle.collapsed( type="button", data-toggle="collapse", data-target="#" + id, aria-expanded="false", aria-controls="navbar")
					span.sr-only Toggle navigation
					span.icon-bar
					span.icon-bar
					span.icon-bar
				a.navbar-brand(href="#")= name
			.collapse.navbar-collapse( id=id )
				block

mixin nav_main_collapse()
	ul.nav.navbar-nav(onclick="$(this).closest('.collapse').collapse('hide');")
		block
	
mixin nav_main_dropdown_right(name)
	ul.nav.navbar-nav.navbar-right
		li.dropdown
			a.dropdown-toggle( href="#", data-toggle="dropdown", role="button", aria-expanded="false" )= name
				span.caret
			ul.dropdown-menu( role="menu" )
				block
					
mixin nav_main_primary(viewformat, date)
	+nav_main("PfarrInfoSystem", "nav_main_primary")
		+nav_main_collapse()
			if viewformat === "day"
				+nav_item( "#", "active" ) Tag
				+nav_item( "javascript: set_viewformat('timeline', '" + date +"');") TagZeitleiste
				+nav_item( "javascript: set_viewformat('pastoralteam', '" + date +"');") Pastoralteam
				+nav_item( "javascript: set_viewformat('pfarreientimeline', '" + date +"');") Pfarreien
				+nav_item( "/week/" + date) Woche
			else if viewformat === "timeline"
				+nav_item( "javascript: set_viewformat('day', '" + date +"');") Tag
				+nav_item( "#", "active" ) TagZeitleiste
				+nav_item( "javascript: set_viewformat('pastoralteam', '" + date +"');") Pastoralteam
				+nav_item( "javascript: set_viewformat('pfarreientimeline', '" + date +"');") Pfarreien
				+nav_item( "/week/" + date) Woche
			else if viewformat === "pastoralteam"
				+nav_item( "javascript: set_viewformat('day', '" + date +"');") Tag
				+nav_item( "javascript: set_viewformat('timeline', '" + date +"');") TagZeitleiste
				+nav_item( "#", "active" ) Pastoralteam
				+nav_item( "javascript: set_viewformat('pfarreientimeline', '" + date +"');") Pfarreien
				+nav_item( "/week/" + date) Woche
			else if viewformat === "pfarreientimeline"
				+nav_item( "javascript: set_viewformat('day', '" + date +"');") Tag
				+nav_item( "javascript: set_viewformat('timeline', '" + date +"');") TagZeitleiste
				+nav_item( "javascript: set_viewformat('pastoralteam', '" + date +"');") Pastoralteam
				+nav_item( "#", "active" ) Pfarreien
				+nav_item( "/week/" + date) Woche
			else
				+nav_item( "/day/" + date ) Tag
				+nav_item( "/timeline/" + date ) TagZeitleiste
				+nav_item( "/pastoralteam/" + date ) Pastoralteam
				+nav_item( "/pfarreientimeline/" + date) Pfarreien
				+nav_item( "#", "active" ) Woche
		+nav_main_dropdown_right("Extras")
			+nav_item_new_window( "/parishdb" ) Pfarrdatenbank
			+nav_item_new_window( "/volunteerslist" ) Ehrenamtlichenliste
			+nav_divider
			+nav_item_new_window( "/parishcalA4week/" + date) 
				#parishcalA4week A4-Wochenübersicht
			+nav_divider
			+nav_item( "/" + viewformat + "/"+date+"/select_punits_for_view" )
				#select_punits_for_view Angezeigte Orte konfigurieren ...
			+nav_divider
			+nav_item( "/about" ) Über Pfis ...

mixin nav(name, id, style)
	- var style = (typeof style === 'undefined') ? "default" : style
	nav( role="navigation", class=["navbar", "navbar-" + style] )
		.container-fluid
			.navbar-header
				button.navbar-toggle.collapsed( type="button", data-toggle="collapse", data-target="#" + id, aria-expanded="false", aria-controls="navbar")
					span.sr-only Toggle navigation
					span.icon-bar
					span.icon-bar
					span.icon-bar
				a.navbar-brand(href="#")= name
 
			.collapse.navbar-collapse( id=id )
				ul.nav.navbar-nav
					block

mixin nav_with_form(name, shortname, id, style)
	- var style = (typeof style === 'undefined') ? "default" : style
	nav( role="navigation", class=["navbar", "navbar-" + style] )
		.container-fluid
			.navbar-header
				a.navbar-brand.hidden-xs(href="#")= name
				a.navbar-brand.visible-xs(href="#")= shortname
				form.form-inline.navbar-form.pull-left(id=id+"-form")

mixin nav_item(href, active)
	li(class=active): a( href=href )
		block

mixin nav_item_new_window(href, active)
	li(class=active): a( href=href, target="_blank" )
		block

mixin nav_item_dropdown(href, active)
	li(class=["dropdown", active])
		a.dropdown-toggle( href=href, data-toggle="dropdown", role="button", aria-expanded="false" )= attributes.label
			span.caret
		ul.dropdown-menu( role="menu" )
			block
 
mixin nav_divider
	li.divider
 
mixin nav_header
	li.dropdown-header
		block

//- End navbar mixins

mixin dropdown_button(name, id, menupos)
	- var menupos_real = (typeof menupos === 'undefined') ? "left" : menupos
	.dropdown(style="display: inline;")
		button(class=["btn", "btn-default", "btn-xs", "dropdown-toggle"], type="button", id=id, data-toggle="dropdown", aria-haspopup="true", aria-expanded="false")
			span #{name}
			span 
			span(class="caret") 
		ul(class=["dropdown-menu", "dropdown-menu-" + menupos_real], aria-labelledby=id)
			block

mixin dropdown_button_element_href(name, href)
	li
		a(href=href) #{name}

mixin messageview(messages)
	each message in messages
		div(class=["alert", "alert-dismissible", "alert-" + message.type], role="alert")
			button(type="button", class="close", data-dismiss="alert", aria-label="Close")
				span(aria-hidden="true") &times;
			strong #{message.title}
			span 
			span #{message.message}

mixin standard_delete_dialog(id)
	.modal.fade(id=id, role="dialog", aria-labelledby=id+"Label", aria-hidden="true")
		.modal-dialog(role="document")
			.modal-content
				.modal-header
					button(type="button", class="close", data-dismiss="modal", aria-hidden="true") &times;
					h4(class="modal-title", id=id+"Label") Löschen bestätigen
				.modal-body
					p Sind Sie sicher, dass Sie das Ereignis löschen wollen?
				.modal-footer
					button(type="button", class="btn btn-default", data-dismiss="modal") Abbrechen
					button(type="button", class="btn btn-danger", id="confirm") Löschen
