smart show/hide of sidebar if it has content
This commit is contained in:
@@ -12,6 +12,22 @@ function do_search (event, tab) {
|
|||||||
$(this).val( $(form).find("input[name=q]").val() );
|
$(this).val( $(form).find("input[name=q]").val() );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// hide or show sidebars depending on previous state,
|
||||||
|
// and whether the sidebar contains any content (detected by TT)
|
||||||
|
if (has_sidebar[tab] == 0) {
|
||||||
|
$('.sidebar, #sidebar_toggle_img_out').hide();
|
||||||
|
$('.content').css('margin-right', '10px !important');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sidebar_hidden) {
|
||||||
|
$('#sidebar_toggle_img_out').show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.content').css('margin-right', '220px !important');
|
||||||
|
$('.sidebar').show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get the form params
|
// get the form params
|
||||||
var query = $(form).serialize();
|
var query = $(form).serialize();
|
||||||
|
|
||||||
@@ -53,6 +69,10 @@ function do_search (event, tab) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keep track of which tabs have a sidebar, for when switching tab
|
||||||
|
var has_sidebar = {};
|
||||||
|
var sidebar_hidden = 0;
|
||||||
|
|
||||||
// the history.js plugin is great, but fires statechange at pushState
|
// the history.js plugin is great, but fires statechange at pushState
|
||||||
// so we have these semaphpores to help avoid messing the History.
|
// so we have these semaphpores to help avoid messing the History.
|
||||||
|
|
||||||
@@ -121,6 +141,7 @@ $(document).ready(function() {
|
|||||||
$('.device_label_right').toggle();
|
$('.device_label_right').toggle();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
sidebar_hidden = 1;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$('#sidebar_toggle_img_out').click(
|
$('#sidebar_toggle_img_out').click(
|
||||||
@@ -133,6 +154,7 @@ $(document).ready(function() {
|
|||||||
$(window).scrollTop(0);
|
$(window).scrollTop(0);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
sidebar_hidden = 0;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,13 @@
|
|||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
[% FOREACH tab IN vars.tabs %]
|
[% FOREACH tab IN vars.tabs %]
|
||||||
<div id="[% tab.id %]_search" class="tab-pane [% 'active' IF params.tab == tab.id %]">
|
<div id="[% tab.id %]_search" class="tab-pane [% 'active' IF params.tab == tab.id %]">
|
||||||
[%+ TRY %][% INCLUDE "sidebar/device/${tab.id}.tt" %][% CATCH %]<!-- no "[% tab.id %]" search options -->[% END %]
|
[% TRY %]
|
||||||
|
[% INCLUDE "sidebar/device/${tab.id}.tt" %]
|
||||||
|
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 1;</script>
|
||||||
|
[% CATCH %]
|
||||||
|
<!-- no "[% tab.id %]" search options -->
|
||||||
|
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 0;</script>
|
||||||
|
[% END %]
|
||||||
</div> <!-- /tab-pane -->
|
</div> <!-- /tab-pane -->
|
||||||
[% END %]
|
[% END %]
|
||||||
</div> <!-- /tab-content -->
|
</div> <!-- /tab-content -->
|
||||||
|
|||||||
@@ -16,8 +16,10 @@
|
|||||||
[% TRY %]
|
[% TRY %]
|
||||||
[% INCLUDE "sidebar/search/${tab.id}.tt" %]
|
[% INCLUDE "sidebar/search/${tab.id}.tt" %]
|
||||||
<button id="[% tab.id %]_submit" type="submit" class="btn info span3">Search Again</button>
|
<button id="[% tab.id %]_submit" type="submit" class="btn info span3">Search Again</button>
|
||||||
|
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 1;</script>
|
||||||
[% CATCH %]
|
[% CATCH %]
|
||||||
<!-- no "[% tab.id %]" search options -->
|
<!-- no "[% tab.id %]" search options -->
|
||||||
|
<script type="text/javascript">has_sidebar["[% tab.id %]"] = 0;</script>
|
||||||
[% END %]
|
[% END %]
|
||||||
</form>
|
</form>
|
||||||
</div> <!-- /tab-pane -->
|
</div> <!-- /tab-pane -->
|
||||||
|
|||||||
Reference in New Issue
Block a user