removed slider functions from torque.js to allow user to use any slider library

This commit is contained in:
andrewxhill 2013-04-03 12:27:58 -04:00
parent 469a868f2c
commit c492f9a0a8
3 changed files with 58 additions and 31 deletions

View File

@ -89,6 +89,28 @@
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
map.setOptions({styles:map_style.google_maps_customization_style});
function init_slider( that ){
var that_opts = that.options;
$('body').append('<div id="torque-slider"></div>');
// Init jQuery UI options
$("#torque-slider").slider({
min: Math.round(that_opts.start),
max: Math.floor(that_opts.end),
value: Math.round(that_opts.start),
step: that._step,
slide: function(event, ui){
that._current = ui.value;
var date = new Date(that._current * 1000);
var date_arry = date.toString().substr(4).split(' ');
that._display.set_time((that._current - that.start) / that._step);
}
});
};
function on_move (that) {
$( "#torque-slider" ).slider({ value: that._current });
}
var TorqueOptions = {
user:'viz2',
table:'ow',
@ -103,7 +125,8 @@
trails:true,
point_type:'circle',
cellsize:1,
scrub: true,
scrub: init_slider,
scrub_move: on_move
}
var torque = null;

View File

@ -76,6 +76,26 @@
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
map.setOptions({styles:map_style.google_maps_customization_style});
function init_slider( that ){
var that_opts = that.options;
$('body').append('<div id="torque-slider"></div>');
// Init jQuery UI options
$("#torque-slider").slider({
min: Math.round(that_opts.start),
max: Math.floor(that_opts.end),
value: Math.round(that_opts.start),
step: that._step,
slide: function(event, ui){
that._current = ui.value;
var date = new Date(that._current * 1000);
var date_arry = date.toString().substr(4).split(' ');
that._display.set_time((that._current - that.start) / that._step);
}
});
};
var TorqueOptions = {
user: "viz2",
table: "us_po_offices",
@ -91,7 +111,7 @@
point_type:'circle',
cellsize:2,
autoplay: false,
scrub: true
scrub: init_slider
}
var torque = null;

View File

@ -151,10 +151,9 @@ Torque.modules.layer = function (torque) {
// If scrubbable, override other options that may have been set
if (this.options.scrub){
this.options.scrub(this);
// this.options.autoplay = false;
// this.options.trails = false;
$('body').append('<div id="torque-slider"></div>');
}
if (this.options.autoplay) {
@ -162,7 +161,6 @@ Torque.modules.layer = function (torque) {
this.play();
}
init_slider(this);
torque.log.info('Layer is now running!');
},
@ -234,8 +232,8 @@ Torque.modules.layer = function (torque) {
this._display.set_time((this._current - this.start) / this._step);
if (this.options.scrub==true){
$( "#torque-slider" ).slider({ value: this._current });
if (this.options.scrub_move){
this.options.scrub_move(this)
}
if (this.running) {
setTimeout(function () {
@ -243,19 +241,19 @@ Torque.modules.layer = function (torque) {
}.bind(this), pause + 1000 * 1 / this.options.fps);
}
},
scrub:function(scrub_current){
this._current = scrub_current;
var date = new Date(this._current * 1000);
var date_arry = date.toString().substr(4).split(' ');
torque.clock.set('<span id="month">' + date_arry[0] + '</span> <span id="year">' + date_arry[2] + '</span>');
// scrub:function(scrub_current){
// this._current = scrub_current;
// var date = new Date(this._current * 1000);
// var date_arry = date.toString().substr(4).split(' ');
// torque.clock.set('<span id="month">' + date_arry[0] + '</span> <span id="year">' + date_arry[2] + '</span>');
if (this.options.subtitles) {
torque.subtitles.set(date);
}
// if (this.options.subtitles) {
// torque.subtitles.set(date);
// }
this._display.set_time((this._current - this.start) / this._step);
// this._display.set_time((this._current - this.start) / this._step);
}
// }
});
}
@ -338,20 +336,6 @@ Torque.modules.subtitles = function (torque) {
};
};
function init_slider( that ){
var that_opts = that.options;
// Init jQuery UI options
$("#torque-slider").slider({
min: Math.round(that_opts.start),
max: Math.floor(that_opts.end),
value: Math.round(that_opts.start),
step: that._step,
slide: function(event, ui){
that.scrub(ui.value);
}
});
};
/**
* Logging module that torquetes log messages to the console and to the Speed
* Tracer API. It contains convenience methods for info(), warn(), error(),