@@ -568,16 +568,16 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
568
568
} ) ;
569
569
if ( opts . multiple ) { // Can choose multiple rows
570
570
$footer . show ( ) ;
571
- $footer . find ( 'label:first' ) . show ( ) ; // Check all
572
- $footer . find ( 'input[type="checkbox"]:first' ) . click ( function ( ) {
573
- var active = $ ( this ) . data ( 'active' ) ;
574
- $wrapper . find ( 'input[type="checkbox"]' ) . each ( function ( ) {
575
- var $this = $ ( this ) ;
576
- if ( active && $this . is ( ':checked' ) ) $this . closest ( 'tr' ) . click ( ) ;
571
+ $footer . find ( 'label:first' ) . show ( ) ; // Check all
572
+ $footer . find ( 'input[type="checkbox"]:first' ) . click ( function ( ) {
573
+ var active = $ ( this ) . data ( 'active' ) ;
574
+ $wrapper . find ( 'input[type="checkbox"]' ) . each ( function ( ) {
575
+ var $this = $ ( this ) ;
576
+ if ( active && $this . is ( ':checked' ) ) $this . closest ( 'tr' ) . click ( ) ;
577
577
if ( ! active && ! $this . is ( ':checked' ) ) $this . closest ( 'tr' ) . click ( ) ;
578
578
} ) ;
579
- $ ( this ) . data ( 'active' , ( ( active ) ?false :true ) ) ;
580
- } ) ;
579
+ $ ( this ) . data ( 'active' , ( ( active ) ?false :true ) ) ;
580
+ } ) ;
581
581
$footer . find ( 'a' ) . eq ( 1 ) . click ( function ( ) { // Cancel button
582
582
if ( $ ( this ) . closest ( '.content_selector_bootbox' ) . length ) {
583
583
$ ( this ) . closest ( '.content_selector_bootbox' ) . modal ( 'hide' ) . data ( 'bs.modal' , null ) ;
@@ -655,32 +655,33 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
655
655
modal_height ( ) ;
656
656
if ( opts . pagination ) { // Endless scroll pagination
657
657
$tbody . find ( '.loadmore' ) . remove ( ) ;
658
- if ( ! opts . data . length ) return ;
659
- var $loadmore = $ ( '<tr><td class="loadmore" colspan="' + ( $this . find ( 'th' ) . length ) + '">Loading more content ...</td></tr>' ) . appendTo ( $tbody ) ;
660
- $loadmore . appendTo ( $tbody ) ;
661
- $loadmore . hide ( ) ;
662
- $this . find ( '.content' ) . unbind ( 'scroll' ) . scroll ( function ( ) {
663
- if ( $loadmore . find ( 'td' ) . hasClass ( 'loading' ) ) return ;
664
- $loadmore . show ( ) ;
665
- var $this = $ ( this ) ;
666
- if ( $this . innerHeight ( ) + $this . scrollTop ( ) < $this [ 0 ] . scrollHeight ) return ;
667
- $loadmore . find ( 'td' ) . addClass ( 'loading' ) ;
668
- opts . start = opts . start + opts . results_per_page ;
669
- go ( ) ;
670
- } ) ;
658
+ if ( opts . data . length ) {
659
+ var $loadmore = $ ( '<tr><td class="loadmore" colspan="' + ( $this . find ( 'th' ) . length ) + '">Loading more content ...</td></tr>' ) . appendTo ( $tbody ) ;
660
+ $loadmore . appendTo ( $tbody ) ;
661
+ $loadmore . hide ( ) ;
662
+ $this . find ( '.content' ) . unbind ( 'scroll' ) . scroll ( function ( ) {
663
+ if ( $loadmore . find ( 'td' ) . hasClass ( 'loading' ) ) return ;
664
+ $loadmore . show ( ) ;
665
+ var $this = $ ( this ) ;
666
+ if ( $this . innerHeight ( ) + $this . scrollTop ( ) < $this [ 0 ] . scrollHeight ) return ;
667
+ $loadmore . find ( 'td' ) . addClass ( 'loading' ) ;
668
+ opts . start = opts . start + opts . results_per_page ;
669
+ go ( ) ;
670
+ } ) ;
671
+ } ;
671
672
} ;
672
- $this . find ( 'tr' ) . find ( 'a' ) . click ( function ( event ) { // Preview|Visit button
673
+ $this . find ( 'tr' ) . find ( 'a' ) . unbind ( 'click' ) . click ( function ( event ) { // Preview|Visit button
673
674
event . stopPropagation ( ) ;
674
675
return true ;
675
676
} ) ;
676
- $this . find ( 'tr' ) . find ( 'input[type="checkbox"]' ) . click ( function ( event ) { // Clicking a <tr> checks the checkbox; this allows it to work properly if checkbox itself is checked
677
+ $this . find ( 'tr' ) . find ( 'input[type="checkbox"]' ) . unbind ( 'click' ) . click ( function ( event ) { // Clicking a <tr> checks the checkbox; this allows it to work properly if checkbox itself is checked
677
678
var $this = $ ( this ) ;
678
679
var checked = $this . is ( ":checked" ) ;
679
680
$this . prop ( 'checked' , ( ( checked ) ?false :true ) ) ;
680
681
return true ;
681
682
} ) ;
682
683
if ( ! opts . multiple ) { // Select a single row
683
- $this . find ( 'tr' ) . click ( function ( ) {
684
+ $this . find ( 'tr' ) . unbind ( 'click' ) . click ( function ( ) {
684
685
var node = $ ( this ) . data ( 'node' ) ;
685
686
if ( $ ( this ) . closest ( '.content_selector_bootbox' ) . length ) {
686
687
$ ( this ) . closest ( '.content_selector_bootbox' ) . modal ( 'hide' ) . data ( 'bs.modal' , null ) ;
@@ -692,7 +693,7 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
692
693
$ ( '.tt' ) . remove ( ) ;
693
694
} ) ;
694
695
} else { // Select multiple rows
695
- $this . find ( 'tr' ) . click ( function ( ) {
696
+ $this . find ( 'tr' ) . unbind ( 'click' ) . click ( function ( ) {
696
697
var $this = $ ( this ) ;
697
698
var checked = $this . find ( 'input[type="checkbox"]' ) . is ( ":checked" ) ;
698
699
$ ( this ) . find ( 'input[type="checkbox"]' ) . prop ( 'checked' , ( ( checked ) ?false :true ) ) ;
@@ -705,7 +706,7 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
705
706
}
706
707
} ) ;
707
708
}
708
- $ ( '.thumb' ) . parent ( ) . mouseover ( function ( ) { // Expand thumbnail
709
+ $ ( '.thumb' ) . parent ( ) . unbind ( 'mouseover' ) . mouseover ( function ( ) { // Expand thumbnail
709
710
var $this = $ ( this ) . children ( '.thumb:first' ) ;
710
711
var offset = $this . offset ( ) ;
711
712
var $div = $ ( '<div class="tt"></div>' ) ;
@@ -717,7 +718,7 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
717
718
$div . remove ( ) ;
718
719
} ) ;
719
720
} ) ;
720
- $ ( '.anno' ) . parent ( ) . mouseover ( function ( ) { // Show item that is annotated
721
+ $ ( '.anno' ) . parent ( ) . unbind ( 'mouseover' ) . mouseover ( function ( ) { // Show item that is annotated
721
722
var $this = $ ( this ) . children ( '.anno:first' ) ;
722
723
var str = '<i>Could not find target of this annotation</i>' ;
723
724
var targets = $this . closest ( 'tr' ) . data ( 'node' ) . targets ;
@@ -735,7 +736,7 @@ isMac = navigator.userAgent.indexOf('Mac OS X') != -1;
735
736
$div . remove ( ) ;
736
737
} ) ;
737
738
} ) ;
738
- $loadmore . hide ( ) ;
739
+ if ( 'undefined' != typeof ( $loadmore ) ) $loadmore . hide ( ) ;
739
740
} ;
740
741
var go = function ( ) {
741
742
opts . data = [ ] ;
0 commit comments