Skip to content
This repository was archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
Added panel option, to change root panel element.
Browse files Browse the repository at this point in the history
Resolves #66. Thanks to Modika for the original source work.
  • Loading branch information
Anthony Colangelo committed Nov 11, 2014
1 parent 6a416fe commit a0d94bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ The following options are set via an `object` passed into the constructor functi

***


###<a href="#options-menu" id="options-menu">menu</a>

A selector string pointing to the desired menu element.
Expand All @@ -85,6 +84,15 @@ A selector string pointing to the desired menu element.

***

###<a href="#options-panel" id="options-panel">panel</a>

A selector string pointing to the desired root panel element. Point this to the element containing all content that should go into the panel.

- **Data Type:** `string`
- **Default Value:** `body`

***

###<a href="#options-trigger" id="options-trigger">trigger</a>

A selector string pointing to the menu-triggering element.
Expand Down
9 changes: 9 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ <h3><a href="#options-menu">menu</a></a></h3>
</div>
</div>

<div class="spec first" id="options-panel">
<h3><a href="#options-panel">panel</a></a></h3>
<p>A selector string pointing to the desired root panel element. Point this to the element containing all content that should go into the panel.</p>
<div class="details">
<p><strong>Data Type:</strong> <code>string</code></p>
<p><strong>Default Value:</strong> <code>body</code></p>
</div>
</div>

<div class="spec" id="options-trigger">
<h3><a href="#options-trigger">trigger</a></h3>
<p>A selector string pointing to the menu-triggering element.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/js/example-jRespond.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/script.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions jquery.jpanelmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var jP = {
options: $.extend({
menu: '#menu',
panel: 'body',
trigger: '.menu-trigger',
excludedPanelContent: 'style, scfript',
clone: true,
Expand Down Expand Up @@ -163,11 +164,11 @@

setMenuState: function(open) {
var position = (open)?'open':'closed';
$('body').attr('data-menu-position', position);
$(jP.options.panel).attr('data-menu-position', position);
},

getMenuState: function() {
return $('body').attr('data-menu-position');
return $(jP.options.panel).attr('data-menu-position');
},

menuIsOpen: function() {
Expand Down Expand Up @@ -446,14 +447,14 @@

setupMarkup: function() {
$('html').addClass('jPanelMenu');
$('body > *').not(jP.menu + ', ' + jP.options.excludedPanelContent).wrapAll('<div class="' + jP.panel.replace('.','') + '"/>');
$(jP.options.panel + ' > *').not(jP.menu + ', ' + jP.options.excludedPanelContent).wrapAll('<div class="' + jP.panel.replace('.','') + '"/>');
var menu = ( jP.options.clone )?$(jP.options.menu).clone(jP.options.keepEventHandlers):$(jP.options.menu);
menu.attr('id', jP.menu.replace('#','')).insertAfter('body > ' + jP.panel);
menu.attr('id', jP.menu.replace('#','')).insertAfter(jP.options.panel + ' > ' + jP.panel);
},

resetMarkup: function() {
$('html').removeClass('jPanelMenu');
$('body > ' + jP.panel + ' > *').unwrap();
$(jP.options.panel + ' > ' + jP.panel + ' > *').unwrap();
$(jP.menu).remove();
},

Expand Down

0 comments on commit a0d94bd

Please sign in to comment.