Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new files for testing

  • Loading branch information...
commit 528d9e5131665b445b829cdfed85aafeb96c01a9 1 parent f8c789b
@dtudury authored
View
42 js/cryptopotamus/view/Base.js
@@ -0,0 +1,42 @@
+CLASS( "cryptopotamus.view.Base")
+.DEFINITION( function() {
+
+ var configure = IMPORT( "utils.configure");
+
+ this.parent = null;
+ this.node = null;
+
+ this.constructor = function( in_parent) {
+ this.parent = in_parent;
+ this.get_node();
+ this.parent.appendChild( this.get_node());
+ };
+
+ this.destructor = function() {
+ this.parent.removeChild( this.node);
+ };
+
+ this.get_node = function() {
+ if( !this.node) {
+ this.create_node();
+ configure( this.node, this.get_configuration());
+ }
+ return this.node;
+ };
+
+ this.create_node = function() {
+ return {};
+ };
+
+ this.get_configuration = function() {
+ return {};
+ };
+
+ this.extend_configuration = function( in_config) {
+ var config = {};
+ configure( config, this.SUPER.get_configuration());
+ configure( config, in_config);
+ return config;
+ };
+
+});
View
48 js/cryptopotamus/view/PasswordInputPrompted.js
@@ -0,0 +1,48 @@
+
+CLASS( "cryptopotamus.view.PasswordInputPrompted")
+.EXTENDS( "cryptopotamus.view.TextInputPrompted")
+.DEFINITION( function() {
+
+ var configure = IMPORT( "utils.configure");
+
+/*
+ this.constructor = function( in_parent, in_prompt_text) {
+ };
+ */
+
+
+});
+
+
+/*
+ var _new_password_input_prompt = function() {
+ var input = document.createElement( "input");
+ var configuration = { type: "text", value: "password",
+ style: {color:"grey"},
+ onfocus: function() {
+ var new_input = _new_password_input_used();
+ input.parentNode.replaceChild( new_input, input);
+ setTimeout( function() { new_input.focus();}, 0);
+ }
+ };
+ return configure( input, configuration);
+ };
+ var _new_password_input_used = function() {
+ var input = document.createElement( "input");
+ var configuration = { type: "password", style: {color:"black"},
+ onblur: function() {
+ if( input.value === "") {
+ var new_input = _new_password_input_prompt();
+ input.parentNode.replaceChild( new_input, input);
+ } else {
+ configure( input, { onfocus: null, onblur: null});
+ }
+ },
+ onkeyup: controller.update_salt
+ };
+ return configure( input, configuration);
+ };
+ this.new_password_input = function( onchange, size) {
+ return _new_password_input_prompt();
+ };
+*/
View
18 js/cryptopotamus/view/Text.js
@@ -0,0 +1,18 @@
+CLASS( "cryptopotamus.view.Text")
+.EXTENDS( "cryptopotamus.view.Base")
+.DEFINITION( function() {
+
+ var SUPER = this.SUPER;
+ var text = "";
+
+ this.constructor = function( in_parent, in_text) {
+ text = in_text;
+ SUPER.constructor.call( this, in_parent);
+ };
+
+ //override
+ this.create_node = function() {
+ this.node = document.createTextNode( text);
+ };
+
+});
View
46 js/cryptopotamus/view/TextInputPrompted.js
@@ -0,0 +1,46 @@
+CLASS( "cryptopotamus.view.TextInputPrompted")
+.EXTENDS( "cryptopotamus.view.Base")
+.DEFINITION( function() {
+
+ var SUPER = this.SUPER;
+ var configure = IMPORT( "utils.configure");
+ var wrap = IMPORT( "utils.Closure.wrap");
+
+ var _disabled_mode = { onfocus: null, onblur: null};
+ var _blurred_mode = { value: "", style: {color:"grey"}};
+ var _focused_mode = { value: "", style: {color:"black"}};
+
+ function onfocus() {
+ configure( this.get_node(), _focused_mode);
+ }
+ function onblur() {
+ if( this.get_node().value === "") configure( this.get_node(), _blurred_mode);
+ else configure( this.get_node(), _disabled_mode);
+ }
+
+
+ this.constructor = function( in_parent, in_prompt_text) {
+ _blurred_mode.value = in_prompt_text;
+ var local_configuration = this.get_configuration();
+ SUPER.constructor.call( this, in_parent);
+ };
+
+ //override
+ this.create_node = function() {
+ this.node = document.createElement( "input");
+ };
+
+ //override
+ this.get_configuration = function() {
+ var default_config = {
+ size: 20,
+ type: "text",
+ onfocus: wrap( this, onfocus),
+ onblur: wrap( this, onblur)
+ };
+ configure( default_config, _blurred_mode);
+ return this.extend_configuration( default_config);
+ };
+
+
+});

0 comments on commit 528d9e5

Please sign in to comment.
Something went wrong with that request. Please try again.