| 1 |
/* global prompt */ |
| 2 |
/* global visualizer */ |
| 3 |
/* global alert */ |
| 4 |
|
| 5 |
(function ($) { |
| 6 |
$(document).ready(function () { |
| 7 |
$('.type-radio').change(function () { |
| 8 |
$('.type-label-selected').removeClass('type-label-selected'); |
| 9 |
$(this).parent().addClass('type-label-selected'); |
| 10 |
}); |
| 11 |
|
| 12 |
$('#vz-chart-settings h2').click(function () { |
| 13 |
$("#vz-chart-source").hide(); |
| 14 |
$(this).parent().removeClass('bottom-fixed').addClass('open'); |
| 15 |
|
| 16 |
return false; |
| 17 |
}); |
| 18 |
$('#vz-chart-settings .customize-section-back').click(function () { |
| 19 |
$("#vz-chart-source").show(); |
| 20 |
$(this).parent().parent().removeClass('open').addClass('bottom-fixed'); |
| 21 |
|
| 22 |
return false; |
| 23 |
}); |
| 24 |
$('.group-title').click(function () { |
| 25 |
var parent = $(this).parent(); |
| 26 |
|
| 27 |
if (parent.hasClass('open')) { |
| 28 |
parent.removeClass('open'); |
| 29 |
} else { |
| 30 |
parent.parent().find('.group.open').removeClass('open'); |
| 31 |
parent.addClass('open'); |
| 32 |
} |
| 33 |
}); |
| 34 |
$('#view-remote-file').click(function () { |
| 35 |
var url = $(this).parent().find('#remote-data').val(); |
| 36 |
|
| 37 |
if (url !== '') { |
| 38 |
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)) { |
| 39 |
if (url.substr(url.length - 8) === '/pubhtml') { |
| 40 |
url = url.substring(0, url.length - 8) + '/export?format=csv'; |
| 41 |
} |
| 42 |
|
| 43 |
$('#canvas').lock(); |
| 44 |
$(this).parent().submit(); |
| 45 |
} else { |
| 46 |
alert(visualizer.l10n.invalid_source); |
| 47 |
} |
| 48 |
} |
| 49 |
}); |
| 50 |
|
| 51 |
$('#vz-import-file').click(function (e) { |
| 52 |
e.preventDefault(); |
| 53 |
if ($.trim($(this).parent().find("#csv-file").val()) !== '') { |
| 54 |
$('#canvas').lock(); |
| 55 |
$(this).parent().submit(); |
| 56 |
} |
| 57 |
}); |
| 58 |
|
| 59 |
$('#thehole').load(function () { |
| 60 |
$('#canvas').unlock(); |
| 61 |
}); |
| 62 |
|
| 63 |
$('.section-title').click(function () { |
| 64 |
$(this).toggleClass('open').parent().find('.section-items').toggle(); |
| 65 |
}); |
| 66 |
|
| 67 |
$('.more-info').click(function () { |
| 68 |
$(this).parent().find('.section-description:first').toggle(); |
| 69 |
return false; |
| 70 |
}); |
| 71 |
|
| 72 |
}); |
| 73 |
})(jQuery); |
| 74 |
|
| 75 |
(function ($) { |
| 76 |
$.fn.lock = function () { |
| 77 |
$(this).each(function () { |
| 78 |
var $this = $(this); |
| 79 |
var position = $this.css('position'); |
| 80 |
|
| 81 |
if (!position) { |
| 82 |
position = 'static'; |
| 83 |
} |
| 84 |
|
| 85 |
switch (position) { |
| 86 |
case 'absolute': |
| 87 |
case 'relative': |
| 88 |
break; |
| 89 |
default: |
| 90 |
$this.css('position', 'relative'); |
| 91 |
break; |
| 92 |
} |
| 93 |
$this.data('position', position); |
| 94 |
|
| 95 |
var width = $this.width(), |
| 96 |
height = $this.height(); |
| 97 |
|
| 98 |
var locker = $('<div class="locker"></div>'); |
| 99 |
locker.width(width).height(height); |
| 100 |
|
| 101 |
var loader = $('<div class="locker-loader"></div>'); |
| 102 |
loader.width(width).height(height); |
| 103 |
|
| 104 |
locker.append(loader); |
| 105 |
$this.append(locker); |
| 106 |
$(window).resize(function () { |
| 107 |
$this.find('.locker,.locker-loader').width($this.width()).height($this.height()); |
| 108 |
}); |
| 109 |
}); |
| 110 |
|
| 111 |
return $(this); |
| 112 |
}; |
| 113 |
|
| 114 |
$.fn.unlock = function () { |
| 115 |
$(this).each(function () { |
| 116 |
$(this).find('.locker').remove(); |
| 117 |
$(this).css('position', $(this).data('position')); |
| 118 |
}); |
| 119 |
|
| 120 |
return $(this); |
| 121 |
}; |
| 122 |
})(jQuery); |