=3))
{
$.ajax({
beforeSend: function(){
$('#search-box').css("background","#f9f9f9 url(LoaderIcon.gif) no-repeat 115px");
},
type: "GET",
data: 'query='+key,
url: "ajax-db-search.php",
dataType: 'html',
success:function(response) {
var len = response.length;
$("#suggesstion-box").empty();
$("#suggesstion-box").show();
$("#search-box").css("background","#FFF","color","#111111");
$("#suggesstion-box").html(response);
},
error: function(xhr, status, error){
var errorMessage = xhr.status + ': ' + xhr.statusText
alert('Error - ' + errorMessage);
}
});
}else{
$("#suggesstion-box").hide();
}
});
$('#closediv').on('click', function() {
deselect($('.messagepop'));
return false;
});
$('#inquiry_form').submit(function(e)
{
e.preventDefault();
//$form = $(this);
var form = $('#inquiry_form');
var formMessages = $('#formMessages');
var formData = $(form).serialize();
//show some response on the button
/*
$('button[type="submit"]', $form).each(function()
{
$btn = $(this);
$btn.prop('type','button' );
$btn.prop('orig_label',$btn.text());
$btn.text('Sending ...');
});
*/
var email = $('#email').val();
//alert email;
$.ajax({
beforeSend: function(){
$('#formMessages').css("background","#f9f9f9 url(https://tradehub.ca/LoaderIcon.gif) no-repeat 65px");
},
cache: false,
type: "post",
url: 'https://tradehub.ca/ajax-inquiry.php',
data: formData,
dataType: 'html',
success:function(response){
$(formMessages).removeClass('error');
$(formMessages).addClass('success');
$('#formMessages').css("background","#ebebeb");
$("#formMessages").text(response);
// Clear the form.
$('#name').val('');
$('#email').val('');
$('#message').val('');
}
,
error: function(xhr, status, error){
var errorMessage = xhr.status + ': ' + xhr.statusText
if (errorMessage !== '') {
$('#formMessages').css("background","#ebebeb");
$(formMessages).text(errorMessage);
} else {
$(formMessages).text('Oops! An error occured and your message could not be sent.');
}
}
});
});
//{fab button start
$.fn.reverse = [].reverse;
// Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
$(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function (e) {
// Open
var $this = $(this);
openFABMenu($this);
// Change background based in data attributes
$("#first-fab").css('background', function () {
return $(this).data('fabcolor')
});
$("#second-fab").css('background', function () {
return $(this).data('fabcolor')
});
$("#third-fab").css('background', function () {
return $(this).data('fabcolor')
});
$("#fourth-fab").css('background', function () {
return $(this).data('fabcolor')
});
});
$(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function (e) {
var $this = $(this);
closeFABMenu($this);
});
// Toggle-on-click behaviour.
$(document).on('click.fixedActionBtn', '.fixed-action-btn.click-to-toggle > a', function (e) {
var $this = $(this);
var $menu = $this.parent();
if ($menu.hasClass('active')) {
closeFABMenu($menu);
} else {
openFABMenu($menu);
}
});
//}fab button end
//for RFS
$("#rfsrequest").click(function(){
var appid = $("#rfsformid").val();
alert(appid);
$("#rfsrequest").hide();
$("#output").load("load.php?appid="+appid);
});
});
//Fab button start
$.fn.extend({
openFAB: function () {
openFABMenu($(this));
},
closeFAB: function () {
closeFABMenu($(this));
}
});
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= '//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js';
head.appendChild(script);
var openFABMenu = function (btn) {
$this = btn;
if ($this.hasClass('active') === false) {
// Get direction option
var horizontal = $this.hasClass('horizontal');
var offsetY, offsetX;
if (horizontal === true) {
offsetX = 40;
} else {
offsetY = 40;
}
$this.addClass('active');
$this.find('ul .btn-floating').velocity(
{ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' },
{ duration: 0 });
var time = 0;
$this.find('ul .btn-floating').reverse().each(function () {
$(this).velocity(
{ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0' },
{ duration: 80, delay: time });
time += 40;
});
}
};
var closeFABMenu = function (btn) {
$this = btn;
// Get direction option
var horizontal = $this.hasClass('horizontal');
var offsetY, offsetX;
if (horizontal === true) {
offsetX = 40;
} else {
offsetY = 40;
}
$this.removeClass('active');
var time = 0;
$this.find('ul .btn-floating').velocity("stop", true);
$this.find('ul .btn-floating').velocity(
{ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px' },
{ duration: 80 }
);
};
//fab button ends
function deselect(e) {
$('.messagepop').slideFadeToggle(function() {
e.removeClass('selected');
});
}
$.fn.slideFadeToggle = function(easing, callback) {
return this.animate({ opacity: 'toggle', height: 'toggle' }, 'fast', easing, callback);
};
function after_form_submitted(data)
{
if(data.result == 'success')
{
$('form#reused_form').hide();
$('#success_message').show();
$('#error_message').hide();
}
else
{
$('#error_message').append('
');
jQuery.each(data.errors,function(key,val)
{
$('#error_message ul').append('
'+key+':'+val+'');
});
$('#success_message').hide();
$('#error_message').show();
//reverse the response on the button
$('button[type="button"]', $form).each(function()
{
$btn = $(this);
label = $btn.prop('orig_label');
if(label)
{
$btn.prop('type','submit' );
$btn.text(label);
$btn.prop('orig_label','');
}
});
}//else
}
});