Merge pull request #1418 from mluto/timeslider-jump-revisions
Jump to revisions in timeslider
This commit is contained in:
Коммит
e1cd34763d
|
@ -107,6 +107,7 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
{
|
||||
newpos = Number(newpos);
|
||||
if (newpos < 0 || newpos > sliderLength) return;
|
||||
window.location.hash = "#" + newpos;
|
||||
$("#ui-slider-handle").css('left', newpos * ($("#ui-slider-bar").width() - 2) / (sliderLength * 1.0));
|
||||
$("a.tlink").map(function()
|
||||
{
|
||||
|
@ -481,6 +482,18 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
|||
}
|
||||
|
||||
$("#timeslider").show();
|
||||
|
||||
var startPos = clientVars.collab_client_vars.rev;
|
||||
if(window.location.hash.length > 1)
|
||||
{
|
||||
var hashRev = Number(window.location.hash.substr(1));
|
||||
if(!isNaN(hashRev))
|
||||
{
|
||||
// this is necessary because of the socket.io-event which loads the changesets
|
||||
setTimeout(function() { setSliderPosition(hashRev); }, 1);
|
||||
}
|
||||
}
|
||||
|
||||
setSliderLength(clientVars.collab_client_vars.rev);
|
||||
setSliderPosition(clientVars.collab_client_vars.rev);
|
||||
|
||||
|
|
|
@ -57,4 +57,95 @@ describe("timeslider", function(){
|
|||
}, 6000);
|
||||
}, revs*timePerRev);
|
||||
});
|
||||
|
||||
it("changes the url when clicking on the timeslider", function(done) {
|
||||
var inner$ = helper.padInner$;
|
||||
var chrome$ = helper.padChrome$;
|
||||
|
||||
// make some changes to produce 7 revisions
|
||||
var timePerRev = 900
|
||||
, revs = 7;
|
||||
this.timeout(revs*timePerRev+10000);
|
||||
for(var i=0; i < revs; i++) {
|
||||
setTimeout(function() {
|
||||
// enter 'a' in the first text element
|
||||
inner$("div").first().sendkeys('a');
|
||||
}, timePerRev*i);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider');
|
||||
|
||||
setTimeout(function() {
|
||||
var timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
var $sliderBar = timeslider$('#ui-slider-bar');
|
||||
|
||||
var latestContents = timeslider$('#padcontent').text();
|
||||
|
||||
var oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
||||
|
||||
// Click somewhere on the timeslider
|
||||
var e = new jQuery.Event('mousedown');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = 60;
|
||||
$sliderBar.trigger(e);
|
||||
|
||||
helper.waitFor(function(){
|
||||
return $('#iframe-container iframe')[0].contentWindow.location.hash != oldUrl;
|
||||
}, 6000).always(function(){
|
||||
expect( $('#iframe-container iframe')[0].contentWindow.location.hash ).not.to.eql( oldUrl );
|
||||
done();
|
||||
});
|
||||
}, 6000);
|
||||
}, revs*timePerRev);
|
||||
});
|
||||
|
||||
it("jumps to a revision given in the url", function(done) {
|
||||
var inner$ = helper.padInner$;
|
||||
var chrome$ = helper.padChrome$;
|
||||
this.timeout(11000);
|
||||
inner$("div").first().sendkeys('a');
|
||||
|
||||
setTimeout(function() {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider#0');
|
||||
var timeslider$;
|
||||
|
||||
helper.waitFor(function(){
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
return timeslider$ && timeslider$('#padcontent').text().length == 230;
|
||||
}, 6000).always(function(){
|
||||
expect( timeslider$('#padcontent').text().length ).to.eql( 230 );
|
||||
done();
|
||||
});
|
||||
}, 2500);
|
||||
});
|
||||
|
||||
it("checks the export url", function(done) {
|
||||
var inner$ = helper.padInner$;
|
||||
var chrome$ = helper.padChrome$;
|
||||
this.timeout(11000);
|
||||
inner$("div").first().sendkeys('a');
|
||||
|
||||
setTimeout(function() {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider#0');
|
||||
var timeslider$;
|
||||
var exportLink;
|
||||
|
||||
helper.waitFor(function(){
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
if(!timeslider$)
|
||||
return false;
|
||||
exportLink = timeslider$('#exportplaina').attr('href');
|
||||
if(!exportLink)
|
||||
return false;
|
||||
return exportLink.substr(exportLink.length - 12) == "0/export/txt";
|
||||
}, 6000).always(function(){
|
||||
expect( exportLink.substr(exportLink.length - 12) ).to.eql( "0/export/txt" );
|
||||
done();
|
||||
});
|
||||
}, 2500);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче