1var windowWidth = jQuery(window).width(); 2window.onresize = function (event) { 3 windowWidth = jQuery(window).width(); 4 5 if(windowWidth < 1365) { 6 jQuery('#scroll-to-top').fadeOut(); 7 } 8}; 9 10jQuery.noConflict(); 11(function ($) { 12 $(document).ready(function () { 13 var self = this; 14 15 if (!$('.affix').length) { 16 var sFooter = $('footer').outerHeight(true) + 40; 17 var sHeader = $('.com-bar').offset().top - $('.navbar-fixed-top').height(); 18 var posLeft = $('.com-bar').offset().left; 19 20 $('.affix').css('left', posLeft - $(window).scrollLeft()); 21 $('#affix-div').attr("data-spy", "affix"); 22 23 24 $('#affix-div').affix({ 25 offset: { 26 top: sHeader, 27 bottom: sFooter + 1 28 } 29 }); 30 31 $("body").on("click", ".ajax-paging", function (event) { 32 var $target = $(this); 33 var url = $target.attr("href"); 34 35 $target.blur(); 36 $wrapper = $(this).parents('.ajax-content'); 37 $wrapper.height($wrapper.height()); 38 $wrapper.html(getloader(loader_type.std.light)); 39 $wrapper.load(url); 40 41 return false; 42 }); 43 44 45 $(window).resize(function () { 46 posLeft = $('.com-bar').offset().left; 47 $('.affix').css('left', posLeft - $(window).scrollLeft()); 48 }); 49 $(window).scroll(function () { 50 $('.affix').css('left', posLeft - $(window).scrollLeft()); 51 $('.affix').css({ 52 bottom: 'auto' 53 }); 54 $('.affix-bottom').css({ 55 bottom: sFooter 56 }); 57 $('.affix-bottom').css({ 58 left: 'auto' 59 }); 60 }); 61 } 62 63 64 $(document).ajaxError(function (e, xhr, settings) { 65 if (xhr.status == "403") // Forbidden 66 { 67 var $window = popup_open(xhr.responseText); 68 $window.find("input[type='submit']").click(function (event) { 69 postModalForm($window); 70 return false; 71 }); 72 } 73 74 }) 75 76 77 78 $(window).scroll(function () { 79 80 if(windowWidth >= 1365) { 81 if ($(this).scrollTop() > 100) { 82 $('#scroll-to-top').fadeIn(); 83 } else { 84 $('#scroll-to-top').fadeOut(); 85 } 86 } 87 88 if ($(window).scrollTop() >= $(document).height() - $(window).height() - 250) { 89 if ($(".auto_expand_items a").length != 0) { 90 expand($(".auto_expand_items a")); 91 } 92 } 93 94 }); 95 96 97 /** 98 * Handle the click on the Back-To-Top-Button 99 */ 100 $('#scroll-to-top').click(function () { 101 $('body,html').animate({ 102 scrollTop: 0 103 }, 800); 104 return false; 105 }); 106 107 /** 108 * Progress button 109 */ 110 111 $("body").on('click', ".btn.btn-progress-trigger", function (event) { 112 btnInProgress(this); 113 }); 114 115 116 $("body").on('click', ".more-message-text", function (event) { 117 var target = $($(this).data('target')); 118 $(this).parents('.truncate').hide(); 119 target.show(); 120 }); 121 122 $("body").on("click", "div.expand_items a", function () { 123 expand($(this)) 124 }); 125 126 $("body").on("click", "div.more_items a", function () { 127 moreResults($(this)) 128 }); 129 130 function expand($target) { 131 var url = $target.attr("request-url") 132 133 var $box = $target.parents("#expandable, .expandable"); 134 var $div = $box.find(".expand_items"); 135 var $loader = $("<div class='loading'><i class='glyphicon glyphicon-refresh spin font-color-dark'></i></div>"); 136 137 $div.css('min-height', '20px'); 138 $target.parent().css('position', 'relative'); 139 $target.replaceWith($loader); 140 141 jQuery.get(url, function (data) { 142 $div.remove(); 143 $box.append(data); 144 return false; 145 }); 146 147 return false; 148 } 149 150 function moreResults($target) { 151 152 if ($target.attr("request-url") != null) { 153 var url = $target.attr("request-url") 154 } else { 155 return false; 156 } 157 158 var $loader = $("<div class='loading'><i class='glyphicon glyphicon-refresh spin font-color-dark'></i></div>"); 159 var box = $target.parents(".result-list"); 160 161 box.css('min-height', box.height()); 162 box.html($loader); 163 164 jQuery.get(url, function ($data) { 165 box.html($data); 166 return false; 167 }); 168 169 return false; 170 } 171 172 // jQuery.noConflict(); 173 // (function ($) { 174 175 176 $(".hastooltip").tooltip(); 177 $(".hastooltip").hover(function (event) { 178 179 $(this).tooltip('show') 180 }) 181 182 183 // })(jQuery); 184 185 186 // $("#search_box a").on("click", function(event){ 187 // var $target = $(this); 188 // var rel = $target.attr( "rel" ); 189 // var url = $target.attr( "href" ); 190 // 191 // $("#search_box").find("a").removeClass("active"); 192 // $("#search_box").find("a[rel='"+rel+"']").addClass("active"); 193 // 194 // jQuery.get(url, function(data){ 195 // $("#search_results > div").remove(); 196 // $("#search_results").html(data); 197 // }); 198 // 199 // return false; 200 // }); 201 202 // $("#search_results div.more_items a").on("click", function(event){ 203 // 204 // var $target = $(this); 205 // var rel = $target.attr( "rel" ); 206 // var url = $target.attr( "href" ); 207 // var page = $target.parent().attr( "rel" ); 208 // 209 // $("#search_box").find("a").removeClass("active"); 210 // $("#search_box").find("a[rel='"+rel+"']").addClass("active"); 211 // 212 // var $div = $target.parent(); 213 // var $loader = $("<div class='loading'></div>"); 214 // 215 // $div.css("background", "white"); 216 // $div.css("padding", "2px"); 217 // $div.html($loader); 218 // 219 // jQuery.get(url, function(data){ 220 // $("#search_results div.more_items").remove(); 221 // 222 // if (page == 1) { 223 // $("#search_results > div").remove(); 224 // $("#search_results").html(data); 225 // } else{ 226 // alert('test'); 227 // $("#search_results").append(data); 228 // } 229 // 230 // }); 231 // 232 // 233 // 234 // return false; 235 // }); 236 237 // $("span.user a, a.user, a.usertext").on("mouseover", function(event){ 238 // var $target = $(this); 239 // var $span = $target.parent(); 240 // var url = $target.attr( "href" ); 241 // var id = $target.attr( "id" ); 242 // var rel = $span.attr( "rel" ); 243 // //var position = $target.position(); 244 // 245 // 246 // if (rel) { 247 // this.timeoutID = window.setTimeout(function(){ 248 // if(typeof self.userinfo == "object") { 249 // $(self.userinfo).remove(); 250 // delete self.userinfo; 251 // } 252 // 253 // self.userinfo = $( "<div class='info user' style='position: absolute; display: none; top: 0px; left: -2px'></div>").appendTo($span); 254 // 255 // 256 // $(self.userinfo).load(rel, function(){ 257 // var height = $(self.userinfo).outerHeight(); 258 // $(self.userinfo).css('top', -(height+8)+"px"); 259 // $(self.userinfo).fadeIn(); 260 // }); 261 // }, 500); 262 // } 263 // }); 264 265 266 $("span.user a, a.user, a.usertext").on("mouseout", function (event) { 267 268 if (typeof this.timeoutID == "number") { 269 window.clearTimeout(this.timeoutID); 270 delete this.timeoutID; 271 } 272 273 self.mouseoutID = window.setTimeout(function () { 274 if (typeof self.userinfo == "object") { 275 $(self.userinfo).remove(); 276 delete self.userinfo; 277 } 278 }, 0); 279 });
280 281 282 $("#messages img.close").on("click", function (event) { 283 var $target = $(this); 284 $target.parent().fadeOut(); 285 }); 286 287 288 // Like Button 289 290 $("body").on("click", "button.button_like_event", function (event) { 291 var $target = $(this); 292 var url = $target.attr("rel"); 293 var icon = $target.find('.glyphicon'); 294 295 jQuery.get(url, function (data) { 296 var text1 = $target.find(".like-text").html(); 297 298 $target.find(".like-text").html($target.attr("toggle-text")); 299 $target.find(".like-counter").html(data); 300 301 $target.attr("toggle-text", text1); 302 303 if (icon.hasClass('glyphicon-ok')) { 304 icon.removeClass('glyphicon-ok'); 305 icon.addClass('glyphicon-remove'); 306 } else if (icon.hasClass('glyphicon-remove')) { 307 icon.removeClass('glyphicon-remove'); 308 icon.addClass('glyphicon-ok'); 309 } 310 }); 311 312 return false; 313 314 }); 315 316 317 // Friend Add Button 318 $("a.button_add_friend").on("click", function (event) { 319 var $target = $(this); 320 var url = $target.attr("request-url"); 321 var title = $target.attr("title"); 322 323 jQuery.get(url, function (data) { 324 $target.fadeOut(); 325 }); 326 327 return false; 328 }); 329 330 // Friend Request Button 331 $("body").on("click", "a.button_friend_accept", function (event) { 332 var $target = $(this); 333 var url = $target.attr("request-url"); 334 var title = $target.attr("title"); 335 336 jQuery.getJSON(url, function (data) { 337 338 $("ul#login_nav li.profile div ul li.friends a").html("" + data.num_requests); 339 340 if (data.accepted) { 341 $target.parent().parent().parent().removeClass('unread'); 342 $target.parent().parent().parent().html("" + data.accepted); 343 } else { 344 $target.parent().parent().parent().fadeOut(); 345 } 346 347 // if (data.num_requests == 0) 348 // $("ul#login_nav li.profile div ul li.friends a, ul#login_nav li.profile div ul li.inbox a").removeClass("active"); 349 // $('ul#login_nav li.profile').find("#show_box").remove(); 350 }); 351 352 }); 353 354 355 // $("button.button_new_message, button.button_suggest_friends").on("click", function(event){ 356 // var $target = $(this); 357 // var url = $target.attr( "rel" ); 358 // var title = $target.attr( "title" ); 359 // 360 // jQuery.get(url, function(data){ 361 // var $window = popup_open(data); 362 // 363 // $window.find("input[type='submit']").click(function(event){ 364 // postModalForm($window); 365 // return false; 366 // }); 367 // }); 368 // 369 // return false; 370 // }); 371 372 $("body").on("click", ".new_thread, .edit_thread, .edit_album, .edit_album_title, .edit_profile", function (event) { 373 var $target = $(this); 374 var url = $target.attr("request-url"); 375 var headline = $target.attr("title"); 376 jQuery.get(url, function (data) { 377 var $window = popup_open(data, headline); 378 379 if ($("#the-dropzone").length != 0) { 380 $("#the-dropzone").dropzone(); 381 } 382 383 $window.find("input[type='submit'], button[type='submit']").click(function (event) { 384 postModalRedirectForm($window); 385 return false; 386 }); 387 388 return false; 389 }); 390 }); 391 392 $("body").on("click", ".album_image_description_edit", function (event) { 393 var $target = $(this); 394 var url = $target.attr("request-url"); 395 var headline = $target.attr("title"); 396 jQuery.get(url, function (data) { 397 var $window = popup_open(data, headline); 398 $window.find("input[type='submit']").click(function (event) { 399 postModalContentAttributeForm($window, $($target.attr("target")), "title"); 400 return false; 401 }); 402 403 return false; 404 }); 405 }); 406 407 $("body").on("click", ".edit_profile_image", function (event) { 408 var $target = $(this); 409 var url = $target.attr("request-url"); 410 var headline = $target.attr("title"); 411 jQuery.get(url, function (data) { 412 var $window = popup_open(data, headline); 413 $window.find("input[type='submit']").click(function (event) { 414 postModalContentAttributeForm($window, $($target.attr("target")), "src"); 415 return false; 416 }); 417 418 return false; 419 }); 420 });
421 422 $("body").on("click", ".edit_album_in_tabbar", function (event) { 423 var $target = $(this); 424 var url = $target.attr("request-url"); 425 var headline = $target.attr("title"); 426 jQuery.get(url, function (data) { 427 var $window = popup_open(data, headline); 428 $(".modal form").attr('action', url); 429 if ($("#the-dropzone").length != 0) { 430 $("#the-dropzone").dropzone(); 431 432 } 433 $window.find("input[type='submit']").click(function (event) { 434 postModalContentForm($window, $($target.attr("target"))); 435 return false; 436 }); 437 438 return false; 439 }); 440 }); 441 442 443 $("body").on("click", ".edit_comment", function (event) { 444 var $target = $(this); 445 var url = $target.attr("request-url"); 446 var headline = $target.attr("title"); 447 jQuery.get(url, function (data) { 448 var $window = popup_open(data, headline); 449 $window.find("[type='submit']").click(function (event) { 450 editComment($window, $target.parents('.media')); 451 return false; 452 }); 453 454 return false; 455 }); 456 }); 457 458 $("body").on("click", "a.button_new_message, .message_answer, a.button_suggest_friends, .add-event-trigger", function (event) { 459 460 var $target = $(this); 461 var url = $target.attr("request-url"); 462 var headline = $target.attr("title"); 463 jQuery.get(url, function (data) { 464 var $window = popup_open(data, headline); 465 $window.find("[type='submit']").click(function (event) { 466 event.stopPropagation(); 467 postModalForm($window); 468 return false; 469 }); 470 471 return false; 472 }); 473 }); 474 // User select 475 476 $("body").on("click", "div.select_user a", function (event) { 477 var $target = $(this); 478 var user_id = $target.attr("rel"); 479 var title = $target.attr("title"); 480 var $input = $target.parents("form").find("#suggest_friends_to_add"); 481 var $box = $target.parent(); 482 483 var value = $input.val(); 484 var values = new Array(); 485 486 if (value) { 487 values = value.split(","); 488 } 489 490 if (jQuery.inArray(user_id, values) != "-1") { 491 values.splice(values.indexOf(user_id), 1); 492 $box.removeClass("active"); 493 } 494 else { 495 values.push(user_id); 496 $box.addClass("active"); 497 } 498 499 $input.val(values.join(",")); 500 501 return false; 502 }); 503 504 505 function popup_open(data, title) { 506 $('#modal').remove(); 507 var $window = $('<div id="modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content">'); 508 var $dialog = $('<div class="modal-dialog">'); 509 var $content = $('<div class="modal-content">'); 510 var $header = $('<div class="modal-header"></div>'); 511 var $close = $('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">Ã</button>'); 512 if (title) { 513 var $title = $('<h4 id="modal-title">' + title + '</h4>'); 514 } else { 515 var $title = $('<h4 id="modal-title"></h4>'); 516 } 517 $header.append($close); 518 $header.append($title); 519 var $body = $('<div class="modal-body">'); 520 $body.html(data); 521 $content.append($header); 522 $content.append($body); 523 524 $dialog.append($content); 525 $window.append($dialog); 526 // var $footer = $('<div class="modal-footer">'); 527 // $window.append($footer); 528 529 $("body").append($window); 530 531 $('#modal').modal('show'); 532 533 $("#modal").on("click", "div.close, input.cancel, button.cancel", function (event) { 534 popup_close($window); 535 }); 536 537 return $window; 538 } 539 540 function lightbox_open(img, cap) { 541 $("#theLightbox").remove(); 542 var $box = $('<div id="theLightbox" class="lightbox fade" tabindex="-1" role="dialog" aria-hidden="true">'); 543 var $header = $('<div class="lightbox-header"><button type="button" class="close" data-dismiss="lightbox" aria-hidden="true">×</button></div>'); 544 var $content = $('<div class="lightbox-content">'); 545 if (cap) { 546 var $caption = $('<div class="lightbox-caption"><p>' + cap + '</p></div>'); 547 } 548 var $image = $('<img src="' + img + '">'); 549 $content.append($image); 550 $content.append($caption); 551 $box.append($header); 552 $box.append($content); 553 554 $('body').append($box); 555 $('#theLightbox img').load(function () { 556 $('#theLightbox').lightbox(); 557 }); 558 559 } 560 561 562 $('body').on('click', '.lightbox-photo', function () { 563 var img = $(this).attr('img-url'); 564 var cap = $(this).attr('title'); 565 lightbox_open(img, cap); 566 });
567 568 569 $("body").on("click", "a.feed_like", function (event) { 570 var $target = $(this); 571 var $div = $target.parents("div.content").find("div.likes"); 572 var url = $target.attr("href"); 573 574 jQuery.getJSON(url, function (data) { 575 $target.html(data.link); 576 $div.html(data.content); 577 }); 578 579 return false; 580 }); 581 582 $("body").on("click", "a.feed_comment", function () { 583 $(this).parent().parent().find('.ufi-box').toggle(); 584 return false; 585 }); 586 587 // $("a.feed_comment").on("click", function(event){ 588 // var $target = $(this); 589 // var $div = $target.parents("div.content").find("div.comment"); 590 // 591 // $div.show(); 592 // $div.find("input").focus(); 593 // 594 // return false; 595 // }); 596 597 $("div.feed ul li div > div.comment input").on("focus", function (event) { 598 var $target = $(this); 599 var $img = $target.parents("div.comment").find("img"); 600 601 $target.addClass("focus"); 602 $target.val(""); 603 $img.fadeIn(); 604 }); 605 606 607 $("body").on("click", "#added-images-action", function (event) { 608 var url = $(this).attr("request-url"); 609 var $target = $($(this).attr("target")); 610 611 $target.html("<div class='loading'><i class='glyphicon glyphicon-refresh spin font-color-dark'></i></div>") 612 jQuery.get(url, function (data) { 613 $target.html(data); 614 }); 615 }) 616 617 618 $("#tabbar_navi a").on("click", "", function (event) { 619 var $target = $(this); 620 var url = $target.attr("href"); 621 622 $target.blur(); 623 $("#tabbar_navi li").removeClass("active"); 624 625 $target.parents('.dropdown').find('.dropdown-toggle').text($target.text()); 626 $("#tabbar_content").css('min-height', '100px'); 627 $("#tabbar_content").html(getloader(loader_type.std.dark)); 628 629 $target.parent().addClass("active"); 630 631 $("#tabbar_content").load(url); 632 633 return false; 634 }); 635 636 //delete Item (it fades out) 637 $("body").on("click", "a.delete_friend, .message-delete, .picture-delete, .album_delete_in_tabbar", function (event) { 638 var $target = $(this); 639 var url = $target.attr("request-url"); 640 var messagehead = $target.attr("message-head"); 641 var message = $target.attr("message"); 642 643 $target.blur(); 644 var $window = popup_open(message, messagehead); 645 646 $window.find('#message-close').on("click", function () { 647 popup_close($window); 648 }); 649 650 $window.find('#message-yes').on("click", function () { 651 jQuery.get(url, function (data) { 652 if (todelete = $target.attr("target")) { 653 popup_close($window); 654 $(todelete).delay(500).slideUp(); 655 } else { 656 popup_close($window); 657 $target.parent().parent().delay(500).slideUp(); 658 } 659 660 }); 661 }) 662 return false; 663 }); 664 665 //delete something big (redirect) 666 $("body").on("click", ".album-delete, .advert-delete", function (event) { 667 var $target = $(this); 668 var url = $target.attr("request-url"); 669 var redirectUrl = $target.attr("redirect-url"); 670 var messagehead = $target.attr("message-head"); 671 var message = $target.attr("message"); 672 673 var $window = popup_open(message, messagehead); 674 675 $window.find('#message-close').on("click", function () { 676 popup_close($window); 677 }); 678 679 $window.find('#message-yes').on("click", function () { 680 jQuery.get(url, function (data) { 681 popup_close($window); 682 window.location.href = redirectUrl; 683 }); 684 }) 685 return false; 686 }); 687 688 $("#tabbar").on("click", ".show-message", function (event) { 689 690 $(this).parent().toggleClass("open-message") 691 var toToggle = $("." + $(this).attr('body-toggle')); 692 toToggle.toggle(); 693 694 var url = $(this).parent().attr("request-url") 695 $(this).parent().find(".unread").fadeOut(); 696 jQuery.get(url, function (data) { 697 698 }); 699 700 });
701 702 703 // Like Item 704 $("a.like").on("click", function (event) { 705 var $target = $(this); 706 var url = $target.attr("href"); 707 708 $target.blur(); 709 710 jQuery.get(url, function (data) { 711 $target.parent().fadeOut(); 712 }); 713 714 return false; 715 }); 716 717 718 $("#tabbar a.expand, div.feed a.expand, fieldset a.expand, #tabbar a.album_photo").on("click", function (event) { 719 var $target = $(this); 720 721 $target.fancybox(); 722 $target.triggerHandler('click'); 723 724 return false; 725 }); 726 727 728 $("#tabbar a.album").on("click", function (event) { 729 var $target = $(this); 730 var url = $target.attr("href"); 731 var $box = $target.parents("#tabbar_content"); 732 var $loader = $("<div class='loading'><i class='glyphicon glyphicon-refresh spin font-color-dark'></i></div>"); 733 734 $box.html($loader); 735 736 jQuery.get(url, function (data) { 737 $box.html(data); 738 }); 739 740 return false; 741 }); 742 743 744 // Delete User Form 745 $("form.form_delete").on({ 746 "submit": function (event) { 747 var $target = $(this); 748 var $input = $target.find("input"); 749 750 if ($input.val() == "on") { 751 return confirm($input.next().html()) 752 } 753 754 return false; 755 } 756 }); 757 758 759 // Edit User Photo 760 // $("body").on("click", "#user_photo_manager a", function(event){ 761 // var $target = $(this); 762 // var url = $target.attr( "rel" ); 763 // var title = $target.attr( "title" ); 764 // 765 // jQuery.get(url, function(data){ 766 // var $window = popup_open(data); 767 // $window.find("input[type='submit']").click(function(event){ 768 // postModalForm($window); 769 // return false; 770 // }); 771 // }); 772 // 773 // return false; 774 // }); 775 776 // $(document).find('#user_album').on('show', function (event) { 777 // alert('Funktion wird aufgerufen!'); 778 // var $target = $(event.target); 779 // var url = $target.attr("request-url"); 780 // jQuery.get(url, function(data){ 781 // $target.html(data); 782 // }); 783 // }) 784 785 $('#tabbar').on('click', '.accordion-toggle', function () { 786 item = $(this); 787 788 var url = $(this).attr('request-url'); 789 var inner = $(this).parents('.accordion-heading').next().find('.accordion-inner'); 790 791 var $loader = $("<div class='loading'><i class='glyphicon glyphicon-refresh spin font-color-dark'></i></div>"); 792 inner.html($loader); 793 794 jQuery.get(url, function (data) { 795 inner.html(data); 796 $('.accordion-toggle').popover('hide'); 797 setTimeout(function () { 798 if (inner.parents('.album-pictures').hasClass('in')) { 799 $(item).popover('show'); 800 } 801 }, 500); 802 }); 803 }); 804 805 $('#tabbar').on('show', '.accordion-group', function (e) { 806 if ($(e.target).hasClass("accordion-body")) { 807 $('.accordion-toggle').popover('hide'); 808 setTimeout(function () { 809 $(item).popover('show'); 810 }, 500) 811 } 812 813 }) 814 $('#tabbar').on('hide', '.accordion-group', function (e) { 815 if ($(e.target).hasClass("accordion-body")) { 816 $('.accordion-toggle').popover('hide'); 817 } 818 819 }) 820 821 822 var timeoutObj; 823 824 $('body').on("mouseenter", '.album_photo_img', function (e) { 825 $(this).popover('show'); 826 }).on("mouseleave", '.album_photo_img', function (e) { // 827 var ref = $(this); 828 timeoutObj = setTimeout(function () { 829 ref.popover('hide'); //popover hides after 0.1s 830 }, 300); 831 $(".popover").on("mouseenter", function () { 832 window.clearTimeout(timeoutObj); //when the popover is entered after less than 0.1s it stays open 833 }).on("mouseleave", function () { 834 ref.popover('destroy'); //when the cursor leaves the popover ist closes 835 }) 836 });
837 838 839 var timeoutObj; 840 841 $('body').on("mouseenter", 'a.usertext', function (e) { // if the mouse enters an element a.usertext a... 842 var url = $(this).attr('request-url'); 843 var status = $(this).attr('online-status'); 844 var popoverId = 'popover-id-' + $(this).data('user-id'); 845 846 $(this).popover({ // ...popover is generated without content 847 offset: 10, 848 trigger: 'manual', 849 html: true, 850 placement: 'bottom', 851 container: 'body', 852 template: '<div id="' + popoverId + '" class="popover bigger"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 853 }).popover('show'); 854 855 var popover = $('#' + popoverId); 856 857 e.preventDefault(); 858 var $this = $(this); 859 if (typeof this.ajaxHtml != 'undefined') { //Retrieve cache response and check if it's a string or undefined 860 popover.find('.popover-content').html(this.ajaxHtml); 861 if (status == "online") { 862 popover.find('.popover-title').append("<div class='pull-right online'></div>"); 863 } // In case of a string, the html is inserted staight in into the popover-content 864 return true; //return if true 865 } else { // ELSE the ajax-request is started via the popovers request-url (url) 866 popover.find('.popover-content').html("<div class='loading'><i class='glyphicon glyphicon-refresh font-color-dark spin'></i></div>"); 867 $.ajax({
868 url: url, 869 context: document.body 870 }).done(function (resp) { 871 $this[0].ajaxHtml = resp; // Is this done the response is binded to the jQuery DOM-object 872 if (status == "online") { 873 popover('.popover-title').append("<div class='pull-right online'></div>"); 874 } 875 popover.find('.popover-content').html(resp); // and the popover-content is filled with the html-response. 876 }); 877 return false 878 } 879 880 }).on("mouseleave", 'a.usertext', function (e) { // 881 var ref = $(this); 882 var popoverId = 'popover-id-' + ref.data('user-id'); 883 var popover = $('#' + popoverId); 884 885 timeoutObj = setTimeout(function () { 886 ref.popover('hide'); //popover hides after 0.1s 887 }, 500); 888 889 popover.on("mouseenter", function () { 890 window.clearTimeout(timeoutObj); //when the popover is entered after less than 0.1s it stays open 891 }).on("mouseleave", function () { 892 ref.popover('destroy'); //when the cursor leaves the popover ist closes 893 }) 894 }); 895 896 897 function postModalForm($window) { 898 var submitBtn = $window.find("input[type='submit'], button[type='submit']")[0]; 899 var form = $(".modal form")[0]; 900 formValdation.observeFormValidation(form); 901 902 if(formValdation.isValid(form)) { 903 btnInProgress(submitBtn).done(function() { 904 var formData = new FormData(form); 905 $.ajax({
906 url: $(form).attr('action'), 907 type: 'POST', 908 data: formData, 909 async: false, 910 cache: false, 911 contentType: false, 912 processData: false, 913 success: function (data) { 914 if (data) { 915 $window.find("div.modal-body").html(data); 916 $window.find("input[type='submit'], button[type='submit']").click(function (event) { 917 postModalForm($window); 918 event.stopPropagation(); 919 return false; 920 }); 921 } else { 922 var msg = $(form).data('msg'); 923 var refresh = $(form).data('refresh'); 924 925 $window.find("div.modal-body").html('<p class="alert alert-success">' + msg + '</p>'); 926 927 setTimeout(function () { 928 popup_close($window); 929 if (refresh) { 930 location.reload(); 931 } 932 }, 1500); 933 } 934 } 935 }); 936 }); 937 } 938 939 return false; 940 } 941 942 function postModalContentForm($window, $domElement) { 943 944 jQuery.post($(".modal form").attr('action'), $(".modal form").serialize(), function (data) { 945 if (data["redirect"]) { 946 $domElement.replaceWith(data["content"]); 947 popup_close($window); 948 } else { 949 $window.find("div.modal-body").html(data["form"]); 950 $window.find("input[type='submit']").click(function (event) { 951 postModalContentForm($window); 952 event.stopPropagation(); 953 return false; 954 }) 955 } 956 957 }, "json"); 958 959 return false; 960 } 961 962 function postModalContentAttributeForm($window, $domElement, attr) { 963 964 jQuery.post($(".modal form").attr('action'), $(".modal form").serialize(), function (data) { 965 if (data["redirect"]) { 966 $domElement.attr(attr, data["content"]); 967 popup_close($window); 968 } else { 969 $window.find("div.modal-body").html(data["form"]); 970 $window.find("input[type='submit']").click(function (event) { 971 postModalContentAttributeForm($window); 972 event.stopPropagation(); 973 return false; 974 }) 975 } 976 977 }, "json"); 978 979 return false; 980 } 981 982 function postModalRedirectForm($window) { 983 var submitBtn = $window.find("[type='submit']")[0]; 984 var form = $(".modal form")[0]; 985 986 btnInProgress(submitBtn).done(function() { 987 var formData = new FormData(form); 988 $.ajax({
989 url: $(form).attr('action'), 990 type: 'POST', 991 data: formData, 992 dataType: 'json', 993 async: false, 994 cache: false, 995 contentType: false, 996 processData: false, 997 success: function (data) { 998 if (data["redirect"]) { 999 window.location.href = data["url"]; 1000 } else { 1001 $window.find("div.modal-body").html(data["form"]); 1002 $window.find("[type='submit']").click(function (event) { 1003 postModalRedirectForm($window); 1004 event.stopPropagation(); 1005 return false; 1006 }) 1007 } 1008 } 1009 }); 1010 }); 1011 1012 return false; 1013 } 1014 1015 $(".dropdown-menu form").on("click", function (e) { 1016 e.stopPropagation(); 1017 }); 1018 }); 1019})(jQuery); 1020 1021 1022function sendPollData(item, url) { 1023 jQuery.noConflict(); 1024 (function ($) { 1025 var data = $("input", "#" + item).serialize(); 1026 1027 1028 if (data) { 1029 $(".answers", "#" + item).load(url, data); 1030 } else { 1031 alert("Bitte treffe eine Auswahl..."); 1032 } 1033 })(jQuery); 1034} 1035 1036 1037function sendComment(url) { 1038 1039 jQuery.noConflict(); 1040 (function ($) { 1041 1042 var form = $("form#comment")[0]; 1043 var button = $(form).find('button')[0]; 1044 var textarea = $("form#comment textarea"); 1045 1046 btnInProgress(button).done(function(){ 1047 var formData = new FormData(form); 1048 $.ajax({
1049 url: url, 1050 type: 'POST', 1051 data: formData, 1052 async: false, 1053 cache: false, 1054 contentType: false, 1055 processData: false, 1056 success: function (data) { 1057 $item = $(data).hide(); 1058 1059 if ($('.thread-post-list #expandable').length > 0) { 1060 $('.thread-post-list #expandable').parent('.hide').removeClass('hide'); 1061 $('.thread-post-list #expandable').append($item); 1062 } else { 1063 $('.commentbox #expandable').parents('.hide').removeClass('hide'); 1064 $('.commentbox #expandable').prepend($item); 1065 } 1066 $item.slideDown(); 1067 1068 textarea.val(""); 1069 btnRelease(button); 1070 } 1071 }); 1072 }); 1073 1074 return false; 1075 })(jQuery); 1076} 1077 1078function sendForumComment(url) { 1079 jQuery.noConflict(); 1080 (function ($) { 1081 1082 jQuery.post(url, $("form#comment").serialize(), function (data) { 1083 $("form#comment textarea").val(""); 1084 $item = $(data); 1085 if ($('#expandable').hasClass('forum-coment-list')) { 1086 $('#expandable').append($item); 1087 } else { 1088 $('#expandable').prepend($item); 1089 } 1090 $item.delay(500).fadeIn(); 1091 }); 1092 1093 return false; 1094 })(jQuery); 1095} 1096 1097function editComment($window, $comment) { 1098 jQuery.noConflict(); 1099 (function ($) { 1100 var form = $(".modal form")[0]; 1101 var button = $(form).find('[type="submit"]')[0]; 1102 1103 btnInProgress(button).done(function() { 1104 var formData = new FormData(form); 1105 $.ajax({
1106 url: $(".modal form").attr('action'), 1107 type: 'POST', 1108 data: formData, 1109 dataType: 'json', 1110 async: false, 1111 cache: false, 1112 contentType: false, 1113 processData: false, 1114 success: function (data) { 1115 if (data["success"]) { 1116 popup_close($window); 1117 var element = $(data["content"]).hide() 1118 setTimeout(function () { 1119 $comment.replaceWith(element); 1120 element.fadeIn(); 1121 }, 700); 1122 } else { 1123 $window.find("div.modal-body").html(data["form"]); 1124 $window.find("input[type='submit']").click(function (event) { 1125 editComment($window, $comment); 1126 return false; 1127 }); 1128 } 1129 } 1130 }); 1131 }); 1132 1133 1134 return false; 1135 })(jQuery); 1136} 1137 1138function sendMarketplaceMessage(url) { 1139 jQuery.noConflict(); 1140 (function ($) { 1141 1142 jQuery.post(url, $("form#message").serialize(), function (data) { 1143 $item = $(data); 1144 $("form.marketplace-message").parent().html($item); 1145 }); 1146 return false; 1147 })(jQuery); 1148} 1149 1150function submitStatus(url, form) { 1151 jQuery.noConflict(); 1152 (function ($) { 1153 var $form = $(form) 1154 var $field = $form.find('input'); 1155 1156 jQuery.post(url, $form.serialize(), function (data) { 1157 var element = $(data).hide(); 1158 1159 $("#tabbar_content").find(".pinnwand").prepend(element); 1160 element.slideDown(); 1161 1162 $field.attr('disabled', false) 1163 $field.val(''); 1164 }); 1165 1166 $field.attr('disabled', true) 1167 $field.val($field.data('msg-wait')); 1168 })(jQuery); 1169} 1170 1171function sendFeedComment(url, itemId) { 1172 jQuery.noConflict(); 1173 (function ($) { 1174 1175 jQuery.getJSON(url, $("form#commentFormFor-" + itemId).serialize(), function (data) { 1176 $item = (data.content); 1177 $('#commentsfor-' + itemId).html($item); 1178 $('form#commentFormFor-' + itemId + ' input[type=text]').val(""); 1179 }); 1180 1181 return false; 1182 })(jQuery); 1183} 1184 1185function popup_close($window) { 1186 jQuery.noConflict(); 1187 (function ($) { 1188 1189 $('#modal').modal('hide'); 1190 setTimeout(function () { 1191 $window.remove(); 1192 }, 300); 1193 })(jQuery); 1194} 1195 1196/** 1197 * Loader wheel 1198 * @type {{std: {light: string, dark: string}}} 1199 */ 1200var loader_type = { 1201 std: { 1202 light: 'std-light', 1203 dark: 'std-dark' 1204 } 1205}; 1206 1207function getloader(type) { 1208 type = typeof type !== 'undefined' ? type : loader_type.std.light; 1209 1210 if (type == loader_type.std.light) { 1211 var loader = "<div class='loading'><i class='glyphicon glyphicon-refresh spin'></i></div>"; 1212 } 1213 if (type == loader_type.std.dark) { 1214 var loader = "<div class='loading'><i class='glyphicon glyphicon-refresh font-color-dark spin'></i></div>"; 1215 } 1216 1217 return loader; 1218} 1219 1220/** 1221 * Progress button 1222 * @param target 1223 * @returns {*} 1224 */ 1225function btnInProgress(target) { 1226 var deferred = jQuery.Deferred(); 1227 var button = jQuery(target); 1228 var buttonText = button.html(); 1229 1230 button.attr('disabled', true); 1231 button.html('<i class="glyphicon glyphicon-refresh spin"></i> Bitte Warten ...'); 1232 button.data('temp-inner-html', buttonText); 1233 1234 // The delay is to send the dom output 1235 // before the aysnc processing will freeze 1236 button.delay(100).promise().done(function(){ 1237 deferred.resolve(); 1238 }); 1239 1240 return deferred; 1241}; 1242 1243function btnRelease (target) { 1244 var button = jQuery(target); 1245 button.attr('disabled', false); 1246 button.html(button.data('temp-inner-html')); 1247}; 1248 1249 1250/** 1251 * For HTML5 form validation 1252 * 1253 */ 1254var formValdation = (function($) { 1255 1256 /** 1257 * Constructor 1258 */ 1259 var formValdation = function () { 1260 }; 1261 1262 1263 /** 1264 * Check if the form ist valid 1265 * 1266 * @param form 1267 * @returns {boolean} 1268 */ 1269 formValdation.prototype.isValid = function (form) { 1270 var errorGroups = $(form).find('.form-group.has-error'); 1271 1272 return errorGroups.length > 0 ? false : true; 1273 } 1274 1275 /** 1276 * Validate an input field 1277 * 1278 * @param input 1279 */ 1280 formValdation.prototype.validateInput = function (input) { 1281 var result = input.checkValidity(); 1282 1283 if(!result) { 1284 $(input).parents('.form-group').addClass('has-error'); 1285 } else { 1286 $(input).parents('.form-group').removeClass('has-error'); 1287 } 1288 }; 1289 1290 /** 1291 * Validate a form 1292 * 1293 * @param form 1294 */ 1295 formValdation.prototype.validateForm = function(form) { 1296 var inputs = $(form).find(':input'); 1297 var _ = this; 1298 1299 inputs.each(function(idx, field){ 1300 _.validateInput(field); 1301 });
1302 }; 1303 1304 1305 /** 1306 * Observe a form of validation 1307 * 1308 * @param form 1309 */ 1310 formValdation.prototype.observeFormValidation = function(form) { 1311 var inputs = $(form).find(':input'); 1312 var _ = this; 1313 1314 inputs.each(function(idx, field){ 1315 $(field).on('keyup change', function(){ 1316 _.validateInput(this); 1317 }); 1318 }); 1319 1320 this.validateForm(form); 1321 }; 1322 1323 return new formValdation(); 1324}(jQuery));
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.