Commits

Kenneth Love committed d8e9353

lists can be created. updated js for adding members. updated display for same.

  • Participants
  • Parent commits 594cd12

Comments (0)

Files changed (4)

File static/css/style.css

       width:12px;
       text-indent:-99999px;
     }
-    #add_key {
+    #add_key,
+    .add_member {
       background:url('../img/add.png') center center no-repeat;
       display:block;
       float:left;
       width:12px;
       text-indent:-99999px;
     }
+    #members {
+      position:relative;
+    }
+    .add_member {
+      bottom:10px;
+      position:absolute;
+      right:-30px;
+    }
   #keylist {
     border:1px solid rgba(30,30,30,0.5);
     clear:both;

File static/js/newkeys.js

+var $member = $("#member").parent('fieldset');
+
+$(".add_member").live('click', function() {
+	var $new_member = $member.clone(),
+        $members = $("#members"),
+		count = $("[id^=member]").length,
+		new_id = $new_member.find('input').attr('id') + '_' + count,
+		$insert_point = $("#key_ttl").parent('fieldset');
+	$("input", $new_member).attr({'id': new_id, 'name': new_id, 'value': ''});
+	$("label", $new_member).attr('for', new_id);
+	$new_member.appendTo($("#members"));
+	$new_member.find('input').focus();
+});

File templates/new_list.html

 	<form action="{{ url_for('new_list') }}" method="post" id="new_key_form">
 		{{ form.csrf }}
 		{{ render_field(form.key_name) }}
-		{{ render_field(form.member) }}
+		<fieldset id="members">
+			<a class="add_member">+</a>
+			{{ render_field(form.member) }}
+		</fieldset>
 		{{ render_field(form.key_ttl, type="number", class="optional") }}
 		<a href="{{ url_for('index') }}" id="cancel">cancel</a>
 		<input type="submit" value="Submit">
 {% endblock %}
 
 {% block extra_scripts %}
-<script>
-	var add_link = $('<a class="add_member">+</a>'),
-		$member = $("#member").parent('fieldset');
-	$(function() {
-		$member.append(add_link);
-		$(".add_member").live('click', function() {
-			var $new_member = $member.clone(),
-				count = $("[id^=member]").length,
-				new_id = $new_member.find('input').attr('id') + '_' + count,
-				$insert_point = $("#key_ttl").parent('fieldset');
-			$("input", $new_member).attr({'id': new_id, 'name': new_id, 'value': ''});
-			$("label", $new_member).attr('for', new_id);
-			$new_member.insertBefore($insert_point);
-			$(this).remove();
-		});
-	});
-</script>
+<script src="{{ url_for('static', filename='js/newkeys.js') }}"></script>
 {% endblock %}

File templates/new_set.html

 	<form action="{{ url_for('new_set') }}" method="post" id="new_key_form">
 		{{ form.csrf }}
 		{{ render_field(form.key_name) }}
-		{{ render_field(form.member) }}
+		<fieldset id="members">
+			<a class="add_member">+</a>
+			{{ render_field(form.member) }}
+		</fieldset>
 		{{ render_field(form.key_ttl, type="number", class="optional") }}
 		<a href="{{ url_for('index') }}" id="cancel">cancel</a>
 		<input type="submit" value="Submit">
 {% endblock %}
 
 {% block extra_scripts %}
-<script>
-	var add_link = $('<a class="add_member">+</a>'),
-		$member = $("#member").parent('fieldset');
-	$(function() {
-		$member.append(add_link);
-		$(".add_member").live('click', function() {
-			var $new_member = $member.clone(),
-				count = $("[id^=member]").length,
-				new_id = $new_member.find('input').attr('id') + '_' + count,
-				$insert_point = $("#key_ttl").parent('fieldset');
-			$("input", $new_member).attr({'id': new_id, 'name': new_id, 'value': ''});
-			$("label", $new_member).attr('for', new_id);
-			$new_member.insertBefore($insert_point);
-			$(this).remove();
-		});
-	});
-</script>
+<script src="{{ url_for('static', filename='js/newkeys.js') }}"></script>
 {% endblock %}