Skip to content

Commit e688265

Browse files
up AutoFixed
1 parent 6cc451c commit e688265

File tree

3 files changed

+97
-19
lines changed

3 files changed

+97
-19
lines changed

deploy/normal/modules/JC.AutoFixed/0.1/AutoFixed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs_api/files/.._modules_JC.AutoFixed_0.1_AutoFixed.js.html

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,26 +544,35 @@ <h1 class="file-heading">File: ../modules/JC.AutoFixed/0.1/AutoFixed.js</h1>
544544
var _clickTs = JC.f.ts();
545545
_p._model.highlightTrigger().on( &#x27;click&#x27;, function(){
546546
_clickTs = JC.f.ts();
547-
_p.trigger( &#x27;setCurHighlight&#x27;, [ this ] );
547+
var _eles = _p._model.findTargetAnchorAndLayout( $( this )) || {};
548+
_p.trigger( &#x27;setCurHighlight&#x27;, [ this, _eles.layout ] );
548549
});
549550

550-
_p.on( &#x27;setCurHighlight&#x27;, function( _evt, _src ){
551+
_p.on( &#x27;setCurHighlight&#x27;, function( _evt, _src, _layout ){
551552
_src = $( _src );
552553
if( !( _src &amp;&amp; _src.length ) ) return;
553554
_p._model.lastHighlightItem() &amp;&amp; _p._model.lastHighlightItem().removeClass( _p._model.highlightClass() );
554555
_src.addClass( _p._model.highlightClass() );
555556
_p._model.lastHighlightItem( _src );
556557

558+
if( _layout &amp;&amp; _layout.length ){
559+
_p._model.lastHighlightLayout() &amp;&amp; _p._model.lastHighlightLayout().removeClass( _p._model.highlightLayoutClass() );
560+
_layout.addClass( _p._model.highlightLayoutClass() );
561+
_p._model.lastHighlightLayout( _layout );
562+
}
563+
557564
});
558565

559566
JWIN.on( &#x27;scroll&#x27;, function( _evt ){
560567
if( JC.f.ts() - _clickTs &lt; 200 ) return;
561-
var _st = JDOC.scrollTop(), _curItem;
568+
var _st = JDOC.scrollTop()
569+
, _curItem
570+
, _anchorOffset
571+
;
562572
_p._model.highlightTrigger().each( function(){
563573
var _src = $( this )
564574
, _anchorName = _src.attr( &#x27;href&#x27; ).replace( /^\#/, &#x27;&#x27; )
565575
, _anchor
566-
, _anchorOffset
567576
;
568577
if( !_anchorName ) return;
569578
_anchor = $( JC.f.printf( &#x27;a[name={0}]&#x27;, _anchorName ) ).first();
@@ -575,9 +584,10 @@ <h1 class="file-heading">File: ../modules/JC.AutoFixed/0.1/AutoFixed.js</h1>
575584
return false;
576585
}
577586
});
587+
_anchorOffset = _anchorOffset || {};
578588
if( _curItem ){
579589
//JC.log( &#x27;_curItem&#x27;, _curItem.attr( &#x27;name&#x27; ) );
580-
_p.trigger( &#x27;setCurHighlight&#x27;, [ _curItem ] );
590+
_p.trigger( &#x27;setCurHighlight&#x27;, [ _curItem, _anchorOffset.layout ] );
581591
}
582592
});
583593

@@ -598,27 +608,55 @@ <h1 class="file-heading">File: ../modules/JC.AutoFixed/0.1/AutoFixed.js</h1>
598608
//JC.log( &#x27;AutoFixed.Model.init:&#x27;, new Date().getTime() );
599609
}
600610

611+
, findTargetAnchorAndLayout:
612+
function( _trigger ){
613+
var _src = $( _trigger )
614+
, _anchorName = _src.attr( &#x27;href&#x27; ).replace( /^\#/, &#x27;&#x27; )
615+
, _anchor
616+
, _anchorOffset
617+
, _r = null
618+
;
619+
if( !_anchorName ) return _r;
620+
_anchor = $( JC.f.printf( &#x27;a[name={0}]&#x27;, _anchorName ) ).first();
621+
if( !_anchor.length ) return _r;
622+
_r = { trigger: _src, target: _anchor, layout: this.highlightAnchorLayout( _anchor ) };
623+
624+
return _r;
625+
}
626+
601627
, gid:
602628
function(){
603629
!this._gid &amp;&amp; ( this._gid = JC.f.gid() );
604630
return this._gid;
605631
}
606632

633+
, lastHighlightLayout:
634+
function( _setter ){
635+
_setter &amp;&amp; ( this._lastHighlightLayout = _setter );
636+
return this._lastHighlightLayout;
637+
}
638+
639+
, highlightLayoutClass:
640+
function(){
641+
return this.attrProp( &#x27;data-highlightLayoutClass&#x27; ) || this.highlightClass() || &#x27;cur&#x27;;
642+
}
643+
607644
, lastHighlightItem:
608645
function( _setter ){
609646
_setter &amp;&amp; ( this._lastHighlightItem = _setter );
610647
return this._lastHighlightItem;
611648
}
612649

613-
, highlightTrigger:
650+
, highlightClass:
614651
function(){
615-
return this.selectorProp( &#x27;data-highlightTrigger&#x27; );
652+
return this.attrProp( &#x27;data-highlightClass&#x27; ) || &#x27;cur&#x27;;
616653
}
617654

618-
, highlightClass:
655+
, highlightTrigger:
619656
function(){
620-
return this.attrProp( &#x27;data-highlightClass&#x27; ) || &#x27;cur&#x27;;
657+
return this.selectorProp( &#x27;data-highlightTrigger&#x27; );
621658
}
659+
622660
, anchorOffset:
623661
function( _a ){
624662
var _r = _a.offset(), _layout = this.highlightAnchorLayout( _a ), _tmp;
@@ -627,6 +665,7 @@ <h1 class="file-heading">File: ../modules/JC.AutoFixed/0.1/AutoFixed.js</h1>
627665
_r = _layout.offset();
628666
_r.top += _layout.height();
629667
}
668+
_r.layout = _layout;
630669

631670
return _r;
632671
}

0 commit comments

Comments
 (0)