Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix customize links

  • Loading branch information...
commit 085a5ba05a7c394e67ccc525b4e0cbd6f4515e25 1 parent 6efafda
@johnpolacek authored
Showing with 24 additions and 3 deletions.
  1. +23 −3 index.html
  2. +1 −0  js/jquery.configurator.js
View
26 index.html
@@ -89,8 +89,10 @@
// get sizes from url params or use default
var frames = [];
+ var isCustomSizes = false;
var sizes = $.Configurator().getConfig().sizes;
if (sizes) {
+ isCustomSizes = true;
$.each(sizes, function(i,val) {
frame = val.split(':');
size = frame[0].toLowerCase().split('x');
@@ -140,10 +142,11 @@
// update share link when hide header option is checked
$('#hide-header').on('change',function() {
+
if ($(this).is(':checked')) {
- $('#share-field-input').val(responsivatorURL+'?site='+site+'&header=hide');
+ $('#share-field-input').val(responsivatorURL+'?site='+site+'&header=hide'+getSizeParams());
} else {
- $('#share-field-input').val(responsivatorURL+'?site='+site);
+ $('#share-field-input').val(responsivatorURL+'?site='+site+getSizeParams());
}
});
@@ -158,6 +161,7 @@
$()
$('#btn-customize').on('click', function (e) {
e.preventDefault();
+ isCustomSizes = true;
$('#form-customize').removeClass('collapsed');
});
$('#customize-btn-finish').on('click', function(e) {
@@ -185,7 +189,7 @@
});
if (valid) {
$('#form-customize').addClass('collapsed');
- window.location = './?sizes='+sizeConfig;
+ window.location = './?site='+site+'&sizes='+sizeConfig;
}
})
$('#form-customize').on('click','.btn-delete', function(e) {
@@ -197,15 +201,31 @@
return sitesArray[Math.floor(Math.random()*sitesArray.length)];
}
+ function getSizeParams() {
+ var sizeParams = '';
+ if (isCustomSizes) {
+ sizeParams += '&sizes='
+ $.each(frames, function(i,val){
+ sizeParams += frames[i].width+'x'+frames[i].height+':'+frames[i].label;
+ if (i !== frames.length-1) {
+ sizeParams += ',';
+ }
+ });
+ }
+ return sizeParams;
+ }
+
function responsivate(url) {
// add http:// if it is missing
if (url.indexOf('http://')===-1) { url = 'http://'+url; }
// create share url (and check if header hide option is checked)
var shareURL = responsivatorURL+'?site='+url;
+
if ($('#hide-header').is(':checked')) {
shareURL += '&header=hide';
}
+ shareURL += getSizeParams();
$('#share-field-input').val(shareURL);
// update frames
View
1  js/jquery.configurator.js
@@ -29,6 +29,7 @@
// Thanks guy on StackOverflow! - http://stackoverflow.com/questions/8648892/convert-url-parameters-to-a-javascript-object
var configDataParams = {};
if (decodeURI((location.search).substr(1)) !== '') {
+ console.log('{"' + decodeURI((location.search).substr(1).replace(/&/g, "\",\"").replace(/=/g,"\":\"")) + '"}');
configDataParams = JSON.parse('{"' + decodeURI((location.search).substr(1).replace(/&/g, "\",\"").replace(/=/g,"\":\"")) + '"}');
$.each(configDataParams, function(key,val){
if (val.indexOf(',') !== -1) {
Please sign in to comment.
Something went wrong with that request. Please try again.