mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-30 05:16:33 +08:00
Updating the expand/collapse JS to allow the control key to be overriden and shortened the cookie name
- also making use of the collapse setting to collapse everything by default --HG-- branch : dev
This commit is contained in:
parent
7eedd60af7
commit
006dcd73cc
@ -5,8 +5,10 @@
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
var _this = $(this);
|
var _this = $(this);
|
||||||
|
var __cookieName = "Exp";
|
||||||
var settings = $.extend({
|
var settings = $.extend({
|
||||||
path: "/",
|
path: "/",
|
||||||
|
key: _this.selector,
|
||||||
collapse: false,
|
collapse: false,
|
||||||
remember: true
|
remember: true
|
||||||
}, options);
|
}, options);
|
||||||
@ -15,18 +17,20 @@
|
|||||||
var glyph = $("<span class=\"expandoGlyph\"></span>");
|
var glyph = $("<span class=\"expandoGlyph\"></span>");
|
||||||
|
|
||||||
glyph.data("controllees", getControllees(controller));
|
glyph.data("controllees", getControllees(controller));
|
||||||
if (settings.remember) {
|
if ((settings.remember && "closed" === $.orchard.setting(__cookieName, { key: settings.key + "-" + controller.text(), path: settings.path }))
|
||||||
var state = $.orchard.setting("expando", { key: _this.selector + "-" + controller.text(), path: settings.path });
|
|| settings.collapse) {
|
||||||
if (state === "closed") {
|
glyph.addClass("closed").data("controllees").hide();
|
||||||
glyph.addClass("closed").data("controllees").hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (settings.collapse) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
glyph.click(function () {
|
glyph.click(function () {
|
||||||
var __this = $(this);
|
var __this = $(this);
|
||||||
|
|
||||||
if (settings.remember) { // remembering closed state as true because that's not the default
|
if (settings.remember && !settings.collapse) { // remembering closed state as true because that's not the default - doesn't make sense to remember if the controllees are always to be collapsed by default
|
||||||
// need to allow specified keys since these selectors could get *really* long
|
// need to allow specified keys since these selectors could get *really* long
|
||||||
$.orchard.setting("expando", !__this.hasClass("closed") ? "closed" : "open", { key: _this.selector + "-" + controller.text(), path: settings.path });
|
$.orchard.setting(__cookieName, !__this.hasClass("closed") ? "closed" : "open", { key: settings.key + "-" + controller.text(), path: settings.path });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__this.hasClass("closed") || __this.hasClass("closing")) {
|
if (__this.hasClass("closed") || __this.hasClass("closing")) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<% using (this.Capture("end-of-page-scripts")) { %>
|
<% using (this.Capture("end-of-page-scripts")) { %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { collapse: false, remember: true, path: "<%:ResolveUrl("~/Admin") %>" });
|
$("#navigation h3").expandoControl(function(controller) { return controller.next(); }, { key: "N42", path: "<%:ResolveUrl("~/Admin") %>" });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
Loading…
Reference in New Issue
Block a user