mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Cleanup; add getHeadRevision function to connection
This commit is contained in:
parent
a5eced9952
commit
275c26f872
3 changed files with 20 additions and 16 deletions
|
@ -36,7 +36,7 @@ $.Class("RevisionSlider",
|
|||
this.revision_number = rev;
|
||||
}
|
||||
|
||||
console.log("New RevisionSlider, head_revision = %d", this.revision_number);
|
||||
console.log("New RevisionSlider, current_revision = %d", this.revision_number);
|
||||
// parse the various elements we need:
|
||||
this.elements = {};
|
||||
this.loadElements(root_element);
|
||||
|
@ -44,7 +44,7 @@ $.Class("RevisionSlider",
|
|||
this.slider = new SliderUI(this.elements.slider_bar,
|
||||
options = {
|
||||
value: this.revision_number,
|
||||
max: this.connection.head_revision,
|
||||
max: this.connection.getHeadRevision(),
|
||||
change: function () { _this.onChange.apply(_this, arguments); },
|
||||
slide: function () { _this.onSlide.apply(_this, arguments); },
|
||||
});
|
||||
|
@ -89,12 +89,12 @@ $.Class("RevisionSlider",
|
|||
}
|
||||
|
||||
var revnum = this.revision_number;
|
||||
if (revnum == this.connection.head_revision)
|
||||
if (revnum == this.connection.getHeadRevision())
|
||||
revnum = 0;
|
||||
|
||||
var _this = this;
|
||||
var keepPlaying = function (current_revnum) {
|
||||
if (current_revnum == _this.connection.head_revision)
|
||||
if (current_revnum == _this.connection.getHeadRevision())
|
||||
_this.is_playing = false;
|
||||
if (!_this.is_playing)
|
||||
return;
|
||||
|
@ -118,7 +118,7 @@ $.Class("RevisionSlider",
|
|||
this.elements.button_play.find("div").addClass("pause");
|
||||
else
|
||||
this.elements.button_play.find("div").removeClass("pause");
|
||||
if (this.revision_number == this.connection.head_revision)
|
||||
if (this.revision_number == this.connection.getHeadRevision())
|
||||
this.elements.button_right.addClass("disabled");
|
||||
else
|
||||
this.elements.button_right.removeClass("disabled");
|
||||
|
@ -137,7 +137,7 @@ $.Class("RevisionSlider",
|
|||
* @param {callback} atRevision_callback - The callback.
|
||||
*/
|
||||
goToRevision: function (revnum, atRevision_callback) {
|
||||
if (revnum > this.connection.head_revision)
|
||||
if (revnum > this.connection.getHeadRevision())
|
||||
revnum = this.connection.latest_revision;
|
||||
if (revnum < 0)
|
||||
revnum = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ $.Class("SliderHandleUI",
|
|||
* @param {Number} position The initial position for this handle.
|
||||
*/
|
||||
init: function (slider, value, type) {
|
||||
console.log("New SliderHandle(%d, %s)", value, type);
|
||||
//console.log("New SliderHandle(%d, %s)", value, type);
|
||||
this.slider = slider;
|
||||
this.value = value;
|
||||
//create the element:
|
||||
|
@ -52,7 +52,7 @@ $.Class("SliderHandleUI",
|
|||
},
|
||||
_mouseInit: function () {
|
||||
this.element.on("mousedown.sliderhandle", null, this, function(event) {
|
||||
console.log("sliderhandleui - mousedown");
|
||||
//console.log("sliderhandleui - mousedown");
|
||||
});
|
||||
},
|
||||
}
|
||||
|
@ -113,14 +113,14 @@ $.Class("SliderUI",
|
|||
this.render();
|
||||
},
|
||||
createHandle: function (value, type) {
|
||||
console.log("createHandle(%d, %s)", value, type);
|
||||
//console.log("createHandle(%d, %s)", value, type);
|
||||
var handle = new SliderHandleUI(this, value, type);
|
||||
this.handles.push(handle);
|
||||
this.element.append(handle.element);
|
||||
return handle;
|
||||
},
|
||||
_trigger: function (eventname, value) {
|
||||
console.log("triggering event: ", eventname);
|
||||
//console.log("triggering event: ", eventname);
|
||||
if (eventname in this.options) {
|
||||
return this.options[eventname](value);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ $.Class("SliderUI",
|
|||
if (event.target == _this.element[0] || $(event.target).hasClass("ui-slider-handle")) {
|
||||
// the click is on the slider bar itself.
|
||||
var start_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
|
||||
console.log("sliderbar mousedown, value:", start_value);
|
||||
//console.log("sliderbar mousedown, value:", start_value);
|
||||
if (_this.current_value != start_value) {
|
||||
//_this.setValue(start_value);
|
||||
}
|
||||
|
@ -140,10 +140,9 @@ $.Class("SliderUI",
|
|||
|
||||
$(document).on("mousemove.slider", function (event) {
|
||||
var current_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
|
||||
console.log("sliderbar mousemove, value:", current_value);
|
||||
//console.log("sliderbar mousemove, value:", current_value);
|
||||
// don't change the value if it hasn't actually changed!
|
||||
if (prev_value != current_value) {
|
||||
//_this.setValue(current_value);
|
||||
_this._trigger("slide", current_value);
|
||||
prev_value = current_value;
|
||||
}
|
||||
|
@ -154,10 +153,8 @@ $.Class("SliderUI",
|
|||
// we don't need them after this 'slide' session is done.
|
||||
$(document).off("mouseup.slider mousemove.slider");
|
||||
var end_value = Math.floor((event.clientX-_this.element.offset().left) / _this._getStep());
|
||||
console.log("sliderbar mouseup, value:", end_value);
|
||||
//console.log("sliderbar mouseup, value:", end_value);
|
||||
// always change the value at mouseup
|
||||
//_this.setValue(end_value);
|
||||
console.log("here");
|
||||
_this._trigger("change", end_value);
|
||||
|
||||
});
|
||||
|
|
|
@ -228,6 +228,13 @@ AuthenticatedSocketClient("TimesliderClient",
|
|||
getCurrentRevision: function () {
|
||||
return this.padClient.revision;
|
||||
},
|
||||
/**
|
||||
* Get the head revision.
|
||||
* @return {Revision} - the head revision.
|
||||
*/
|
||||
getHeadRevision: function () {
|
||||
return this.head_revision;
|
||||
},
|
||||
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue