Resources/js/d/prefs.js
changeset 1 b3419d05eabb
parent 0 80c32ef237c6
--- a/Resources/js/d/prefs.js	Mon Sep 02 02:22:21 2013 -0700
+++ b/Resources/js/d/prefs.js	Mon Sep 23 09:10:55 2013 -0700
@@ -1,3 +1,5 @@
+
+D = Ti.API.get( 'D' );
 
 $( window ).ready( function() {
 	new PrefsRouter( $('#content') );
@@ -9,7 +11,7 @@
 /* ---------------------------------------------- */
 PrefsRouter = can.Control({
 	defaults: {
-		menu: $( '#sections' ),
+		menu: '#sections',
 		default_route: 'app'
 	}
 }, {
@@ -26,12 +28,10 @@
 	reset: function() {
 		var self = this;
 		var current_route = can.route.attr( 'route' );
-		var menu = self.options.menu;
+		var menu = $( self.options.menu );
 
-		// FIXME
 		menu.find( 'a' ).removeClass( 'selected' );
-		console.log( menu.find( 'a' ) );
-		console.log( menu.find( 'a[href="#' + current_route + '"]' ) );
+		menu.find( 'a[href="#' + current_route + '"]' ).addClass( 'selected' );
 
 		while ( control = self.controls.pop() ) control.destroy();
 	},
@@ -62,11 +62,16 @@
 		// Get the current preference values.
 		//
 		var bool_prefs = {
-			hidesplash: [ D.getBoolPref( 'hidesplash' ), 'Skip splash screen at startup' ],
-			fullscreen: [ D.getBoolPref( 'fullscreen' ), 'Go full screen by default' ],
-			devmode:    [ D.getBoolPref( 'devmode' ), 'Developer mode' ]
+			hidesplash:      [ D.getBoolPref( 'hidesplash' ), 'Skip splash screen at startup' ],
+			remember_window: [ D.getBoolPref( 'remember_window' ), 'Remember main window position' ],
 		}
 
+		// Running from the builder env (or manually with --debug), include
+		// developer options.
+		//
+		if ( Ti.App.getArguments()[0] == "--debug" )
+			bool_prefs.devmode = [ D.getBoolPref( 'devmode' ), 'Developer mode' ];
+
 		self.element.html(
 			can.view( self.options.view, {
 				bool_prefs: bool_prefs
@@ -109,9 +114,19 @@
 	// Update the server URI preference.
 	//
 	updateServer: function( uri ) {
-		console.log( 'Updated server_uri to ' + uri + '.' );
-		D.setPref( 'server_uri', uri );
-		D.tf.uri = uri;
+		if ( uri.length == 0 ) return;
+		D.tf.attr( 'uri', uri );
+
+		if ( D.tf.version ) {
+			D.setPref( 'server_uri', uri );
+			console.log( 'Updated server_uri to ' + uri + '.' );
+			$( '#test .info' ).html( D.tf.version );
+			$( '#test .icon' ).html( '' );
+		}
+		else {
+			$( '#test .info' ).empty();
+			$( '#test .icon' ).html( '' );
+		}
 	},
 
 	// Hitting the return key on input fields defer to the 'blur' event,
@@ -121,21 +136,14 @@
 		if ( event.which == 13 ) ele.trigger( 'blur' );
 	},
 	'#server change': function( ele, event ) {
-		this.updateServer( ele.val() );
+		var self = this;
+		self.updateServer( ele.val() );
 	},
 	'#server keyup': function( ele, event ) {
+		var self = this;
 		D.delay( function() {
-			this.updateServer( ele.val() );
-		}, 500, true );
-	},
-
-
-	// Talk to the remote server, check to see if it's really
-	// a ThingFish handler or not.
-	//
-	'#test click': function( ele, event ) {
-		var server = $( '#server' ).val();
-		D.checkServer( server );
-	},
+			self.updateServer( ele.val() );
+		}, 1000, true );
+	}
 });