I implemented somethink like on this picture:
if you click on a link popup will appear and you can follow the link.
jQuery(function($){
/**
* add the follow link popup to all TinyMCE instances
*/
if (!window.tinymce) return;
tinymce.on('AddEditor', function( event ) {
tinymce.editors.forEach(function(editor) {
if (!editor.isFollowLinkAdded) {
editor.isFollowLinkAdded = true;
editor.on('blur', function(e) {
jQuery(e.target.contentDocument.body).find('#followLink').remove();
});
editor.on('click', function(e) {
var link = jQuery(e.target).closest('a');
jQuery(e.view.document.body).find('#followLink').remove();
if (link.length) {
e.preventDefault();
var POPUP_WIDTH = 215,
isRightSide = (jQuery(e.view.document).width()-e.pageX) >= POPUP_WIDTH,
boxCss = {
top: e.pageY,
padding: '6px 10px',
position: 'absolute',
backgroundColor: '#ffffff',
border: '1px solid #a8a8a8',
borderRadius: '2px',
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.2)',
color: '#666666',
cursor: 'pointer',
whiteSpace: 'nowrap',
zIndex: 502
};
boxCss[(isRightSide) ? 'left' : 'right'] = (isRightSide) ? e.pageX : jQuery(e.view.document).width()-e.pageX;
jQuery('<a/>', {
href: link.attr('href'),
text: link.attr('href'),
target: '_blank'
}).css({
cursor: 'pointer',
display: 'inline-block',
maxWidth: '100px',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}).wrap(
jQuery('<p/>', {
text: 'Click to follow: ',
id: 'followLink',
}).on('click', function(){
var win = window.open(link.attr('href'), '_blank');
win.focus();
}).css(boxCss)
).parent().appendTo(e.view.document.body);
}
});
}
});
}, true );
});
The most recent version of TinyMCE 4 (4.5.3) includes the option to open a link in the right click menu of the editor - no need to write your own custom code.
Related
I want to create a pop up under ionic that appears at the bottom and disappears when you click above it exactly like on the Youtube application when you click on the middle button.
How can i do that ?
This example image also shows well.
This is a possible solution :
// ------------------- TS CODE -----------------------------
constructor(public modalController: ModalController) {}
openBottomPopUp() {
this.modalController
.create(
{
component: PopUpPageToDisplayPage,
backdropDismiss: true,
swipeToClose: true,
cssClass: 'bottom-pop-up'
})
.then(modal => {
modal.present().then();
});
}
// ------------------- SCSS CODE -----------------------------
.bottom-modal {
.modal-wrapper {
width: 100%;
height: 35%;
position: absolute;
bottom: 0;
border-radius: 10% 10% 0 0;
}
.modal-shadow {
position: absolute;
height: 35%;
bottom: 0;
}
}
the modal-shadow must also be changed so that the pop up disappears when clicked outside. The height can be defined according to your needs.
PopUpPageToDisplayPage is the page you want to display in the popup.
You can use all parameters of ion-modal (https://ionicframework.com/docs/api/modal)
An Ionic implementation exists for this component through the ActionSheetController:
constructor(private actionSheetController: ActionSheetController) { }
async open() {
(await this.actionSheetController.create({
buttons: [
{text: 'item 1'},
{text: 'item 2'},
{text: 'item 3', handler: () => console.log('clicked')},
{text: 'cancel', role: 'cancel'},
]
})).present();
}
I have test where I test drag and drop element. In localhost is everything ok. When I do pull request on github the test falls on the drag and drop movement. Do you have any advice what I can do?I am using this code.
cy.dragAndDrop('[style="width: 843px; height: 230px; position: absolute; transform: translate(10px, 10px); z-index: 0;"] > .rounded-xl > .absolute > .pt-4 > .drag-handle','[style="transform: translate(10px, 490px); width: 843px; height: 230px; position: absolute;"] > .rounded-xl > .flex-col' )
cy.dragAndDrop('[style="transform: translate(10px, 10px); width: 843px; height: 230px; position: absolute; z-index: 0;"] > .rounded-xl > .absolute > .pt-4 > .drag-handle','[style="transform: translate(10px, 250px); width: 843px; height: 230px; position: absolute;"] > .rounded-xl')
here is the commands.ts part:
Cypress.Commands.add('dragAndDrop', (subject, target) => {
Cypress.log({
name: 'DRAGNDROP',
message: `Dragging element ${subject} to ${target}`,
consoleProps: () => {
return {
subject: subject,
target: target
};
}
});
const BUTTON_INDEX = 0;
const SLOPPY_CLICK_THRESHOLD = 10;
cy.get(target)
.first()
.then($target => {
let coordsDrop = $target[0].getBoundingClientRect();
cy.get(subject)
.first()
.then(subject => {
const coordsDrag = subject[0].getBoundingClientRect();
cy.wrap(subject)
.trigger('mousedown', {
button: BUTTON_INDEX,
clientX: coordsDrag.x,
clientY: coordsDrag.y,
force: true
})
.trigger('mousemove', {
button: BUTTON_INDEX,
clientX: coordsDrag.x + SLOPPY_CLICK_THRESHOLD,
clientY: coordsDrag.y,
force: true
});
cy.get('body')
.trigger('mousemove', {
button: BUTTON_INDEX,
clientX: coordsDrop.x,
clientY: coordsDrop.y,
force: true
})
.trigger('mouseup',{force:true});
I have some boolean fields inside my ag-grid. In addition to be possible to navigate with the keyboard, I would also like to be possible to check/uncheck these checkboxes with the keyboard. I mean let the user move inside the grid with cursor keys, then when the current cell is a checkbox simply use the Space of Enter keys to check/uncheck.
I ended with the solution showed below but I am curious if there is a better/nicer solution for that ?
The trick I used is to catch keyboard events on the grid and change values (true/false) if focused cell is a checkbox.
Example: Plunker demo here
var columnDefs = [
{headerName: "Athlete", field: "athlete", width: 150, editable: true},
{headerName: "Age", field: "age", width: 60, editable: true},
{headerName: "Country", field: "country", width: 120, editable: true},
{headerName: "Boo1", field: "boo1", width: 60, cellRenderer: boolRenderer},
{headerName: "Boo2", field: "boo2", width: 60, cellRenderer: boolRenderer}
];
function boolRenderer(params) {
return `<input type="checkbox" ${params.value ? 'checked' : ''} />`;
}
var gridOptions = {
columnDefs: columnDefs,
onCellKeyPress: cellKeyPress
};
function cellKeyPress(e) {
let ENTER_KEY = 13;
let SPACE_KEY = 32;
var event = e.event;
if (event.keyCode == SPACE_KEY || event.keyCode == ENTER_KEY)
{
var isCheckbox = $(event.target).find("input[type='checkbox']").length > 0;
if (isCheckbox)
{
var currentCell = gridOptions.api.getFocusedCell();
var rowIndex = currentCell.rowIndex;
var colId = currentCell.column.getId();
var rowNode = gridOptions.api.getDisplayedRowAtIndex(rowIndex);
var cellValue = gridOptions.api.getValue(colId, rowNode) || false;
rowNode.setDataValue(colId, !cellValue);
}
}
}
// setup the grid after the page has finished loading
document.addEventListener('DOMContentLoaded', function() {
var gridDiv = document.querySelector('#myGrid');
new agGrid.Grid(gridDiv, gridOptions);
// do http request to get our sample data - not using any framework to keep the example self contained.
// you will probably use a framework like JQuery, Angular or something else to do your HTTP calls.
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'https://raw.githubusercontent.com/ag-grid/ag-grid/master/packages/ag-grid-docs/src/olympicWinnersSmall.json');
httpRequest.send();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
var httpResult = JSON.parse(httpRequest.responseText);
gridOptions.api.setRowData(httpResult);
}
};
});
.test-container {
height: 100%;
display: flex;
flex-direction: column;
}
<!DOCTYPE html>
<html lang="en">
<head>
<script> var __basePath = ''; </script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
}
html {
position: absolute;
top: 0;
left: 0;
padding: 0;
overflow: auto;
}
body {
padding: 1rem;
overflow: auto;
}
</style>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://unpkg.com/ag-grid-community#21.2.0/dist/ag-grid-community.min.js"></script> <link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="test-container">
<div id="myGrid" class="ag-theme-balham" style="height: calc(100% - 30px);"></div>
</div>
<script src="main.js"></script>
</body>
</html>
if you asking about alternative way , this is my suggestion .
you can try agSelectCellEditor in the columnDefs , user will still be able to change it using keyboard by pressing enter and select true or false using arrow key.
this.columnDefs = [
{
headerName: 'ID',
field: 'id',
width: 50
},
headerName: 'IsCompleted',
field: 'isCompleted',
editable: true,
filter: true,
sortable: true,
cellEditor: "agSelectCellEditor",
cellEditorParams:
{
values: ["True", "False"]
},
width: 105}
]
And to save your changes on the server side:
(cellEditingStopped)="UpdateTrainingData()" //as an example your ag-grid html tag.
I am making an ionic app with version 3.20.0. I'm using alert controller and I add three button ,Annuler ,ok and Scan.
I want to place it like in the photo below:
my css code in ionic like that:
.myalert .alert-wrapper {
padding: 0;
flex-wrap: wrap;
input.alert-input:nth-child(1){
flex: 0 0 60%;
max-width: 80%;
}
button.alert-button:nth-child(1) {
background-image:url('../assets/imgs/icon.png');
background-repeat: no-repeat;
background-position: center;
max-width: 40%;
}
}
.myalert button.alert-button-group {
flex: 0 0 50%;
max-width: 50%;
}
.myalert .alert-button-group-vertical {
flex-direction: row;
}
and my script ionic to show alert is like that ,i need help to show it
like photo below
showPrompt() {
this.donebtn = true;
let prompt = this.alertCtrl.create({
title: 'Espace Client',
message: "Tapez votre code secret",
cssClass: 'myalert',
inputs: [{
name: 'code',
placeholder: 'Mot de passe',
type: 'password',
}, ],
buttons: [{
text: '',
handler: data => {
this.scannerCAB();
let pass = this.votreCode;
this.verifierclient(this.codeclient, pass);
// console.log('Barcode data', this.votreCode);
// let pass = data.code;
//this.verifierclient(this.codeclient, pass);
}
},{
text: 'Annuler ',
handler: data => {
}
},
{
text: 'ok ',
handler: data => {
let pass = data.code;
this.verifierclient(this.codeclient, pass);
}
},
]
});
prompt.present({
keyboardClose: false
})
.then(() => this.donebtn = false);
}
Since my answer was "Trivial" hence "converted to comment" here's a repost of my answer.
A bit late response. I tried to achieve this today, and I made it like this:
Create a css class in your app.scss and add that class in the alert option "cssClass".
app.scss
.yourClass{
background-image: url(your-image-url);
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}
These css values can be changed per your requirements.
And in the Alert:
buttons: [
{
text: '',
cssClass: 'yourClass',
handler: data => {}
}
]
I am wondering if there is a way to set the tooltip for L.CircleMarker?
var geojsonLayerVessel = new L.GeoJSON(null, {
pointToLayer: function (latlng){
return new L.CircleMarker(latlng, {
radius: 5,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8,
title: "test"
});
}
});
tried the above code, but it is not working.
This does not work for CircleMarkers.
But you can create a little DivIcon and style it with rounded corners.
DivIcons do support the 'title' option.
http://jsfiddle.net/63teycsq/1/
The function to provide as pointToLayer:
function (latlng){
return L.marker(latlng,
{ icon : L.divIcon({ className : 'circle',
iconSize : [ 5, 5 ]}),
title: 'test'});
}
And the div's styling:
div.circle {
background-color: #ff7800;
border-color: black;
border-radius: 3px;
border-style: solid;
border-width: 1px;
width:5px;
height:5px;
}
For GeoJSON layers you can listen to the 'featureparse' event to bind popups, as per this example. Something along these lines:
var geoJsonLayer = new L.GeoJSON(null,{
pointToLayer: function (latlng){
return new L.CircleMarker(latlng, {
radius: 5,
fillColor: "#ff7800",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8,
});
geoJsonLayer.on('featureparse', function(e){
//Now you can bind popups to features in the layer, and you have access to
//attributes on the GeoJSON object through e.properties:
e.layer.bindPopup('Hello! ' + e.properties.someProperty);
});
//now you add some some data to your layer and add it to the map....
geoJsonLayer.addGeoJSON(someGeoJson);
map.addLayer(geoJsonLayer);
Hope this helps!