Skip to content
Code-Schnipsel Gruppen Projekte
Commit ac037370 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

code style

Übergeordneter 6032dfd5
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
/**
* Category handling
* Set events and scroll effects
*
* @module package/quiqqer/faq/bin/Category
* @author www.pcsg.de (Henning Leutz)
*
* @require qui/QUI
* @require qui/controls/Control
*/
define('package/quiqqer/faq/bin/Category', [ define('package/quiqqer/faq/bin/Category', [
'qui/QUI', 'qui/QUI',
'qui/controls/Control' 'qui/controls/Control'
], function(QUI, QUIControl) ], function (QUI, QUIControl) {
{
"use strict"; "use strict";
return new Class({ return new Class({
Extends : QUIControl, Extends: QUIControl,
Type : 'package/quiqqer/faq/bin/Category', Type : 'package/quiqqer/faq/bin/Category',
Binds : [ Binds: [
'$onImport', '$onImport',
'scrollToTop', 'scrollToTop',
'$scrollToClick' '$scrollToClick'
], ],
initialize : function(options) initialize: function (options) {
{ this.parent(options);
this.parent( options );
this.addEvents({ this.addEvents({
onImport: this.$onImport onImport: this.$onImport
...@@ -31,26 +38,25 @@ define('package/quiqqer/faq/bin/Category', [ ...@@ -31,26 +38,25 @@ define('package/quiqqer/faq/bin/Category', [
/** /**
* event : on import * event : on import
*/ */
$onImport : function() $onImport: function () {
{ var links = this.getElm().getElements('.quiqqer-faq-list li a'),
var links = this.getElm().getElements( '.quiqqer-faq-list li a'), topList = this.getElm().getElements('[href="#top"]');
topList = this.getElm().getElements( '[href="#top"]' );
for ( var i = 0, len = links.length; i < len; i++ ) { for (var i = 0, len = links.length; i < len; i++) {
links[ i ].addEvent( 'click', this.$scrollToClick ); links[i].addEvent('click', this.$scrollToClick);
} }
topList.addEvent( 'click', this.scrollToTop ); topList.addEvent('click', this.scrollToTop);
// check location // check location
if ( !window.location.hash || window.location.hash === '' ) { if (!window.location.hash || window.location.hash === '') {
return; return;
} }
var Article = this.getElm().getElement( window.location.hash ); var Article = this.getElm().getElement(window.location.hash);
if ( Article ) { if (Article) {
new Fx.Scroll( window ).toElement( Article ); new Fx.Scroll(window).toElement(Article);
} }
}, },
...@@ -59,33 +65,31 @@ define('package/quiqqer/faq/bin/Category', [ ...@@ -59,33 +65,31 @@ define('package/quiqqer/faq/bin/Category', [
* *
* @param {DOMEvent} event - click event * @param {DOMEvent} event - click event
*/ */
$scrollToClick : function(event) $scrollToClick: function (event) {
{ if (typeOf(event) === 'domevent') {
if ( typeOf( event ) === 'domevent' ) {
event.stop(); event.stop();
} }
var Target = event.target, var Target = event.target,
href = Target.get( 'href' ); href = Target.get('href');
href = href.split( '#' ); href = href.split('#');
if ( typeof href[ 1 ] === 'undefined' ) { if (typeof href[1] === 'undefined') {
return; return;
} }
var Article = this.getElm().getElement( '#'+ href[ 1 ] ); var Article = this.getElm().getElement('#' + href[1]);
if ( !Article ) { if (!Article) {
return; return;
} }
new Fx.Scroll(window, { new Fx.Scroll(window, {
onComplete: function() onComplete: function () {
{ window.location = '#' + href[1];
window.location = '#'+ href[ 1 ];
} }
}).toElement( Article ); }).toElement(Article);
}, },
/** /**
...@@ -93,14 +97,13 @@ define('package/quiqqer/faq/bin/Category', [ ...@@ -93,14 +97,13 @@ define('package/quiqqer/faq/bin/Category', [
* *
* @param {DOMEvent} [event] - (optional) click dom event * @param {DOMEvent} [event] - (optional) click dom event
*/ */
scrollToTop : function(event) scrollToTop: function (event) {
{ if (typeOf(event) === 'domevent') {
if ( typeOf( event ) === 'domevent' ) {
event.stop(); event.stop();
} }
new Fx.Scroll(window, { new Fx.Scroll(window, {
onComplete: function() { onComplete: function () {
window.location = '#'; window.location = '#';
} }
}).toTop(); }).toTop();
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren