Skip to content

Instantly share code, notes, and snippets.

@lafikl lafikl/app.js
Created Jun 9, 2014

Embed
What would you like to do?
$(document).ready( function() {
var acl = $('.active').offset();
var aw = $('.active').width();
var ll = acl.left + parseInt( aw / 2 );
var tt = acl.top + 39;
$('#active').css({
left : ll + 'px',
top : tt + 'px'
});
$('.link.ac a').on('click', function() {
var acl = $(this).offset();
var aw = $(this).width();
var ll = acl.left + parseInt( aw / 2 );
var tt = acl.top + 39;
$('#active').animate({
left : ll + 'px',
top : tt + 'px'
});
});
$('.about').on('click', function() {
//$('.cm-content').find('.tt-row').removeClass('hidden');
$('.cm-content').find('.tt-row').fadeIn('slow');
$('.get-status-div').removeClass('animated slideInDown');
$('.get-status-div').fadeOut('fast');
});
$('.get-status').on('click', function() {
$('.cm-content').find('.tt-row').fadeOut('fast');
//$('.cm-content').find('.tt-row').addClass('hidden');
$('.get-status-div').removeClass('hidden');
$('.get-status-div').fadeIn('animated slideInDown');
});
$('body').on('click', '.hideThat', function(e) {
e.preventDefault();
var el = $(this);
el.closest(el.data('target')).slideUp();
});
$('.hidden-tabs dd a').on('click', function(e) {
e.preventDefault();
var el = $(this);
// $('.hidden-tabs').next().find('.tt-tabs__body');
var tab_body = $('.hidden-tabs').find('.tt-tabs__body');
tab_body.slideDown();
});
});
// // navigate tabs with keyboard
$(document).keydown( function(event) {
var keycode = event.keyCode ? event.keyCode : event.which;
// right key
if ( keycode == 39 ) {
prev();
}
// left key
if ( keycode == 37 ) {
next();
}
});
// caching selectors..
var $stepsContainer = $("#tt-tabs-container-steps");
var $stepsTabContainer = $(".js-steps-tab-container");
var $tabsSteps = $(".js-tabs-steps");
var $headTabs = $tabsSteps.find('.tt-tabs__header');
function next() {
// tab is not active, do nothing...
if ( !$stepsTabContainer.hasClass('tt-active') ) return;
var $active = $($headTabs.find('.tt-active'));
var nextEl = $active.next();
if ( !nextEl.length ) return;
var activeTarget = $active.attr('data-tabs-target');
var nextTarget = $(nextEl).attr('data-tabs-target');
$active.removeClass('tt-active');
$(activeTarget).removeClass('tt-active');
$(nextEl).addClass('tt-active');
$(nextTarget).addClass('tt-active');
}
function prev() {
// tab is not active, do nothing...
if ( !$stepsTabContainer.hasClass('tt-active') ) return;
var $active = $($headTabs.find('.tt-active'));
var nextEl = $active.prev();
if ( !nextEl.length ) return;
var activeTarget = $active.attr('data-tabs-target');
var nextTarget = $(nextEl).attr('data-tabs-target');
$active.removeClass('tt-active');
$(activeTarget).removeClass('tt-active');
$(nextEl).addClass('tt-active');
$(nextTarget).addClass('tt-active');
}
$(".js-step-prev").click(function() {
prev();
});
$(".js-step-next").click(function() {
next();
});
/* dialogs */
$(".get-dialog").click(function(e){
e.preventDefault();
$('.cm-content').find('.tt-row').fadeOut('fast');
$.ajax({
url: $(this).data('url'),
context: document.body
}).done(function(data) {
var content1 = {
statesdemo: {
html: data,
buttons : { 'إغلاق' : true },
title: 'بلاغ',
submit:function(ee,v,m,f){
$.prompt.close();
$('.cm-content').find('.tt-row').fadeIn('fast');
$('.get-status-div').fadeOut('fast');
}
}
};
$.prompt(content1);
});
})
$(".get-dialog-confirm").click(function(e){
e.preventDefault();
var datab;
$.ajax({
url: $(this).data('urlb'),
context: document.body
}).done(function(data) {
datab = data;
});
$.ajax({
url: $(this).data('url'),
context: document.body
}).done(function(data) {
var statesdemo = {
state0: {
html:' وافق أولاً على الشروط!...',
buttons: { 'لا أوافق': false, أوافق: true },
focus: 1,
submit:function(e,v,m,f){
if(v){
e.preventDefault();
$.prompt.goToState('state1');
return false;
}else{
e.preventDefault();
$.prompt.goToState('state2');
return false;
}
}
},
state1: {
html:data,
buttons: { إغلاق: 0 },
focus: 1,
submit:function(e,v,m,f){
e.preventDefault();
$.prompt.close();
$('.cm-content').find('.tt-row').fadeIn('fast');
$('.get-status-div').fadeOut('fast');
}
},
state2: {
html: datab
,
buttons: { إغلاق: 0 },
focus: 1,
submit:function(e,v,m,f){
e.preventDefault();
$.prompt.close();
$('.cm-content').find('.tt-row').fadeIn('fast');
$('.get-status-div').fadeOut('fast');
}
}
};
$.prompt(statesdemo);
});
})
/*
$("#dialog2").click(function(e){
e.preventDefault();
var content1 = {
statesdemo: {
html: $(this).find('.dialog-content').html(),
focus: 1,
submit:function(e,v,m,f){
$.prompt.close();
}
}
};
$.prompt(content1);
})
*/
$(".js-load-more").click(function(e) {
e.preventDefault();
var oldContent = $(this).parents('.tt-col-7').html();
$(this).parents('.tt-col-7').load('about .content .field-items .field-item');
$(".js-load-less").click(function(e) {
e.preventDefault();
$(this).parents('.tt-col-7').html(oldContent);
});
});
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
if ( getParameterByName('field_ticket_number_value') ) {
$(".get-status").trigger('click');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.