Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working date slider for discussion #4491

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bokehjs/gulp/paths.coffee
Expand Up @@ -42,7 +42,7 @@ module.exports = {
minified: "bokeh-compiler.min.js"
sources: [
"./src/coffee/main.coffee"
"./src/coffee/widget/main.coffee"
"./src/coffee/models/widgets/main.coffee"
]
watchSources: [
"./src/coffee/**/**"
Expand Down
6 changes: 6 additions & 0 deletions bokehjs/package.json
Expand Up @@ -76,7 +76,13 @@
"slick_grid/plugins/slick.rowselectionmodel": "./src/vendor/slick-grid-2.1.0/plugins/slick.rowselectionmodel.js",
"slick_grid/plugins/slick.checkboxselectcolumn": "./src/vendor/slick-grid-2.1.0/plugins/slick.checkboxselectcolumn.js",
"jqrangeslider/jQRangeSlider": "./src/vendor/jqrangeslider-5.7.0/jQRangeSlider.js",
"jqrangeslider/jQRangeSliderBar": "./src/vendor/jqrangeslider-5.7.0/jQRangeSliderBar.js",
"jqrangeslider/jQRangeSliderDraggable": "./src/vendor/jqrangeslider-5.7.0/jQRangeSliderDraggable.js",
"jqrangeslider/jQRangeSliderHandle": "./src/vendor/jqrangeslider-5.7.0/jQRangeSliderHandle.js",
"jqrangeslider/jQRangeSliderLabel": "./src/vendor/jqrangeslider-5.7.0/jQRangeSliderLabel.js",
"jqrangeslider/jQRangeSliderMouseTouch": "./src/vendor/jqrangeslider-5.7.0/jQRangeSliderMouseTouch.js",
"jqrangeslider/jQDateRangeSlider": "./src/vendor/jqrangeslider-5.7.0/jQDateRangeSlider.js",
"jqrangeslider/jQDateRangeSliderHandle": "./src/vendor/jqrangeslider-5.7.0/jQDateRangeSliderHandle.js",
"jquery_event_drag": "./src/vendor/jquery-event-2.2/jquery.event.drag.js",
"jquery_event_drop": "./src/vendor/jquery-event-2.2/jquery.event.drop.js",
"gear_utils": "./src/vendor/gear-utils/gear-utils.js",
Expand Down
20 changes: 11 additions & 9 deletions bokehjs/src/coffee/models/widgets/date_range_slider.coffee
@@ -1,6 +1,13 @@
_ = require "underscore"
$ = require "jquery"
$1 = require "jqrangeslider/jQDateRangeSlider"
$1 = require "jqrangeslider/jQRangeSlider"
$6 = require "jqrangeslider/jQRangeSliderMouseTouch"
$3 = require "jqrangeslider/jQRangeSliderDraggable"
$2 = require "jqrangeslider/jQRangeSliderBar"
$4 = require "jqrangeslider/jQRangeSliderHandle"
$5 = require "jqrangeslider/jQRangeSliderLabel"
$7 = require "jqrangeslider/jQDateRangeSlider"
$8 = require "jqrangeslider/jQDateRangeSliderHandle"

p = require "../../core/properties"

Expand All @@ -11,18 +18,12 @@ class DateRangeSliderView extends Widget.View

initialize: (options) ->
super(options)
@render()
@listenTo(@model, 'change', () => @render)

render: () ->
super()
@$el.empty()

[value_min, value_max] = @mget("value")
[range_min, range_max] = @mget("range")
[bounds_min, bounds_max] = @mget("bounds")

@$el.dateRangeSlider({
@slider = $("<div>").dateRangeSlider({
defaultValues: { min: new Date(value_min), max: new Date(value_max) },
bounds: { min: new Date(bounds_min), max: new Date(bounds_max) },
range: {
Expand All @@ -39,9 +40,10 @@ class DateRangeSliderView extends Widget.View
})

@$el.on "userValuesChanged", (event, data) =>
@mset('value', [data.values.min, data.values.max])
@mset('value', [Date(data.values.min), Date(data.values.max)])
@mget('callback')?.execute(@model)

@$el.append([@slider])
return @

class DateRangeSlider extends InputWidget.Model
Expand Down
Expand Up @@ -20,7 +20,7 @@
},

_getValueForPosition: function(position){

var raw = this._getRawValueForPositionAndBounds(position, this.options.bounds.min.valueOf(), this.options.bounds.max.valueOf());

return this._constraintValue(new Date(raw));
Expand Down Expand Up @@ -177,9 +177,9 @@
if (negative){
max = this.add(max, this.options.step);
}else{
min = this.add(min, this.options.step);
min = this.add(min, this.options.step);
}

steps++;
}

Expand Down Expand Up @@ -207,4 +207,4 @@
}
}
});
}(jQuery));
}(Bokeh.$));
Expand Up @@ -96,4 +96,4 @@
}
});

}(jQuery));
}(Bokeh.$));
Expand Up @@ -143,4 +143,4 @@

});

}(jQuery));
}(Bokeh.$));
2 changes: 1 addition & 1 deletion bokehjs/src/vendor/jqrangeslider-5.7.0/jQRangeSliderBar.js
Expand Up @@ -550,4 +550,4 @@
return value;
}

}(jQuery));
}(Bokeh.$));
Expand Up @@ -24,7 +24,7 @@

destroy: function(){
this.cache = null;

$.ui.rangeSliderMouseTouch.prototype.destroy.apply(this);
},

Expand Down Expand Up @@ -89,7 +89,7 @@

_constraintPosition: function(position){
if (this.element.parent().length !== 0 && this.cache.parent.offset !== null){
position = Math.min(position,
position = Math.min(position,
this.cache.parent.offset.left + this.cache.parent.width - this.cache.width.outer);
position = Math.max(position, this.cache.parent.offset.left);
}
Expand Down Expand Up @@ -175,4 +175,4 @@
}
});

}(jQuery));
}(Bokeh.$));
Expand Up @@ -337,4 +337,4 @@
}
}
});
}(jQuery));
}(Bokeh.$));
Expand Up @@ -479,6 +479,6 @@
this.Init();
}

}(jQuery));
}(Bokeh.$));


Expand Up @@ -27,7 +27,7 @@
$(document)
.unbind('touchmove.' + this.widgetName, this._touchMoveDelegate)
.unbind('touchend.' + this.widgetName, this._touchEndDelegate);

$.ui.mouse.prototype._mouseDestroy.apply(this);
},

Expand All @@ -41,7 +41,7 @@

destroy: function(){
this._mouseDestroy();

$.ui.mouse.prototype.destroy.apply(this);

this._mouseInit = null;
Expand Down Expand Up @@ -116,4 +116,4 @@
event.pageY = touch.pageY;
}
});
}(jQuery));
}(Bokeh.$));