Hi,
first of all very nice module and I choose this one instead of another one...

Is there is the way to put the button inside the Sheet instead of the body?
what I mean is - for example - the website I'm working on are orientated for Photographers, and most of them have a LARGE screens - the website content sheet have fixed width 1024px - so imagine somebody have the screen resolution of width 1920px or more... so the button will be on the edge of the screen, far away from the content.
How to make it inside the content sheet or just next to the border of the content sheet ?
In the attachment I have the current position of the div and desired position the last inside kos-content div, indicated with the arrow.
Please assist if this possible.

CommentFileSizeAuthor
bactotop_placement.png22.42 KBKoshaK
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acke’s picture

Issue summary: View changes
Status: Active » Fixed

I think the best way is to provide the back to top as a block so you can place it, but thats not possible right now. But it should also be possible to change the code in js/back_to_top.js so the selector body instead is your kos-content div, i e:

  var exist= jQuery('#backtotop').length;
    if(exist == 0) {
      $(".kos-content", context).once(function() {

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

upunkt’s picture

I cannot build patches where I'm at work, but here is what I just did to Backtotop 7.x 1.4 to get this functionality mentioned by acke on the Back-to-Top-settings page. Note: I put all code inside php-tags just for better readability.

However, you'll have to alter your CSS also: unset top and left of the button-css and prefer to work with margins. There is some guidance here: http://stackoverflow.com/questions/6794000/fixed-position-but-relative-to-container/15559540#15559540

Maybe acke can add this to his wonderful module.

back_to_top.admin.inc (changes from line 59)

    ),
    '#default_value' => variable_get('back_to_top_button_place', 1),
  );
  $form['back_to_top_parent_container'] = array(
    '#type' => 'textfield',
    '#title' => 'Parent Container',
    '#description' => 'Change the Parent Container of the Button, e.g. for wide screens. Default is "body".',
    '#default_value' => variable_get('back_to_top_parent_container', "body"),
    '#size' => 30,
    '#maxlength' => 60,
  );
  $form['back_to_top_tag_or_div'] = array(
    '#type' => 'radios',
    '#title' => 'Is the parent a tag or a div?',
    '#description' => 'In case of div make sure to provide a unique ID above and not a CSS-class. Default is "Tag".',
    '#options' => array(
    'tag' => t('Tag'),
    'div' => t('Div')
    ),
    '#default_value' => variable_get('back_to_top_tag_or_div', 'tag'),
  );
  $form['back_to_top_button_text'] = array(
    '#type' => 'textfield',
    '#title' => 'Button text', 

back_to_top.module (changes from line 37)

function back_to_top_page_build() {
  $settings = array(
    'back_to_top_prevent_on_mobile' => variable_get('back_to_top_prevent_on_mobile', TRUE),
    'back_to_top_prevent_in_admin' => variable_get('back_to_top_prevent_in_admin', TRUE),
    'back_to_top_button_type' => variable_get('back_to_top_button_type', 'image'),
    'back_to_top_parent_container' => variable_get('back_to_top_parent_container', 'body'),
    'back_to_top_tag_or_div' => variable_get('back_to_top_tag_or_div', 'tag'),
    'back_to_top_button_text' => variable_get('back_to_top_button_text', 'Back to top'),
  );

js/back_to_top.js (changes from line 6)

(function ($) {
	Drupal.behaviors.backtotop = {
		attach: function(context) {
			var exist= jQuery('#backtotop').length;
      if(exist == 0) {
		var $parent_container = Drupal.t(Drupal.settings.back_to_top.back_to_top_parent_container);
		var $tag_or_div = Drupal.t(Drupal.settings.back_to_top.back_to_top_tag_or_div);
		if ($tag_or_div == 'div'){
			$parent_container = '#' + $parent_container;
		}
        $($parent_container, context).once(function() {
          $(this).append("<div id='backtotop'>"+Drupal.t(Drupal.settings.back_to_top.back_to_top_button_text)+"</div>");
        });
      }