@@ -378,6 +378,19 @@ function updatePayMe() {
378
378
}
379
379
}
380
380
381
+ /**
382
+ * Updates the text of Quick Pay Me button with total amount of owed payments.
383
+ */
384
+ function updateQuickPayMe ( ) {
385
+ var total = totalOwedPayments ;
386
+ $ ( '#quickPayMe' ) . val ( 'Pay Me: $' + total . toFixed ( 2 ) ) ;
387
+ if ( total < MINIMUM_PAYMENT_ACCRUAL_AMOUNT ) {
388
+ $ ( '#quickPayMe' ) . attr ( 'disabled' , 'disabled' ) ;
389
+ } else {
390
+ $ ( '#quickPayMe' ) . removeAttr ( 'disabled' ) ;
391
+ }
392
+ }
393
+
381
394
/**
382
395
* Calculates the total amount of payments selected by user.
383
396
*
@@ -687,6 +700,66 @@ $(document).ready(function() {
687
700
}
688
701
} ) ;
689
702
703
+ $ ( '#quickPayMe' ) . click ( function ( ) {
704
+ var total = totalOwedPayments ;
705
+ var confirmationMessage = PAY_ME_CONFIRMATION_TEMPLATE . replace ( '{0}' , '$' + total . toFixed ( 2 ) ) ;
706
+
707
+ var isNativeDialog = $ ( '#payment-confirm-modal-id' ) . length === 0 ;
708
+
709
+ if ( isNativeDialog ) {
710
+ if ( confirm ( confirmationMessage ) ) {
711
+ var myForm = document . f ;
712
+ myForm . method = 'POST' ;
713
+ myForm . module . value = 'PayMe' ;
714
+ myForm . submit ( ) ;
715
+ }
716
+ } else {
717
+ var resultPromise = new Promise ( function ( resolve ) {
718
+ $ ( '#payment-confirm-modal-id .modal-body' ) . text ( confirmationMessage ) ;
719
+ document . body . style . overflow = 'hidden' ;
720
+
721
+ function onCancel ( ) {
722
+ document . body . style . overflow = '' ;
723
+ $ ( '#payment-confirm-modal-id' ) . removeClass ( 'show' ) ;
724
+ $ ( '#payment-confirm-modal-id .close-btn' ) . off ( 'click' ) ;
725
+ $ ( '#payment-confirm-modal-id .button-secondary' ) . off ( 'click' ) ;
726
+ $ ( '#payment-confirm-modal-id .button-primary' ) . off ( 'click' ) ;
727
+ resolve ( false ) ;
728
+ }
729
+ function onOk ( ) {
730
+ document . body . style . overflow = '' ;
731
+ $ ( '#payment-confirm-modal-id' ) . removeClass ( 'show' ) ;
732
+ $ ( '#payment-confirm-modal-id .close-btn' ) . off ( 'click' ) ;
733
+ $ ( '#payment-confirm-modal-id .button-secondary' ) . off ( 'click' ) ;
734
+ $ ( '#payment-confirm-modal-id .button-primary' ) . off ( 'click' ) ;
735
+ resolve ( true ) ;
736
+ }
737
+
738
+ $ ( '#payment-confirm-modal-id' ) . addClass ( 'show' ) ;
739
+ $ ( '#payment-confirm-modal-id .close-btn' ) . one ( 'click' , onCancel ) ;
740
+ $ ( '#payment-confirm-modal-id .button-secondary' ) . one ( 'click' , onCancel ) ;
741
+ $ ( '#payment-confirm-modal-id .button-primary' ) . one ( 'click' , onOk ) ;
742
+ } ) ;
743
+
744
+ resultPromise . then ( function ( ok ) {
745
+ if ( ok ) {
746
+ var myForm = document . f ;
747
+ myForm . method = 'POST' ;
748
+ myForm . module . value = 'PayMe' ;
749
+ for ( var i = 0 ; i < owedPayments . length ; i ++ ) {
750
+ var paymentId = owedPayments [ i ]
751
+ var input = document . createElement ( 'input' ) ;
752
+ input . type = 'hidden' ;
753
+ input . value = paymentId ;
754
+ input . name = 'paymentId' ;
755
+ myForm . appendChild ( input ) ;
756
+ }
757
+ myForm . submit ( ) ;
758
+ }
759
+ } )
760
+ }
761
+ } ) ;
762
+
690
763
$ ( '.getable' ) . click ( function ( ) {
691
764
var myForm = document . f ;
692
765
myForm . method = 'GET' ;
@@ -697,6 +770,8 @@ $(document).ready(function() {
697
770
698
771
updatePayMe ( ) ;
699
772
773
+ updateQuickPayMe ( ) ;
774
+
700
775
$ ( '.buttonArea .register' ) . click ( function ( ) {
701
776
// the 'isAnonymous' is defined in the projectDetails.jsp file
702
777
if ( ! isAnonymous ) {
0 commit comments