diff --git a/bin/Category.js b/bin/Category.js new file mode 100644 index 0000000000000000000000000000000000000000..d6a73d09372098d5d68ceed670d56852bbc4ea58 --- /dev/null +++ b/bin/Category.js @@ -0,0 +1,109 @@ + +define('packages/quiqqer/faq/bin/Category', [ + + 'qui/QUI', + 'qui/controls/Control' + +], function(QUI, QUIControl) +{ + "use strict"; + + return new Class({ + + Extends : QUIControl, + Type : 'packages/quiqqer/faq/bin/Category', + + Binds : [ + '$onImport', + 'scrollToTop', + '$scrollToClick' + ], + + initialize : function(options) + { + this.parent( options ); + + this.addEvents({ + onImport: this.$onImport + }); + }, + + /** + * event : on import + */ + $onImport : function() + { + var links = this.getElm().getElements( '.quiqqer-faq-list li a'), + topList = this.getElm().getElements( '[href="#top"]' ); + + for ( var i = 0, len = links.length; i < len; i++ ) { + links[ i ].addEvent( 'click', this.$scrollToClick ); + } + + topList.addEvent( 'click', this.scrollToTop ); + + // check location + if ( !window.location.hash || window.location.hash === '' ) { + return; + } + + var Article = this.getElm().getElement( window.location.hash ); + + if ( Article ) { + new Fx.Scroll( window ).toElement( Article ); + } + }, + + /** + * event : on click at a faq entry + * + * @param {DOMEvent} event - click event + */ + $scrollToClick : function(event) + { + if ( typeOf( event ) === 'domevent' ) { + event.stop(); + } + + var Target = event.target, + href = Target.get( 'href' ); + + href = href.split( '#' ); + + if ( typeof href[ 1 ] === 'undefined' ) { + return; + } + + var Article = this.getElm().getElement( '#'+ href[ 1 ] ); + + if ( !Article ) { + return; + } + + new Fx.Scroll(window, { + onComplete: function() + { + window.location = '#'+ href[ 1 ]; + } + }).toElement( Article ); + }, + + /** + * Scroll the window to top and clear the anchor + * + * @param {DOMEvent} [event] - (optional) click dom event + */ + scrollToTop : function(event) + { + if ( typeOf( event ) === 'domevent' ) { + event.stop(); + } + + new Fx.Scroll(window, { + onComplete: function() { + window.location = '#'; + } + }).toTop(); + } + }); +}); diff --git a/bin/types/category.css b/bin/types/category.css new file mode 100644 index 0000000000000000000000000000000000000000..eb902afdf2aab5bd38f8559214f49c03a03abcdb --- /dev/null +++ b/bin/types/category.css @@ -0,0 +1,4 @@ +.quiqqer-faq-list-linkToTop { + clear: both; + float: right; +} \ No newline at end of file diff --git a/types/category.html b/types/category.html index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..251ede606a44a27c7ae1bf58d666816c574d21fe 100644 --- a/types/category.html +++ b/types/category.html @@ -0,0 +1,70 @@ + +<section> + {if $Template->getAttribute('content-header')} + <div class="content-header grid-100 mobile-grid-100"> + <header> + <h1>{$Site->getAttribute('title')}</h1> + </header> + + {if $Site->getAttribute('short')} + <div class="content-short"> + {$Site->getAttribute('short')|nl2br} + </div> + {/if} + </div> + {/if} + + {if $Template->getAttribute('content-body') && $Site->getAttribute('content')} + <div class="content-body grid-100 mobile-grid-100"> + {$Site->getAttribute('content')} + </div> + {/if} +</section> + +<section itemscope itemtype="http://schema.org/ItemList" + class="content-template grid-100 mobile-grid-100" + data-qui="packages/quiqqer/faq/bin/Category" +> + {if count($entries)} + <ul class="quiqqer-faq-list"> + {foreach $entries as $Faq} + <li> + <a href="{url site=$Site}#faq{$Faq->getId()}"> + {$Faq->getAttribute('title')} + </a> + </li> + {/foreach} + </ul> + {/if} + + <hr /> + + {foreach $entries as $Faq} + <article id="faq{$Faq->getId()}"> + <header> + <h2>{$Faq->getAttribute('title')}</h2> + </header> + + {if $Faq->getAttribute('short')} + <div class="content-short"> + {$Faq->getAttribute('short')|nl2br} + </div> + {/if} + + <div class="content-body"> + {$Faq->getAttribute('content')} + </div> + + <a href="#top" class="button quiqqer-faq-list-linkToTop"> + {locale group="quiqqer/faq" value="link.to.top"} + </a> + + </article> + + {if !($Faq@last)} + <hr /> + {/if} + + {/foreach} + +</section> diff --git a/types/category.php b/types/category.php new file mode 100644 index 0000000000000000000000000000000000000000..7131583e5b9f827f40edb5bfa07042aa5944932b --- /dev/null +++ b/types/category.php @@ -0,0 +1,9 @@ +<?php + +$entries = $Site->getChildren(array( + 'type' => 'quiqqer/faq:types/entry' +)); + +$Engine->assign(array( + 'entries' => $entries +)); diff --git a/types/list.html b/types/list.html index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4f06382893d920b6fa96c92d0b1ba6acbe5539fe 100644 --- a/types/list.html +++ b/types/list.html @@ -0,0 +1,55 @@ + +<div> + + {if $Template->getAttribute('content-header')} + <section class="content-header grid-100 mobile-grid-100"> + <header> + <h1>{$Site->getAttribute('title')}</h1> + </header> + + {if $Site->getAttribute('short')} + <div class="content-short"> + {$Site->getAttribute('short')|nl2br} + </div> + {/if} + </section> + {/if} + + {if $Template->getAttribute('content-body') && $Site->getAttribute('content')} + <section class="content-body grid-100 mobile-grid-100"> + {$Site->getAttribute('content')} + </section> + {/if} + + <div class="content-template grid-100 mobile-grid-100"> + + {foreach from=$categories item=Category} + <section class="content-template-faq-list-category"> + <h2> + <a href="{url site=$Category}"> + {$Category->getAttribute('title')} + </a> + </h2> + + <div class="content-short"> + {$Category->getAttribute('short')} + </div> + + {assign var=faqList value=$Category->getChildren()} + {if count($faqList)} + <ul itemscope itemtype="http://schema.org/ItemList"> + {foreach $faqList as $Faq} + <li> + <a href="{url site=$Category}#faq{$Faq->getId()}"> + {$Faq->getAttribute('title')} + </a> + </li> + {/foreach} + </ul> + {/if} + + </section> + {/foreach} + + </div> +</div> \ No newline at end of file diff --git a/types/list.php b/types/list.php new file mode 100644 index 0000000000000000000000000000000000000000..7c418125dcf1fee783e71492c9a39efa231d3421 --- /dev/null +++ b/types/list.php @@ -0,0 +1,9 @@ +<?php + +$categories = $Site->getChildren(array( + 'type' => 'quiqqer/faq:types/category' +)); + +$Engine->assign(array( + 'categories' => $categories +));