Skip to content

Commit

Permalink
Fixed loading of Main page link in mega menu with no headings. More t…
Browse files Browse the repository at this point in the history
…weaks to Grids.
  • Loading branch information
Paul Jackson authored and Paul Jackson committed Sep 14, 2012
1 parent 9ab1197 commit d2764ee
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 37 deletions.
Binary file modified build/grids/images/module.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build/js/css/pe-ap-ie-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/css/pe-ap-min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/theme-gcwu-intranet/css/theme-ie-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 3 additions & 17 deletions demos/grids/grid-module-eng.html
Expand Up @@ -171,24 +171,10 @@ <h2 class="background-accent">Heading</h2>
<div class="clear"></div>

<h2 id="related"><code>module-related</code> style</h2>
<p>Use the <code>module-related</code> class to feature a <strong>list of links that point to related Web pages</strong>. This module is typically located on the right.</p><div class="span-2"></div>
<p>Use the <code>module-related</code> class to feature a <strong>list of links that point to related Web pages</strong>. This module is typically located on the right.</p><div class="span-4"></div>
<div class="span-2">
<div class="span-2 module-related">
<div class="span-2 module-related">
<h2>Related Links</h2>
<ul>
<li><a href="#related">Fake link </a></li>
<li>Text and <a href="#related">fake link</a></li>
</ul>
</div>
<div class="clear"></div>
<details>
<summary>View code</summary>
<pre>&lt;div class=&quot;span-2 module-related&quot;&gt;<br> &lt;h2&gt;Related Links&lt;/h2&gt;<br> &lt;ul&gt;<br> &lt;li&gt;&lt;a href=&quot;#related&quot;&gt;Fake link &lt;/a&gt;&lt;/li&gt;<br> &lt;li&gt;Text and &lt;a href=&quot;#related&quot;&gt;fake link&lt;/a&gt;&lt;/li&gt;<br> &lt;/ul&gt;<br>&lt;/div&gt;</pre>
</details>
</div>
<div class="span-2">
<div class="span-2 module-related">
<h2 class="background-accent">Related Links</h2>
<ul>
<li><a href="#related">Fake link </a></li>
<li>Text and <a href="#related">fake link</a></li>
Expand All @@ -199,7 +185,7 @@ <h2 class="background-accent">Related Links</h2>
<details>
<summary>View code</summary>
<pre>&lt;div class=&quot;span-2 module-related&quot;&gt;
&lt;h2 class=&quot;background-accent&quot;&gt;Related Links&lt;/h2&gt;
&lt;h2&gt;Related Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#related&quot;&gt;Fake link &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Text and &lt;a href=&quot;#related&quot;&gt;fake link&lt;/a&gt;&lt;/li&gt;
Expand Down
Binary file modified src/grids/images/module.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 25 additions & 16 deletions src/js/pe-ap.js
Expand Up @@ -760,12 +760,12 @@
heading = 'h' + hlevel,
headingOpen = '<' + heading + '>',
headingClose = '</' + heading + '>',
headingNext = 'h' + hlevel + 1,
menuitems = (typeof menusrc.jquery !== 'undefined' ? menusrc : $(menusrc)).find('> div, > ul, ' + heading),
next,
subsection,
hlink,
nested,
hasHeading,
menubar = (mbar !== undefined ? mbar : false),
expand = (expandall !== undefined ? expandall : false),
mainText = pe.dic.get('%main-page'),
Expand All @@ -774,20 +774,15 @@
if (menuitems.get(0).tagName.toLowerCase() === 'ul') {
menu.append($(listView).append(menuitems.first().children('li')));
} else {
hasHeading = menuitems.filter(heading).length !== 0;
menuitems.each(function () {
var $this = $(this);
var $this = $(this),
tagName = this.tagName.toLowerCase();
// If the menu item is a heading
if (this.tagName.toLowerCase() === heading) {
if (tagName === heading) {
hlink = $this.children('a');
subsection = $('<div data-role="collapsible"' + (expand || hlink.hasClass('nav-current') ? ' data-collapsed="false"' : '') + '>' + headingOpen + $this.text() + headingClose + '</div>');
// If the original menu item was in a menu bar
if (menubar) {
$this = $this.parent().find('a').eq(1).closest('ul, div, ' + headingNext).first();
next = $this;
} else {
next = $this.next();
}

next = $this.next();
if (next.get(0).tagName.toLowerCase() === 'ul') {
// The original menu item was not in a menu bar
if (!menubar) {
Expand All @@ -814,17 +809,31 @@
});
subsection.append($(listView).append(next.children('li')));
subsection.find('ul').wrap('<div data-role="controlgroup">' + (nested.length > 0 ? collapsibleSet : '') + '</div>');
} else {
// If the section contains sub-sections
subsection.append(pe.menu.buildmobile($this.parent(), hlevel + 1, theme, false, expand));
} else { // If the section contains sub-sections
if (menubar) {
subsection.append(pe.menu.buildmobile($this.parent().find('.mb-sm'), hlevel + 1, theme, false, expand));
} else {
subsection.append(pe.menu.buildmobile($this.parent(), hlevel + 1, theme, false, expand));
}
// If the original menu item was not in a menu bar
if (!menubar) {
subsection.find('div[data-role="collapsible-set"]').eq(0).append($this.children('a').html(hlink[0].innerHTML + ' - ' + mainText).attr({'data-role': 'button', 'data-theme': theme, 'data-icon': 'arrow-r', 'data-iconpos': 'right'}));
}
}
menu.append(subsection);
} else if (this.tagName.toLowerCase() === 'div') { // If the menu item is a div
menu.append($this.children('a').attr({ 'data-role': 'button', 'data-theme': theme, 'data-icon': 'arrow-r', 'data-iconpos': 'right' }));
} else if (tagName === 'div') { // If the menu item is a div
next = $this.children('a, ul');
if (next.length > 0) {
if (next.get(0).tagName.toLowerCase() === 'a') {
if (hasHeading) {
menu.append('<a href="' + next.attr('href') + '" data-role="button" data-theme="' + theme + '" data-icon="arrow-r" data-iconpos="right">' + next.html() + '</a>');
} else {
menu.append('<ul data-role="listview" data-theme="' + theme + '"><li><a href="' + next.attr('href') + '">' + next.html() + '</a></li></ul>');
}
} else {
menu.append($this.children('ul').attr({ 'data-role': 'listview', 'data-theme': theme }));
}
}
}
});
menu.children().wrapAll(collapsibleSet);
Expand Down
1 change: 1 addition & 0 deletions src/theme-gcwu-intranet/sass/theme-ie.scss
Expand Up @@ -6,6 +6,7 @@
/* -----Build Include Section Start----- */
@import url('includes/default.css');
@import url('includes/default-ie7.css');
@import url('includes/default-ie8.css');
@import url('includes/default-desktop.css');
/* -----Build Include Section End----- */

Expand Down

0 comments on commit d2764ee

Please sign in to comment.