Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fullscreen button #121

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions installer/templates/new/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import '../stylesheets/application.scss';

import $ from 'jquery';
import {Kitto} from 'kitto';
import fscreen from 'fscreen';

window.jQuery = window.$ = $;

Kitto.start();

var i = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

application.js is meant for the user to extend / modify appearance and behaviour.

Let's have this in an initializeFullScreenButton function in https://github.com/kittoframework/kitto/blob/master/priv/static/kitto.js also move the fscreen import there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like the following (haven't tried it):

function initializeFullScreenButton() {
  var timer;
  var $button = $('.fullscreen-button');

  $('body').on('mousemove', function() {
    clearTimeout(timer);
    if (!$button.hasClass('active')) { $button.addClass('active') }
    timer = setTimeout(function() { $button.removeClass('active') }, 1000);
  })

  $button.on('click', function() {
    fscreen.requestFullscreen(document.getElementById('container'));
  })

  return this;
}

which will be called in Kitto.start

$("body").mousemove(function() {
clearTimeout(i);
$(".fullscreen-button").addClass("active");
i = setTimeout('$(".fullscreen-button").removeClass("active");', 1000);
})

$(".fullscreen-button").click(function() {
var ele = document.getElementById("container");
fscreen.requestFullscreen(ele);
})
13 changes: 13 additions & 0 deletions installer/templates/new/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ h3 {
padding-top: 5px;
}

.fullscreen-button {
cursor: pointer;
position: fixed;
right: 5px;
top: 5px;
opacity: 0;
transition: opacity 0.5s ease-out;

&.active {
opacity: 1;
}
}

// ----------------------------------------------------------------------------
// Clearfix
// ----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions installer/templates/new/dashboards/layout.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<%= @template %>
</div>

<i class="fullscreen-button fa fa-arrows-alt"></i>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have this before the #container div.


<script type="text/javascript" src="/assets/application.js"></script>
<script type="text/javascript" src="/assets/widgets.js"></script>
</body>
Expand Down
3 changes: 2 additions & 1 deletion installer/templates/new/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"imports": "^1.0.0",
"rickshaw": "1.6.0",
"jquery": "2.2.3",
"jquery-knob": "1.2.11"
"jquery-knob": "1.2.11",
"fscreen": "^1.0.2"
}
}