File modules/cms/ui/themes/default/script/plugin/jquery-plugin-orLinkify.js

Last commit: Fri Feb 11 01:28:51 2022 +0100	dankert	Fixed some UI problems: The dialogs are now closed after submitting the data; Workbench is reloaded after login/logout.
1 import $ from "../jquery-global.js"; 2 import Workbench from "../openrat/workbench.js"; 3 import Api from "../openrat/api.js"; 4 5 /** 6 * JQuery-Plugin, enable clicking on an area. 7 * It searches for an anchor (<a href="..." />) in the child elements and virtually clicks on it. 8 */ 9 export default function( options ) 10 { 11 // Create some defaults, extending them with any options that were provided 12 var settings = $.extend( { 13 'openAction' : function(name,action,id) { 14 Workbench.getInstance().openNewAction( name,action,id ); 15 } 16 }, options); 17 18 $(this).addClass('linkified'); 19 20 // Disable all links in this linkified area. 21 // The user is already able to open the link in a new tab. 22 if ( $(this).is('a') ) 23 $(this).addClass('act-prevented-link').click( function(event) { 24 event.preventDefault(); 25 } ); 26 else 27 $(this).find('a').addClass('act-prevented-sublink').click( function(event) { 28 event.preventDefault(); 29 } ); 30 31 return $(this).click(function(event) 32 { 33 34 // Searching for the first link in all children. 35 let $el = $(this); 36 let $link; 37 38 if ( $el.is('a') ) 39 $link = $el; 40 else 41 $link = $el.find('a').first(); 42 43 let type = $link.attr('data-type'); 44 45 // Inaktive Menüpunkte sind natürlich nicht anklickbar. 46 if ( $link.parent().hasClass('dropdown-entry--inactive') ) 47 return; 48 49 switch( type ) 50 { 51 /** 52 * Creating a temporary form element for submitting a POST request. 53 */ 54 case 'post': 55 56 let api = new Api(); 57 let formData = new FormData(); 58 59 let params = JSON.parse( $link.attr('data-data') ); 60 params.output = 'json'; 61 62 // Add formular data... 63 Object.keys( params ).forEach( (key) => { 64 formData.append( key, params[key] ); 65 } ); 66 if (!formData.get('id') ) 67 formData.set('id',Workbench.state.id); 68 if (!formData.get('action') ) 69 formData.set('action',Workbench.state.action); 70 71 // Submit the form. 72 api.sendData( formData ); 73 74 if ( $link.data('afterSuccess') === 'reload' ) 75 Workbench.getInstance().reloadViews(); 76 if ( $link.data('afterSuccess') === 'reloadAll' ) 77 Workbench.getInstance().reloadAll(); 78 79 break; 80 81 case 'edit': 82 case 'dialog': 83 let dialog = Workbench.getInstance().createDialog(); 84 let name = $link.attr('data-name'); 85 if ( !name ) 86 name = $link.text(); // get the name from the combined text of all children. 87 88 let extraValue = Workbench.htmlDecode($link.attr('data-extra')); 89 let extraData = JSON.parse(extraValue); 90 91 dialog.start(name,$link.attr('data-action'),$link.attr('data-method'),$link.attr('data-id'),extraData ); 92 break; 93 94 case 'external': 95 window.open( $link.attr('data-url'),' _blank' ); 96 break; 97 case 'window': 98 window.location.href = View.createUrl($link.attr('data-action'), $link.attr('data-method'), $link.attr('data-id')); 99 break; 100 101 case 'popup': 102 Workbench.popupWindow = window.open( $link.attr('data-url'), 'Popup', 'location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes'); 103 break; 104 105 case 'help': 106 help($link,$link.attr('data-url'),$link.attr('data-suffix') ); 107 break; 108 109 case 'fullscreen': 110 fullscreen($link); 111 break; 112 113 case 'open': 114 settings.openAction( $link.text().trim(),$link.attr('data-action'),$link.attr('data-id') ); 115 break; 116 117 default: 118 throw "UI error: Unknown link type: "+type+" in link "+$link.html(); 119 } 120 }); 121 }; 122 123 124
Download modules/cms/ui/themes/default/script/plugin/jquery-plugin-orLinkify.js
History Fri, 11 Feb 2022 01:28:51 +0100 dankert Fixed some UI problems: The dialogs are now closed after submitting the data; Workbench is reloaded after login/logout. Sun, 6 Feb 2022 22:06:09 +0100 dankert Refactoring: Ommit unnecessary parameters. Fri, 17 Dec 2021 04:29:47 +0100 dankert New: Opening a dialog creates a new entry in history api. So, using the back button will close the dialog. Sat, 27 Nov 2021 18:34:08 +0100 Jan Dankert Fix: Set form id if not already set. Sat, 27 Nov 2021 04:39:51 +0100 Jan Dankert Refactoring: Extract the api request form.js into a new api class which returns a promise. Thu, 1 Apr 2021 01:01:54 +0200 Jan Dankert New: Some fixes for OQuery, our new selfmade light JQuery replacement. Now the UI is back again. Wed, 31 Mar 2021 01:52:57 +0200 Jan Dankert New: Replace JQuery with OQuery, a selfmade light JQuery replacement. Sat, 27 Mar 2021 05:14:11 +0100 Jan Dankert Refactoring: Converting all script files to ES6 modules (work in progress); removed jquery-ui (drag and drop will be replaced by HTML5, sortable by a small lib) Wed, 17 Mar 2021 02:18:50 +0100 Jan Dankert Refactoring: Using "Jquery slim" without ajax and effects. Tue, 16 Mar 2021 23:52:22 +0100 Jan Dankert Refactoring: Use ES6 classes. Tue, 16 Mar 2021 02:38:13 +0100 Jan Dankert Fix: Using the new FormData object instead of JQuery (JQuery's serialize-functions are not available in the slim version) Mon, 8 Mar 2021 15:04:16 +0100 Jan Dankert UI Fixes: Table filter should not hide the table header; open actual object in navigation tree; load dialog name from link text. Wed, 17 Feb 2021 02:34:51 +0100 Jan Dankert Refactoring: Extract Dialog into a separate js class Sat, 31 Oct 2020 00:55:00 +0100 Jan Dankert Fix: OpenId-Connect-Buttons must be clickable; Fixed OpenId-Connect configuration. Sat, 31 Oct 2020 00:43:29 +0100 Jan Dankert New: Support for OpenId Connect; Removed: Support for LDAP. Mon, 26 Oct 2020 21:36:14 +0100 Jan Dankert Rename css class 'clickable' to 'act-clickable'; enhanced view 'info' for projects. Sat, 24 Oct 2020 23:51:11 +0200 Jan Dankert Cleanup LESS files, introduce BEM. Sat, 10 Oct 2020 01:29:41 +0200 Jan Dankert Refactoring: Only using CSS classes with the 'or-'-prefix. Wed, 7 Oct 2020 22:25:28 +0200 Jan Dankert Fix: Selecting a link with the selector tree. Thu, 1 Oct 2020 20:55:34 +0200 Jan Dankert Refactoring: Moving some global JS functions into the OR Namespace Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.