PageSourceSearch

https://www.queenslibrary.org/modules/custom/qbpl_user_account/js/alter_login.js?tl8z8n

js queenslibrary.org collected 2026-09-24 08:49:18 UTC 11,500 bytes, 224 lines download raw bytes

1/*global jQuery, Drupal, drupalSettings, window*/
2/*jslint white:true, multivar, this, browser:true*/
3
4(function ($, Drupal, drupalSettings, AjaxCommands, once) {
5    "use strict";
6    Drupal.behaviors.Popup = { //the name of our behavior
7        attach: function (context, settings) {
8          once('preventEnter', '[name="name"]', context).forEach(function (el) {
9            $(el).on('keydown', function (e) {
10              if (e.key === 'Enter') {
11                e.preventDefault();
12                return false;
13              }
14            });
15            // Ensure focus is placed on this field after modal opens.
16            setTimeout(function () {
17              el.focus();
18            }, 100);
19          });
20            function strip_tags(input, allowed) { //the strip_tags function that cuts unnecessary tags on regular expression and returns clean text. Important! The input parameter works correctly only string data type.
21                allowed = (((allowed || '') + '')
22                    .toLowerCase()
23                    .match(/<[a-z][a-z0-9]*>/g) || [])
24                    .join('');
25                var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
26                    commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
27                return input.replace(commentsAndPhpTags, '')
28                    .replace(tags, function($0, $1) {
29                        return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
30                    });
31            }
32            $(document).bind('ajaxSuccess.Popup', function() { //run the main code only after Ajax has successfully downloaded your node
33                var value = $(".modal-title"); //matching the popup title class
34                $(".modal-title").html('');
35
36                //$(".modal-dialog").css({"width": "90%" }); // , "height" : "90%"
37                $(".modal-content").css({"width": "99%", "height" : "99%","min-height":"230px"  });
38                //$('[id^="edit-action"]').hide();
39                // Due the /Applications/MAMP/htdocs/dp8/themes/bootstrap/js/modal.jquery.ui.bridge.js line 272 changes for modal
40                // Need explicit reassign css properties
41                $('[id^="user-login-form"],[id^="login-redirect-spinner"]').parents("#drupal-modal--body").css({"overflow":"visible"});
42                if($("#login-redirect-spinner").length > 0) {
43                    $("#drupal-modal--content").attr('style', 'display: block !important;min-height:200px');//css({"display":"block !important"});
44                    //alert($('[id^="login-redirect-spinner"]').parents("#drupal-modal--content").css())
45                }
46                //alert($('[id^="user-login-form"]').parents("#drupal-modal--body").attr("id"));
47                $('[id^="edit-submit"].use-ajax-submit').css({"width": "100%", "height" : 60 , "border" : "1px solid" });
48                $("#drupal-modal").addClass( "modal-login-popup" );
49
50                    //var apply = $('<div class="popup-signup">Don`t have Library Card? <a href="#"> Apply here</a></div>');
51                    //$(".modal-footer ").append(apply);
52                    //$(".modal-footer ").css({"text-align":"center"});
53
54                $(".modal-footer button").hide();
55                var pass = $('[id^="edit-pass"]');
56                var label = $("label[for='"+pass.attr('id')+"']")
57                var oldLabel = label.html();
58                //label.html('PIN' + ' <a href="#"> Forgot?</a>');
59                if (value.length && !value.hasClass('do-once')) { //if there is no do-once class,
60                    //var text = strip_tags($(value).text()); //then run the strip_tags() function
61                    var text = $(value).text(); //then run the strip_tags() function
62                    $(value).text(text);
63                    value.addClass('do-once');
64
65                }
66
67                $(this).unbind('ajaxSuccess.Popup');
68
69                $('.path-event .modal-header button.close').on("click", function(){
70                    window.location.reload(true);
71                });
72
73                if ( !$(".modal-header").find('#login-logo').length)
74                    $(".modal-header").prepend('<div id="login-logo"> <img src="/themes/renovate/logo.svg" alt="Queens Public Library"/> </div>');
75                $('#drupal-modal').on('shown.bs.modal', function () {
76                    $('[id^="edit-name"]').focus()
77                });
78
79                /**
80                 * Below, attaching custom function to jquery
81                 * and reload page (or another action)
82                 *  commented, due created updateAccount command,
83                 *  Left as an example
84                 */
85                /**
86                $.fn.updateMenu = function() {
87                    return this.each(function() {
88                        //console.log("here");
89                        //updateNavbarUserInfo();
90                        location.reload();
91                    });
92                };
93                 */
94                // ------------------------------------------- //
95                // Hi Roman I just put this here for temporary //
96                //                                             //
97                //                        Thanks               //
98                //                        Sarun 08/02/17       //
99                // ------------------------------------------- //
100                if ( document.URL.search('widget') > -1 ) {
101
102                  $('.modal-open .modal').css( 'background' , '#282561');
103
104                  $( 'div.modal-header' ).css( 'padding' , '5px' );
105                  $( '#login-logo' ).css( 'display' , 'none' );
106
107                  $('h4.modal-title.do-once').css( 'display' , 'none' );
108
109                  $( '#user-login h3' ).css( 'display' , 'none' );
110                  $( '.help-block' ).css( 'display' , 'none' );
111                  $( 'label.control-label.option' ).css( 'display' , 'none' );
112                  $( '.popup-signup').css( 'display' , 'none' );
113                  $( 'button.close' ).css( 'margin' , '0px' );
114                  $( 'button.close' ).css( 'padding' , '0px' );
115                  $( 'button.close' ).css( 'width' , '10px' );
116                  $( 'button.close' ).css( 'height' , '10px' );
117                  //$( 'button.close' ).css( 'background-color' , 'grey' ); // done by rama
118                  $( 'div.modal-body' ).css( 'padding' , '5px' );
119
120                  //$( 'button.close span' ).css( 'display' , 'none' ); // done by rama
121                  $( 'button.close span' ).css( 'position' , 'absolute' ); // done by rama
122                  $( 'button.close span' ).css( 'right' , '3px' ); // done by rama
123                  $( 'button.close span' ).css( 'top' , '-3px' ); // done by rama
124                  $( 'button.close span' ).css( 'vertical-align' , 'middle' ); // done by rama
125                  $( 'button.close span' ).css( 'font-size' , '24px' ); // done by rama
126                  $( 'button.close span' ).css( 'font-weight' , '600' ); // done by rama
127
128
129                  $( 'label.control-label.js-form-required.form-required' ).css( 'font-size' , '12px' );
130                  $( 'button.use-ajax-submit.button.js-form-submit.form-submit.btn-primary.btn' ).css( 'height' , '30px' );
131                  $( 'button.use-ajax-submit.button.js-form-submit.form-submit.btn-primary.btn' ).css( 'padding-top' , '5px' );
132
133                  // $('div.alert.alert-danger.alert-dismissible').css( 'display' , 'none' );
134
135                  if ( document.URL.search( "bgc=0" ) > -1 ) {
136                     // $( 'div#drupal-modal' ).attr( 'style' , 'background-color:#FFFFFF !important' );  // Replace by Sravan's logic
137                     $( 'div#drupal-modal' ).css( 'background-color' , '#FFFFFF' );
138                     $( 'div.available-at span' ).attr( 'style' , 'color:#1f2031 !important');
139                  }
140
141                }
142                // ------------------------------------------- //
143
144            });
145
146            // $("input[name='name'],input[name='library_card']").on("keyup",function(){
147            //       var val = $(this).val();
148            //       var reg = new RegExp('^[a-zA-Z0-9]+$');
149            //       if(reg.test(val)){
150            //         $('.err-login-name, .err-login-validname').css("display","none");
151            //         $(this).css({
152            //           "background-color": "#ffffff",
153            //           "border" : "1px solid lightgray"
154            //         });
155            //       }
156            //       else {
157            //         $('.err-login-validname').css("display","table");
158            //         $(this).css({
159            //           "background-color":"#fff1f1",
160            //           "border": "1px solid red"
161            //         });
162            //       }
163            // });
164
165            // $("input[name='email']").on("keyup",function(){
166            //       var val = $(this).val();
167            //       var reg = new RegExp('^[A-Za-z0-9_]+@[a-z]+[.][a-z]+$');
168            //       if(reg.test(val)){
169            //         $('.err-login-email, .err-login-validemail').css("display","none");
170            //         $(this).css({
171            //           "background-color": "#ffffff",
172            //           "border" : "1px solid lightgray"
173            //         });
174            //       }
175            //       else {
176            //         $('.err-login-validemail').css("display","table");
177            //         $(this).css({
178            //           "background-color":"#fff1f1",
179            //           "border": "1px solid red"
180            //         });
181            //       }
182            // });
183
184            // $('#user-login button').on("click",function(e){
185            //       //e.preventDefault();
186            //       console.log($(this).off("click"));
187            //       if($("input[name='name']").val()==""){
188            //         $(".err-login-name").css("display","table");
189            //         $(".err-login-validname").css("display","none");
190            //       }
191            //       if($("input[name='pass']").val()==""){
192            //           $(".err-login-pass").css("display","table");
193            //       }
194            // });
195
196            // $('#user-reset-pin button').on("click",function(e) {
197            //       if($("input[name='library_card']").val()=="") {
198            //         $(".err-login-name").css("display","table");
199            //         $(".err-login-validname").css("display","none");
200            //       }
201            //       if($("input[name='email']").val()=="") {
202            //           $(".err-login-email").css("display","table");
203            //       }
204            // });
205
206          once('override-ajax-error', 'body', context).forEach(() => {
207            AjaxCommands.prototype.error = function (ajax, response, statusText) {
208              console.warn('AJAX failed:', statusText, response);
209              // optionally show your own toast/snackbar here
210            };
211          });
212          once('remove-ajax-error-message', '[data-drupal-messages]', context).forEach(function () {
213            $('[data-drupal-message-type="error"]').each(function () {
214              if ($(this).text().includes("Oops, something went wrong")) {
215                $(this).remove();
216                console.log('Removing generic AJAX error');
217
218              }
219            });
220          });
221
222        }
223    };
224})(jQuery, Drupal, drupalSettings, Drupal.AjaxCommands, once);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.