Browse Source

Adds a toggle for email lists.

1).  Improvments to name/email regexp
2).  beginnings of validation logic for email list toggle
devel
Jonathan Rosenbaum 10 years ago
parent
commit
763587f840
  1. 2
      Connections/database_functions.php
  2. 7
      contact_add_edit.php
  3. 40
      css/contacts.css
  4. 1
      css/jquery.nouislider.css
  5. 60
      js/contact.js

2
Connections/database_functions.php

@ -418,7 +418,7 @@ function list_contacts_edit_add($form_name = "contact_id", $default_value = "")
function list_contacts_select_user($form_name = "contact_id", $default_value = "")
{
echo "<select name={$form_name} class='yb_standard'>\n";
echo "<option value='no_selection'>Select User</option>\n";
echo "<option value='no_selection'>Select Yourself<section></section></option>\n";
echo "<option value='no_selection'>--------------</option>";
list_contacts("none",$default_value);
echo "</select>\n";

7
contact_add_edit.php

@ -150,6 +150,13 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1);
<td><input id="email" type="text" name="email" value="<?php echo $row_Recordset1['email']; ?>" size="32">
<span id="email_error"></span></td>
</tr>
<tr>
<td><label>Email List:</label></td>
<td>
<div id="email_list_toggle" style="width: 50px;"></div>
<span id="email_list_error"></span>
</td>
</tr>
<tr >
<td ><label>Phone:</label></td>
<td><input id="phone" type="text" name="phone" value="<?php echo $row_Recordset1['phone']; ?>" size="32">

40
css/contacts.css

@ -4,4 +4,42 @@
#first_name_error, #last_name_error
{
color: red;
}
}
/* toggle for mailman or other email list */
.toggle {
height: 50px;
}
.toggle.off .noUi-handle {
border-color: red;
}
.toggle.on .noUi-handle {
border-color: green;
}
/* get rid of the pesky handle stripping with specificity */
#email_list_toggle > div > div > div.hello:before, #email_list_toggle > div > div > div.hello:after,
{
content: none;
}
.toggle.noUi-horizontal .noUi-handle {
width: 34px;
height: 20px;
top: -2px;
}
.toggle.noUi-horizontal.noUi-extended {
padding-right: 32px;
}
.toggle.noUi-horizontal.noUi-extended .noUi-handle {
left: -1px;
}
.toggle.noUi-horizontal.noUi-extended .noUi-origin {
right: -32px;
}

1
css/jquery.nouislider.css

@ -126,6 +126,7 @@
inset 0 1px 7px #DDD,
0 3px 6px -3px #BBB;
}
/* Handle stripes;
*/

60
js/contact.js

@ -12,11 +12,12 @@ $(function(){
var state_abbreviation = $("#state_abbreviation");
// sensible defaults
first_name.mask('#',{placeholder: "first", translation: {"#": {pattern: /[A-Za-z0-9@.]/, recursive: true} } });
last_name.mask('#',{placeholder: "last", translation: {"#": {pattern: /[A-Za-z0-9@.]/, recursive: true} } });
first_name.mask('#',{placeholder: "first", translation: {"#": {pattern: /[A-Za-z0-9.\-]/, recursive: true} } });
last_name.mask('#',{placeholder: "last", translation: {"#": {pattern: /[A-Za-z0-9.\-]/, recursive: true} } });
birth_date.mask("0000-00-00", {placeholder: "yyyy-mm-dd" });
phone.mask('(000) 000-0000', {placeholder: "(000) 000-0000"});
email.mask('#',{placeholder: "_@_", translation: {"#": {pattern: /[A-Za-z0-9@.]/, recursive: true} } });
email.mask('#',{placeholder: "_@_", translation: {"#": {pattern: /[A-Za-z0-9@._\-+~!\$&''\(\)\*,;=:\%}{]/,
recursive: true} } });
zip.mask('00000-0000', {placeholder: "00000-0000"});
state_abbreviation.mask('AA',{placeholder: "WV", translation: {"A": {pattern: /[A-Za-z]/, recursive: false} } });
@ -44,8 +45,13 @@ $(function(){
email_error.hide();
phone_error.hide();
phone_validator(phone.val(),e);
var r = phone_validator(phone.val(),e);
if (r) {
if($("#email_list_toggle").val() == 1) {
console.log("here i am s" + r);
}
}
} else if ( (email.val() !== "" && phone.val() === "") ) {
email_error.hide();
@ -80,13 +86,17 @@ $(function(){
$('#waiver').slideUp();
$(this).attr("value","Show Waiver");
c--;
} });
}
});
function phone_validator(val, e) {
var re = /^\(\d{3}\)\s?\d{3}-\d{4}$/;
if ( !re.test(val) ) {
error_handler(false, phone_error, false,"*Enter a correct phone number",e);
} else {
return true;
}
}
@ -121,5 +131,43 @@ $(function(){
return trans_error;
} // end error_handling function
// email_list_toggle
function toggle( value ){
$(this).toggleClass('off', value === "0");
$(this).toggleClass('on', value === "1");
}
$("#email_list_toggle").noUiSlider({
orientation: "horizontal",
start: 1,
range: {
'min': [0, 1],
'max': 1
},
format: wNumb({
decimals: 0
})
})
$("#email_list_toggle").addClass('toggle');
$("#email_list_toggle").addClass('noUi-extended');
$("#email_list_toggle > div > div > div").addClass("hello");
$('.noUi-handle').hover(function(){
$(this).attr('data-content','none');
});
$("#email_list_toggle").Link('lower').to(toggle);
$("#email_list_toggle").Link('lower').to('-inline-<div id="off_or_on"></div>', function(value) {
if (value == 0) {
$(this).html("no");
} else if (value == 1) {
$(this).html("yes");
}
});
// end email_list_toggle
});
Loading…
Cancel
Save