| 1 |
(function($) { |
| 2 |
$(document).ready(function() { |
| 3 |
$('.type-radio').change(function() { |
| 4 |
$('.type-label-selected').removeClass('type-label-selected'); |
| 5 |
$(this).parent().addClass('type-label-selected'); |
| 6 |
}); |
| 7 |
|
| 8 |
$('.group-title').click(function() { |
| 9 |
var parent = $(this).parent(); |
| 10 |
|
| 11 |
if (parent.hasClass('open')) { |
| 12 |
parent.removeClass('open'); |
| 13 |
} else { |
| 14 |
$('.group.open').removeClass('open'); |
| 15 |
parent.addClass('open'); |
| 16 |
} |
| 17 |
}); |
| 18 |
|
| 19 |
$('#remote-file').click(function() { |
| 20 |
var url = $.trim(prompt(visualizer.l10n.remotecsv_prompt)); |
| 21 |
|
| 22 |
if (url != '') { |
| 23 |
if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)) { |
| 24 |
if (url.substr(url.length - 8) == '/pubhtml') { |
| 25 |
url = url.substring(0, url.length - 8) + '/export?format=csv'; |
| 26 |
} |
| 27 |
|
| 28 |
$('#remote-data').val(url); |
| 29 |
$('#csv-file').val(''); |
| 30 |
$('#canvas').lock(); |
| 31 |
$('#csv-form').submit(); |
| 32 |
} else { |
| 33 |
alert(visualizer.l10n.invalid_source); |
| 34 |
} |
| 35 |
} |
| 36 |
}); |
| 37 |
|
| 38 |
$('#csv-file').change(function() { |
| 39 |
if ($.trim($(this).val()) != '') { |
| 40 |
$('#remote-data').val(''); |
| 41 |
$('#canvas').lock(); |
| 42 |
$('#csv-form').submit(); |
| 43 |
} |
| 44 |
}); |
| 45 |
|
| 46 |
$('#thehole').load(function() { |
| 47 |
$('#canvas').unlock(); |
| 48 |
}); |
| 49 |
|
| 50 |
$('.section-title').click(function() { |
| 51 |
$(this).toggleClass('open').parent().find('.section-items').toggle(); |
| 52 |
}); |
| 53 |
|
| 54 |
$('.more-info').click(function() { |
| 55 |
$(this).parent().find('.section-description:first').toggle(); |
| 56 |
return false; |
| 57 |
}); |
| 58 |
|
| 59 |
}); |
| 60 |
})(jQuery); |
| 61 |
|
| 62 |
(function($) { |
| 63 |
$.fn.lock = function() { |
| 64 |
$(this).each(function() { |
| 65 |
var $this = $(this); |
| 66 |
var position = $this.css('position'); |
| 67 |
|
| 68 |
if (!position) { |
| 69 |
position = 'static'; |
| 70 |
} |
| 71 |
|
| 72 |
switch(position) { |
| 73 |
case 'absolute': |
| 74 |
case 'relative': |
| 75 |
break; |
| 76 |
default: |
| 77 |
$this.css('position', 'relative'); |
| 78 |
break; |
| 79 |
} |
| 80 |
$this.data('position', position); |
| 81 |
|
| 82 |
var width = $this.width(), |
| 83 |
height = $this.height(); |
| 84 |
|
| 85 |
var locker = $('<div class="locker"></div>'); |
| 86 |
locker.width(width).height(height); |
| 87 |
|
| 88 |
var loader = $('<div class="locker-loader"></div>'); |
| 89 |
loader.width(width).height(height); |
| 90 |
|
| 91 |
locker.append(loader); |
| 92 |
$this.append(locker); |
| 93 |
$(window).resize(function() { |
| 94 |
$this.find('.locker,.locker-loader').width($this.width()).height($this.height()); |
| 95 |
}); |
| 96 |
}); |
| 97 |
|
| 98 |
return $(this); |
| 99 |
} |
| 100 |
|
| 101 |
$.fn.unlock = function() { |
| 102 |
$(this).each(function() { |
| 103 |
$(this).find('.locker').remove(); |
| 104 |
$(this).css('position', $(this).data('position')); |
| 105 |
}); |
| 106 |
|
| 107 |
return $(this); |
| 108 |
} |
| 109 |
})(jQuery); |
| 110 |
|
| 111 |
//Hide / show settings in sidebar |
| 112 |
(function($) { |
| 113 |
$(document).ready(function() { |
| 114 |
|
| 115 |
$('.advanced-settings-btn').click(function(){ |
| 116 |
$('.second-screen, .return-settings-btn').removeClass("hidden-setting"); |
| 117 |
$('.initial-screen').addClass("hidden-setting"); |
| 118 |
}); |
| 119 |
|
| 120 |
$('.return-settings-btn').click(function(){ |
| 121 |
$('.second-screen, .return-settings-btn').addClass("hidden-setting"); |
| 122 |
$('.initial-screen').removeClass("hidden-setting"); |
| 123 |
}); |
| 124 |
}); |
| 125 |
})(jQuery); |
| 126 |
|