// ------------------------------------------------------------------//
// 420A3© Setup Configuation
// ------------------------------------------------------------------//
// REQUIRED: url: your web page's unique url
// REQUIRED: theme: options - light or dark
// REQUIRED: id: unique 420A3© connector id
// ------------------------------------------------------------------//
var a3setup = { "url": "/contact-us", "theme": "dark", "id": "420a3com-1" };
function getTicks() {
var d = new Date();
return d.getTime();
}
// FUNCTIONS
function getToken() {
return $('#ContentPlaceHolder1_hf_Token').val();
}
function getCompanyID() {
return $('#ContentPlaceHolder1_hf_CompanyID').val();
}
function setCompanyID(inval) {
return $('#ContentPlaceHolder1_hf_CompanyID').val(inval);
}
var isvalid = false;
var ischeckboxvalid = false;
var iscompanynamevalid = false;
var iscontactphonevalid = false;
var iscontactvalid = false;
var g_iscapchavalid = false;
var isselected = false;
var inloop = false;
function syncKeywords(ctl) {
var chk = $(ctl).is(':checked');
var target = $(ctl).attr('data-target');
// since we're dealing with groups of checkboxes
// we needed only 1 entrance, this might be solved
// by apply the .prop..but let just see how this goes..
// only enter loop 1x
if (inloop == false) {
}
else {
return false;
}
$('body').find('input[data-target="' + $(ctl).attr('data-target') + '"]').each(function () {
if (inloop == false) {
inloop = true;
}
if (chk == true) {
$(this)[0].click();
}
else {
$(this).removeAttr('checked');
}
});
inloop = false;
var foundchecked = false;
//type-display
$('input.type-display').each(function () {
var tchk = $(this).is(':checked');
if (tchk == true) {
foundchecked = true;
}
});
//alert('foundchecked ' + foundchecked);
if (foundchecked == true) {
ischeckboxvalid = true;
//isvalid = true;
$('li.current').removeClass('error');
$('#alertDayMessage').text('');
}
else {
ischeckboxvalid = false;
//isvalid = false;
$('li.current').addClass('error');
$('#alertDayMessage').text('You must select at least one(1) keyword');
}
}
// .ready
jQuery(document).ready(function () {
// make sure bootstrap tooltips work.
$(document.body).tooltip({ selector: "[title]", trigger: 'hover', container: 'body', html: true });
$("#wizard").steps({
headerTag: "h3",
bodyTag: "div.panel-body",
transitionEffect: "slideLeft",
autoFocus: true,
enableAllSteps: false,
enableFinishButton: true,
enablePagination: true,
onFinishing: function (event, currentIndex) {
if (currentIndex == 1) {
if ($('body').find('small.help-block[data-fv-for="g-recaptcha-response"][data-fv-result="VALID"]').length > 0) {
g_iscapchavalid = true;
}
if (g_iscapchavalid == false) {
$('#420A3').formValidation('validateField', 'g-recaptcha-response');
return false;
}
}
return true;
},
onFinished: function (event, currentIndex) {
if (g_iscapchavalid == true && iscompanynamevalid == true) {
//id="form-basic"
$('#form-basic').fadeOut(function () {
$('#form-done').fadeIn();
submitContactRequest();
});
//alert('gather data...save, notify user someone will contact them next available business day asap');
return true;
}
else {
return false;
}
},
onStepChanging: function (event, currentIndex, newIndex) {
var stepchangevalid = false;
// Allways allow step back to the previous step even if the current step is not valid!
if (currentIndex > newIndex) {
stepchangevalid = true;
if (currentIndex >= 1) {
isselected = false;
}
return stepchangevalid;
}
// console.log('onStepChanging isvalid:=' + isvalid + ' currentIndex:=' + currentIndex);
if (currentIndex == 0) {
var text = $('input.company-name').val();
// console.log('input.company-name:=' + text + ' currentIndex:=' + currentIndex);
iscompanynamevalid = (text.trim().length >= 3 && text.trim().length <= 254);
if (iscompanynamevalid == false) {
// console.log('iscompanynamevalid = false call validator');
$('#420A3').formValidation('validateField', 'companyname');
$('#420A3').formValidation('validateField', 'content');
return false;
}
var myText = $('#summernote-comments').summernote('isEmpty') ? '' : $('#summernote-comments').summernote('code');
if (myText == "
") {
$('#420A3').formValidation('validateField', 'content');
return false;
}
if ($('small[data-fv-for="content"][data-fv-result="INVALID"]').css('display') == 'block') {
$('#420A3').formValidation('validateField', 'content');
return false;
}
// console.log('iscompanynamevalid:=' + iscompanynamevalid + ' currentIndex:=' + currentIndex);
if (iscompanynamevalid == true) {
}
return true;
}
//////////if (currentIndex == 1) {
////////// //iscontactphonevalid
////////// var contact = $('input.admin-contact').val();
////////// // console.log('input.admin-contact:=' + contact + ' currentIndex:=' + currentIndex);
////////// iscontactvalid = (contact.trim().length > 0);
////////// //
////////// var contactph = $('input.admin-phone').val();
////////// // console.log('input.admin-phone:=' + contactph + ' currentIndex:=' + currentIndex);
////////// iscontactphonevalid = (contactph.trim().length > 0);
////////// if (iscontactvalid == false) {
////////// // console.log('contact info failed');
////////// $('#420A3').formValidation('validateField', 'admincontact');
////////// valididateStepsPhone();
////////// //$('#420A3').formValidation('validateField', 'adminphone');
////////// //if (iscontactphonevalid == false) {
////////// //$('#420A3').formValidation('validateField', 'adminphone');
////////// // return false;
////////// //}
////////// return false;
////////// }
////////// valididateStepsPhone();
////////// if (iscontactphonevalid == false) {
////////// //$('#420A3').formValidation('validateField', 'adminphone');
////////// return false;
////////// }
////////// if (iscontactvalid == true && iscontactphonevalid == true) {
////////// setTimeout(function () { $('a[href="#next"]')[0].focus(); }, 100);
////////// return true;
////////// }
////////// //
////////// //var text = $('input.company-name').val();
////////// //// console.log('input.company-name:=' + text + ' currentIndex:=' + currentIndex);
////////// //iscompanynamevalid = (text.trim().length >= 3 && text.trim().length <= 254);
//////////}
//////////if (currentIndex == 2) {
////////// if (ischeckboxvalid == false) {
////////// $('#420A3').formValidation('validateField', 'companykeyword');
////////// return false;
////////// }
//////////}
return true;
}
});
function valididateStepsPhone() {
// t-X (currentindex)
//
// current step: 2. Contact Information
// alert($('input.admin-phone').length);
var contactph = $('input.admin-phone').val();
// console.log('input.admin-phone:=' + contactph + ' currentIndex:=' + currentIndex);
iscontactphonevalid = (contactph.trim().length > 0);
//
//
//
//We need someone to talk to - Thanks!
// Think I need to just hard code this validator interaction myself.
//
//
//
//We need a number to call - Thanks!
//
We need a number to call - Thanks!
if (iscontactphonevalid == true) {
//has - feedback has - success
$('li.current').removeClass('error');
$('small.help-block[data-fv-for="adminphone"]').parents().closest('div.form-group').addClass('has-feedback has-success');
$('small.help-block[data-fv-for="adminphone"]').data('fv-result', "VALID").hide();
} else {
if ($('li.current').hasClass('error') == false) {
$('li.current').addClass('error');
}
$('small.help-block[data-fv-for="adminphone"]').parents().closest('div.form-group').addClass('has-feedback has-error');
$('small.help-block[data-fv-for="adminphone"]').data('fv-result', "INVALID").show();
}
return iscontactphonevalid;
}
$('#420A3').formValidation({
framework: 'bootstrap',
excluded: [':disabled'],
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
addOns: {
reCaptcha2: {
element: 'pwdrecaptcha',
language: 'en',
theme: 'dark',
siteKey: '6LcBMiETAAAAAHetXeEab5eTC1una9oob399C_Rm',
timeout: 120,
message: 'The captcha is not valid'
}
},
fields: {
content: {
validators: {
callback: {
message: 'The content is required and cannot be empty',
callback: function (value, validator, $field) {
var code = $('[name="content"]').summernote('code');
//alert('FFF');
// Revalidate the content when its value is changed by Summernote
var textonly = htmlDecode($('div.note-editable').html().replace(/ /g, ''));
textonly = $('
').append(textonly).text().trim();
if (textonly.length == 0) {
isvalid = false;
}
else {
isvalid = true;
}
// fixUp(code);
//
is code generated by Summernote for empty content
//isvalid = (code !== '' && code !== '
' && code !== '
');
return isvalid;
}
}
}
},
companyname: {
validators: {
callback: {
message: 'email must be at least 3 characters, max characters 254
(required)',
callback: function (value, validator, $field) {
// Get the plain text without HTML
var text = value;
iscompanynamevalid = (text.trim().length >= 3 && text.trim().length <= 254);
return iscompanynamevalid;
}
},
emailAddress: {
message: 'The value is not a valid email address.'
}
}
},
companykeyword: {
err: '#alertDayIcon',
validators: {
notEmpty: {
message: 'Please choose at least one (1) checkbox'
}
}
},
admincontact: {
validators: {
callback: {
message: '
We need someone to talk to - Thanks!',
callback: function (value, validator, $field) {
// Get the plain text without HTML
var text = value;
iscontactvalid = (text.trim().length >= 1 && text.trim().length <= 254);
if (iscontactvalid == false) {
setTimeout(function () { $('.admin-contact').focus(); }, 300);
}
return iscontactvalid;
}
}
}
}
//,
//adminphone: {
// validators: {
// callback: {
// message: '
We need a number to call - Thanks!',
// callback: function (value, validator, $field) {
// // Get the plain text without HTML
// var text = value;
// iscontactphonevalid = (text.trim().length >= 1);
// if (iscontactphonevalid == false) {
// setTimeout(function () { $('.admin-phone').focus(); }, 300);
// }
// return iscontactphonevalid;
// }
// }
// }
//}
}
}).on('err.form.fv', function (e, data) {
e.preventDefault();
// console.log('err.form.fv');
isvalid = false;
$('i.form-control-feedback').hide();
//try {
// //$('span[data-index="2"]').addClass('has-error');
// $('i.form-control-feedback').show();
//}
//catch (err) {
//}
}).on('success.field.fv', function (e, data) {
$('li.error').removeClass('error');
$('i.form-control-feedback').hide();
}).on('err.validator.fv', function (e, data) {
// $(e.target) --> The field element
// data.fv --> The FormValidation instance
// data.field --> The field name
// data.element --> The field element
// data.validator --> The current validator name
data.element
.data('fv.messages')
// Hide all the messages
.find('.help-block[data-fv-for="' + data.field + '"]').hide()
// Show only message associated with current validator
.filter('[data-fv-validator="' + data.validator + '"]').show()
}).on('success.form.fv', function (e, data) {
e.preventDefault();
// console.log('success.form.fv');
isvalid = true;
//
current step: 1. Start
$('li.error').removeClass('error');
$('i.form-control-feedback').hide();
//// If the field is empty
//// supresses success fields..too distracting on this form.
//var $parent = data.element.parents('.form-group');
//try {
// $('i.form-control-feedback').hide();
//}
//catch (err) {
//}
//return false;
}).find('[name="content"]')
.summernote({
height: 100, // set editor height
disableResizeEditor: true,
disableDragAndDrop: true,
toolbar: false,
placeholder: 'Let us know what you think....',
fontsize: '20',
cleaner: {
notTime: 2400, // Time to display Notifications.
action: 'both', // both|button|paste 'button' only cleans via toolbar button, 'paste' only clean when pasting content, both does both options.
newline: '
', // Summernote's default is to use '
'
notStyle: 'position:absolute;top:0;left:0;right:0', // Position of Notification
icon: '
[Your Button]',
keepHtml: false, // Remove all Html formats
keepClasses: false, // Remove Classes
badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], // Remove full tags with contents
badAttributes: ['style', 'start'] // Remove attributes from remaining tags
},
callbacks: {
onKeyup: function (e) {
//if (dosec === 0) {
// dosec == 1
// if ($('.a3-email').is(':visible') === false) {
// youNeedToJoin('info', 'fa fa-exclamation-circle', 'Warning', 'Only Registered Users May Leave Ratings, Comments or Replies', 'Find Out More...');
// }
//}
var myText = $('#summernote-comments').summernote('isEmpty') ? '' : $('#summernote-comments').summernote('code');
if (myText.trim().length === 0) {
$('div.note-placeholder').css('display', 'block');
//dosec = 0;
}
else {
$('div.note-placeholder').css('display', 'none');
//dosec = 1;
}
}
}
})
.on('summernote.change', function (customEvent, contents, $editable) {
// Revalidate the content when its value is changed by Summernote
$('#420A3').formValidation('revalidateField', 'content');
})
.end();
setTimeout(function () {
$('.company-name').focus();
}, 100);
//$("#adminphone").inputmask({ "mask": "(999) 999-9999" });
//$('#adminphone').on("paste change keyup blur input", function () {
// var contactph = $(this).val();
// iscontactphonevalid = (contactph.trim().length > 0);
// valididateStepsPhone();
//});
$('#summernote-comments').html('');
$('#summernote-comments').summernote({
height: 100, // set editor height
disableResizeEditor: true,
disableDragAndDrop: true,
toolbar: false,
placeholder: 'Let us know what you think....',
fontsize: '20',
cleaner: {
notTime: 2400, // Time to display Notifications.
action: 'both', // both|button|paste 'button' only cleans via toolbar button, 'paste' only clean when pasting content, both does both options.
newline: '
', // Summernote's default is to use '
'
notStyle: 'position:absolute;top:0;left:0;right:0', // Position of Notification
icon: '
[Your Button]',
keepHtml: false, // Remove all Html formats
keepClasses: false, // Remove Classes
badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], // Remove full tags with contents
badAttributes: ['style', 'start'] // Remove attributes from remaining tags
},
callbacks: {
onKeyup: function (e) {
//if (dosec === 0) {
// dosec == 1
// if ($('.a3-email').is(':visible') === false) {
// youNeedToJoin('info', 'fa fa-exclamation-circle', 'Warning', 'Only Registered Users May Leave Ratings, Comments or Replies', 'Find Out More...');
// }
//}
var myText = $('#summernote-comments').summernote('isEmpty') ? '' : $('#summernote-comments').summernote('code');
if (myText.trim().length === 0) {
$('div.note-placeholder').css('display', 'block');
//dosec = 0;
}
else {
$('div.note-placeholder').css('display', 'none');
//dosec = 1;
}
}
}
});
setTimeout(function () {
var myText = $('#summernote-comments').summernote('isEmpty') ? '' : $('#summernote-comments').summernote('code');
if (myText.trim.length === 0) {
$('div.note-placeholder').css('display', 'block');
}
else {
$('div.note-placeholder').css('display', 'none');
}
}, 100);
// used for bootstrap
var $b = $('body');
$b.find('.a3-theme').removeClass('-light').removeClass('-dark');
$b.find('.a3-theme').addClass('-' + a3setup.theme);
// ------------------------------------------------------------------//
// DON'T EDIT BELOW THIS LINE //
// ------------------------------------------------------------------//
$(".a3-wait-display").show(function () { (function () { var n = document; s = n.createElement("script"); s.type = "text/javascript"; s.async = !0; s.src = "/a3comments/embed.v1.min.js"; s.setAttribute("data-timestamp", +new Date); (n.getElementsByTagName("head")[0] || n.getElementsByTagName("body")[0]).appendChild(s) })() });
//////////var donce = 0, $w = $(window), a3c = $("#a3_comments");
//////////$w.scroll(function () {
////////// var toe = $(a3c).offset().top;
////////// var boe = $(a3c).offset().top + $(a3c).outerHeight();
////////// var bos = $w.scrollTop() + window.innerHeight;
////////// var tos = $w.scrollTop();
////////// if ((bos > toe) && (tos < boe)) {
////////// // The element is visible, do something
////////// if (donce === 0) {
////////// donce = 1;
////////// $(".a3-wait-display").show(function () {
////////// (function () { var n = document; s = n.createElement("script"); s.type = "text/javascript"; s.async = !0; s.src = "/a3comments/embed.v1.min.js"; s.setAttribute("data-timestamp", +new Date); (n.getElementsByTagName("head")[0] || n.getElementsByTagName("body")[0]).appendChild(s) })()
////////// });
////////// }
////////// }
//////////});
});
// end.ready
function stripHtmlEntities(text) {
return $('
' + text + '
').text();
}
function submitContactRequest() {
var xmlin = "
";
xmlin += "" + $('input.company-name').val() + "";
xmlin += "" + getComment() + "";
xmlin += "";
try {
$.ajax({
type: 'POST',
url: '/MailWebService.aspx/SubmitContactRequest',
data: '{"token":"' + getToken() + '","xmlin":' + JSON.stringify(xmlin) + '}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: true,
cache: false,
success: function (response) {
},
failure: function (response) {
showMessagePrompt('danger', 'Error', "An Unexpected Saving Failure Occurred.
Please check your request and try again.", 'passwordreset');
},
error: function (response) {
showMessagePrompt('danger', 'Error', "An Unexpected Saving Error Occurred.
Please check your request and try again.", 'passwordreset');
}
});
}
catch (err) {
showMessagePrompt('danger', 'Error', "An Unexpected Saving Failure Occurred.
" + err.message, 'company-rating');
}
}
function initCompanyListGrid() {
//alert('check after async');
//alert(getCurrentStateForLookup());
try {
$.ajax({
type: 'POST',
url: '/SimpleWebService.aspx/GetCompaniesQuickListJSON',
data: '{"token":"' + getToken() + '","key":' + JSON.stringify($('#companyname').val()) + '}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: true,
cache: false,
success: function (response) {
if (response.d != "") {
try {
var myjson = $.parseJSON(response.d);
//alert(myjson);
$('#Company-List-Grid').html('');
$('#Company-List-Grid').footable({
"editing": {
showToggle: true,
enabled: true,
position: "right",
alwaysShow: true,
allowAdd: false,
editRow: function (row) {
company_grid_currow = row;
var values = row.val();
isselected = true;
setCompanyID(values.company_id);
setTimeout(function () {
//isvalid = true;
$('a[href="#next"]')[0].click();
//alert('and then?');
}, 10);
//alert('company id: ' + values.company_id);
//showCompanyListEditor('light',
// values.company_id,
// values.company_name,
// values.location_id,
// values.address_1,
// values.address_2,
// values.phone,
// values.email,
// values.override_url,
// values.created_date,
// 'company-ratings-admin-edit');
}
},
"paging": {
"enabled": true,
"size": 5
},
"filtering": {
"enabled": true
},
"sorting": {
"enabled": true
},
"columns": [
{ "name": "company_id", "title": "company id", "classes": "admin-company-id", "visible": false, "filterable": false },
{ "name": "company_name", "title": "name", "style": { "maxWidth": 400, "border-color": "#ddd", "border-right": "none", "border-left": "none", "overflow": "hidden", "textOverflow": "ellipsis", "wordBreak": "keep-all", "whiteSpace": "nowrap", "text-align": "left" } },
{ "name": "location_id", "title": "location id", "style": { "maxWidth": 60, "border-color": "#ddd", "border-right": "none", "border-left": "none", "overflow": "hidden", "textOverflow": "ellipsis", "wordBreak": "keep-all", "whiteSpace": "nowrap", "text-align": "center" }, "breakpoints": "sm, xs" },
{ "name": "address_1", "title": "address 1", "style": { "maxWidth": 200, "border-color": "#ddd", "border-right": "none", "border-left": "none", "overflow": "hidden", "textOverflow": "ellipsis", "wordBreak": "keep-all", "whiteSpace": "nowrap", "text-align": "left" }, "breakpoints": "sm, xs" },
{ "name": "address_2", "title": "address 2", "visible": false, "filterable": false },
{ "name": "city", "title": "city" },
{ "name": "state", "title": "state" },
{ "name": "phone", "title": "phone", "visible": false, "filterable": false },
{ "name": "email", "title": "email", "visible": false, "filterable": false },
{ "name": "override_url", "title": "url", "visible": false, "filterable": false },
{ "name": "created_date", "title": "date", "visible": false, "filterable": false }
],
"rows": myjson
});
$('#Company-List-Grid').on('before.ft.sorting', function (e) {
$('table.footable').find('th').each(function () {
$(this).find('span.fooicon').each(function () {
$(this).removeClass('fa fa-sort-asc');
$(this).removeClass('fa fa-sort-desc');
});
});
});
$('#Company-List-Grid').on('after.ft.sorting', function (e) {
$('table.footable').addClass("breakpoint breakpoint-lg");
$('table.footable').find('th').each(function () {
$(this).find('span.fooicon').each(function () {
if ($(this).hasClass('fooicon-sort-asc') == true) {
$(this).addClass('fa fa-sort-asc');
}
if ($(this).hasClass('fooicon-sort-desc') == true) {
$(this).addClass('fa fa-sort-desc');
}
});
});
setFootableButtons(0);
});
$('#Company-List-Grid').on('view.ft.editing', function (e) {
});
$('#Company-List-Grid').on('show.ft.editing', function (e) {
});
$('#Company-List-Grid').on('before.ft.paging', function (e) {
setFootableButtons(100);
$('tr.footable-paging').find('ul').each(function () {
// note: theme needs to be variable driven...
$(this).find('li').removeClass('-active');
});
});
setFootableButtons(1000);
$('.wrapper-company-comments-grid').show(function () {
});
}
catch (err) {
debugger;
showMessagePrompt('danger', 'Error', 'Unexpected Error: + ' + err.message);
}
}
else {
debugger;
showMessagePrompt('danger', 'Error', "An Unexpected Service Failure Occurred. GetCompaniesListByStateJSON.
Please check your request and try again.", 'company-rating');
}
},
failure: function (response) {
showMessagePrompt('danger', 'Error', "An Unexpected Service Failure Occurred.
Please check your request and try again.", 'company-rating');
},
error: function (response) {
showMessagePrompt('danger', 'Error', "An Unexpected Service Failure Occurred.
Please check your request and try again.", 'company-rating');
}
});
}
catch (err) {
showMessagePrompt('danger', 'Error', "An Unexpected Saving Failure Occurred.
" + err.message, 'company-rating');
}
}
function setFootableButtons(delay) {
//
//alert($('#Company-List-Grid').css('display'));
setTimeout(function () {
$('td.footable-editing').find('div.btn-group').each(function (e) {
//$(this).addClass('comment-editing');
if ($(this).hasClass('_text-center') == false) {
$(this).addClass('_text-center');
}
$(this).removeAttr('role');
//$(this).find('button.footable-edit').css('display', 'inline-block');
$(this).find('button.footable-edit').addClass('-success -xs').removeClass('btn-default').attr('title', 'select').fadeIn();
// //$(this).find('button.footable-delete').addClass('-dark -xs').removeClass('btn-default').attr('title', 'delete');
$(this).find('button.footable-edit').find('span.fooicon').attr('class', 'fa fa-plus');
// //$(this).find('button.footable-delete').find('span.fooicon').attr('class', 'fa fa-trash');
// //
if ($('th.footable-editing').text() == '') {
$('th.footable-editing').text('action');
$('th.footable-editing').css('text-align', 'center');
$('th.footable-editing').css('width', '100px');
}
});
setFootablePagers(delay);
if ($('#Company-List-Grid').css('display') !== 'block') {
// $('#Company-List-Grid').fadeIn();
}
//var tmps = [];
//var outs = [];
////$.each(simplemaps_usmap_mapdata.state_specific, function (key, value) {
//// if (value.color) {
//// tmps.push(key);
//// }
////});
//tmps.sort();
//var dds = '
';
//$('tr.footable-filtering > th > form.form-inline').find('.state-ddl').remove();
//$('tr.footable-filtering > th > form.form-inline').append(dds);
// make sure dropdowns work
//$('.dropdown-togglex').dropdown();
}, delay);
}
function setFootablePagers(delay) {
setTimeout(function () {
$('tr.footable-paging').find('ul').each(function () {
// note: theme needs to be variable driven...
$(this).addClass('-dark');
$(this).find('li').each(function () {
$(this).addClass('pagination-item');
if ($(this).hasClass('active') == true) {
$(this).addClass('-active');
}
});
});
$('tr.footable-paging').addClass('animated fadeIn').css('visibility', 'visible');
}, delay);
}
function getCurrentStateForLookup() {
return $('#ContentPlaceHolder1_hf_CurrentStateView').val();
}
function setCurrentStateForLookup(inval) {
return $('#ContentPlaceHolder1_hf_CurrentStateView').val(inval);
}
function CompanyExists() {
// note: forcing synch lookup.
var gExists = false;
try {
$.ajax({
type: 'POST',
url: '/SimpleWebService.aspx/CompanyExists',
data: '{"token":"' + getToken() + '","company_name":' + JSON.stringify($('#companyname').val()) + '}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
success: function (response) {
if (response.d != "") {
gExists = true;
}
},
failure: function (response) {
// hideBackground();
showMessagePrompt('danger', 'Error', 'Unexpected Failure Company Name Lookup');
},
error: function (response) {
// hideBackground();
showMessagePrompt('danger', 'Error', 'Unexpected Error Company Name Lookup');
}
});
}
catch (err) {
// hideBackground();
showMessagePrompt('danger', 'Error', 'Unexpected Error: ' + err.message + ' Company Name Lookup');
}
return gExists;
}
//
function showMessagePrompt(classname, title, msg, target, image_url) {
var message_icon = '';
switch (classname) {
case "success": {
message_icon = "pe pe-check";
getModalContentSave(classname, message_icon, title, msg, target);
break;
}
case "error": {
message_icon = "pe pe-check";
getModalContentError(classname, message_icon, title, msg, target);
break;
}
case "special": {
message_icon = "fa fa-exclamation-circle";
getModalContentError(classname, message_icon, title, msg);
break;
}
case "warning": {
message_icon = "fa fa-exclamation-circle";
getModalContentError(classname, message_icon, title, msg);
break;
}
}
}
function getModalContentError(classname, icon, icon_message, body) {
var output = '';
var template_path = "/assets/templates/volta/a3/modal/template_default.html";
$.ajax({
url: template_path,
dataType: "text",
success: function (data) {
display = data;
// do replacements...
display = display.replace('$$modal_icon$$', icon);
display = display.replace('$$modal_icon_message$$', icon_message);
display = display.replace('$$modal_body$$', body);
//var dw = 'smallBootboxWidth';
var box = bootbox.dialog({
closeButton: false,
className: '-' + classname,
message: display,
buttons: {
ok: {
label: "Done",
className: "-light",
callback: function () {
bootbox.hideAll();
}
}
}
})
.on('shown.bs.modal', function (e) {
$('button[data-bb-handler="ok"]').focus();
})
.on('hide.bs.modal', function (e) {
})
.find("div.modal-dialog");
//.addClass(dw);
}
});
return output;
}
function getModalContentSave(classname, icon, icon_message, body, target) {
var output = '';
var template_path = "/assets/templates/volta/a3/modal/template_default.html";
$.ajax({
url: template_path,
dataType: "text",
success: function (data) {
display = data;
// do replacements...
display = display.replace('$$modal_icon$$', icon);
display = display.replace('$$modal_icon_message$$', icon_message);
display = display.replace('$$modal_body$$', body);
//var dw = 'smallBootboxWidth';
var box = bootbox.dialog({
closeButton: false,
className: '-' + classname,
message: display,
buttons: {
cancel: {
label: "Keep Editing",
className: "-dark _margin-right-1x",
callback: function () {
box.modal('hide');
}
},
ok: {
label: "Done",
className: "-light",
callback: function () {
bootbox.hideAll();
if (target.trim().length > 0) {
window.location.assign("/account/user/profile");
}
}
}
}
})
.on('shown.bs.modal', function (e) {
$('button[data-bb-handler="ok"]').focus();
})
.on('hide.bs.modal', function (e) {
})
.find("div.modal-dialog");
//.addClass(dw);
}
});
return output;
}
function getModalContentSpecial(classname, icon, icon_message, body, target) {
var output = '';
var template_path = "/assets/templates/volta/a3/modal/_template_companyname_account_default.html";
$.ajax({
url: template_path,
dataType: "text",
success: function (data) {
display = data;
// do replacements...
display = display.replace('$$modal_icon$$', icon);
display = display.replace('$$modal_icon_message$$', icon_message);
display = display.replace('$$modal_body$$', body);
//var dw = 'smallBootboxWidth';
var box = bootbox.dialog({
closeButton: false,
className: '-' + classname,
message: display,
buttons: {
cancel: {
label: "Keep Editing",
className: "-dark _margin-right-1x",
callback: function () {
box.modal('hide');
}
},
ok: {
label: "Done",
className: "-light",
callback: function () {
bootbox.hideAll();
if (target.trim().length > 0) {
window.location.assign("/account/user/profile");
}
}
}
}
})
.on('shown.bs.modal', function (e) {
$('button[data-bb-handler="ok"]').focus();
})
.on('hide.bs.modal', function (e) {
})
.find("div.modal-dialog");
//.addClass(dw);
}
});
return output;
}
//$('input[id="companyname"][type="text"]').keypress(function (event) {
//
//("input[type='text']").bind("keydown", function (event) {
// if (event.keyCode === 10 || event.keyCode === 13) {
// event.preventDefault();
// alert('?');
// $('a[hfref="#next"]').click();
// }
//});
//alert($("input[type='text']").length);
$("input[type='text']").bind("keydown", function (event) {
var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
//alert('and then');
//alert($('body').find('has-error').length);
if (keycode === 10 || keycode === 13) {
// event.preventDefault();
//if (keycode == 13) {
//}
}
});
$(document).keypress(function (event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
if (keycode === 10 || keycode === 13) {
if ($('a[href="#next"]').css('display') == 'block') {
$('a[href="#next"]')[0].click();
//alert('enter pressed');
}
else {
if ($('a[href="#next"]').css('display') == 'block') {
$('a[href="#next"]')[0].click();
}
}
}
});
function getComment() {
var content = $("#summernote-comments").summernote('code');
content = $("
").html(content).text();
return content;
}
function htmlEncode(value) {
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('