Skip to content

Instantly share code, notes, and snippets.

View caleboleary's full-sized avatar

Caleb O'Leary caleboleary

View GitHub Profile
@caleboleary
caleboleary / gist:c8bbca9b2094a6faa6f8
Created June 26, 2015 17:38
Smart Tabs conflicting with Carousel Fix
//If a Product Carousel looks all messed up inside of Smart Tabs, this can fix it. Basically what you need to do is find your tab that contains the carousel and don't initialize the carousel until half a second after that tab is clicked. A lot of this code can be removed pertaining to your implementation.
$.ajax({
cache: true,
crossDomain: true,
dataType: 'script',
url: '../js/jquery.smartTabs.min.js'
}).done(function () {
$('#js-smart-tabs').smartTabs(864, null, 'auto');
});
@caleboleary
caleboleary / gist:fd4fe64d5a7f528f3f4e
Last active August 29, 2015 14:24
Detect Mobile Zoom
myPinchZoom = document.documentElement.clientWidth / window.innerWidth
//this will give you 1 if they are zoomed out all the way (mobile) and will give you an increasing number the more that they zoom in. Must put it somewhere where it checks continuously rather than on page load if you want it to do something actively
@caleboleary
caleboleary / fullzizeimg
Last active August 29, 2015 14:24
Grab the URL of any miva-sized image and rip off the dimensions from the end, variable workingJoined becomes url of full sized image. Not the best option but worked for a specific case for me
var working = $( '#js-main-image' ).attr('src');
var workingSplit = working.split('_');
var fileExt = (workingSplit[workingSplit.length-1].split('.'));
workingSplit.pop();
var workingJoined = workingSplit.join('_');
workingJoined = workingJoined + '.' + fileExt[fileExt.length-1];
$( '.output' ).text(workingJoined);
@caleboleary
caleboleary / regenprices
Last active August 29, 2015 14:25
Attribute Machine doesn't work with Miva's multiadd currently, here's the js I used to detect any changes in the page and update the prices. I passed all prices through data-prices.
<script type="text/javascript">
function regenPrices() {
$(".multiAddTableRow").each(function() {
var row = $(this);
var rowPrice = [];
(row).find('select').each(function(){
var select = $(this);
$(select).find('option:selected').each(function(){
var option = $(this);
@caleboleary
caleboleary / mivaredir
Last active August 29, 2015 14:25
Miva Redirect
<mvt:assign name="g.redirect" value="miva_output_header( 'Location', g.domain:mm_url $ 'Screen=CTGY&Category_Code=' $ g.category_code $ '&multiAdd=true&Per_Page=0')"/>
@caleboleary
caleboleary / query
Created July 17, 2015 20:52
toolbelt sql query
<mvt:item name="ry_toolbelt" param="assign|g.select_sql|'INSERT INTO custcomments (category, custname, email, country, comment, commentdate, status) VALUES (`test`, `test`, `test`, `test`, `test`, NOW(), `active`)'" />
<mvt:item name="ry_toolbelt" param="query|g.select_sql|MyOrders" />
@caleboleary
caleboleary / showallinarray-glosub
Last active August 29, 2015 14:25
mvt show all entities in array
<mvt:eval expr="glosub(miva_array_serialize(l.settings:quote), ',', '<br />')" />
@caleboleary
caleboleary / zoominterval.js
Created August 12, 2015 17:28
When using the zoom plugin at http://www.jacklmoore.com/zoom/ if you enter the image that triggers the magnify before the large image is done loading, nothing will happen until you trigger mouseleave and retrigger mouseenter. This will hit mouseleave and mouseenter every second to fix this problem for people with slow internet.
var interval = null;
$('#js-main-image').on('mouseenter', function() {
$('#zoom-hold').show();
interval = setInterval(function(){
$('#js-main-image').trigger('mouseleave');
$('#js-main-image').trigger('mouseenter');
}, 1000);
}).on('mouseleave', function(){
$('#zoom-hold').hide();
window.clearInterval(interval);
@caleboleary
caleboleary / recaptcha-v2-instructions.html
Last active February 17, 2021 14:01
Install google recaptcha v2 on Miva
-Sign up and register your site at https://www.google.com/recaptcha/intro/index.html
-Add this line to your head tag content:
<script src='https://www.google.com/recaptcha/api.js'></script>
-Add this line inside the form tag where you want the recaptcha to appear
<div class="g-recaptcha" data-sitekey="YOURSITEKEY"></div>
-Create a new page with the code RECAP and put this code in (don’t forget to add in your real key):
<mvt:assign name="g.secretKey" value="'YOURSITEKEY'" />
@caleboleary
caleboleary / QjwgVr.markdown
Last active September 4, 2015 01:10 — forked from anonymous/QjwgVr.markdown
QjwgVr