Blueimp Gallery automatically starts on slideshow mode - gallery

I have a Blueimp gallery working, but when the page loads, it immediately goes to slideshow mode, instead of only displaying the thumbnails.
I'd like to display thumbnails first, so that if someone wants to start in the middle of the show they can easily do that.
How can I stop it from automatically going to slideshow mode?
Here is my html
18 <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-start-slideshow="false">
19 <!-- The container for the modal slides -->
20 <div class="slides"></div>
21 <!-- Controls for the borderless lightbox -->
22 <h3 class="title"></h3>
23 <p class="description"></p>
24 <a class="prev">‹</a>
25 <a class="next">›</a>
26 <a class="close">×</a>
27 <a class="play-pause"></a>
28 <ol class="indicator"></ol>
29 <!-- The modal dialog, which will be used to wrap the lightbox content -->
30 <div class="modal fade">
31 <div class="modal-dialog">
32 <div class="modal-content">
33 <div class="modal-header">
34 <button type="button" class="close" aria-hidden="true">×</button>
35 <h4 class="modal-title"></h4>
36 </div>
37 <div class="modal-body next"></div>
38 <div class="modal-footer">
39 <button type="button" class="btn btn-default pull-left prev">
40 <i class="glyphicon glyphicon-chevron-left"></i>
41 Previous
42 </button>
43 <button type="button" class="btn btn-primary next">
44 Next
45 <i class="glyphicon glyphicon-chevron-right"></i>
46 </button>
47 </div>
48 </div>
49 </div>
50 </div>
51 </div>
60 <div id="links">
61 #foreach ($finalQuery as $image)
62 <a href="{{ URL::route ('ppMiscGetProtectedFile', [ 'fileID' => $image['fileID'], 'size' => 'original' ] ) }}"
63 title="{{ $image['image_number'] }}"
64 data-description="Year: {{ $image['year'] }}"
65 data-gallery
66 >
67 <img src="{{ URL::route( 'ppMiscGetProtectedFile', [ 'fileID' => $image['fileID'], 'size' => 'thumbSmall'] ) }}" alt="{{ $image['image_number'] }}" />
68 </a>
69 #endforeach
70
71 </div>
And here is the Javascript
78 <script src="//blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"></script>
79 <script src="/js/bs_gallery/blueimp-gallery.min.js"></script>
80
86 <script>
87 blueimp.Gallery(
88 document.getElementById('links').getElementsByTagName('a'),
89 {
90 startSlideshow:false,
91 onslide: function (index, slide) {
92 var text = this.list[index].getAttribute('data-description'),
93 node = this.container.find('.description');
94 node.empty();
95 if (text) {
96 node[0].appendChild(document.createTextNode(text));
97 }
98 }
99 }
100 );
101
102
103 var options = {
104 startSlideshow: false,
105 };
106
107
108
109
110 </script>
It works, I get the gallery and I get the description field showing up (the Year: tag). It took a while to figure out how to get the description field to show. The blueimp documentation code doesn't work, but searching stack exchange got that fixed.
But now it always starts in slideshow mode. How do I get it to default to displaying the wall of thumbnails instead?

The reason it starts immediately is that you are creating the gallery instance as soon as the script loads. The way to load the thumbnail view first is to put the gallery initializer code inside a click handler set up on the thumbnail images.
Example:
<script>
document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = { index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
</script>
Also, the startSlideshow option is for controlling whether the slideshow begins when the gallery launches, which I think is different than what you are after.

Related

Pass JSON returned from Handlebars Helper as parameter into Handlebars Partial

I want to set up a partial to render a generic, customizable modal. {{> myModal }}.
I want to customize the modal from the calling view by sending an object.
I have tried the approach as recommended here: Passing an array of objects to a partial - handlebars.js
Here is my code from within the view which calls the partial:
{{# getJsonContext '
{
"id": "deleteModal",
"title": "Are you sure?",
"formId": "delete-form",
"body": "Press Yes to delete this record. Press No to cancel."
}
'}}
{{> myModal this }}
{{/ getJsonContext }}
Here is my helper:
getJsonContext: function(data, options) {
console.log(data); <-- The result is correct.
let jsonReturn = JSON.parse(data);
console.log(jsonReturn.title); <-- The result is correct.
return jsonReturn;
},
Here is my partial:
<div class="modal fade" id="{{ id }}">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header bg-light">
<h4 class="modal-title">{{ title }}</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Form -->
<form id="{{ formId }}" method="post">
<!-- Modal body -->
<div class="modal-body">
{{ body }}
</div>
<!-- Modal footer -->
<div class="modal-footer rounded-bottom bg-light">
</div>
</form>
</div>
</div>
</div>
I expect the partial view to render the customized modal.
The partial does not seem to render at all. When I "View Page Source" in the browser, in the place of all of the partial <html>, all it shows is [object Object].
If I place the {{> myModal this}} outside of the helper, "View Page Source" shows all the modal's <html>, but naturally, the id, title, formId and body are all blank (null).
After racking my brain with lots of trial and error and research, I finally found out the problem. I had to pass the JSON as a named parameter in the main view's call to the partial. The syntax should have been:
{{> jeff-modal <anyVariableName> = getJsonContext }}
I finished up and made my generic {{> jeff-modal }} accept a list of buttons, which can be customized.
The modal is now useful as a generic, customizable, simple modal which can be rendered as a partial from within any view to require the user to press one of x-number of buttons to make a choice.
Example
The main (calling) view has a list of journal entries (transactions) in date order. For each transaction, there is a clickable "delete" icon. The modal opens when the user presses the icon. When the modal is opened, we need to know which transaction to delete. We have its _id.
After setting up the table and columns in <html> and starting an {{# each }} iterator, the following is how the "delete" icon is set up for each transaction. Notice how the data-id's value is set to the transaction's _id property:
<!-- table stuff up here -->
{{# each transactions}}
<tr class="journal-entry-row">
<!-- some `<td>`'s -->
<span class="journalData">
<a href='#' class="open-deleteDialog"
data-id="{{this._id}}" data-backdrop="static"
data-toggle="modal" data-target="#deleteModal">
<span class="material-icons md-24 md-dark">delete</span>
</a>
</span>
<!-- more table stuff -->
{{/ each }}
The material-icons, above, can be found here: https://material.io/icons/
"delete" is a trash can.
Below is the javascript to set the onclick for all the trash cans. Notice how the transaction's _id makes the trip from the <html> into the javascript via the data-id (above). (I thought that was pretty clever, whoever thought of it.)
Also, since our custom modal was assigned an id of "delete-form", we can get it to set the modal's <form> action.
Finally, a little CSS is added to highlight the row being deleted.
$(document).on("click", ".open-deleteDialog", function () {
var myTransactionId = $(this).data('id');
// Set form action to call delete with _id parameter
$("#delete-form").attr("action", "/transaction/delete?_id=" + myTransactionId );
// Highlight the selected row.
$(this).closest(".journal-entry-row").addClass("table-warning");
});
Now, let's go back to the calling view after the end of the <table>. This is where the modal is called within the handlebars helper block (but only when the trash can is clicked):
<!-- The Delete modal -->
{{# getJsonContext '
{
"id": "deleteModal",
"title": "Are you sure?",
"formId": "delete-form",
"body": "Press \"Yes\" to delete this record. Press \"No\" to cancel.",
"buttons":
[
{ "type": "submit", "onclick": "", "class": "btn btn-primary", "text": "Yes" },
{ "type": "button", "onclick": "removeHighlightEffect()", "class": "btn btn-secondary", "dataDismiss": "modal", "text": "No" }
]
}'
}}
{{> jeff-modal options = getJsonContext }}
{{/ getJsonContext }}
Here's the helper:
getJsonContext: function(data, options) {
let jsonReturn = options.fn(JSON.parse(data));
return jsonReturn;
},
Finally, the partial {{> jeff-modal }}:
<div class="modal fade" id="{{ id }}">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header bg-light">
<h4 class="modal-title">{{ title }}</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Form -->
<form id="{{ formId }}" method="post">
<!-- Modal body -->
<div class="modal-body">
{{ body }}
</div>
<!-- Modal footer -->
<div class="modal-footer rounded-bottom bg-light">
{{# each buttons }}
<button type = "{{ type }}" onclick = "{{ onclick }}" class = "{{ class }}" data-dismiss = "{{ dataDismiss }}" >{{ text }}</button>
{{/ each }}
</div>
</form>
</div>
</div>
</div>
I am not sure whether I can call multiple instances of this modal from the same view with different titles, bodies, buttons, etc. Some tweaking might be required for that, and I'm not going to worry about it until the need arises.

Wordpress Plugin Fullcalendar not showing in bootstrap modal dialog

I am using WP Fullcalendar Plugin (https://wordpress.org/plugins/wp-fullcalendar/) on my website. It works fine as a shortcode placed on a normal page template. However I want it to work in a Bootstrap Modal Dialog box which is opened on clicking a link.
Here is my code of modal Dialog with Fullcalendar shortcode in it.
<!-- Modal -->
<div class="modal fade" id="myCalendarModal" tabindex="-1" role="dialog" aria-labelledby="myCalendarModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myCalendarModalLabel">Modal title</h4>
</div>
<div class="modal-body"><?php echo do_shortcode( ' [fullcalendar] ' ); ?></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
And here is the link to open this dialog box
<a class="open-cal" href="#" data-toggle="modal" data-target="#myCalendarModal">Open Calendar</a>
Now when I open the modal dialog box it does not load the calendar and only shows the loader spinning and spinning.
As suggested in answers like this one, Full calendar not showing inside bootstrap modal, the solution like
$('#myCalendarModal').on('shown.bs.modal', function () {
$(".wpfc-calendar").fullCalendar('render');
});
is not feasible here because the fullCalendar function needs to be passed the "fullcalendar_args" which is set in a footer hook and the related javascript file is located within the plugin files.
Any suggestion to make it work without hacking core plugin files?
Yes I have had to hack the core plugin inline.js file, as there is no other option right now.
1.You have to declare the "fullcalendar_args" variable as global
In line 4 of /includes/js/inline.js, Change
var fullcalendar_args = {
to
fullcalendar_args = {
2.Comment out 90 and 91 lines in the same file
/*
$(document).trigger('wpfc_fullcalendar_args', [fullcalendar_args]);
$('.wpfc-calendar').first().fullCalendar(fullcalendar_args);
*/
And then
3.Call these two lines in the page template where you have modal to be called, such as:
$('#myCalendarModal').on('shown.bs.modal', function () {
$(document).trigger('wpfc_fullcalendar_args', [fullcalendar_args]);
jQuery(".wpfc-calendar").fullCalendar(fullcalendar_args);
});
After this has been done, if wanted to show normal calendar on any other page, you may have to call the following two lines where ever you want calendar to appear, such as in footer or something, based on a condition etc.
$(document).trigger('wpfc_fullcalendar_args', [fullcalendar_args]);
jQuery(".wpfc-calendar").fullCalendar(fullcalendar_args);
It would be good if further updates to WP Fullcalendar Plugin incorporate these changes based on a shortcode argument or something similar approach.

vba to click a css button with no href link

I am trying to click a button in css with no success, the code does not give any error while running but it does not click either.
The button I want to click is here:
<form id="transactionHistoryReportForm" class="report-form">
<div style="clear:both;" class="days-back-buttons">
Edit Columns
<a class="io-button daysBackButton" data-days="1" href="#"><span>Last Day</span></a>
<a class="io-button daysBackButton" data-days="7" href="#"><span>Last 7 Days</span></a>
<a class="io-button daysBackButton active-days" data-days="30" href="#"><span>Last 30 Days</span></a>
<a class="io-button daysBackButton" data-days="180" href="#"><span>Last 180 Days</span></a>
</div>
<!--
<div class="currently-showing">
<span>Currently showing:</span>
<span data-id="currently-showing-value"></span>
</div>
-->
<input type="hidden" class="daysBack" name="daysBack" value="30">
<input type="hidden" class="account" name="account" value="username">
<input type="hidden" class="deviceId" name="deviceId" value="">
</form>
Last 30 days is selected by default. Last 180 days is the button to be clicked. I have tried to run the following code with no success:
Set oElementCollection = IE.document.getElementsByClassName("report-form")
For Each link In oElementCollection
If link.innerHTML = "Last 180 Days" Then
link.Click
Exit For
End If
Next link
However, for another link on the same website this is working perfectly.
The solution was this simple
Set backbutton = IE.document.getElementsByClassName("io-button daysBackButton").Item(Index:=3)
backbutton.Click
Getting elements by class name and pointing to the third item (First is 0, therefore 4-1)

Getting a meteor modal to be dynamic

I'm working w/ a modal template (maybe I shouldn't be?). On screen, I have a list of products. When a user clicks on a product, I want the modal to open w/ details of that given product.
Right now, what I'm trying to do is update the subscription of the modal. However, the OnCreate() and OnRender() are not firing when the modal opens. Right now the rendered, OnRender, created, and onCreated of the modal all fire when the parent template (the product list) is first opened. I need it to happen when a product is clicked and the modal is shown.
Am I attacking this wrong? Or do I just need to position my subscription somewhere else in the modal?
(adding code - very simple)
<template name="parent">
...
<div class="row form-row">
<div class="col-sm-12 text-right">
<a class="btn btn-outline" type="button" id="remove">Remove</a>
</div>
</div>
{{> productEditModal}}
</template>
<template name="productEditModal">
<div class="modal inmodal" id="productEditModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated bounceInRight">
<div class="modal-header">
...
Template.parent.events({
...
"click #aEditProduct": function (e) {
e.preventDefault();
Session.set("productId", this._id);
$('#productEditModal').modal('toggle');
$('#productEditModal').modal('show');
Template.productEditModal.onRendered(function() {
var self = this;
self.autorun(function() {
self.subscribe("products", Session.get("bid"), function() {
var bProduct = BoardProducts.findOne(Session.get("productId")); // some reactive operation
// do fun stuff with thing
});
});
});
ok, here is how I would approach this, assuming you did meteor add peppelg:bootstrap-3-modal
parent template: loop over products and display preview
<template name="parent">
{{#each products}}
{{name}}
{{pic}}
etc...
<a class="btn show-details" type="button">show details</a>
{{/each}}
</template>
create a details modal
<template name="productDetailsModal">
<div class="modal" id="productDetailsModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Details for product {{name}}
...
parent template helper to return products cursor:
Template.parent.helpers({
products() {
return Products.find();
},
})
the event to show details modal for every product
Template.parent.events({
'click .show-details'() {
Modal.show('productDetailsModal', this);
},
})
I wrote this off the top of my head and did not test it. Let me know if it works for you.

Meteor Bootstrap 3 Form does not Submit

I'm working with meteor#1.1.10 and twbs:bootstrap#3.3.5
I can get a modal window to spawn, close, and register a button has been clicked. I cannot get it to read any information from a form though. It just closes. I included a console message and it never shows up to either the browser or the command prompt.
Is there a way to do this without including another package? I've included my modal HTML template and Javascript. I'm hoping it's just something missed in the code.
Below is the HTML:
<template name="emodal">
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Spends Email Details</h4>
</div>
<div class="modal-body">
<form class="emailspends">
<label for="input">Recipient:</label>
<input type="text" name="emailto" required>
<label for="input">Character Name:</label>
<input type="text" name="charname" required>
<input type="submit" id="sendemail" class="email" value="Email Spends" data-dismiss="modal">
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</template>
Below is the Javascript:
Template.emodal.events({
"submit .emailspends": function (event) {
console.log(Meteor.user().emails[0].address);
// Prevent default browser form submit
event.preventDefault();
// Get value from form element
//var emailto = event.target.emailto.value;
var emailto = event.target.emailto.value;
var charname = event.target.charname.value;
var title = "Experience spends for " + charname;
Meteor.call('sendEmail', emailto,
'zbottorff#uwalumni.com', title,
'Yup, modal testies.');
// Clear form
event.target.emailto.value = "";
event.target.charname.value = "";
}
});
Update: Realized I should include this, but I did make sure I could get a submit-able template without it being in a modal window. Now I want to turn it into a modal and it's not submitting.
Bah! I found it just after I posted this.
I had too many parts to my submit button. I removed the "Class" and "id" parts, changed my Javascript to look for a 'submit form' event instead. Voala! Got the bugger to work.

Resources