2011-12-04 15:33:56 +00:00
|
|
|
/**
|
2013-11-23 19:39:52 +02:00
|
|
|
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
2011-12-04 15:33:56 +00:00
|
|
|
* This helps other people to understand this code better and helps them to improve it.
|
|
|
|
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
|
|
|
*/
|
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
/**
|
|
|
|
* Copyright 2009 Google Inc.
|
2011-07-07 18:59:34 +01:00
|
|
|
*
|
2011-06-20 11:44:04 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-07-07 18:59:34 +01:00
|
|
|
*
|
2011-06-20 11:44:04 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-07-07 18:59:34 +01:00
|
|
|
*
|
2011-06-20 11:44:04 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS-IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-01-26 21:20:26 -08:00
|
|
|
// These parameters were global, now they are injected. A reference to the
|
|
|
|
// Timeslider controller would probably be more appropriate.
|
2012-03-17 13:36:42 +01:00
|
|
|
var _ = require('./underscore');
|
2012-04-23 14:47:07 +02:00
|
|
|
var padmodals = require('./pad_modals').padmodals;
|
2013-12-05 16:41:50 +02:00
|
|
|
var sliderui = require('./sliderui');
|
2013-12-05 18:41:06 +02:00
|
|
|
require('./jquery.class');
|
2013-11-28 18:48:11 +02:00
|
|
|
|
|
|
|
$.Class("RevisionSlider",
|
2013-11-24 20:14:21 +02:00
|
|
|
{//statics
|
|
|
|
},
|
|
|
|
{//instance
|
|
|
|
init: function (timeslider, root_element) {
|
|
|
|
this.timeslider = timeslider;
|
2013-12-02 17:43:39 +02:00
|
|
|
this.revision_number = this.timeslider.head_revision;
|
|
|
|
console.log("New RevisionSlider, head_revision = %d", this.revision_number);
|
2013-11-24 20:14:21 +02:00
|
|
|
// parse the various elements we need:
|
|
|
|
this.elements = {};
|
|
|
|
this.loadElements(root_element);
|
2013-11-28 18:48:11 +02:00
|
|
|
var _this = this;
|
2013-12-12 13:43:33 +02:00
|
|
|
this.slider = new SliderUI(this.elements.slider_bar,
|
2013-11-28 18:48:11 +02:00
|
|
|
options = {
|
|
|
|
max: this.timeslider.head_revision,
|
|
|
|
change: function () { _this.onChange.apply(_this, arguments); },
|
|
|
|
slide: function () { _this.onSlide.apply(_this, arguments); },
|
|
|
|
});
|
2013-12-02 17:43:39 +02:00
|
|
|
this.loadSavedRevisionHandles();
|
|
|
|
|
|
|
|
this._mouseInit();
|
2013-11-28 18:48:11 +02:00
|
|
|
},
|
|
|
|
onChange: function (value) {
|
|
|
|
console.log("in change handler:", value);
|
|
|
|
},
|
|
|
|
onSlide: function (value) {
|
|
|
|
console.log("in slide handler:", value);
|
2013-11-24 20:14:21 +02:00
|
|
|
},
|
|
|
|
loadElements: function (root_element) {
|
2013-12-12 13:43:33 +02:00
|
|
|
this.elements.root = root_element;
|
2013-11-24 20:14:21 +02:00
|
|
|
//this.elements['slider-handle'] = root_element.first("#ui-slider-handle");
|
2013-12-12 13:43:33 +02:00
|
|
|
this.elements.slider_bar = root_element.find("#ui-slider-bar");
|
|
|
|
this.elements.slider = root_element.find("#timeslider-slider");
|
|
|
|
this.elements.button_left = root_element.find("#leftstep");
|
|
|
|
this.elements.button_right = root_element.find("#rightstep");
|
|
|
|
this.elements.button_play = root_element.find("#playpause_button");
|
|
|
|
this.elements.timestamp = root_element.find("#timer");
|
|
|
|
this.elements.revision_label = root_element.find("#revision_label");
|
|
|
|
this.elements.revision_date = root_element.find("#revision_date");
|
|
|
|
this.elements.authors = root_element.first("#authorsList");
|
2013-11-24 20:14:21 +02:00
|
|
|
},
|
2013-12-02 17:43:39 +02:00
|
|
|
loadSavedRevisionHandles: function () {
|
2013-11-24 20:14:21 +02:00
|
|
|
for (var r in this.timeslider.savedRevisions) {
|
|
|
|
var rev = this.timeslider.savedRevisions[r];
|
2013-12-05 16:41:50 +02:00
|
|
|
this.slider.createHandle(rev.revNum, "star");
|
2013-12-12 13:43:33 +02:00
|
|
|
}
|
2013-11-24 20:14:21 +02:00
|
|
|
},
|
|
|
|
goToRevision: function (revNum) {
|
|
|
|
//TODO: this should actually do an async jump to revision (with all the server fetching
|
|
|
|
//and changeset rendering that that implies), and perform the setPosition in a callback.
|
2013-12-02 17:43:39 +02:00
|
|
|
//TODO: we need some kind of callback for setting revision metadata.
|
|
|
|
//TODO: at some point we need to set window.location.hash
|
|
|
|
if (revNum > this.timeslider.head_revision)
|
2013-11-24 20:14:21 +02:00
|
|
|
revNum = this.timeslider.latest_revision;
|
2013-12-02 17:43:39 +02:00
|
|
|
if (revNum < 0)
|
|
|
|
revNum = 0;
|
2013-12-12 13:43:33 +02:00
|
|
|
console.log("GO TO REVISION", revNum);
|
2013-12-12 13:51:03 +02:00
|
|
|
this.elements.revision_label.html(html10n.get("timeslider.version", { "version": revNum }));
|
2013-11-28 18:48:11 +02:00
|
|
|
this.slider.setValue(revNum);
|
2013-12-02 17:43:39 +02:00
|
|
|
this.revision_number = revNum;
|
|
|
|
//TODO: set the enabled/disabled for button-left and button-right
|
2013-11-24 20:14:21 +02:00
|
|
|
},
|
2013-12-02 17:43:39 +02:00
|
|
|
_mouseInit: function () {
|
|
|
|
var _this = this;
|
2013-12-12 13:43:33 +02:00
|
|
|
this.elements.button_left.on("click", function (event) {
|
2013-12-02 17:43:39 +02:00
|
|
|
console.log("was :", _this.revision_number);
|
|
|
|
_this.goToRevision(_this.revision_number - 1);
|
|
|
|
});
|
|
|
|
|
2013-12-12 13:43:33 +02:00
|
|
|
this.elements.button_right.on("click", function (event) {
|
2013-12-02 17:43:39 +02:00
|
|
|
_this.goToRevision(_this.revision_number + 1);
|
|
|
|
});
|
2013-11-24 20:14:21 +02:00
|
|
|
|
2013-12-02 17:43:39 +02:00
|
|
|
}
|
2013-11-24 20:14:21 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
function loadBroadcastSliderJS(tsclient, fireWhenAllScriptsAreLoaded)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-01-26 21:20:26 -08:00
|
|
|
var BroadcastSlider;
|
2011-06-20 11:44:04 +01:00
|
|
|
|
2011-07-07 18:59:34 +01:00
|
|
|
(function()
|
2011-06-20 11:44:04 +01:00
|
|
|
{ // wrap this code in its own namespace
|
2013-11-24 20:14:21 +02:00
|
|
|
|
2013-11-28 18:48:11 +02:00
|
|
|
tsui = new RevisionSlider(tsclient, $("#timeslider-top"));
|
2013-11-24 20:14:21 +02:00
|
|
|
|
|
|
|
// if there was a revision specified in the 'location.hash', jump to it.
|
|
|
|
if (window.location.hash.length > 1) {
|
|
|
|
var rev = Number(window.location.hash.substr(1));
|
|
|
|
if(!isNaN(rev))
|
|
|
|
tsui.goToRevision(rev);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
var sliderLength = 1000;
|
|
|
|
var sliderPos = 0;
|
|
|
|
var sliderActive = false;
|
|
|
|
var slidercallbacks = [];
|
|
|
|
var savedRevisions = [];
|
|
|
|
var sliderPlaying = false;
|
2013-11-24 20:14:21 +02:00
|
|
|
clientVars = tsclient.clientVars;
|
2011-06-20 11:44:04 +01:00
|
|
|
|
|
|
|
function disableSelection(element)
|
|
|
|
{
|
2011-07-07 18:59:34 +01:00
|
|
|
element.onselectstart = function()
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
element.unselectable = "on";
|
|
|
|
element.style.MozUserSelect = "none";
|
|
|
|
element.style.cursor = "default";
|
|
|
|
}
|
2011-07-07 18:59:34 +01:00
|
|
|
var _callSliderCallbacks = function(newval)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
sliderPos = newval;
|
|
|
|
for (var i = 0; i < slidercallbacks.length; i++)
|
|
|
|
{
|
|
|
|
slidercallbacks[i](newval);
|
|
|
|
}
|
2013-12-12 13:43:33 +02:00
|
|
|
};
|
2011-07-07 18:59:34 +01:00
|
|
|
var removeSavedRevision = function(position)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
var element = $("div.star [pos=" + position + "]");
|
|
|
|
savedRevisions.remove(element);
|
|
|
|
element.remove();
|
|
|
|
return element;
|
2012-04-23 14:47:07 +02:00
|
|
|
};
|
2011-06-20 11:44:04 +01:00
|
|
|
|
|
|
|
/* Begin small 'API' */
|
|
|
|
|
|
|
|
function onSlider(callback)
|
|
|
|
{
|
|
|
|
slidercallbacks.push(callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSliderPosition()
|
|
|
|
{
|
|
|
|
return sliderPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSliderPosition(newpos)
|
|
|
|
{
|
|
|
|
newpos = Number(newpos);
|
|
|
|
if (newpos < 0 || newpos > sliderLength) return;
|
2013-02-06 23:35:58 +00:00
|
|
|
if(!newpos){
|
|
|
|
newpos = 0; // stops it from displaying NaN if newpos isn't set
|
|
|
|
}
|
2013-02-07 15:34:10 +01:00
|
|
|
window.location.hash = "#" + newpos;
|
2011-06-20 11:44:04 +01:00
|
|
|
$("#ui-slider-handle").css('left', newpos * ($("#ui-slider-bar").width() - 2) / (sliderLength * 1.0));
|
2011-07-07 18:59:34 +01:00
|
|
|
$("a.tlink").map(function()
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
$(this).attr('href', $(this).attr('thref').replace("%revision%", newpos));
|
|
|
|
});
|
2013-02-07 15:34:10 +01:00
|
|
|
|
2012-12-19 19:55:31 +01:00
|
|
|
$("#revision_label").html(html10n.get("timeslider.version", { "version": newpos}));
|
2011-06-20 11:44:04 +01:00
|
|
|
|
2013-12-12 13:43:33 +02:00
|
|
|
if (newpos === 0)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
$("#leftstar").css('opacity', 0.5);
|
|
|
|
$("#leftstep").css('opacity', 0.5);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#leftstar").css('opacity', 1);
|
|
|
|
$("#leftstep").css('opacity', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newpos == sliderLength)
|
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
$("#rightstar").css('opacity', 0.5);
|
|
|
|
$("#rightstep").css('opacity', 0.5);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#rightstar").css('opacity', 1);
|
|
|
|
$("#rightstep").css('opacity', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
sliderPos = newpos;
|
|
|
|
_callSliderCallbacks(newpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSliderLength()
|
|
|
|
{
|
|
|
|
return sliderLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSliderLength(newlength)
|
|
|
|
{
|
|
|
|
sliderLength = newlength;
|
|
|
|
updateSliderElements();
|
|
|
|
}
|
|
|
|
|
|
|
|
// just take over the whole slider screen with a reconnect message
|
|
|
|
|
|
|
|
function showReconnectUI()
|
|
|
|
{
|
2012-07-14 15:54:44 +02:00
|
|
|
padmodals.showModal("disconnected");
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 18:48:11 +02:00
|
|
|
//TODO: figure out what the hell this is for
|
2012-03-24 20:35:45 +01:00
|
|
|
var fixPadHeight = _.throttle(function(){
|
|
|
|
var height = $('#timeslider-top').height();
|
|
|
|
$('#editorcontainerbox').css({marginTop: height});
|
|
|
|
}, 600);
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
function setAuthors(authors)
|
|
|
|
{
|
2012-03-24 20:35:45 +01:00
|
|
|
var authorsList = $("#authorsList");
|
|
|
|
authorsList.empty();
|
2011-06-20 11:44:04 +01:00
|
|
|
var numAnonymous = 0;
|
|
|
|
var numNamed = 0;
|
2012-03-25 15:48:31 +02:00
|
|
|
var colorsAnonymous = [];
|
2012-03-17 13:36:42 +01:00
|
|
|
_.each(authors, function(author)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-03-25 15:48:31 +02:00
|
|
|
var authorColor = clientVars.colorPalette[author.colorId] || author.colorId;
|
2011-06-20 11:44:04 +01:00
|
|
|
if (author.name)
|
|
|
|
{
|
2012-03-24 20:35:45 +01:00
|
|
|
if (numNamed !== 0) authorsList.append(', ');
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2012-03-25 15:48:31 +02:00
|
|
|
$('<span />')
|
|
|
|
.text(author.name || "unnamed")
|
|
|
|
.css('background-color', authorColor)
|
|
|
|
.addClass('author')
|
|
|
|
.appendTo(authorsList);
|
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
numNamed++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numAnonymous++;
|
2012-03-25 15:48:31 +02:00
|
|
|
if(authorColor) colorsAnonymous.push(authorColor);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (numAnonymous > 0)
|
|
|
|
{
|
2013-07-23 12:43:30 +02:00
|
|
|
var anonymousAuthorString = html10n.get("timeslider.unnamedauthors", { num: numAnonymous });
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2012-03-24 20:35:45 +01:00
|
|
|
if (numNamed !== 0){
|
|
|
|
authorsList.append(' + ' + anonymousAuthorString);
|
|
|
|
} else {
|
|
|
|
authorsList.append(anonymousAuthorString);
|
|
|
|
}
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2012-03-25 15:48:31 +02:00
|
|
|
if(colorsAnonymous.length > 0){
|
|
|
|
authorsList.append(' (');
|
|
|
|
_.each(colorsAnonymous, function(color, i){
|
2013-11-23 19:39:52 +02:00
|
|
|
if( i > 0 ) authorsList.append(' ');
|
2012-04-15 19:18:29 +02:00
|
|
|
$('<span> </span>')
|
2012-03-25 15:48:31 +02:00
|
|
|
.css('background-color', color)
|
|
|
|
.addClass('author author-anonymous')
|
|
|
|
.appendTo(authorsList);
|
|
|
|
});
|
|
|
|
authorsList.append(')');
|
|
|
|
}
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2013-12-12 13:43:33 +02:00
|
|
|
if (authors.length === 0)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-12-19 19:55:31 +01:00
|
|
|
authorsList.append(html10n.get("timeslider.toolbar.authorsList"));
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2012-03-24 20:35:45 +01:00
|
|
|
fixPadHeight();
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
|
2013-12-02 17:43:39 +02:00
|
|
|
//This API is in use by broadcast.js
|
|
|
|
//TODO: refactor broadcast.js to use RevisionSlider instead
|
2012-01-26 21:20:26 -08:00
|
|
|
BroadcastSlider = {
|
2011-06-20 11:44:04 +01:00
|
|
|
onSlider: onSlider,
|
|
|
|
getSliderPosition: getSliderPosition,
|
|
|
|
setSliderPosition: setSliderPosition,
|
|
|
|
getSliderLength: getSliderLength,
|
|
|
|
setSliderLength: setSliderLength,
|
2011-07-07 18:59:34 +01:00
|
|
|
isSliderActive: function()
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
return sliderActive;
|
|
|
|
},
|
|
|
|
playpause: playpause,
|
|
|
|
showReconnectUI: showReconnectUI,
|
|
|
|
setAuthors: setAuthors
|
2013-12-12 13:43:33 +02:00
|
|
|
};
|
2011-06-20 11:44:04 +01:00
|
|
|
|
|
|
|
function playButtonUpdater()
|
|
|
|
{
|
|
|
|
if (sliderPlaying)
|
|
|
|
{
|
|
|
|
if (getSliderPosition() + 1 > sliderLength)
|
|
|
|
{
|
|
|
|
$("#playpause_button_icon").toggleClass('pause');
|
|
|
|
sliderPlaying = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setSliderPosition(getSliderPosition() + 1);
|
|
|
|
|
|
|
|
setTimeout(playButtonUpdater, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function playpause()
|
|
|
|
{
|
|
|
|
$("#playpause_button_icon").toggleClass('pause');
|
|
|
|
|
|
|
|
if (!sliderPlaying)
|
|
|
|
{
|
|
|
|
if (getSliderPosition() == sliderLength) setSliderPosition(0);
|
|
|
|
sliderPlaying = true;
|
|
|
|
playButtonUpdater();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sliderPlaying = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// assign event handlers to html UI elements after page load
|
|
|
|
//$(window).load(function ()
|
2011-07-07 18:59:34 +01:00
|
|
|
fireWhenAllScriptsAreLoaded.push(function()
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
disableSelection($("#playpause_button")[0]);
|
|
|
|
disableSelection($("#timeslider")[0]);
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2012-04-15 19:25:23 +02:00
|
|
|
$(document).keyup(function(e)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-04-15 19:25:23 +02:00
|
|
|
var code = -1;
|
2013-12-12 13:43:33 +02:00
|
|
|
if (!e) e = window.event;
|
2012-04-15 19:25:23 +02:00
|
|
|
if (e.keyCode) code = e.keyCode;
|
|
|
|
else if (e.which) code = e.which;
|
|
|
|
|
|
|
|
if (code == 37)
|
|
|
|
{ // left
|
|
|
|
if (!e.shiftKey)
|
|
|
|
{
|
|
|
|
setSliderPosition(getSliderPosition() - 1);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2012-04-15 19:25:23 +02:00
|
|
|
else
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-04-15 19:25:23 +02:00
|
|
|
var nextStar = 0; // default to first revision in document
|
|
|
|
for (var i = 0; i < savedRevisions.length; i++)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2012-04-15 19:25:23 +02:00
|
|
|
var pos = parseInt(savedRevisions[i].attr('pos'));
|
|
|
|
if (pos < getSliderPosition() && nextStar < pos) nextStar = pos;
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2012-04-15 19:25:23 +02:00
|
|
|
setSliderPosition(nextStar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (code == 39)
|
|
|
|
{
|
|
|
|
if (!e.shiftKey)
|
|
|
|
{
|
|
|
|
setSliderPosition(getSliderPosition() + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
var _nextStar = sliderLength; // default to last revision in document
|
|
|
|
for (var _i = 0; _i < savedRevisions.length; _i++)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
var _pos = parseInt(savedRevisions[_i].attr('pos'));
|
|
|
|
if (_pos > getSliderPosition() && _nextStar > _pos) _nextStar = _pos;
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2013-12-12 13:43:33 +02:00
|
|
|
setSliderPosition(_nextStar);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2012-04-15 19:25:23 +02:00
|
|
|
}
|
|
|
|
else if (code == 32) playpause();
|
2011-06-20 11:44:04 +01:00
|
|
|
|
2012-04-15 19:25:23 +02:00
|
|
|
});
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
|
|
|
|
// play/pause toggling
|
2013-12-02 17:43:39 +02:00
|
|
|
$("XXXX#playpause_button").mousedown(function(evt)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
var self = this;
|
|
|
|
|
2011-06-20 15:37:41 +01:00
|
|
|
$(self).css('background-image', 'url(/static/img/crushed_button_depressed.png)');
|
2011-07-07 18:59:34 +01:00
|
|
|
$(self).mouseup(function(evt2)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2011-06-20 15:37:41 +01:00
|
|
|
$(self).css('background-image', 'url(/static/img/crushed_button_undepressed.png)');
|
2011-06-20 11:44:04 +01:00
|
|
|
$(self).unbind('mouseup');
|
|
|
|
BroadcastSlider.playpause();
|
|
|
|
});
|
2011-07-07 18:59:34 +01:00
|
|
|
$(document).mouseup(function(evt2)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2011-06-20 15:37:41 +01:00
|
|
|
$(self).css('background-image', 'url(/static/img/crushed_button_undepressed.png)');
|
2011-06-20 11:44:04 +01:00
|
|
|
$(document).unbind('mouseup');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// next/prev saved revision and changeset
|
2013-12-02 17:43:39 +02:00
|
|
|
$('XXX.stepper').mousedown(function(evt)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
var self = this;
|
|
|
|
var origcss = $(self).css('background-position');
|
|
|
|
if (!origcss)
|
|
|
|
{
|
|
|
|
origcss = $(self).css('background-position-x') + " " + $(self).css('background-position-y');
|
|
|
|
}
|
|
|
|
var origpos = parseInt(origcss.split(" ")[1]);
|
|
|
|
var newpos = (origpos - 43);
|
|
|
|
if (newpos < 0) newpos += 87;
|
|
|
|
|
|
|
|
var newcss = (origcss.split(" ")[0] + " " + newpos + "px");
|
|
|
|
if ($(self).css('opacity') != 1.0) newcss = origcss;
|
|
|
|
|
2013-12-12 13:43:33 +02:00
|
|
|
$(self).css('background-position', newcss);
|
2011-06-20 11:44:04 +01:00
|
|
|
|
2011-07-07 18:59:34 +01:00
|
|
|
$(self).mouseup(function(evt2)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
$(self).css('background-position', origcss);
|
|
|
|
$(self).unbind('mouseup');
|
|
|
|
$(document).unbind('mouseup');
|
|
|
|
if ($(self).attr("id") == ("leftstep"))
|
|
|
|
{
|
|
|
|
setSliderPosition(getSliderPosition() - 1);
|
|
|
|
}
|
|
|
|
else if ($(self).attr("id") == ("rightstep"))
|
|
|
|
{
|
|
|
|
setSliderPosition(getSliderPosition() + 1);
|
|
|
|
}
|
|
|
|
else if ($(self).attr("id") == ("leftstar"))
|
|
|
|
{
|
|
|
|
var nextStar = 0; // default to first revision in document
|
|
|
|
for (var i = 0; i < savedRevisions.length; i++)
|
|
|
|
{
|
|
|
|
var pos = parseInt(savedRevisions[i].attr('pos'));
|
|
|
|
if (pos < getSliderPosition() && nextStar < pos) nextStar = pos;
|
|
|
|
}
|
|
|
|
setSliderPosition(nextStar);
|
|
|
|
}
|
|
|
|
else if ($(self).attr("id") == ("rightstar"))
|
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
var _nextStar = sliderLength; // default to last revision in document
|
|
|
|
for (var _i = 0; _i < savedRevisions.length; _i++)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
2013-12-12 13:43:33 +02:00
|
|
|
var _pos = parseInt(savedRevisions[_i].attr('pos'));
|
|
|
|
if (_pos > getSliderPosition() && _nextStar > _pos) _nextStar = _pos;
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2013-12-12 13:43:33 +02:00
|
|
|
setSliderPosition(_nextStar);
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
});
|
2011-07-07 18:59:34 +01:00
|
|
|
$(document).mouseup(function(evt2)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
$(self).css('background-position', origcss);
|
|
|
|
$(self).unbind('mouseup');
|
|
|
|
$(document).unbind('mouseup');
|
|
|
|
});
|
2013-12-12 13:43:33 +02:00
|
|
|
});
|
2011-06-20 11:44:04 +01:00
|
|
|
|
|
|
|
if (clientVars)
|
|
|
|
{
|
2012-04-15 19:25:23 +02:00
|
|
|
$("#timeslider").show();
|
2013-11-23 19:39:52 +02:00
|
|
|
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
|
2011-07-07 18:59:34 +01:00
|
|
|
BroadcastSlider.onSlider(function(loc)
|
2011-06-20 11:44:04 +01:00
|
|
|
{
|
|
|
|
$("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content");
|
2013-12-12 13:43:33 +02:00
|
|
|
});
|
2012-01-26 21:20:26 -08:00
|
|
|
|
|
|
|
return BroadcastSlider;
|
2011-06-20 11:44:04 +01:00
|
|
|
}
|
2012-01-15 17:23:48 -08:00
|
|
|
|
|
|
|
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|