diff --git a/themes/bootstrap/js/flot/jquery.flot.resize.min.js b/themes/bootstrap/js/flot/jquery.flot.resize.min.js new file mode 100644 index 0000000000000000000000000000000000000000..1fa0771f570ea1a6cfd9259fb02d707d279ca859 --- /dev/null +++ b/themes/bootstrap/js/flot/jquery.flot.resize.min.js @@ -0,0 +1 @@ +(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this);(function(b){var a={};function c(f){function e(){var h=f.getPlaceholder();if(h.width()==0||h.height()==0){return}f.resize();f.setupGrid();f.draw()}function g(i,h){i.getPlaceholder().resize(e)}function d(i,h){i.getPlaceholder().unbind("resize",e)}f.hooks.bindEvents.push(g);f.hooks.shutdown.push(d)}b.plot.plugins.push({init:c,options:a,name:"resize",version:"1.0"})})(jQuery); \ No newline at end of file diff --git a/themes/bootstrap/js/pubdate_vis.js b/themes/bootstrap/js/pubdate_vis.js index 3c25119be9ff72b006a9bfc7d1dfdf2d7c3ce755..24c28c8d27b72043161adb2c4788cdd128455311 100644 --- a/themes/bootstrap/js/pubdate_vis.js +++ b/themes/bootstrap/js/pubdate_vis.js @@ -2,118 +2,118 @@ function PadDigits(n, totalDigits) { - if (n <= 0){ - n= 1; - } - n = n.toString(); - var pd = ''; - if (totalDigits > n.length) + if (n <= 0){ + n= 1; + } + n = n.toString(); + var pd = ''; + if (totalDigits > n.length) + { + for (var i=0; i < (totalDigits-n.length); i++) { - for (var i=0; i < (totalDigits-n.length); i++) - { - pd += '0'; - } + pd += '0'; } - return pd + n; + } + return pd + n; } function loadVis(facetFields, searchParams, baseURL, zooming) { - // options for the graph, TODO: make configurable - var options = { - series: { - bars: { - show: true, - align: "center", - fill: true, - fillColor: "rgb(234,234,234)" - } - }, - colors: ["#0088CC"], - legend: { noColumns: 2 }, - xaxis: { tickDecimals: 0 }, - yaxis: { min: 0, ticks: [] }, - selection: {mode: "x"}, - grid: { backgroundColor: null /*"#ffffff"*/ } - }; + // options for the graph, TODO: make configurable + var options = { + series: { + bars: { + show: true, + align: "center", + fill: true, + fillColor: "rgb(234,234,234)" + } + }, + colors: ["#0088CC"], + legend: { noColumns: 2 }, + xaxis: { tickDecimals: 0 }, + yaxis: { min: 0, ticks: [] }, + selection: {mode: "x"}, + grid: { backgroundColor: null /*"#ffffff"*/ } + }; - // AJAX call - var url = baseURL + '/AJAX/json?method=getVisData&facetFields=' + encodeURIComponent(facetFields) + '&' + searchParams; - $.getJSON(url, function (data) { - if (data.status == 'OK') { - $.each(data['data'], function(key, val) { - //check if there is data to display, if there isn't hide the box - if (val['data'] == undefined || val['data'].length == 0) { - return; - } - $("#datevis" + key + "xWrapper").show(); + // AJAX call + var url = baseURL + '/AJAX/json?method=getVisData&facetFields=' + encodeURIComponent(facetFields) + '&' + searchParams; + $.getJSON(url, function (data) { + if (data.status == 'OK') { + $.each(data['data'], function(key, val) { + //check if there is data to display, if there isn't hide the box + if (val['data'] == undefined || val['data'].length == 0) { + return; + } + $("#datevis" + key + "xWrapper").show(); - // plot graph - var placeholder = $("#datevis" + key + "x"); + // plot graph + var placeholder = $("#datevis" + key + "x"); - //set up the hasFilter variable - var hasFilter = true; + //set up the hasFilter variable + var hasFilter = true; - //set the has filter - if (val['min'] == 0 && val['max']== 0) { - hasFilter = false; - } + //set the has filter + if (val['min'] == 0 && val['max']== 0) { + hasFilter = false; + } - //check if the min and max value have been set otherwise set them to the ends of the graph - if (val['min'] == 0) { - val['min'] = val['data'][0][0] - 5; - } - if (val['max']== 0) { - val['max'] = parseInt(val['data'][val['data'].length - 1][0], 10) + 5; - } + //check if the min and max value have been set otherwise set them to the ends of the graph + if (val['min'] == 0) { + val['min'] = val['data'][0][0] - 5; + } + if (val['max']== 0) { + val['max'] = parseInt(val['data'][val['data'].length - 1][0], 10) + 5; + } - if (zooming) { - //check the first and last elements of the data array against min and max value (+padding) - //if the element exists leave it, otherwise create a new marker with a minus one value - if (val['data'][val['data'].length - 1][0] != parseInt(val['max'], 10) + 5) { - val['data'].push([parseInt(val['max'], 10) + 5, -1]); - } - if (val['data'][0][0] != val['min'] - 5) { - val['data'].push([val['min'] - 5, -1]); - } - //check for values outside the selected range and remove them by setting them to null - for (var i=0; i<val['data'].length; i++) { - if (val['data'][i][0] < val['min'] -5 || val['data'][i][0] > parseInt(val['max'], 10) + 5) { - //remove this - val['data'].splice(i,1); - i--; - } - } + if (zooming) { + //check the first and last elements of the data array against min and max value (+padding) + //if the element exists leave it, otherwise create a new marker with a minus one value + if (val['data'][val['data'].length - 1][0] != parseInt(val['max'], 10) + 5) { + val['data'].push([parseInt(val['max'], 10) + 5, -1]); + } + if (val['data'][0][0] != val['min'] - 5) { + val['data'].push([val['min'] - 5, -1]); + } + //check for values outside the selected range and remove them by setting them to null + for (var i=0; i<val['data'].length; i++) { + if (val['data'][i][0] < val['min'] -5 || val['data'][i][0] > parseInt(val['max'], 10) + 5) { + //remove this + val['data'].splice(i,1); + i--; + } + } - } else { - //no zooming means that we need to specifically set the margins - //do the last one first to avoid getting the new last element - val['data'].push([parseInt(val['data'][val['data'].length - 1][0], 10) + 5, -1]); - //now get the first element - val['data'].push([val['data'][0][0] - 5, -1]); - } + } else { + //no zooming means that we need to specifically set the margins + //do the last one first to avoid getting the new last element + val['data'].push([parseInt(val['data'][val['data'].length - 1][0], 10) + 5, -1]); + //now get the first element + val['data'].push([val['data'][0][0] - 5, -1]); + } - var plot = $.plot(placeholder, [val], options); - if (hasFilter) { - // mark pre-selected area - plot.setSelection({ x1: val['min'] , x2: val['max']}); - } - // selection handler - placeholder.bind("plotselected", function (event, ranges) { - var from = Math.floor(ranges.xaxis.from); - var to = Math.ceil(ranges.xaxis.to); - location.href = val['removalURL'] + '&daterange[]=' + key + '&' + key + 'to=' + PadDigits(to,4) + '&' + key + 'from=' + PadDigits(from,4); - }); + var plot = $.plot(placeholder, [val], options); + if (hasFilter) { + // mark pre-selected area + plot.setSelection({ x1: val['min'] , x2: val['max']}); + } + // selection handler + placeholder.bind("plotselected", function (event, ranges) { + var from = Math.floor(ranges.xaxis.from); + var to = Math.ceil(ranges.xaxis.to); + location.href = val['removalURL'] + '&daterange[]=' + key + '&' + key + 'to=' + PadDigits(to,4) + '&' + key + 'from=' + PadDigits(from,4); + }); - if (hasFilter) { - var newdiv = document.createElement('div'); - var text = document.getElementById("clearButtonText").innerHTML; - newdiv.setAttribute('id', 'clearButton' + key); - newdiv.innerHTML = '<a href="' + htmlEncode(val['removalURL']) + '">' + text + '</a>'; - newdiv.className += "dateVisClear"; - placeholder.append(newdiv); - } - }); + if (hasFilter) { + var newdiv = document.createElement('div'); + var text = document.getElementById("clearButtonText").innerHTML; + newdiv.setAttribute('id', 'clearButton' + key); + newdiv.innerHTML = '<a href="' + htmlEncode(val['removalURL']) + '">' + text + '</a>'; + newdiv.className += "dateVisClear"; + placeholder.append(newdiv); } - }); + }); + } + }); } \ No newline at end of file diff --git a/themes/bootstrap/templates/Recommend/PubDateVisAjax.phtml b/themes/bootstrap/templates/Recommend/PubDateVisAjax.phtml index b167774124222c2846e499a679333602acfaeb79..d949e4bec0227abbced069ee8d3ce081e0e88693 100644 --- a/themes/bootstrap/templates/Recommend/PubDateVisAjax.phtml +++ b/themes/bootstrap/templates/Recommend/PubDateVisAjax.phtml @@ -4,6 +4,7 @@ <? /* load jQuery flot */ ?> <?$this->headScript()->appendFile('flot/excanvas.min.js', null, array('conditional' => 'IE')); $this->headScript()->appendFile('flot/jquery.flot.min.js'); + $this->headScript()->appendFile('flot/jquery.flot.resize.min.js'); $this->headScript()->appendFile('flot/jquery.flot.selection.min.js'); $this->headScript()->appendFile('pubdate_vis.js'); ?>