summaryrefslogtreecommitdiff
path: root/src/static
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2012-04-15 12:11:46 -0700
committerJohn McLear <john@mclear.co.uk>2012-04-15 12:11:46 -0700
commit7cf4510bf545927edead70931befb7d62ca5863c (patch)
tree08f065276126727696d001d7126fa0b11537fe13 /src/static
parent0e0e084077253be97b992387721b940c8f9ea933 (diff)
parente664320b8ceb734a333c1877a3f358975e55cf33 (diff)
downloadetherpad-lite-7cf4510bf545927edead70931befb7d62ca5863c.zip
Merge pull request #637 from fourplusone/feature/timeslider_cleanup
Feature/timeslider cleanup
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/broadcast_slider.js123
1 files changed, 48 insertions, 75 deletions
diff --git a/src/static/js/broadcast_slider.js b/src/static/js/broadcast_slider.js
index 6dffc0ef..87007263 100644
--- a/src/static/js/broadcast_slider.js
+++ b/src/static/js/broadcast_slider.js
@@ -162,11 +162,8 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
function showReconnectUI()
{
- if (!clientVars.sliderEnabled || !clientVars.supportsSlider)
- {
- $("#padmain, #rightbars").css('top', "130px");
- $("#timeslider").show();
- }
+ $("#padmain, #rightbars").css('top', "130px");
+ $("#timeslider").show();
$('#error').show();
}
@@ -287,55 +284,52 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
{
disableSelection($("#playpause_button")[0]);
disableSelection($("#timeslider")[0]);
-
- if (clientVars.sliderEnabled && clientVars.supportsSlider)
+
+ $(document).keyup(function(e)
{
- $(document).keyup(function(e)
- {
- var code = -1;
- if (!e) var e = window.event;
- if (e.keyCode) code = e.keyCode;
- else if (e.which) code = e.which;
-
- if (code == 37)
- { // left
- if (!e.shiftKey)
- {
- setSliderPosition(getSliderPosition() - 1);
- }
- else
- {
- 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);
- }
+ var code = -1;
+ if (!e) var e = window.event;
+ if (e.keyCode) code = e.keyCode;
+ else if (e.which) code = e.which;
+
+ if (code == 37)
+ { // left
+ if (!e.shiftKey)
+ {
+ setSliderPosition(getSliderPosition() - 1);
}
- else if (code == 39)
+ else
{
- if (!e.shiftKey)
+ var nextStar = 0; // default to first revision in document
+ for (var i = 0; i < savedRevisions.length; i++)
{
- setSliderPosition(getSliderPosition() + 1);
+ var pos = parseInt(savedRevisions[i].attr('pos'));
+ if (pos < getSliderPosition() && nextStar < pos) nextStar = pos;
}
- else
+ setSliderPosition(nextStar);
+ }
+ }
+ else if (code == 39)
+ {
+ if (!e.shiftKey)
+ {
+ setSliderPosition(getSliderPosition() + 1);
+ }
+ else
+ {
+ var nextStar = sliderLength; // default to last revision in document
+ for (var i = 0; i < savedRevisions.length; i++)
{
- var nextStar = sliderLength; // default to last 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);
+ var pos = parseInt(savedRevisions[i].attr('pos'));
+ if (pos > getSliderPosition() && nextStar > pos) nextStar = pos;
}
+ setSliderPosition(nextStar);
}
- else if (code == 32) playpause();
-
- });
- }
+ }
+ else if (code == 32) playpause();
+ });
+
$(window).resize(function()
{
updateSliderElements();
@@ -485,37 +479,16 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
$("#revision").css('right', "20px");
$("#revision").css('top', "20px");
}
-
-
- if (clientVars.sliderEnabled)
- {
- if (clientVars.supportsSlider)
- {
- $("#timeslider").show();
- setSliderLength(clientVars.totalRevs);
- setSliderPosition(clientVars.revNum);
- _.each(clientVars.savedRevisions, function(revision)
- {
- addSavedRevision(revision.revNum, revision);
- })
- }
- else
- {
- // slider is not supported
- $("#padmain, #rightbars").css('top', "130px");
- $("#timeslider").show();
- $("#error").html("The timeslider feature is not supported on this pad. <a href=\"/ep/about/faq#disabledslider\">Why not?</a>");
- $("#error").show();
- }
- }
- else
+
+ $("#timeslider").show();
+ setSliderLength(clientVars.totalRevs);
+ setSliderPosition(clientVars.revNum);
+
+ _.each(clientVars.savedRevisions, function(revision)
{
- if (clientVars.supportsSlider)
- {
- setSliderLength(clientVars.totalRevs);
- setSliderPosition(clientVars.revNum);
- }
- }
+ addSavedRevision(revision.revNum, revision);
+ })
+
}
});
})();