mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	Translationsupport for JSON Forms & Bootstrap Switches (#188)
* Example JSON Form Example with General setting I have created a new Category "General" with several Settings for Hyperion. For now the Submit Button only console.log's the values. Known Bug: For some reason it seems to do not load the bootstrap correctly or maybe the Lib isn't compatible with the newest version of bootstrap. * Translationsupport for JSON Forms * Hotfix * Added Bootstrap Switches for all checkboxes All checkboxes will be converted to Switches
This commit is contained in:
		
							
								
								
									
										22
									
								
								assets/webconfig/css/bootstrap-switch.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								assets/webconfig/css/bootstrap-switch.min.css
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -7,16 +7,13 @@ | ||||
| 			</div> | ||||
| 			<hr> | ||||
| 			<div class="col-lg-12"> | ||||
|         <form></form> | ||||
|         <form id="generalConfForm"></form> | ||||
|       </div> | ||||
| 		</div> | ||||
| 	</div> | ||||
| </div> | ||||
|  | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|  | ||||
|     </script> | ||||
| <script> | ||||
|  | ||||
| 	$(document).ready( function() { | ||||
| @@ -64,12 +61,16 @@ | ||||
|  | ||||
|  | ||||
|  | ||||
|       enableFormTranslation("generalConfForm", "generalConfForm"); | ||||
|  | ||||
|       $("[type='checkbox']").bootstrapSwitch(); | ||||
|  | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 	}); | ||||
|   }); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| </script> | ||||
|   | ||||
| @@ -11,9 +11,13 @@ | ||||
|  | ||||
|     <title>Hyperion - WebUI</title> | ||||
|  | ||||
|  | ||||
| 	<!-- jQuery --> | ||||
|   <!-- jQuery --> | ||||
|     <script src="js/jquery.min.js"></script> | ||||
|     <script src="js/hyperion.js"></script> | ||||
|  | ||||
|   <!-- Bootstrap Switch --> | ||||
|     <script src="js/bootstrap-switch.min.js"></script> | ||||
|     <link href="css/bootstrap-switch.min.css" rel="stylesheet"> | ||||
|  | ||||
|   <!-- JSONForm --> | ||||
|     <script src="js/underscore.js"></script> | ||||
| @@ -436,6 +440,10 @@ | ||||
|       $("#load_confGeneral").on("click", function() { | ||||
| 				$("#page-wrapper").load("generalconf.html"); | ||||
| 			}); | ||||
|  | ||||
|       //Change all Checkboxes to Switches | ||||
|       $("[type='checkbox']").bootstrapSwitch(); | ||||
|  | ||||
|     }); | ||||
| 		$(function(){ | ||||
| 			var sidebar = $('#side-menu');  // cache sidebar to a variable for performance | ||||
|   | ||||
							
								
								
									
										22
									
								
								assets/webconfig/js/bootstrap-switch.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								assets/webconfig/js/bootstrap-switch.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										22
									
								
								assets/webconfig/js/hyperion.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								assets/webconfig/js/hyperion.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
|  | ||||
| /** | ||||
| * Enables translation for the form | ||||
| * with the ID given in "formID" | ||||
| * Generates token with the given token prefix | ||||
| * and an underscore followed by the input id | ||||
| * Example: input id = input_one | ||||
| * token prefix = tokenprefix | ||||
| * The translation token would be: "tokenprefix_input_one" | ||||
| * Default language in "lang" attribute will always be "en" | ||||
| * @param {String} tokenPrefix | ||||
| * @param {String} formID | ||||
| */ | ||||
| function enableFormTranslation(tokenPrefix, formID) { | ||||
| var $inputs = $("#" + formID + " :input"); | ||||
|  | ||||
| $inputs.each(function() { | ||||
|   console.log("InputID: " + $(this).attr('id')); | ||||
|   var oldtext = $("label[for='" + $(this).attr('id') + "']").text(); | ||||
|   $("label[for='" + $(this).attr('id') + "']").html('<span lang="en" data-lang-token="' + tokenPrefix + "_" + $(this).attr('id') + '">' + oldtext + '</span>'); | ||||
| }); | ||||
| } | ||||
| @@ -57,8 +57,23 @@ | ||||
| 		"support_label_wikitext" : "Von A bis Z - Alles wissenwerte zu Hyperion", | ||||
| 		"support_label_forumtitle" : "Forum", | ||||
| 		"support_label_forumtext" : "Diskussion und Hilfestellung von der Community", | ||||
| 		"main_menu_general_conf_token":"Allgemein", | ||||
| 		"remote_general_conf_intro":"Hier kannst du allgemeine Einstellungen von Hyperion vornehmen." | ||||
| 		"main_menu_general_conf_token" : "Allgemein", | ||||
| 		"remote_general_conf_intro" : "Hier kannst du allgemeine Einstellungen von Hyperion vornehmen.", | ||||
| 		"generalConfForm_jsonform-0-elt-logger.level" : "Stufe Logging", | ||||
| 		"generalConfForm_jsonform-0-elt-jsonServer.port" : "Port", | ||||
| 		"generalConfForm_jsonform-0-elt-protoServer.port" : "Port", | ||||
| 		"generalConfForm_jsonform-0-elt-boblightServer.enable" : "Aktivieren", | ||||
| 		"generalConfForm_jsonform-0-elt-boblightServer.port" : "Port", | ||||
| 		"generalConfForm_jsonform-0-elt-boblightServer.priority" : "Prioität", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.address" : "IP-Addresse", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.enable" : "Aktivieren", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.port" : "Port", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.priority" : "Prioität", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.shared" : "Shared", | ||||
| 		"generalConfForm_jsonform-0-elt-udpListener.timeout" : "Timeout", | ||||
| 		"generalConfForm_jsonform-0-elt-webConfig.document_root" : "Root Verzeichnis", | ||||
| 		"generalConfForm_jsonform-0-elt-webConfig.enable" : "Aktivieren" | ||||
|  | ||||
| 	}, | ||||
| 	"regex": [ | ||||
| 		["^Something at start of text", ""], | ||||
|   | ||||
		Reference in New Issue
	
	Block a user