include mixins

form(class="form-horizontal subroot", id="form-locationeditor")
	.new_flex_zero(style="margin-bottom: 20px;")
		.container-fluid
			h4 Ort aus manuellen Angaben hinzufügen
	
			button(class="btn btn-success btn-sm", type="submit", id="submit_button") 
				span(class="glyphicon glyphicon-ok", aria-hidden="true")
				span 
				span Übernehmen
			
			button(class="btn btn-warning btn-sm", type="button", onclick="history.back();") 
				span(class="glyphicon glyphicon-remove-circle", aria-hidden="true")
				span 
				span Abbrechen
								
		
	.new_flex_one
		.container-fluid
		
			.form-group
				label(for='edit_name', class="col-sm-2 control-label") Name
				.col-sm-10
					input(id='edit_name', type="text", class="form-control noEnterSubmit", value="#{location.name}", required)
					.help-block.with-errors

			.form-group
				label(for='edit_sign', class="col-sm-2 control-label") Signum
				.col-sm-2
					input(id='edit_sign', type="text", class="form-control noEnterSubmit", maxlength="5", value="#{location.sign}")
					.help-block.with-errors
					
	script.
		
		/*show_submitbutton("submit-btn-locationeditor", "$('#form-locationeditor').submit();","");
		
		function update_submitbutton() {
			console.log($("#submit_button").hasClass('disabled'));
			$("#submit-btn-locationeditor").toggleClass('disabled', $("#submit_button").hasClass('disabled'));
		}*/

		$('#form-locationeditor').validator().on('submit', function(e) {
			if( ! e.isDefaultPrevented() )
			{
				e.preventDefault();
				
				var data = {
					id   : "other",
					name : $("#edit_name").val(),
					sign : $("#edit_sign").val(),
					uid  : "#{location.uid}"
				};
				
				pcal_pentry_edit_manager.#{type}_location(data);
			}
		});/*.on('validated.bs.validator', function(e) {
			console.log('validated');
			update_submitbutton();
		});
		
		update_submitbutton();*/
		
		
