Skip to content
This repository
Browse code

fix bug 855714 - Restore previous editor scrolling behavior

  • Loading branch information...
commit 51cadb8425fc102e39fc07b72ebb7a72b1d293a4 1 parent 5428513
David Walsh darkwing authored

Showing 1 changed file with 40 additions and 62 deletions. Show diff stats Hide diff stats

  1. +40 62 media/js/wiki_ckeditor.js
102 media/js/wiki_ckeditor.js
... ... @@ -1,81 +1,59 @@
1   -(function() {
  1 +(function () {
2 2
3 3 // Callback functions after CKE is ready
4   - var setup_ckeditor = function() {
  4 + var setup_ckeditor = function () {
5 5
6   - var $head = $("#article-head"),
7   - $tools = $(".cke_toolbox"),
8   - contentTop = $("#content").offset(),
9   - headHeight = $head.height(),
10   - toolHeight = $tools.height(),
11   - contentBottom = $(".page-meta").first().offset().top - 300,
12   - fixed = false;
  6 + var $head = $("#article-head");
  7 + var $tools = $(".cke_toolbox");
  8 + var contentTop = $("#content").offset();
  9 + var headHeight = $head.height();
  10 + var toolHeight = $tools.height();
  11 + var fixed = false;
13 12
14 13 // Switch header and toolbar styles on scroll to keep them on screen
15 14 $(document).scroll(function() {
16   - //Position of the first metadata at 300px of the top
17   - if ($(this).scrollTop() >= contentTop.top && $(this).scrollTop() < contentBottom) { // If top of the window is betwen top of #content and top of metadata (first .page-meta) blocks, the header is fixed
18   - if (!fixed) {
19   - fixed = true;
20   - $head.css({
21   - position: "fixed",
22   - top: 19,
23   - width: "95%"
24   - });
25   - $tools.css({
26   - position: "fixed",
27   - top: headHeight + 28,
28   - width: $("#cke_id_content").width() - 11
29   - });
30   - $("td.cke_top").css({
31   - height: toolHeight + 28
32   - });
33   - $("#cke_id_content").css({
34   - marginTop: headHeight
35   - });
  15 + var contentBottom = $(".page-meta").first().offset().top - 300; //Position of the first metadata at 300px of the top
  16 + if( $(this).scrollTop() >= contentTop.top && $(this).scrollTop() < contentBottom ) { // If top of the window is betwen top of #content and top of metadata (first .page-meta) blocks, the header is fixed
  17 + if( !fixed ) {
  18 + fixed = true;
  19 + $head.css({position:'fixed', top:19, width:"95%"});
  20 + $tools.css({position:'fixed', top:headHeight+28, width:$("#cke_id_content").width()-11});
  21 + $("td.cke_top").css({ height: toolHeight+28 });
  22 + $("#cke_id_content").css({ marginTop: headHeight });
  23 + }
  24 + } else { // If not, header is relative
  25 + if( fixed ) {
  26 + fixed = false;
  27 + $head.css({position:'relative', top:"auto", width:"auto"});
  28 + $tools.css({position:'relative', top:"auto", width:"auto"});
  29 + $("td.cke_top").css({ height: "auto" });
  30 + $("#cke_id_content").css({ marginTop: 0 });
  31 + }
36 32 }
37   - } else { // If not, header is relative
38   - if (fixed) {
39   - fixed = false;
40   - $head.css({
41   - position: "relative",
42   - top: "auto",
43   - width: "auto"
44   - });
45   - $tools.css({
46   - position: "relative",
47   - top: "auto",
48   - width: "auto"
49   - });
50   - $("td.cke_top").css({
51   - height: "auto"
52   - });
53   - $("#cke_id_content").css({
54   - marginTop: 0
55   - });
56   - }
57   - }
58 33 });
59 34
60 35 $(window).resize(function() { // Recalculate box width on resize
61   - if (fixed) {
62   - $tools.css({
63   - width: $("#cke_id_content").width() - 10
64   - }); // Readjust toolbox to fit
  36 + if ( fixed ) {
  37 + $tools.css({width:$("#cke_id_content").width()-10}); // Readjust toolbox to fit
65 38 }
66 39 });
67 40
68 41 // remove the id_content required attribute
69   - $("#id_content").removeAttr("required");
  42 + $('#id_content').removeAttr("required");
70 43
71 44 };
72 45
73   - $("#id_content").each(function() {
74   - if (!$("body").is(".edit.is-template")) {
75   - $(this).ckeditor(setup_ckeditor, {
76   - customConfig: "/docs/ckeditor_config.js"
77   - });
78   - }
  46 + jQuery("#id_content").each(function () {
  47 +
  48 + var el = jQuery(this),
  49 + doc_slug = $('#id_slug').val();
  50 +
  51 + if (!$('body').is('.is-template')) {
  52 + el.ckeditor(setup_ckeditor, {
  53 + customConfig : '/docs/ckeditor_config.js'
  54 + });
  55 + }
  56 +
79 57 });
80 58
81   -})(jQuery);
  59 +})();

0 comments on commit 51cadb8

Please sign in to comment.
Something went wrong with that request. Please try again.