Move sidebar JS to application bundle
It's required on the main page so will nearly always be loaded anyway. Enclosed in an anonymous function to avoid leaking the onclose global.
This commit is contained in:
parent
434e603cd6
commit
d6a8aaa369
3 changed files with 41 additions and 44 deletions
|
@ -10,6 +10,7 @@
|
||||||
//= require export
|
//= require export
|
||||||
//= require map
|
//= require map
|
||||||
//= require menu
|
//= require menu
|
||||||
|
//= require sidebar
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called as the user scrolls/zooms around to aniplate hrefs of the
|
* Called as the user scrolls/zooms around to aniplate hrefs of the
|
||||||
|
|
40
app/assets/javascripts/sidebar.js
Normal file
40
app/assets/javascripts/sidebar.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
var openSidebar;
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var onclose;
|
||||||
|
|
||||||
|
openSidebar = function(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
if (onclose) {
|
||||||
|
onclose();
|
||||||
|
onclose = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.title) { $("#sidebar_title").html(options.title); }
|
||||||
|
|
||||||
|
if (options.width) { $("#sidebar").width(options.width); }
|
||||||
|
else { $("#sidebar").width("30%"); }
|
||||||
|
|
||||||
|
$("#sidebar").css("display", "block");
|
||||||
|
|
||||||
|
$("#sidebar").trigger("opened");
|
||||||
|
|
||||||
|
onclose = options.onclose;
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$(".sidebar_close").click(function (e) {
|
||||||
|
$("#sidebar").css("display", "none");
|
||||||
|
|
||||||
|
$("#sidebar").trigger("closed");
|
||||||
|
|
||||||
|
if (onclose) {
|
||||||
|
onclose();
|
||||||
|
onclose = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
|
@ -8,47 +8,3 @@
|
||||||
<div id="sidebar_content">
|
<div id="sidebar_content">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
<!--
|
|
||||||
var onclose;
|
|
||||||
|
|
||||||
function openSidebar(options) {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
if (onclose) {
|
|
||||||
onclose();
|
|
||||||
onclose = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.title) { $("#sidebar_title").html(options.title); }
|
|
||||||
|
|
||||||
if (options.width) { $("#sidebar").width(options.width); }
|
|
||||||
else { $("#sidebar").width("30%"); }
|
|
||||||
|
|
||||||
$("#sidebar").css("display", "block");
|
|
||||||
|
|
||||||
$("#sidebar").trigger("opened");
|
|
||||||
|
|
||||||
onclose = options.onclose;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".sidebar_close").click(function (e) {
|
|
||||||
$("#sidebar").css("display", "none");
|
|
||||||
|
|
||||||
$("#sidebar").trigger("closed");
|
|
||||||
|
|
||||||
if (onclose) {
|
|
||||||
onclose();
|
|
||||||
onclose = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
function updateSidebar(title, content) {
|
|
||||||
$("#sidebar_title").html(title);
|
|
||||||
$("#sidebar_content").html(content);
|
|
||||||
}
|
|
||||||
// -->
|
|
||||||
</script>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue