jquery-plugin-orLinkify.js (2141B)
1 /** 2 * Enable clicking on '.clickable'-Areas. 3 */ 4 5 var popupWindow; 6 7 jQuery.fn.orLinkify = function() 8 { 9 10 // Das 'echte' Ausführen der Links deaktivieren, da dies schon per Javascript erfolgt. 11 // Das Öffnen in einem neuen Tab funktioniert aber weiterhin über die URL. 12 $(this).find('a').click( function(event) { 13 event.preventDefault(); 14 } ); 15 16 return $(this).click(function() 17 { 18 19 $(this).find('a').first().each( function() { 20 21 let type = $(this).attr('data-type'); 22 23 // Inaktive Menüpunkte sind natürlich nicht anklickbar. 24 if ( $(this).parent().hasClass('inactive') ) 25 return; 26 27 switch( type ) 28 { 29 case 'post': 30 31 // Create a temporary form element. 32 $form = $('<form />').attr('method','POST').addClass('invisible'); 33 $form.data('afterSuccess', $(this).data('afterSuccess')); 34 let params = jQuery.parseJSON( $(this).attr('data-data') ); 35 params.output = 'json'; 36 37 // Add input elements... 38 $.each( params, function(key,value) { 39 let $input = $('<input />').attr('type','hidden').attr('name',key).attr('value',value); 40 $form.append( $input ); 41 } ); 42 43 // Submit the form. 44 let form = new Openrat.Form(); 45 form.initOnElement( $form ); 46 form.submit(); 47 48 break; 49 50 case 'edit': 51 case 'dialog': 52 startDialog($(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-method'),$(this).attr('data-id'),$(this).attr('data-extra') ); 53 break; 54 55 case 'external': 56 window.open( $(this).attr('data-url'),' _blank' ); 57 break; 58 59 case 'popup': 60 popupWindow = window.open( $(this).attr('data-url'), 'Popup', 'location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes'); 61 break; 62 63 case 'help': 64 help(this,$(this).attr('data-url'),$(this).attr('data-suffix') ); 65 break; 66 67 case 'fullscreen': 68 fullscreen(this); 69 break; 70 71 case 'open': 72 openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id') ); 73 break; 74 75 default: 76 throw "UI error: Unknown link type: "+type+" in link "+$(this).html(); 77 } 78 } ); 79 }); 80 }; 81 82 83