// @codekit-prepend "gui.js" // @koala-prepend "gui_ck_fw/gui.js" (function($) { MaterioUser = function(){ var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186'); function init() { //trace('MaterioUser init compile test 3'); if(_isAdhesion) initAdhesion(); }; function initAdhesion(){ // trace('initAdhesion'); $('.get-link a').bind('click', function(event) { // trace('get-link click'); // do not show the registration form if already logged-in if($('body').is('.logged-in')) return true; // else show the ajaxified registration form event.preventDefault(); var $this = $(this), href = $this.attr("href"), destination = href.match('/\?destination=([^,]+)'); destination = "/" + destination[1].replace('%23', '#'); destination = destination.replace('//', '/'); // trace('destination', destination); if($this.parents('.gratos').size()){ loadRegisterBlock(destination); }else{ loadLoginAndRegisterBlock(destination); } return false; }); }; function loadRegisterBlock (destination) { // trace("loadRegisterBlock :: dest = "+destination); $.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_user/registerblock', function(json){formLoaded(json, destination);}); } function loadLoginAndRegisterBlock(destination){ // trace('loadRegistrationBlock :: dest = '+destination); $.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_user/loginandregisterblock', function(json){formLoaded(json, destination);}); }; function formLoaded(json, destination){ //trace('formLoaded | json', json); var $modal = $('