Created
June 3, 2016 02:49
-
-
Save jchansen/eb052af3d129f891d682f70be9456f16 to your computer and use it in GitHub Desktop.
Changes made to `3-custom.js` to get PopupMaker to work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var App = App || { | |
// Initialization. | |
init: function () { | |
App.initGlobal(); | |
App.initBlog(); | |
}, | |
//------------------------------------------------------------------------------------------------------------------ | |
// Global | |
//------------------------------------------------------------------------------------------------------------------ | |
initGlobal: function () { | |
App.globalContactForm(); | |
}, | |
globalContactForm: function() { | |
$(document).on('click', '.cf-submitted', function(e) { | |
e.preventDefault(); | |
var form = $(this).closest('form'); | |
App.globalReloadContent(form, '.ajaxify'); | |
}); | |
}, | |
//------------------------------------------------------------------------------------------------------------------ | |
// Blog | |
//------------------------------------------------------------------------------------------------------------------ | |
blogCurentPage: 1, | |
blogPostPerPage: 4, | |
initBlog: function () { | |
App.blogPaging(); | |
}, | |
blogPaging: function() { | |
$(document).on("click", "#more_posts", function() { // When btn is pressed. | |
$(".section-blog-more-block").remove(); | |
//$("#more_posts").attr("disabled",true); // Disable the button, temp. | |
$.post(ajaxurl, { | |
action:"more_blog_items_ajax", | |
offset: (App.blogCurentPage * App.blogPostPerPage), | |
ppp: App.blogPostPerPage | |
}).success(function(posts){ | |
App.blogCurentPage++; | |
$(".ajaxify").append(posts); | |
//$("#more_posts").attr("disabled",false); | |
}); | |
}); | |
}, | |
/** | |
* Perform ajax request. | |
* | |
* @param {String} target | |
* @param {String} content | |
* @param {integer} scroll Scrooll to location? | |
* @param {String} renderPartial Custom renderPartial parameter for request. | |
* @param {String} callback Callback to execute after ajax is done. | |
* @param {bool} async Perform asynchronious request? | |
* @returns {boolean} | |
*/ | |
globalReloadContent: function(target, content, scroll, renderPartial, callback, async) { | |
var type = "POST"; | |
var url = ajaxurl; | |
var data = ""; | |
if (typeof target != 'string') { | |
data = target.serialize(); | |
type = "POST"; | |
} else { | |
url = ajaxurl; | |
} | |
$('.form-success', target).hide(); | |
$('.form-input', target).hide(); | |
$('.form-error', target).hide(); | |
jQuery.ajax( | |
{ | |
type: type, | |
url: url, | |
data: data, | |
async: (async != undefined ? async : true), | |
success: function (r) { | |
if (async !== false) { | |
if (r == 'success') { | |
$('.form-success', target).show(); | |
} else if (r == 'input') { | |
$('.form-input', target).show(); | |
} else { | |
$('.form-error', target).show(); | |
} | |
} | |
} | |
} | |
); | |
return false; | |
}, | |
}; | |
// Document ready trigger. | |
$(document).ready(function() { | |
// Run main application initialization. | |
App.init(); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment