var mySwfu; var ajax_key; var auth_token; var mediacenter_selecteditems = new Array(); var mediacenter_selectionqry; var mediacenter_mode; var postbox_messagecount = -1; var isCtrl = false; function createUploadPreviewTooltip(){ return '
'; } $(document).ready(function(){ /* init upload tooltips */ $(".upload-tooltip").tooltip({ track: true, bodyHandler: createUploadPreviewTooltip }); $(".upload-preview").mouseover(function(){ $("img#upload-preview").attr('src', ('http://www.talentsuche.de/media/get/11?file=' + $(this).attr('rel'))); }); /* init sidebar */ if($('.sidebar-pane')){ $('.sidebar').css('height', $('.sidebar-pane').height() + 'px'); } /* autoclear inputs */ $("input.autoclear, select.autoclear").focus(function(){ if($(this).attr('value') == $(this).attr('rel')){ this.value = ''; this.style.color='#000'; }}); $("input.autoclear, select.autoclear").blur(function(){ if($(this).attr('value') == ''){ this.value = $(this).attr('rel'); this.style.color='#999'; }}); $("input.autoselect").focus(function(){ if($(this).attr('value') == $(this).attr('rel')){ this.select(); }}); /* geoinfo inputs */ $("input.geoinfo-resolve").keyup(function(){ $.ajax({ url: '/register/resolve_geoinfo/'+$(this).attr('value'), method: 'get', complete: function(x){ if(x.responseText.length>1){ $('#geoinfo-placeholder').html(x.responseText); }} }); }); /* watchlist buttons */ $(".watchlist-button").click(function(){ var button = $(this); if(button.hasClass('watchlist-button-ticked')){ button.removeClass('watchlist-button-ticked'); button.html("Merken"); } else { button.addClass('watchlist-button-ticked'); button.html("✓ Gemerkt"); } $('.watchlist-notification').html('
'); $.get(('/watchlist/add/' + button.attr('rel')), {}, function(data, status, xhp){ $('.watchlist-notification').load('/watchlist/preview', function(){ $('.watchlist-notification').show(); }); }); }); /* inline edit */ $(".inline-edit").mouseover(showInlineEdit); $(".inline-edit").mouseout(hideInlineEdit); }); $(document).keyup(function (e) { if(e.which == 17) isCtrl=false; }).keydown(function (e) { if(e.which == 17) isCtrl=true; if(e.which == 83 && isCtrl == true) { /*ctrl+s*/ } }); /*function borrowed from Hamid Alipour Codehead @ webmaster-forums.code-head.com*/ function is_child_of(parent, child) { if( child != null ) { while( child.parentNode ) { if( (child = child.parentNode) == parent ) { return true; } } } return false; } function hideDropdown(element, event, dd_id) { var current_mouse_target = null; if( event.toElement ) { current_mouse_target = event.toElement; } else if( event.relatedTarget ) { current_mouse_target = event.relatedTarget; } if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) { $('#' + dd_id).css('visibility', 'hidden'); } } function showDropdown(dd_id){ $('#' + dd_id).css('visibility', 'visible'); } function showInlineEdit(){ if($(this).hasClass("inline-edit-active") == false){ $(this).addClass("inline-edit-active"); $(this).prepend('Bearbeiten'); $(".inline-edit-do", this).css('marginLeft', (($(this).width()-80)+'px')); } } function hideInlineEdit(event) { var current_mouse_target = null; if( event.toElement ) { current_mouse_target = event.toElement; } else if( event.relatedTarget ) { current_mouse_target = event.relatedTarget; } if( !is_child_of(this, current_mouse_target) && this != current_mouse_target ) { $(this).removeClass("inline-edit-active"); $(".inline-edit-do", this).remove(); } } function feedbackDialog(){ $.fancybox({ 'padding' : 0, 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'title' : this.title, 'width' : 560, 'height' : 400, 'href' : ('/welcome/feedback'), 'type' : 'iframe' }); } function postboxCompose(profileId){ $.fancybox({ 'padding' : 0, 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'title' : this.title, 'width' : 560, 'height' : 470, 'href' : ('/postbox/compose/'+profileId+'?ajax=1'), 'type' : 'iframe' }); } function postboxComposeClose(msg){ showNotification('info', msg); $.fancybox.close(); } function feedbackClose(msg){ showNotification('info', 'Vielen Dank! Wir werden uns schnellstmöglich darum kümmern.'); $.fancybox.close(); } function postboxUpdateView(conversationId){ $.ajax({ method: 'get', url: ('/postbox/conversation_length/'+conversationId+'?ajax=1'), complete: function(x){ new_messagecount = parseInt(x.responseText); if(new_messagecount > postbox_messagecount){ if(postbox_messagecount != -1){ postboxDoUpdateView(conversationId); } postbox_messagecount = new_messagecount; } } }); } function postboxDoUpdateView(conversationId){ //$("#conversation").html('
'); $("#conversation").load(('/postbox/view/'+conversationId+'?ajax=1')); } function showNotification(mode, msg){ $("#notifications").html(('
'+msg+'
')); } function postboxAnswerSubmit(conversationId){ var my_data = $("#conversation-answer-form").serialize(); $.ajax({ method: 'post', url: ('/postbox/submit/'+conversationId+'?ajax=1'), data: my_data, complete: function(x){ showNotification('info', x.responseText); $("#conversation-answer-textarea").attr('value', ''); postbox_messagecount += 1; postboxDoUpdateView(conversationId); } }); } function profileSliderNext(){ var e = $("#profileslider-profiles"); var f = $(".slider-profile-first"); f.animate({marginLeft: '-100px'}, function(){ f.removeClass('slider-profile-first'); f.next().addClass('slider-profile-first'); f.remove(); f.css('marginLeft', '10px'); e.append(f); }); } function popupbarOpen(){ $("#popupbar").fadeIn(); } function popupbarClose(){ $("#popupbar").fadeOut(); } function popupbarLoad(what){ popupbarOpen(); $.ajax({ 'url': '/welcome/popupbar/'+what, 'method': 'get', 'complete': function(x){ $("#popupbar .inner").html(x.responseText); } }); } function mediacenterInit(my_ajax_key, my_mediacenter_mode){ ajax_key = my_ajax_key; mediacenter_mode = my_mediacenter_mode; mediacenterInstallEvents(); mediacenterLoadSelection(); } function mediacenterInitUpload(){ mySwfu = new SWFUpload({ upload_url: "/upload/put", file_post_name: 'file', post_params:{ "ajax": ajax_key }, flash_url: "http://assets.talentsuche.de/images/swfupload.swf", button_placeholder_id: 'uploadButtonPlaceholder', /*button_width: 150, button_height: 27, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, */ upload_progress_handler: mediacenterUploadProgressHandler, upload_success_handler: mediacenterUploadSuccessHandler, file_queued_handler: function(file){ mySwfu.startUpload(); $("#uploadStatusBox").show(); }, file_size_limit : "200 MB" }); } function mediacenterSwitch(my_mediacenter_mode){ mediacenter_mode = my_mediacenter_mode; mediacenterUpdateInterface(); mediacenterReload(); mediacenter_selecteditems=new Array(); mediacenterSerializeSelection(); mediacenterLoadSelection(); } function mediacenterUpdateInterface(){ $("#mediacenter-menu li.active").removeClass('active'); $(("#mediacenter-menu li[rel='"+mediacenter_mode+"']")).addClass('active'); $(".uploadButtonExplain").hide(); $((".uploadButtonExplain[rel='"+mediacenter_mode+"']")).show(); if(mediacenter_mode=='pictures'){ $(".mediacenter-pictures-only").show(); } else { $(".mediacenter-pictures-only").hide(); } } function mediacenterInstallEvents(){ $(".upload-selectable").click(mediacenterSelect); $(".upload-selectable").mouseover(function(){ $(this).addClass('upload-hover'); }); $(".upload-selectable").mouseout(function(){ $(this).removeClass('upload-hover'); }); } function mediacenterSerializeSelection(){ var qry=""; $(mediacenter_selecteditems).each(function(i,v){ if(v){ qry += v + "!"; } }); mediacenter_selectionqry=qry; } function mediacenterActionDelete(){ if(confirm("Alle ausgewählten Dateien löschen? (Aktion ist unwiederruflich)")==true){ $.ajax({ method: 'get', url: ('/edit_profile/mediacenter_delete/'+mediacenter_selectionqry), complete: function(x){ mediacenter_selecteditems=new Array(); mediacenterSerializeSelection(); mediacenterLoadSelection(); mediacenterReload(); } }); } } function mediacenterActionRename(){ var newname = prompt("Neuer Titel"); $.ajax({ method: 'get', url: ('/edit_profile/mediacenter_rename/'+mediacenter_selecteditems[0]+'?n='+newname), complete: function(x){ mediacenterSerializeSelection(); mediacenterLoadSelection(); mediacenterReload(); } }); } function mediacenterReload(){ $("#mediacenter-content").html('
'); if(mediacenter_mode=="mixed"){ $("#mediacenter-content").load("/edit_profile/mediacenter", mediacenterReloadReady); } else { $("#mediacenter-content").load("/edit_profile/mediacenter/" + mediacenter_mode, mediacenterReloadReady); } } function mediacenterReloadReady(){ mediacenterInstallEvents(); } function mediacenterSelect(){ if(mediacenter_selecteditems.length==0){ $("#mediacenterSelectionBox").show(); } if(isCtrl == false){ mediacenter_selecteditems = new Array(); $('.upload-selected').removeClass('upload-selected'); $('.upload-selected').removeClass('upload-hover'); } var ind = mediacenter_selecteditems.indexOf($(this).attr('rel')); if(ind==-1){ mediacenter_selecteditems.push($(this).attr('rel')); $(this).addClass('upload-selected'); } else { mediacenter_selecteditems.splice(ind,1); $(this).removeClass('upload-selected'); } oldqry = mediacenter_selectionqry; mediacenterSerializeSelection(); if(oldqry!=mediacenter_selectionqry){ mediacenterLoadSelection(); } if(mediacenter_selecteditems.length==0){ /*$("#mediacenterSelectionBox").hide();*/ } } function mediacenterLoadSelection(){ $("#mediacenterSelection").html('
'); $("#mediacenterSelection").load("/edit_profile/mediacenter_selection/" + mediacenter_selectionqry); } function mediacenterAddFiles(){ mySwfu.selectFiles(); } function mediacenterUploadProgressHandler(file, bytesLoaded, bytesTotal){ $("#uploadStatus").html(file.name + ': ' + Math.round((bytesLoaded*100)/bytesTotal) + '%'); } function mediacenterUploadSuccessHandler(file, server_data, response){ /*alert(server_data);*/ mediacenterReload(); if(mySwfu.getStats().files_queued==0){ $("#uploadStatusBox").hide(); } else { mySwfu.startUpload(); } }