1(function(R, $) { 2 3 /* default options */ 4 R.config = { 5 'projects' : ['cb-register'], 6 'ajax' : '/register/ajax.php', 7 'layerFrame' : true, 8 'showShadow' : true, 9 'height' : '610', 10 'submitClass' : '__CbUiSubmitting', 11 'supportUrl' : 'register.culturebase.org/support/' 12 }; 13 14 R.onceOnClickIfValid = function(element, self, callback, invalidCallback, 15 alreadySubmittingCallback) { 16 $.CbWidget.window.onceOnClickIfValid(element, self, callback, 17 invalidCallback, alreadySubmittingCallback, R.config.submitClass); 18 }; 19 20 R.prepare = function(GEToptions) { 21 $.extend(R.config, GEToptions); 22 $.CbWidgetRegistry.projects = R.config.projects ? R.config.projects : ['cb-register']; 23 $.CbWidgetRegistry.language = R.config.language; 24 if (R.config.createLabels) { 25 $.CbWidgetRegistry.brickSource += '?createNewLabels'; 26 } 27 }; 28 29 R.openWindow = function(GEToptions, data, initial) { 30 R.prepare(GEToptions); 31 $(document).ready(function() { 32 var constructor = R[initial]; 33 if (typeof constructor !== 'function') constructor = window[initial]; 34 if (typeof constructor === 'function') { 35 new constructor({}, R.config, data).open({delay : 500}); 36 } 37 $('.support.__CbUiText').attr('href', R.config.supportUrl); 38 }); 39 }; 40 41 R.bindEnterSubmit = function(inputs, button) { 42 inputs.each(function(i, field) { 43 $(field).unbind('keypress').keypress(function(e) { 44 if (e.which === 13) { 45 $(this).blur(); 46 button.click(); 47 } 48 }); 49 }); 50 }; 51 52 /** 53 * Open the next window based on the "next" field in data. If there is no 54 * such field in data show a message window. 55 */ 56 R.nextWindow = function(self, data) { 57 // $('body').scrollTop(0); 58 if (data.next) { 59 self.close(0); 60 var win = R[data.next]; 61 if (typeof win !== "function") { 62 win = window[data.next]; 63 } 64 if (typeof win === "function") { 65 return new win({}, self.options, data).open(0); 66 } else { 67 return self.trigger('error', "No such window"); 68 } 69 } else if (data.error) { 70 return self.trigger('error', data); 71 } else { 72 var conf = { 73 'message' : 'registerframe_message_fail' 74 }; 75 if (typeof data.close_callback === 'function') $.extend(conf, {close_callback: data.close_callback}); 76 self.close(0); 77 return new R.CbMessageWindow({}, self.options, conf).open(0); 78 } 79 }; 80 81 /** 82 * Post something to the ajax handler and open the next window based on the 83 * reply. 84 * @param params Parameters to post. 85 * @param old_window Window to be closed when reply with next window is received. 86 */ 87 R.postAndShow = function(params, old_window) { 88 $.post(R.config.ajax, params, function(data) { 89 if (old_window.next) { 90 data.next = old_window.next[data.next] ? old_window.next[data.next] : data.next; 91 } 92 R.nextWindow(old_window, data); 93 }, 'json'); 94 }; 95 96 R.doRedirect = function(url) { 97 if (url === true) { 98 window.location.reload(); 99 } else { 100 window.location = url; 101 } 102 }; 103 104 R.processToken = function(params, successCallback, failCallback) { 105 $.post(R.config.ajax, $.extend({action: 'process_token'}, params), function(data) { 106 if (data) { 107 successCallback(data); 108 } else { 109 failCallback(data); 110 } 111 }, 'json'); 112 }; 113 114 /** 115 * Add default value class to unedited elements that are filled with the default value. 116 * @param elements of window object 117 */ 118 R.addDefaultValueClass = function(elements) { 119 $('.__CbUiFieldUnedited', elements).each(function(i, element){ 120 var idAttr = typeof $(element).attr('id') !== 'undefined' ? $(element).attr('id') : $(element).parent('span').attr('id'); 121 if($.CbWidgetRegistry.bricks[idAttr] === $(element).val()) 122 $(element).addClass('__CbUiFieldDefaultValue'); 123 }); 124 }; 125 126 /** 127 * General message window. Title and text can be specified and patterns can be 128 * replaced. 129 */ 130 R.CbMessageWindow = $.CbWidget.text_window.extend({ 131 constructor : function(loadOptions, options, data) { 132 var self = this; 133 this.base($.extend({template : '/register/templates/frame.php?content=message', cls: '__CbUiRegisterWindow'}, loadOptions), 134 options, data ? data.replace_text : {}); 135 this.autocenter(); 136 this.message = data.message; 137 this.title = data.title; 138 this.redirect = data.redirect; 139 this.button_ok_text = data.button_ok_text ? data.button_ok_text : null; 140 if (typeof data.close_callback === 'function') { 141 this.close_callback = data.close_callback; 142 } else { 143 this.close_callback = function() { }; 144 } 145 if (data && data.redirect) { 146 this.destroy(function() { 147 R.doRedirect(data.redirect); 148 }); 149 } 150 }, 151 152 handleLoad : function() { 153 if (this.title) $('#registerframe_title').text(this.title); 154 if (this.button_ok_text) $('#registerframe_button_ok').text(this.button_ok_text); 155 $('#registerframe_message').text(this.message); 156 var self = this; 157 var doclose = function(e) { 158 if (e.keyCode === 13 || e.keyCode === 27) { 159 close(); 160 } 161 }; 162 var close = function() { 163 self.close(500); 164 self.close_callback(); 165 }; 166 $(document).keypress(doclose); 167 self.destroy(function() {
168 $(document).unbind("keypress", doclose); 169 }); 170 self.element().find('.__CbUiHeader .__CbUiCloseButton').off('click').click(close); 171 $('#registerframe_button_ok').click(close); 172 $('#registerframe_button_open_link').click(function(e) { 173 var link = $(this).attr('href'); 174 var win = window.open(link, '_blank'); 175 if(win) { 176 win.focus(); 177 } 178 }); 179 return this.base(); 180 } 181 }); 182 183 184 /** 185 * Window to initiate an email verification of some account. You get the option 186 * to either send a mail to a registered account or send a mail to the editors 187 * to ask for help. The mail to a registered account can be disabled. 188 */ 189 R.CbVerifyMailWindow = R.CbMessageWindow.extend({ 190 constructor : function(loadOptions, options, data) { 191 this.base($.extend({template : '/register/templates/frame.php?content=verifymail', cls: '__CbUiRegisterWindow'}, loadOptions), options, data); 192 this.disableRegistered = (data && data.disable_registered); 193 this.problem = data ? data.problem : 'password'; 194 this.autocenter(); 195 }, 196 197 handleReady : function() { 198 this.base(); 199 var self = this; 200 R.onceOnClickIfValid($('#registerframe_button_send_to_cb'), self, function() { 201 R.postAndShow({'action' : 'request_to_cb', 'problem' : self.problem}, self); 202 }); 203 204 if (this.disableRegistered) { 205 $('#registerframe_button_send_to_registered').hide(); 206 } else { 207 R.onceOnClickIfValid($('#registerframe_button_send_to_registered'), 208 self, function() { 209 R.postAndShow({'action' : 'check_account'}, self); 210 }); 211 } 212 R.addDefaultValueClass($(this)); 213 } 214 }); 215 216 /** 217 * Abstract window to handle selection from a list of options. 218 */ 219 R.CbSelectWindow = $.CbWidget.window.extend({ 220 constructor : function(loadOptions, options, data, template) { 221 this.base($.extend({template : '/register/templates/frame.php?content=' + template, cls: '__CbUiRegisterWindow'}, loadOptions), options); 222 this.data = data; 223 this.autocenter(); 224 }, 225 226 handleReady : function() { 227 var self = this; 228 $('#registerframe_choose').CbWidget().select(function(params) {self.choose(params);}); 229 return this.base(); 230 }, 231 232 handleLoad : function() { 233 var chooseList = $('#registerframe_choose'); 234 $.each(this.data, function(index, val) { 235 var entry = $(document.createElement('span')); 236 entry.text(val.text); 237 entry.addClass('__CbUiText'); 238 $.CbWidget.chooseList.addOption(chooseList, val.id, entry); 239 }); 240 return this.base(); 241 } 242 }); 243 244 /** 245 * Window presenting a list of names to select from. 246 */ 247 R.CbNameSelectWindow = R.CbSelectWindow.extend({ 248 constructor : function(loadOptions, options, data) { 249 this.base($.extend({cls: '__CbUiRegisterWindow'}, loadOptions), options, data.data, 'nameselect'); 250 var self = this; 251 if (typeof self.data.close_callback === 'function') { 252 self.close_callback = self.data.close_callback; 253 } 254 /* 255 * Delete the callback because of the following piece 256 * of code. 257 * 258 * If the property wasn't there to begin with delete 259 * will return true anyway 260 */ 261 delete self.data.close_callback; 262 $.each(self.data, function(index, val) { 263 self.data[index].text = val.firstname + " " + val.surname + " | " + val.city + " | " + val.email; 264 }); 265 return this; 266 }, 267 268 handleReady : function() { 269 $('#registerframe_someone_else').click(function() { 270 $('#registerframe_choose').CbWidget().trigger('select', {id : 0}); 271 }); 272 R.addDefaultValueClass($(this)); 273 return this.base(); 274 }, 275 276 choose : function(params) { 277 if (!this.submitting) { 278 this.submitting = true; 279 var self = this; 280 if (params.id === 0) { // registerframe_someone_else 281 R.postAndShow({'action': 'insert_user'}, self); 282 } else { 283 $.post(R.config.ajax, { 284 'action' : 'check_mail', 285 'id' : params.id 286 }, function(data) { 287 R.nextWindow(self, $.extend(data, {close_callback: self.close_callback})); 288 }, 'json'); 289 } 290 } 291 return this; 292 } 293 294 }); 295 296 /** 297 * Window to input your name and address. 298 */ 299 R.CbNameAddressWindow = $.CbWidget.window.extend({ 300 constructor : function(loadOptions, options, data) { 301 302 this.base($.extend({template : '/register/templates/frame.php?content=nameaddress', cls: '__CbUiRegisterWindow'}, loadOptions), options , data ? data.replace_text : {}); 303 if (data && typeof data.close_callback === 'function') { 304 this.close_callback = data.close_callback; 305 } 306 if(data && typeof data.get_loggedin_user_data_callback === 'function'){ 307 this.get_loggedin_user_data_callback = data.get_loggedin_user_data_callback; 308 } 309 this.next = data && data.next ? data.next : {}; 310 this.remove_terms = data && data.remove_terms ? true : false;
311 this.autocenter(); 312 this.dataAccount = data && data.replace_text ? data.replace_text.account : null; 313 }, 314 315 handleReady : function(params) { 316 var self = this, 317 city_widget = $('#registerframe_input_city').CbWidget(), 318 terms = $('#registerframe_input_terms, #registerframe_input_terms+span', self.element()); 319 if (city_widget) { 320 $.extend(city_widget.options, { 321 requestUrl : "/module/lib/framework/selectBoxDataCity.php", 322 requestParam : "actualInput", 323 closeWhenBlur : false, 324 community : 73, 325 spaceAsWildcard : true 326 }); 327 } 328 if(self.remove_terms) { 329 terms.remove(); 330 } 331 332 params = params || {}; 333 // set action param to doublet check as default 334 params.action = 'check_doublet'; 335 336 // check if user exists and in case fill out and disable form elements 337 $.post(R.config.ajax, {'action': 'get_loggedin_user_data'}, function (data) { 338 if (data !== null) { 339 if (data.id) { 340 // set action to insert if user data was found 341 params.action = "insert"; 342 } 343 if (data.email) { 344 $('#registerframe_input_mail').val(data.email).attr('disabled', true); 345 } 346 $('#registerframe_input_first').val(data.firstname); 347 $('#registerframe_input_last').val(data.surname); 348 if (data.city && data.city_id) { 349 city_widget.valueId(data.city_id); 350 city_widget.value(data.city); 351 /* validate the field 352 * TODO: provide a more comprehensive API 353 * for CbWidget and Autocomplete plugin 354 */ 355 city_widget.name_field.removeClass('__AC_invalidated __AC_validating __AC_editing __AC_freetext') 356 .addClass('__AC_validated'); 357 } 358 if (data.street) { 359 $('#registerframe_input_street').val(data.street); 360 } 361 if (data.plz) { 362 $('#registerframe_input_zip').val(data.plz); 363 } 364 if (data.phone) { 365 $('#registerframe_input_phone').val(data.phone); 366 } 367 if (data.nr) { 368 $('#registerframe_input_nr').val(data.nr); 369 } 370 if (data.gender) { 371 $('#registerframe_input_gender').val(data.gender); 372 } 373 if (data.description && typeof params.getDescription !== 'undefined') { 374 $('#registerframe_input_description').val(data.description); 375 } 376 R.addDefaultValueClass(self.element()); 377 378 //focus all input fields once to trigger the input.js functions that set the defined/undefined classification 379 $('input:not(.__CbUiSearchBox)').each( function(){$(this).focus();} ); 380 381 if(typeof self.get_loggedin_user_data_callback === 'function'){ 382 self.get_loggedin_user_data_callback(data); 383 } 384 } else if(self.dataAccount !== null) { 385 $('#registerframe_input_mail').val(self.dataAccount).attr('disabled', true); 386 } 387 388 }, 'json'); 389 var register_button = $('#registerframe_button_register'); 390 R.onceOnClickIfValid(register_button, self, function() { 391 $.each({ 392 surname: 'last', 393 firstname: 'first', 394 city : 'city', 395 email: 'mail', 396 gender: 'gender', 397 plz: 'zip', 398 phone: 'phone', 399 street: 'street', 400 nr : 'nr', 401 description : 'description', 402 birthday: 'birthday' 403 }, function(key, idname) { 404 var widget = $('#registerframe_input_' + idname).CbWidget(); 405 if (widget) { 406 params[key] = $.CbWidgetRegistry.bricks['registerframe_input_'+idname] === widget.value() ? '' : widget.value(); 407 if (typeof widget.valueId === 'function') params[key + '_id'] = widget.valueId(); 408 } 409 }); 410 411 $.post(R.config.ajax, params, function(data) { 412 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 413 R.nextWindow(self, $.extend(data, { 414 close_callback: self.close_callback, 415 next : next 416 })); 417 }, 'json'); 418 }); 419 R.bindEnterSubmit($('.__CbUiInputText', $(this)), register_button); 420 421 return this.base(); 422 }, 423 424 handleError : function() { 425 $('#registerframe_error_user').CbWidget().showText('registerframe_error_user'); 426 return this.base(); 427 } 428 }); 429 430 R.CbCheckDoubletInfoWindow = $.CbWidget.window.extend({ 431 constructor: function (loadOptions, options, data) { 432 this.base($.extend({ 433 template: '/register/templates/frame.php?content=checkdoubletinfo', 434 cls: '__CbUiRegisterWindow' 435 }, loadOptions), options); 436 this.next = data && data.next ? data.next : {}; 437 this.data = data; 438 this.originalRequest = data.originalRequest; 439 this.autocenter(); 440 441 var self = this; 442 if (typeof self.data.close_callback === 'function') { 443 self.close_callback = self.data.close_callback; 444 } 445 /* 446 * Delete the callback because of the following piece 447 * of code. 448 * 449 * If the property wasn't there to begin with delete
450 * will return true anyway 451 */ 452 delete self.data.close_callback; 453 454 return this; 455 }, 456 457 handleReady : function() { 458 var self = this; 459 $('#registerframe_button_register_send_doublet_info').click(function() { 460 var params = {'action' : 'check_doublet_info_and_insert'}; 461 $.each(self.data.originalRequest, function(key, value) { 462 if (key !== "action") params[key] = value; 463 }); 464 params.doublet_id = self.data.doublet_id; 465 params.doublet_text = self.data.doublet_text; 466 params.info_text = $('#registerframe_doublet_info_text').val(); 467 $.post(R.config.ajax, params, function(data) { 468 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 469 R.nextWindow(self, $.extend(data, { 470 close_callback: self.close_callback, 471 next : next 472 })); 473 }, 'json'); 474 }); 475 }, 476 477 handleLoad : function() { 478 var self = this; 479 var registerframe_doublet_login_data = $('#registerframe_doublet_login_data'); 480 var registerframe_doublet_doublet_data = $('#registerframe_doublet_doublet_data'); 481 var login_data = $(document.createElement('div')); 482 login_data.html( 483 self.data.originalRequest.firstname + " " + self.data.originalRequest.surname + "<br />" + 484 self.data.originalRequest.street + " " + self.data.originalRequest.nr + ", " + self.data.originalRequest.plz + " " + self.data.originalRequest.city + "<br /><br />" + 485 self.data.originalRequest.email 486 ); 487 var doublet_data = registerframe_doublet_login_data.append(login_data); 488 var doublet_data = $(document.createElement('div')); 489 var doublet_data_array = self.data.doublet_text.split('|'); 490 // doublet_data.html(self.data.doublet_text); 491 for(var i = 0; i<= doublet_data_array.length-1; i++) { 492 console.log(doublet_data_array[i]); 493 doublet_data.append('<span>' + doublet_data_array[i] + '</span></br>'); 494 } 495 registerframe_doublet_doublet_data.append(doublet_data); 496 } 497 498 }); 499 500 /** 501 * Window to select a doublet 502 * eturn this.base(); 503 */ 504 R.CbCheckDoubletWindow = $.CbWidget.window.extend({ 505 constructor : function(loadOptions, options, data) { 506 this.base($.extend({ 507 template : '/register/templates/frame.php?content=checkdoublet', 508 cls: '__CbUiRegisterWindow' 509 }, loadOptions), options); 510 this.next = data && data.next ? data.next : {}; 511 this.data = data.data; 512 this.originalRequest = data.originalRequest; 513 this.autocenter(); 514 515 var self = this; 516 if (typeof self.data.close_callback === 'function') { 517 self.close_callback = self.data.close_callback; 518 } 519 /* 520 * Delete the callback because of the following piece 521 * of code. 522 * 523 * If the property wasn't there to begin with delete 524 * will return true anyway 525 */ 526 delete self.data.close_callback; 527 return this; 528 }, 529 530 handleReady : function() { 531 var self = this; 532 $('#registerframe_someone_else').click(function() { 533 $('#registerframe_choose_high_match').CbWidget().trigger('select', {id : 0}); 534 }); 535 536 $('#registerframe_choose_high_match .selection, #registerframe_choose_medium_match .selection').click(function() { 537 $('.entryblock').not($(this).parent()).removeClass('opened'); 538 if ($(this).parent().find('.selection-block').is(":visible")) { 539 $(this).parent().find('.selection-block').slideToggle(500); 540 $(this).parent().toggleClass('opened'); 541 542 } else { 543 $('#registerframe_checkdoublet_block').find('.selection-block').hide(); 544 $(this).parent().find('.selection-block').slideToggle(500); 545 $(this).parent().toggleClass('opened'); 546 } 547 }); 548 549 // $('#registerframe_choose_medium_match .selection').click(function() { 550 // $('.entryblock').removeClass('opened'); 551 // $('#registerframe_checkdoublet_block').find('.selection-block').hide(); 552 // $(this).parent().find('.selection-block').toggle(); 553 // $(this).parent().toggleClass('opened'); 554 555 556 // }); 557 558 $('.choose_high_match_button').click(function() { 559 self.takeDoublet($(this)); 560 }); 561 562 $('.choose_medium_match_button').click(function() { 563 self.takeDoublet($(this)); 564 }); 565 566 // insert anyway 567 $('#registerframe_button_register_no_doublet').click(function() { 568 var params = {'action' : 'insert'}; 569 $.each(self.originalRequest, function(key, value) { 570 if (key !== "action") params[key] = value; 571 }); 572 $.post(R.config.ajax, params, function(data) { 573 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 574 R.nextWindow(self, $.extend(data, { 575 close_callback: self.close_callback, 576 next : next 577 })); 578 }, 'json'); 579 }); 580 581 R.addDefaultValueClass($(this)); 582 return this.base(); 583 }, 584 585 takeDoublet : function(element) { 586 var self = this; 587 var data = self.data; 588 data.doublet_id = element.attr('data-doublet-id'); 589 data.doublet_text = element.attr('data-doublet-text'); 590 data.originalRequest = self.originalRequest; 591 //var next = 'CbCheckDoubletInfoWindow'; 592 var next = self.next.CbCheckDoubletInfoWindow ? self.next.CbCheckDoubletInfoWindow : 'CbCheckDoubletInfoWindow'; 593 R.nextWindow(self, $.extend(data, { 594 close_callback: self.close_callback, 595 next : next 596 })); 597 }, 598 599 handleLoad : function() { 600 var self = this; 601 if (this.data.fullmatch.length > 0) { 602 self.addAditionalData('#registerframe_choose_high_match', this.data.fullmatch, 'high'); 603 $('#registerframe_doublet_high_matches_block').show(); 604 } 605// if (this.data.firstnameFirstChar.length > 0) { 606// self.addAditionalData('#registerframe_choose_medium_match', this.data.firstnameFirstChar, 'medium'); 607// $('#registerframe_doublet_medium_matches_block').show(); 608// } 609 // ToDo add low match when needed 610 return this.base(); 611 }, 612 613 addAditionalData : function(element, matchdata, identifier) { 614 var chooseList = $(element); 615 616 $.each(matchdata, function(index, val) { 617 var entryblock = $(document.createElement('div')); 618 entryblock.addClass('entryblock'); 619 620 var entry = $(document.createElement('div')); 621 var profile_image = $(document.createElement('img')); 622 var profile_image_wrp = $(document.createElement('div')); 623 profile_image_wrp.addClass('duplicate-profile-img-wrp clearfix'); 624 profile_image_wrp.append(profile_image); 625 profile_image.attr('src', val.addData.profile_image); 626 var infotext = val.firstname + " " + val.surname + (val.city != "n/a" && val.city !== "" ? " | " + val.city : "") + (val.email != "n/a" && val.email !== "" ? " | " + val.email : ""); 627 var profile_info_text_wrp = $(document.createElement('div')); 628 profile_info_text_wrp.addClass('duplicate-info-text-wrp'); 629 profile_info_text_wrp.append(infotext); 630 entry.append(profile_image_wrp); 631 profile_image_wrp.append(profile_info_text_wrp); 632 entry.addClass('styled-select-autoheight selection'); 633 var inner = $(document.createElement('div')); 634 inner.addClass('selection-block'); 635 inner.css('display', 'none'); 636 637 // Film 6 638 var film6block = $(document.createElement('div')); 639 film6block.attr('class', 'film-6-block'); 640 $.each(val.addData.film6, function(index_film, film6Film) { 641 var film6LinkBlock = $(document.createElement('div')); 642 var film6Link = $(document.createElement('a')); 643 var film6Url = 'https://dev.culturebase.org/player/?id=' + film6Film.id + '&type=film6'; 644 film6LinkBlock.attr('class', 'film-6-link-block'); 645 film6Link.attr('href', film6Url); 646 film6Link.attr('target', '_blank'); 647 film6Link.text(film6Url); 648 film6LinkBlock.append(film6Link); 649 film6block.append(film6LinkBlock); 650 }); 651 652 if (film6block.html().length > 0) { 653 var film6Header = $('#registerframe_headline_doublet_film6_ml').html(); 654 film6block.prepend(film6Header); 655 inner.append(film6block); 656 } 657 658 // Film 5 659 var film5block = $(document.createElement('div')); 660 film5block.attr('class', 'film-5-block'); 661 $.each(val.addData.film5, function(index_film, film5Film) { 662 var film5LinkBlock = $(document.createElement('div')); 663 var film5Link = $(document.createElement('a')); 664 var film5Url = 'http://hff-muc.de/de_DE/film-detail/' + film5Film.id; 665 film5LinkBlock.attr('class', 'film-5-link-block'); 666 film5Link.attr('href', film5Url); 667 film5Link.attr('target', '_blank'); 668 film5Link.text(film5Url); 669 film5LinkBlock.append(film5Link); 670 film5block.append(film5LinkBlock); 671 }); 672 if (film5block.html().length > 0) { 673 var film5Header = $('#registerframe_headline_doublet_film5_ml').html(); 674 film5block.prepend(film5Header); 675 inner.append(film5block); 676 } 677 678 // user id 679 var userIdblock = $(document.createElement('div')); 680 userIdblock.attr('class', 'user-id-block'); 681 $.each(val.addData.userId, function(index_film, userId) { 682 var userIdLinkBlock = $(document.createElement('div')); 683 var userIdLink = $(document.createElement('a')); 684 var userIdUrl = 'http://kulturportal.de/-/kulturschaffende/detail/' + userId; 685 userIdLinkBlock.attr('class', 'user-id-link-block'); 686 userIdLink.attr('href', userIdUrl); 687 userIdLink.attr('target', '_blank'); 688 userIdLink.text(userIdUrl); 689 userIdLinkBlock.append(userIdLink); 690 userIdblock.append(userIdLinkBlock); 691 }); 692 if (userIdblock.html().length > 0) { 693 var userIdHeader = $('#registerframe_headline_doublet_userid_ml').html(); 694 userIdblock.prepend(userIdHeader); 695 inner.append(userIdblock); 696 } 697 698 inner.append($('<div class="match-button-container"><button class="__CbUiTextButton choose_' + identifier + '_match_button" data-doublet-id="' + val.id + '" data-doublet-text="' + infotext + '">registerframe_button_register_take_doublet</button></div>')); 699 entryblock.append(entry); 700 entryblock.append(inner); 701 chooseList.append(entryblock); 702 }); 703 // $('.user-id-link-block, .film-5-link-block, .film-6-link-block').prepend('<span class="dash-delimiter">- <span>'); 704 // $('.user-id-link-block').prepend('<span class="dash-delimiter">- <span>'); 705 } 706 707 }); 708 709 /** 710 * Window to select a username and password. 711 */ 712 R.CbUserPassWindow = $.CbWidget.window.extend({ 713 714 constructor : function(loadOptions, options, data) { 715 this.base($.extend({ 716 template : '/register/templates/frame.php?content=userpass', 717 cls: '__CbUiRegisterWindow' 718 }, loadOptions), options); 719 this.autocenter(); 720 if (data !== undefined) { 721 this.on_login = data.on_login; 722 this.user_mail = data.user_mail; 723 this.user_id = data.user_id; 724 if (typeof data.close_callback === 'function') this.close_callback = data.close_callback; 725 } 726 this.next = data && data.next ? data.next : {}; 727 }, 728 729 /** 730 * 731 * @param {type} showOrHide set true to show reg new container, hide reg container and switch title 732 * @returns {undefined} 733 */ 734 toggleRegNewContainer : function(showOrHide){ 735 $(".__CbRegNewAccountPasswordContainer").toggle(showOrHide); 736 $(".__CbRegNewAccountText").toggle(showOrHide); 737 $("#registerframe_title_alt").toggle(showOrHide); 738 $(".__CbRegExistAccountPasswordContainer").toggle(!showOrHide); 739 $(".__CbRegExistAccountText").toggle(!showOrHide); 740 $("#registerframe_title").toggle(!showOrHide); 741 }, 742 743 handleReady : function() { 744 var self = this, 745 account_element = $('#registerframe_input_account'), 746 passwd_element = $('#registerframe_input_password'), 747 passwdlost_inactive_element = $('#registerframe_button_password_lost_inactive'), 748 passwdlost_element = $('#registerframe_button_password_lost'), 749 new_passwd_element = $('#registerframe_input_new_password'), 750 new_passwd_confirm_element = $('#registerframe_input_new_password_confirm'), 751 stay_logged_in_element = $('#registerframe_input_stay_logged_in'),
752 stay_logged_in_element_text = $('+span', stay_logged_in_element), 753 hint_widget = $('#registerframe_password_hint').CbWidget(), 754 register_button = $('#registerframe_button_register'); 755 756 var hideReminderIfEnabled = function(){ 757 if (self.reminder_enabled) { 758 $('#registerframe_button_password_reminder').hide().unbind('click'); 759 register_button.show(); 760 self.reminder_enabled = false; 761 } 762 }; 763 var keepLoggedIn = function(element) { 764 return element.length && 765 // some projects use 'on' and others 'true' we need to support both 766 (element.CbWidget().value() === 'true' || element.CbWidget().value() === 'on') ? 1 : 0; 767 }; 768 769 self.toggleRegNewContainer(false); 770 771 R.onceOnClickIfValid(register_button, self, function(e, unlock_button) { 772 $.ajax({ 773 type : 'POST', 774 url : R.config.ajax, 775 data : { 776 action : 'try_login', 777 username : account_element.CbWidget().value(), 778 passwd : self.skip_passwd_checks ? 779 passwd_element.CbWidget().value() : new_passwd_element.CbWidget().value(), 780 user_id : self.user_id, 781 on_login : self.on_login, 782 stay_logged_in : keepLoggedIn(stay_logged_in_element) 783 }, 784 success : function(data) { 785 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 786 if (data.error) unlock_button(); 787 788 R.nextWindow(self, $.extend(data, { 789 close_callback: self.close_callback, 790 next : next 791 })); 792 }, 793 dataType : 'json' 794 }); 795 }); 796 R.bindEnterSubmit($('.__CbUiInputText, .__CbUiPassword', $(this)), register_button); 797 798 var hideStrengthCheck = function() { 799 self.skip_passwd_checks = true; 800 if(new_passwd_element.CbWidget()){ 801 new_passwd_element.CbWidget().removeStrengthCheck(hint_widget); 802 new_passwd_element.CbWidget().suspendValidation(); 803 } 804 if(new_passwd_confirm_element.CbWidget()){ 805 new_passwd_confirm_element.CbWidget().suspendValidation(); 806 } 807 self.toggleRegNewContainer(false); 808 }; 809 810 account_element.blur(function() { 811 // base account syntax validation. 812 $('#registerframe_error').CbWidget().hide(); 813 stay_logged_in_element.show(); 814 stay_logged_in_element_text.show(); 815 816 // trim account input 817 account_element.val($.trim(account_element.val())); 818 819 if (account_element.CbWidget().validate()) { 820 // account check via ajax. 821 $.get(R.config.ajax, { 822 'action' : 'check_account_exists', 823 'account' : account_element.val() 824 }, function (data) { 825 if (data.exists === true) { 826 // account exists. 827 hideStrengthCheck(); 828 passwd_element.CbWidget().resumeValidation(); 829 passwdlost_inactive_element.hide(); 830 passwdlost_element.show(); 831 } else if(account_element.val().match(/@/)) { 832 // account does not exist, but has email syntax, offer new reg. 833 self.skip_passwd_checks = false; 834 if(passwd_element.CbWidget()){ 835 passwd_element.CbWidget().suspendValidation(); 836 } 837 if(new_passwd_element.CbWidget()){ 838 new_passwd_element.CbWidget().resumeValidation(); 839 new_passwd_confirm_element.CbWidget().resumeValidation(); 840 } 841 self.toggleRegNewContainer(true); 842 // trigger focus on the widget's first input el 843 new_passwd_element.find('input').first().focus(); 844 new_passwd_element.CbWidget().addStrengthCheck(hint_widget); 845 passwdlost_inactive_element.hide(); 846 stay_logged_in_element.hide(); 847 stay_logged_in_element_text.hide(); 848 } else { 849 self.trigger('error', {element : account_element}); 850 } 851 }, 'json'); 852 } else { 853 self.trigger('error', {element : account_element}); 854 } 855 }); 856 account_element.focus(function(){ 857 hideStrengthCheck(); 858 if(!passwdlost_inactive_element.is(':visible') && 859 !passwdlost_element.is(':visible') && 860 !$('#registerframe_error span').is(':visible')){ 861 passwdlost_inactive_element.show(); 862 stay_logged_in_element.show(); 863 stay_logged_in_element_text.show(); 864 } 865 866 }); 867
868 /* clear errors when the problematic field gets focus: The user is going 869 * to fix the problem. 870 */ 871 self.element().find('input').focus(function() { 872 if ($(this).hasClass('__CbUiInputError')) { 873 $('.__CbUiInputError').each(function(i, element) { 874 $(element).CbWidget().valid(); 875 }); 876 $('#registerframe_error').CbWidget().hide(); 877 hideReminderIfEnabled(); 878 } 879 }); 880 self.setSupportLink(this.options); 881 R.addDefaultValueClass($(this)); 882 if (self.user_mail) { 883 account_element.val(self.user_mail).trigger('blur'); 884 } 885 886 passwdlost_inactive_element.click(function(){ 887 $.ajax({ 888 type : 'POST', 889 url : R.config.ajax, 890 data : { 891 'action' : 'try_login', 892 'username' : account_element.CbWidget().value(), 893 'passwd' : self.skip_passwd_checks ? 894 passwd_element.CbWidget().value() : new_passwd_element.CbWidget().value(), 895 'user_id' : self.user_id, 896 'on_login' : self.on_login 897 }, 898 success : function(data){ 899 if(data.error){ 900 self.trigger('error', {error : data.error}); 901 } else { 902 passwdlost_inactive_element.hide(); 903 passwdlost_element.show(); 904 } 905 }, 906 dataType : 'json' 907 }); 908 }); 909 passwdlost_element.click(function(){ 910 account_element.unbind('blur'); 911 register_button.click(); 912 }); 913 return this.base(); 914 }, 915 916 handleError : function(params) { 917 var self = this, 918 text = '', 919 passwdlost_element = $('#registerframe_button_password_lost'), 920 passwdlost_inactive_element = $('#registerframe_button_password_lost_inactive'), 921 stay_logged_in_element = $('#registerframe_input_stay_logged_in'), 922 stay_logged_in_element_text = $('+span', stay_logged_in_element); 923 924 if ($(params.element).attr('id') === 'registerframe_input_account') { 925 text = 'registerframe_error_account'; 926 } else if (params.element) { 927 text = 'registerframe_error_passwd'; 928 } else { 929 text = params.error; 930 var suffixes = []; 931 switch (text) { 932 case 'registerframe_error_account': 933 case 'registerframe_error_unfinished': 934 suffixes.push("account"); 935 break; 936 case 'registerframe_error_exists': 937 suffixes.push("password"); 938 break; 939 case 'registerframe_error_passwd': 940 suffixes.push("new_password", "new_password_confirm"); 941 break; 942 } 943 $.each(suffixes, function (i, suffix){ 944 $('#registerframe_input_' + suffix).CbWidget().error(); 945 }); 946 } 947 if (text) { 948 if($('#registerframe_error').CbWidget()) 949 $('#registerframe_error').CbWidget().showText(text); 950 passwdlost_element.hide(); 951 passwdlost_inactive_element.hide(); 952 } 953 954 if ((params.error === 'registerframe_error_exists' || params.error === 'registerframe_error_unfinished') && 955 !self.reminder_enabled) { 956 $('#registerframe_button_register').hide(); 957 var account = $('#registerframe_input_account'); 958 var reminder = $('#registerframe_button_password_reminder'); 959 reminder.show(); 960 passwdlost_element.hide(); 961 stay_logged_in_element.hide(); 962 stay_logged_in_element_text.hide(); 963 R.onceOnClickIfValid(reminder, account.CbWidget(), function() { 964 R.postAndShow({ 965 account : account.CbWidget().value(), 966 action : 'send_reminder' 967 }, self); 968 }, function() { 969 self.trigger('error', {element : account}); 970 }); 971 self.reminder_enabled = true; 972 } 973 return this.base(params); 974 }, 975 976 handleValid : function() { 977 $('#registerframe_error').CbWidget().hide(); 978 return this.base(); 979 } 980 }); 981 982 /** 983 * Window to create a new account. 984 */ 985 R.CbNewAccountWindow = $.CbWidget.text_window.extend({ 986 constructor: function(loadOptions, options, data) { 987 this.base($.extend({ 988 template : '/register/templates/frame.php?content=newaccount', 989 cls: '__CbUiRegisterWindow' 990 }, loadOptions 991 ), 992 options, data ? data.replace_text : {} 993 ); 994 this.autocenter(); 995 if (data !== undefined) { 996 this.account = data.account; 997 this.on_login = data.on_login; 998 this.user_mail = data.user_mail; 999 this.user_id = data.user_id; 1000 if (typeof data.close_callback === 'function') this.close_callback = data.close_callback; 1001 if (data.redirect) { 1002 this.destroy(function() {R.doRedirect(data.redirect);}); 1003 } 1004 } 1005 this.next = data && data.next ? data.next : {}; 1006 }, 1007 1008 handleLoad : function(params) { 1009 if (!this.texts.email) { 1010 $('#registerframe_new_email').show(); 1011 } else { 1012 $('#registerframe_new_email').remove(); 1013 $('#registerframe_newaccount_email').text(this.texts.email).show(); 1014 } 1015 this.base(params); 1016 }, 1017 1018 handleReady : function() { 1019 // simply repeat user greeting from cbui header 1020 if ($('#top .username').text() !== '') { 1021 $('#registerframe_main_page .__CbUiTitle .__CbUiText').prepend($('#top .username').text()+' | '); 1022 } 1023 1024 $('#registerframe_input_password').CbWidget().addStrengthCheck($('#registerframe_password_hint').CbWidget()); 1025 var self = this; 1026 var submit_button = $('#registerframe_button_newaccount'); 1027 R.onceOnClickIfValid(submit_button, self, function() { 1028 var passwd = $('#registerframe_input_password').CbWidget().value(
1028); 1029 var username = $('#registerframe_input_mail').CbWidget(); 1030 $.ajax({ 1031 method : 'POST', 1032 url : R.config.ajax, 1033 data : { 1034 'action' : 'create_account', 1035 'passwd' : passwd, 1036 'username' : username.value(), 1037 'user_id' : self.user_id, 1038 'on_login' : self.on_login 1039 }, success : function(data) { 1040 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 1041 1042 R.nextWindow(self, $.extend(data, { 1043 close_callback: self.close_callback, 1044 next : next 1045 })); 1046 }, dataType : 'json' 1047 }); 1048 }); 1049 R.bindEnterSubmit($('.__CbUiPassword', $(this)), submit_button); 1050 R.addDefaultValueClass($(this)); 1051 if (self.user_mail) { 1052 $('#registerframe_input_mail').val(self.user_mail).trigger('blur'); 1053 } 1054 return this.base(); 1055 }, 1056 1057 handleError : function(params) { 1058 var id = $(params.element).attr('id') || $(params.element).parent().attr('id'); 1059 $('#registerframe_error').CbWidget().showText(id.replace(/_input_/, '_error_')); 1060 return this.base(); 1061 }, 1062 1063 handleValid : function() { 1064 $('#registerframe_error').CbWidget().hide(); 1065 return this.base(); 1066 } 1067 }); 1068 1069 /** 1070 * Window to change a password. 1071 */ 1072 R.CbPasswdChangeWindow = $.CbWidget.text_window.extend({ 1073 constructor: function(loadOptions, options, data) { 1074 this.base($.extend({template : '/register/templates/frame.php?content=passwdchange', cls: '__CbUiRegisterWindow'}, loadOptions), 1075 options, data ? data.replace_text : {}); 1076 this.autocenter(); 1077 this.account = data.account; 1078 if (typeof data.close_callback === 'function') { 1079 this.close_callback = data.close_callback; 1080 } 1081 if (data.redirect) { 1082 this.destroy(function() {R.doRedirect(data.redirect);}); 1083 } 1084 this.next = data && data.next ? data.next : {}; 1085 }, 1086 1087 handleLoad : function(params) { 1088 if (!this.texts.email) { 1089 // email here not needed for now 1090 //$('#registerframe_new_email').show(); 1091 } else { 1092 $('#registerframe_new_email').remove(); 1093 $('#registerframe_changepass_email').text(this.texts.email).show(); 1094 } 1095 this.base(params); 1096 }, 1097 1098 handleReady : function() { 1099 // simply repeat user greeting from cbui header 1100 if ($('#top .username').text() !== '') { 1101 $('#registerframe_main_page .__CbUiTitle .__CbUiText').prepend($('#top .username').text()+' | '); 1102 } 1103 1104 $('#registerframe_input_password').CbWidget().addStrengthCheck($('#registerframe_password_hint').CbWidget()); 1105 var self = this; 1106 // this is actually unused, but we fetch anyway 1107 $.post(R.config.ajax, {'action' : 'get_loggedin_user_data'}, function(data) { 1108 if (data.email) { 1109 $('#registerframe_input_mail').val(data.email).attr('disabled', true); 1110 } 1111 }, 'json'); 1112 // this is actually unused, just to show account 1113 $.post(R.config.ajax, {'action' : 'get_session_data'}, function(data) { 1114 if(data.account){ 1115 $('#registerframe_input_account').val(data.account).attr('disabled', true); 1116 } 1117 }, 'json'); 1118 var submit_button = $('#registerframe_button_passwdchange'); 1119 R.onceOnClickIfValid(submit_button, self, function() { 1120 var passwd = $('#registerframe_input_password').CbWidget().value(); 1121 var email = $('#registerframe_input_mail').CbWidget(); 1122 $.ajax({ 1123 method : 'POST', 1124 url : R.config.ajax, 1125 data : { 1126 'action' : 'change_password', 1127 'password' : passwd, 1128 'email' : email ? email.value() : undefined 1129 }, success : function(data) { 1130 var next = data.next ? (self.next[data.next] ? self.next[data.next] : data.next) : null; 1131 1132 R.nextWindow(self, $.extend(data, { 1133 close_callback: self.close_callback, 1134 next : next 1135 })); 1136 }, dataType : 'json' 1137 }); 1138 }); 1139 R.bindEnterSubmit($('.__CbUiPassword', $(this)), submit_button); 1140 R.addDefaultValueClass($(this)); 1141 window.history.pushState(null, null, window.location.pathname); 1142 return this.base(); 1143 }, 1144 1145 handleError : function(params) { 1146 var id = $(params.element).attr('id') || $(params.element).parent().attr('id'); 1147 $('#registerframe_error').CbWidget().showText(id.replace(/_input_/, '_error_')); 1148 return this.base(); 1149 }, 1150 1151 handleValid : function() { 1152 $('#registerframe_error').CbWidget().hide(); 1153 return this.base(); 1154 } 1155 }); 1156 1157 R.CbVoucherWindow = R.CbMessageWindow.extend({ 1158 constructor: function (loadOptions, options, data) { 1159 this.voucherRole = data.voucherRole; 1160 return this.base($.extend({ 1161 template: '/register/templates/frame.php?content=voucher', 1162 cls: '__CbUiRegisterWindow cb-window' 1163 }, loadOptions), options, $.extend(data, { 1164 next: { 1165 'CbMessageWindow': 'CbMessageWindow' 1166 } 1167 })); 1168 }, 1169 handleReady: function (params) { 1170 var self = this; 1171 1172 $('#registerframe_input_voucher').on('keypress', function (e) { 1173 if (e.which == 13) { 1174 e.preventDefault(); 1175 e.stopPropagation(); 1176 $('#registerframe_button_voucher_to_account').click(); 1177 } 1178 }); 1179 1180 $('#registerframe_button_voucher_to_account').on('click', function (e) { 1181 var voucher = $('input[name="voucher"]').val(); 1182 $.ajax({ 1183 url: R.config.ajax, 1184 type: 'GET', 1185 data: { 1186 'action': 'check_voucher', 1187 'voucher': voucher, 1188 'voucher_role': self.voucherRole 1189 } 1190 }) 1191 .success(function (data) { 1192 if (data === true || data === 'true') { 1193 $('.voucher-error-message').hide(); 1194 $.ajax({ 1195 url: R.config.ajax, 1196 type: 'GET', 1197 data: { 1198 'action': 'set_acl_by_voucher', 1199 'voucher': voucher, 1200 'voucher_role': self.voucherRole 1201 } 1202 }) 1203 .success(function (data) { 1204 if (data === true || data === 'true') { 1205 $('.voucher-error-message').hide(); 1206 location.reload(); 1207 } else { 1208 $('.voucher-error-message').fadeIn(500); 1209 } 1210 }); 1211 } else { 1212 $('.voucher-error-message').fadeIn(500); 1213 } 1214 1215 }); 1216 }); 1217 } 1218 }); 1219 1220})(window.REGISTER = {}, jQuery); 1221 1222// Backward compatibility. Don't use those in new projects 1223// For obvious reasons it's bad to keep those generically named things in the 1224// global namespace. Only access them from the REGISTER namespace from now on. 1225window.CbRegisterConfig = REGISTER.config; 1226window.openWindow = REGISTER.openWindow; 1227window.bindEnterSubmit = REGISTER.bindEnterSubmit; 1228window.doRedirect = REGISTER.doRedirect; 1229window.nextWindow = REGISTER.nextWindow; 1230window.postAndShow = REGISTER.postAndShow; 1231window.prepare = REGISTER.prepare; 1232window.CbUserPassWindow = REGISTER.CbUserPassWindow; 1233window.CbMessageWindow = REGISTER.CbMessageWindow; 1234window.CbVerifyMailWindow = REGISTER.CbVerifyMailWindow; 1235window.CbSelectWindow = REGISTER.CbSelectWindow; 1236window.CbNameSelectWindow = REGISTER.CbNameSelectWindow; 1237window.CbNameAddressWindow = REGISTER.CbNameAddressWindow; 1238window.CbCheckDoubletWindow = REGISTER.CbCheckDoubletWindow; 1239window.CbCheckDoubletInfoWindow = REGISTER.CbCheckDoubletInfoWindow; 1240window.CbPasswdChangeWindow = REGISTER.CbPasswdChangeWindow; 1241window.CbVoucherWindow = REGISTER.CbVoucherWindow;
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.