Skip to content
Browse files

fix bug 855714 - Restore previous editor scrolling behavior

  • Loading branch information...
1 parent 5428513 commit 51cadb8425fc102e39fc07b72ebb7a72b1d293a4 @darkwing darkwing committed Mar 28, 2013
Showing with 40 additions and 62 deletions.
  1. +40 −62 media/js/wiki_ckeditor.js
View
102 media/js/wiki_ckeditor.js
@@ -1,81 +1,59 @@
-(function() {
+(function () {
// Callback functions after CKE is ready
- var setup_ckeditor = function() {
+ var setup_ckeditor = function () {
- var $head = $("#article-head"),
- $tools = $(".cke_toolbox"),
- contentTop = $("#content").offset(),
- headHeight = $head.height(),
- toolHeight = $tools.height(),
- contentBottom = $(".page-meta").first().offset().top - 300,
- fixed = false;
+ var $head = $("#article-head");
+ var $tools = $(".cke_toolbox");
+ var contentTop = $("#content").offset();
+ var headHeight = $head.height();
+ var toolHeight = $tools.height();
+ var fixed = false;
// Switch header and toolbar styles on scroll to keep them on screen
$(document).scroll(function() {
- //Position of the first metadata at 300px of the top
- 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
- if (!fixed) {
- fixed = true;
- $head.css({
- position: "fixed",
- top: 19,
- width: "95%"
- });
- $tools.css({
- position: "fixed",
- top: headHeight + 28,
- width: $("#cke_id_content").width() - 11
- });
- $("td.cke_top").css({
- height: toolHeight + 28
- });
- $("#cke_id_content").css({
- marginTop: headHeight
- });
+ var contentBottom = $(".page-meta").first().offset().top - 300; //Position of the first metadata at 300px of the top
+ 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
+ if( !fixed ) {
+ fixed = true;
+ $head.css({position:'fixed', top:19, width:"95%"});
+ $tools.css({position:'fixed', top:headHeight+28, width:$("#cke_id_content").width()-11});
+ $("td.cke_top").css({ height: toolHeight+28 });
+ $("#cke_id_content").css({ marginTop: headHeight });
+ }
+ } else { // If not, header is relative
+ if( fixed ) {
+ fixed = false;
+ $head.css({position:'relative', top:"auto", width:"auto"});
+ $tools.css({position:'relative', top:"auto", width:"auto"});
+ $("td.cke_top").css({ height: "auto" });
+ $("#cke_id_content").css({ marginTop: 0 });
+ }
}
- } else { // If not, header is relative
- if (fixed) {
- fixed = false;
- $head.css({
- position: "relative",
- top: "auto",
- width: "auto"
- });
- $tools.css({
- position: "relative",
- top: "auto",
- width: "auto"
- });
- $("td.cke_top").css({
- height: "auto"
- });
- $("#cke_id_content").css({
- marginTop: 0
- });
- }
- }
});
$(window).resize(function() { // Recalculate box width on resize
- if (fixed) {
- $tools.css({
- width: $("#cke_id_content").width() - 10
- }); // Readjust toolbox to fit
+ if ( fixed ) {
+ $tools.css({width:$("#cke_id_content").width()-10}); // Readjust toolbox to fit
}
});
// remove the id_content required attribute
- $("#id_content").removeAttr("required");
+ $('#id_content').removeAttr("required");
};
- $("#id_content").each(function() {
- if (!$("body").is(".edit.is-template")) {
- $(this).ckeditor(setup_ckeditor, {
- customConfig: "/docs/ckeditor_config.js"
- });
- }
+ jQuery("#id_content").each(function () {
+
+ var el = jQuery(this),
+ doc_slug = $('#id_slug').val();
+
+ if (!$('body').is('.is-template')) {
+ el.ckeditor(setup_ckeditor, {
+ customConfig : '/docs/ckeditor_config.js'
+ });
+ }
+
});
-})(jQuery);
+})();

0 comments on commit 51cadb8

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