1/*global jQuery, Drupal, window */ 2/*jslint white:true, multivar, this, browser:true*/ 3 4(function($, Drupal, window) 5{ 6 "use strict"; 7 8 var popupVisible, ctrlPressed, fancyLoginBox, messageContainer; 9 10 popupVisible = false; 11 ctrlPressed = false; 12 13 function moveMessages() 14 { 15 var messages = $("#fancy_login_login_box .messages"); 16 17 if(messages.length) 18 { 19 if(!messageContainer) 20 { 21 messageContainer = $("<div/>", {id:"fancy_login_messages_container_wrapper"}).prependTo("body"); 22 } 23 messages.each(function() 24 { 25 $(this).appendTo( 26 $("<div/>", {"class":"fancy_login_messages_container"}).appendTo(messageContainer) 27 ).before( 28 $("<div/>", {"class":"fancy_login_message_close_button"}).text("X") 29 ); 30 }); 31 } 32 } 33 34 function showLogin() 35 { 36 var settings = Drupal.settings.fancyLogin; 37 38 if(!popupVisible) 39 { 40 popupVisible = true; 41 if(settings.hideObjects) 42 { 43 $("object, embed").css("visibility", "hidden"); 44 } 45 46 $("#fancy_login_dim_screen").css({backgroundColor:settings.screenFadeColor, zIndex:settings.screenFadeZIndex, opacity:0, display:"block"}).fadeTo(settings.dimFadeSpeed, 0.8, function() 47 { 48 var eHeight, eWidth, eTopMargin, eLeftMargin; 49 50 eHeight = fancyLoginBox.height(); 51 eWidth = fancyLoginBox.width(); 52 eTopMargin = - 1 * (eHeight / 2); 53 eLeftMargin = -1 * (eWidth / 2); 54 55 if($("#fancy_login_close_button").css("display") === "none") 56 { 57 $("#fancy_login_close_button").css("display", "block"); 58 } 59 60 fancyLoginBox.css({marginLeft:eLeftMargin, marginTop:eTopMargin, color:settings.loginBoxTextColor, backgroundColor:settings.loginBoxBackgroundColor, borderStyle:settings.loginBoxBorderStyle, borderColor:settings.loginBoxBorderColor, borderWidth:settings.loginBoxBorderWidth, zIndex:(settings.screenFadeZIndex + 1)}).fadeIn(settings.boxFadeSpeed).find(".form-text:first").focus().select(); 61 $("html, body").css("overflow", "hidden"); 62 }); 63 } 64 } 65 66 function hideLogin() 67 { 68 var settings = Drupal.settings.fancyLogin; 69 70 if(popupVisible) 71 { 72 popupVisible = false; 73 $("#fancy_login_login_box").fadeOut(settings.boxFadeSpeed, function() 74 { 75 $("#fancy_login_dim_screen").fadeOut(settings.dimFadeSpeed, function() 76 { 77 if(settings.hideObjects) 78 { 79 $("object, embed").css("visibility", "visible"); 80 } 81 }); 82 $(window).focus(); 83 $("html, body").css("overflow", "auto"); 84 }); 85 } 86 } 87 88 function popupCloseListener() 89 { 90 $("#fancy_login_dim_screen, #fancy_login_close_button").once("fancy-login-close-listener", function() 91 { 92 $(this).click(function(e) 93 { 94 e.preventDefault(); 95 96 hideLogin(); 97 }); 98 }); 99 } 100 101 function statusMessageCloseListener() 102 { 103 $(".fancy_login_message_close_button").once("status-message-close-listener", function() 104 { 105 $(this).click(function() 106 { 107 $(this).parent().fadeOut(250, function() 108 { 109 $(this).remove(); 110 }); 111 }); 112 }); 113 } 114 115 function loginLinkListener() 116 { 117 var settings = Drupal.settings.fancyLogin; 118 119 $("a[href*='" + settings.loginPath + "']:not(.fancy_login_disable), .fancy_login_show_popup:not(.fancy_login_disable)").once("login-link-listener", function() 120 { 121 $(this).click(function(e) 122 { 123 e.preventDefault(); 124 125 showLogin(); 126 }); 127 }); 128 } 129 130 function init() 131 { 132 $("body").once("fancy-login-init", function() 133 { 134 fancyLoginBox = $("#fancy_login_login_box"); 135 $(window.document).keyup(function(e) 136 { 137 if(e.keyCode === 17) 138 { 139 ctrlPressed = false; 140 } 141 else if(e.keyCode === 27) 142 { 143 hideLogin(); 144 } 145 }); 146 $(window.document).keydown(function(e) 147 { 148 if(e.keyCode === 17) 149 { 150 ctrlPressed = true; 151 } 152 if(ctrlPressed === true && e.keyCode === 190) 153 { 154 ctrlPressed = false; 155 156 if(popupVisible) 157 { 158 hideLogin(); 159 } 160 else 161 { 162 showLogin(); 163 } 164 } 165 }); 166 }); 167 } 168 169 function popupTextfieldListener() 170 { 171 fancyLoginBox.find(".form-text").once("fancy-login-popup-textfield-listener", function() 172 { 173 $(this).keydown(function (event) 174 { 175 if(event.keyCode === 13) 176 { 177 $(this).parent().siblings(".form-actions:first").children(".form-submit:first").mou
177sedown(); 178 } 179 }); 180 }); 181 } 182 183 function loadForm(type) 184 { 185 var formLoadDimmer = $("<div/>", {"id":"form_load_dimmer"}).appendTo(fancyLoginBox).fadeTo(250, 0.8); 186 187 $.ajax( 188 { 189 url:Drupal.settings.basePath + "fancy_login/ajax/" + type, 190 success:function(data) 191 { 192 var wrapper, oldContents, newContents, oldHeight, newHeight, newMargin; 193 194 wrapper = fancyLoginBox.find("#fancy_login_user_login_block_wrapper"); 195 oldContents = wrapper.contents(); 196 oldHeight = wrapper.css("height"); 197 newContents =$("<div/>").html(data.content).contents(); 198 oldContents.replaceWith(newContents); 199 newHeight = wrapper.css("height"); 200 newMargin = fancyLoginBox.outerHeight() / -2; 201 newContents.replaceWith(oldContents); 202 wrapper.css("height", oldHeight); 203 oldContents.fadeOut(250, function() 204 { 205 $(this).remove(); 206 fancyLoginBox.animate( 207 { 208 marginTop:newMargin 209 }, 210 { 211 duration:250 212 }); 213 wrapper.animate( 214 { 215 height:newHeight 216 }, 217 { 218 duration:250, 219 complete:function() 220 { 221 newContents.appendTo(wrapper).fadeIn(250, function() 222 { 223 wrapper.css("height", "auto"); 224 formLoadDimmer.fadeOut(250, function() 225 { 226 $(this).remove(); 227 }); 228 }); 229 Drupal.attachBehaviors(); 230 } 231 }); 232 }); 233 } 234 }); 235 } 236 237 function linkListeners() 238 { 239 var anchors = fancyLoginBox.find("a"); 240 241 if(!Drupal.settings.fancyLogin.disableRegistration) 242 { 243 anchors.filter("[href*='user/register']").once("fancy-login-register-link", function() 244 { 245 $(this).click(function(e) 246 { 247 e.preventDefault(); 248 loadForm("register"); 249 }); 250 }); 251 } 252 253 anchors.filter("[href*='user/password']").once("fancy-login-password-link", function() 254 { 255 $(this).click(function(e) 256 { 257 e.preventDefault(); 258 loadForm("password"); 259 }); 260 }); 261 262 anchors.filter("[href*='user/login']").once("fancy-login-login-link", function() 263 { 264 $(this).click(function(e) 265 { 266 e.preventDefault(); 267 loadForm("login"); 268 }); 269 }); 270 } 271 272 Drupal.behaviors.fancyLogin = { 273 attach:function() 274 { 275 if(window.XMLHttpRequest) 276 { 277 init(); 278 loginLinkListener(); 279 popupTextfieldListener(); 280 popupCloseListener(); 281 statusMessageCloseListener(); 282 moveMessages(); 283 linkListeners(); 284 } 285 286 Drupal.ajax.prototype.commands.fancyLoginRefreshPage = function(ajax, response) 287 { 288 // For JSLint compatibility 289 ajax = ajax; 290 291 if(response.closePopup) 292 { 293 hideLogin(); 294 } 295 296 window.location.reload(); 297 }; 298 299 Drupal.ajax.prototype.commands.fancyLoginRedirect = function(ajax, response) 300 { 301 // For JSLint compatibility 302 ajax = ajax; 303 304 if(response.closePopup) 305 { 306 hideLogin(); 307 } 308 309 if(response.destination.length) 310 { 311 window.location = response.destination; 312 } 313 else 314 { 315 window.location = "user"; 316 } 317 }; 318 319 Drupal.ajax.prototype.commands.fancyLoginClosePopup = function() 320 { 321 hideLogin(); 322 }; 323 } 324 }; 325}(jQuery, Drupal, window));
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.