Permalink
Browse files

#649 added jquery_exists

  • Loading branch information...
1 parent f644492 commit c94097e649e2a093593eafe072c1b76c5ace59e3 @almossawi almossawi committed Jul 29, 2016
View
Oops, something went wrong.
Oops, something went wrong.
@@ -31,6 +31,7 @@
<!-- dev start -->
<script src='../src/js/MG.js'></script>
+ <script src='../src/js/misc/utility.js'></script>
<script src='../src/js/common/data_graphic.js'></script>
<script src='../src/js/common/hooks.js'></script>
<script src='../src/js/common/register.js'></script>
@@ -56,7 +57,6 @@
<script src='../src/js/misc/smoothers.js'></script>
<script src='../src/js/misc/formatters.js'></script>
<script src='../src/js/misc/transitions.js'></script>
- <script src='../src/js/misc/utility.js'></script>
<script src='../src/js/misc/error.js'></script>
<!-- dev end -->
@@ -28,6 +28,7 @@
<!-- dev start -->
<script src='../src/js/MG.js'></script>
+ <script src='../src/js/misc/utility.js'></script>
<script src='../src/js/common/data_graphic.js'></script>
<script src='../src/js/common/hooks.js'></script>
<script src='../src/js/common/register.js'></script>
@@ -52,7 +53,6 @@
<script src='../src/js/misc/smoothers.js'></script>
<script src='../src/js/misc/formatters.js'></script>
<script src='../src/js/misc/transitions.js'></script>
- <script src='../src/js/misc/utility.js'></script>
<script src='../src/js/misc/error.js'></script>
<!-- dev end -->
@@ -102,10 +102,9 @@
download it. Try doubling the number of sightings in, say, 1995 and see
how that affects the graphic. Or how about changing any of the options in
<i>MG.data_graphic</i>? Or perhaps change the chart type to a scatterplot by
- setting <code>chart_type:'point'</code>, switching the x and y accessors and
- increasing the height? The data object is set to the contents of the
- <i>Data</i> text area. Errors are logged to the
- console.</p>
+ setting <code>chart_type:'point'</code>, switching the <i>x</i> and <i>y</i>
+ accessors and increasing the <i>height</i>? The data object is set to the
+ contents of the <i>Data</i> text area. Errors are logged to the console.</p>
</div>
</div>
View
@@ -22,6 +22,7 @@ var
dist = './dist/',
jsFiles = [
src + 'MG.js',
+ src + 'misc/utility.js',
src + 'common/register.js',
src + 'common/hooks.js',
src + 'common/data_graphic.js',
@@ -47,7 +48,6 @@ var
src + 'misc/smoothers.js',
src + 'misc/formatters.js',
src + 'misc/transitions.js',
- src + 'misc/utility.js',
src + 'misc/error.js'
];
View
@@ -18,6 +18,7 @@
<!-- dev start -->
<script src='js/MG.js'></script>
+ <script src='js/misc/utility.js'></script>
<script src='js/common/data_graphic.js'></script>
<script src='js/common/hooks.js'></script>
<script src='js/common/register.js'></script>
@@ -42,7 +43,6 @@
<script src='js/misc/smoothers.js'></script>
<script src='js/misc/formatters.js'></script>
<script src='js/misc/transitions.js'></script>
- <script src='js/misc/utility.js'></script>
<script src='js/misc/error.js'></script>
<!-- dev end -->
@@ -120,7 +120,7 @@ MG.data_table = function(args) {
.style('text-align', td_type === 'title' ? 'left' : 'right')
.text(th_text);
- if (args.show_tooltips && this_col.description && typeof jQuery !== 'undefined') {
+ if (args.show_tooltips && this_col.description && jquery_exists()) {
th.append('i')
.classed('fa', true)
.classed('fa-question-circle', true)
@@ -1,4 +1,4 @@
-if (typeof jQuery !== 'undefined') {
+if (jquery_exists()) {
/* ========================================================================
* Bootstrap: tooltip.js v3.3.5
* http://getbootstrap.com/javascript/#tooltip
@@ -623,4 +623,4 @@ if (typeof jQuery !== 'undefined') {
}
}(jQuery);
-}
+}
@@ -20,7 +20,7 @@ function chart_title(args) {
.text(args.title);
//show and activate the description icon if we have a description
- if (args.show_tooltips && args.description && typeof jQuery !== 'undefined') {
+ if (args.show_tooltips && args.description && jquery_exists()) {
chartTitle.append('tspan')
.attr('class', 'mg-chart-description')
.attr('dx', '0.3em')
@@ -1,4 +1,4 @@
-if (typeof jQuery !== 'undefined') {
+if (jquery_exists()) {
/*!
* Bootstrap v3.3.1 (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
@@ -174,4 +174,4 @@ if (typeof jQuery !== 'undefined') {
.on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown);
}(jQuery);
-}
+}
@@ -26,6 +26,14 @@ MG.time_format = function(utc, specifier) {
return utc ? d3.utcFormat(specifier) : d3.timeFormat(specifier);
};
+function jquery_exists() {
+ if (typeof jQuery !== 'undefined' || typeof $ !== 'undefined') {
+ return true;
+ } else {
+ return false;
+ }
+}
+
function mg_get_rollover_time_format(args) {
var fmt;
switch (args.processed.x_time_frame) {
View
@@ -5,6 +5,7 @@
"node_modules/d3/build/d3.js",
"src/js/MG.js",
+ "src/js/misc/utility.js",
"src/js/common/register.js",
"src/js/common/hooks.js",
"src/js/common/data_graphic.js",
@@ -29,7 +30,6 @@
"src/js/misc/smoothers.js",
"src/js/misc/formatters.js",
"src/js/misc/transitions.js",
- "src/js/misc/utility.js",
"src/js/misc/error.js",
"tests/helpers.js",

0 comments on commit c94097e

Please sign in to comment.