Skip to content

Instantly share code, notes, and snippets.

@Sasoon
Created November 29, 2016 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sasoon/a4d75b5b2e087511b526cc8667bfadce to your computer and use it in GitHub Desktop.
Save Sasoon/a4d75b5b2e087511b526cc8667bfadce to your computer and use it in GitHub Desktop.
Drupal Lightbox module
/**
* Subscribe Lightbox
*/
Drupal.behaviors.dgLightbox = {
attach: function (context, settings) {
$('body', context).once('dgLightbox', function () {
var webform = $('.webform-client-form-271');
if (webform.length) {
(webform.children('div')).prepend($("<p class='close-lightbox'>Cancel</p>"));
$('body').addClass('lightbox');
$('.close-lightbox').click(function(){
location.reload();
});
}
});
}
};
<?php
/**
* @file
* A module to render a webform lightbox
*/
function breezes_lightbox_help($path, $arg) {
switch ($path) {
case "admin/help#breezes_lightbox":
return '' . t("This is the help text for the breezes lightbox") . '';
break;
}
}
function breezes_lightbox_page_build(&$page) {
$block = module_invoke('webform', 'block_view', 'client-block-271');
if(!isset($_COOKIE['lightbox'])){
echo('no cookie - setting');
setcookie('lightbox', 1, 0);
print render($block['content']);
} else {
echo('we have a cookie!');
}
}
// Subscribe lightbox styles
.webform-client-form-271 {
position: absolute;
width: 500px;
height: 500px;
z-index: 10001;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
> div {
background: #cccccc;
padding: 2em;
}
.close-lightbox {
@include fontello-replace-with-icon($icon-cancel);
position: absolute;
top: 0;
right: 0;
cursor: pointer;
z-index: 10001;
}
}
body.lightbox:before {
content: '';
position: absolute;
height: 100%;
width: 100%;
background:rgba(0,0,0,0.5);
top: 0;
z-index: 10000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment