Is there any way to have a Calendar input for dat.GUI? I'd like to be able to use the UI to input dates if possible. My work around is currently to enter the dates as Text, but I would prefer to have some type of calendar. Thanks!
I know the question was asked sometime ago, but it hasn't been answered yet. Out of a similar need, I created this codepen that demonstrates the integration of jquery-simple-datetimepicker with dat.GUI. The pertinent section/logic follows:
$(function(){
//Create dat.gui instance
var gui = new dat.GUI({closeOnTop: true, width:450});
var calendarFolder = gui.addFolder("Calendar");
//Add calendarDate to dat.GUI
var dateController = calendarFolder.add({Date: ""}, "Date");
calendarFolder.open();
//Append Date Picker to calendarDate and show it.
var guiInput = $(calendarFolder.domElement).find("input").eq(0);
//Create event handler to update the dat.GUI input element when calendar is hidden
var datePickerOptions = {"onHide": function(handler){ fnSetGuiDate(); } };
//Add the calendar to the dat.GUI input element and immediately show it for demonstration
guiInput.appendDtpicker(datePickerOptions).handleDtpicker('show');
//Initialize the dat.GUI input value
fnSetGuiDate();
function fnSetGuiDate() {
var date = guiInput.handleDtpicker('getDate');
var strDate = date.getFullYear() + "-" +
fnFormat(date.getMonth() + 1) + "-" +
fnFormat(date.getDate()) + " " +
fnFormat(date.getHours()) + ":" +
fnFormat(date.getMinutes());
dateController.setValue(strDate);
function fnFormat(mnthOrDate) {
return mnthOrDate < 10 ? "0" + mnthOrDate : mnthOrDate;
}
}
});
Related
When the users selects some text, I want to be able to show a tooltip, right below the selected text?
Any ideas how can I do that?
You could add a component that creates the tooltip, such as paper-tooltip, or create one, even with css only, depends on your usecase.
Here is a W3 example of a CSS tooltip
As far as I can tell, react-draft-wysiwyg does not support arbitrary plugins in the same way that draft-js-plugins does.
Searching on NPM, the only text selection related plugin I found is draft-js-delete-selection-plugin. You could use that as a starting point, as well as look at the documentation for SelectionState.
Without any idea of what you have so far it is hard to provide more info. I have created a JS fiddle that shows a simple tool tip with an event listener that gets the selected text by element id
https://jsfiddle.net/03Lu28qb/1/
$(document).ready(function () {
const textSelectionTooltipContainer = document.createElement("div");
textSelectionTooltipContainer.setAttribute(
"id",
"textSelectionTooltipContainer"
);
textSelectionTooltipContainer.innerHTML = `<p id="textSelected">Selected! </p>`;
const bodyElement = document.getElementsByTagName("BODY")[0];
bodyElement.addEventListener("mouseup", function (e) {
var textu = document.getSelection().toString();
if (!textu.length) {
textSelectionTooltipContainer.remove();
}
});
document
.getElementById("textToSelect")
.addEventListener("mouseup", function (e) {
let textu = document.getSelection().toString();
let matchu = /\r|\n/.exec(textu);
if (textu.length && !matchu) {
let range = document.getSelection().getRangeAt(0);
rect = range.getBoundingClientRect();
scrollPosition = $(window).scrollTop();
containerTop = scrollPosition + rect.top - 50 + "px";
containerLeft = rect.left + rect.width / 2 - 50 + "px";
textSelectionTooltipContainer.style.transform =
"translate3d(" + containerLeft + "," + containerTop + "," + "0px)";
bodyElement.appendChild(textSelectionTooltipContainer);
}
});
});
If you trying to do it in react try this.
If you trying to do it in js try this.
In my screen the Kendo UI Calendar used behaves odd.
When i come on to editing the screen and click on Calendar field if the date is past date (disabled on calendar) then the existing date value gets cleared, even though i am not making any change.
How can i persist the date value for the past dates that are disabled in the calendar.
It would be helpful to give sample code for the fix.
The same we tried with HTML calendar and JQuery Calendar and the behavior is same as of Kendo UI Calendar.
The code used is in javascript
$('#txtWFITaskStartDate').change(function (e) {
e.preventDefault();
e.stopImmediatePropagation();
var labelName = $(this).data('validatelabel');
var CurrentId = $(this).attr('id');
var startDate = $("#" + CurrentId).val();
var duration = $('#txtWFITaskDuration').val();
if ($('#' + CurrentId).val() === "") {
varErrorClassName = 'errmsgStartDate';
DisableTaskEditControls();
$('#StartDate').after('<span class="text-danger ' + varErrorClassName + '">' + Web_IsRequired.replace("{0}", labelName) + '</span>');
}
else {
$('.errmsgStartDate').remove();
$('.errmsgEndDate').remove();
EnableTaskEditControls();
var endDate = CalculateEndDate(duration, startDate);
$('#txtWFITaskEndDate').val(endDate);
$('#EndDate').datepicker('setDate', new Date(endDate));
endDate = $('#txtWFITaskEndDate').val();
if (endDate !== "") {
EnableTaskEditControls();
} else {
varErrorClassName = 'errmsgEndDate';
$('#EndDate').after('<span class="text-danger ' + varErrorClassName + '">' + Web_IsRequired.replace("{0}", "End date") + '</span>');
DisableTaskEditControls();
}
}
});
Below is the screenshot of the dates displayed on modal popup view (MVC)
As the Start Date is past date the control displays in disabled mode. When focus to the Start Date control and focus out from it. The past date gets cleared. I want to hold the existing value, until user changes the date else the same value has to persist in the Start date text box.
I'm setting up a Google Sheet with a few columns to be filled for a certain request. So, I included a checkbox to be clicked at the end as a confirmation the request is done. My idea is to have an automated column called 'Request Date' automatically filled with the current date as soon as the Confirmation checkbox is clicked. However, can't use TODAY() formula once it's going to change the date every day. Any solution for this?
unfortunately no. you can't stop TODAY on demand by any means without a script. but you could have a script which would print out the date if certain checkboxes were checked.
function onEdit(e) {
var aCell = e.source.getActiveCell(), col = aCell.getColumn();
if(col == 5) { //number of column where you have a checkbox
var adjacentCell = aCell.offset(0,1);
var newDate = Utilities.formatDate(new Date(),
"GMT+1", "dd/MM/yyyy");
adjacentCell.setValue(newDate);
}}
this will print date in column F if a checkbox in column E is checked
or perhaps like this:
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
if (activeSheet.getName() == "Sheet1") { // SHEET NAME
var aCell = e.source.getActiveCell(), col = aCell.getColumn();
if (col == 12) { // COLUMN WITH CHECKBOXES
var dateCell = aCell.offset(0,1); // OFFSET ROWS, COLUMNS
if (aCell.getValue() === true) { // VALUE OF CHECKED CHECKBOX
var newDate = new Date();
dateCell.setValue(newDate);
} else {
dateCell.setValue("");
}}}}
I'm really just looking to assign additional information to dates. I am currently setting up datepicker with the following:
beforeShowDay: function(date){
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, ajaxDates) != -1) {
return [true, "","Available"];
} else {
return [false,"","unAvailable"];
}
},
Where ajaxDates is an array containing a list of available dates such as:
var ajaxDates = [ "26-2-2015", "27-2-2015"];
It's for a booking system were I have another array containing the number of seats available for every date. I had seen a post that I can no longer find were someone was attaching additional information to the dates. If someone could point me in the right direction that would be great!
Edit: I have noticed that the a title is attached to each date which on hover shows the tooltip as "Available" or "Unavailable". Is there any easy method to access through the datepicker?
The solution that I was referring to was:
Add custom parameter to jQuery UI Datepicker
An example of how to set additional parameters is as followed:
var input = $("#datepicker");
var result = $("#result");
var courses = {
"02-09-2013" : "history",
"10-09-2013": "physics"
};
input.datepicker({
dateFormat: 'dd-mm-yy',
showWeek: true,
firstDay: 1,
numberOfMonths: 3,
onSelect: function(dateText, pickerObj){
result.attr("data-course-id", courses[dateText]);
course.innerHTML = courses[dateText];
},
altField: "#result"
});
http://jsfiddle.net/Seandeburca/qbLwD/
I have had some trouble with fetching json from a groups events on facebook and then put them in a tableview to be used in a Appcelerator mobile app.
The idea is to have this as a calendar to show events for a club in a simple way.
I want to show the name of the event. The picture for that event and the date for the event.
All in a tablerow.
I have gotten to the part where i can get the Name and date for the events with this code:
Ti.UI.backgroundColor = '#dddddd';
var access_token='AAACEdEose0cBAAICGa4tFTcZAqCOGm2w9qPYGZBwNtJ1oZAcwaMAP2DDHZCN58cvVBZCHZADZAZBTPC8tTnpfQ7uGKI5j3SbMYcRmWquZCdPzhwZDZD';
var url = "https://graph.facebook.com/64306617564/events?&access_token=" + access_token ;
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var tableData = [];
var json, data, row, name, start_time, id;
var xhr = Ti.Network.createHTTPClient({
onload: function() {
// Ti.API.debug(this.responseText);
json = JSON.parse(this.responseText);
for (i = 0; i < json.data.length; i++) {
data = json.data[i];
row = Ti.UI.createTableViewRow({
height:'60dp'
});
var name = Ti.UI.createLabel({
text:data.name,
font:{
fontSize:'18dp',
fontWeight:'bold'
},
height:'auto',
left:'50dp',
top:'5dp',
color:'#000',
touchEnabled:true
});
var start_time = Ti.UI.createLabel({
text:'"' + data.start_time + '"',
font:{
fontSize:'13dp'
},
height:'auto',
left:'15dp',
bottom:'5dp',
color:'#000',
touchEnabled:true
});
row.add(name);
row.add(start_time);
tableData.push(row);
}
table.setData(tableData);
},
onerror: function(e) {
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:5000
});
xhr.open("GET", url);
xhr.send();
But when i want the specific event to open in a new window when clicked i just get the event that lies last on the screen when i put this in a browser:
https://graph.facebook.com/64306617564/events?&access_token=AAACEdEose0cBAOLAFWMKPmvgqEwap1ldnl7DeZBDKJC6YTZC4Goh6K5NHsvpOFmFQaGp1IekVsCxZCZCz3lwGpRcQG9ZBkcMrZAnLk4As8kgZDZD
And the access token expires REALLY fast. Any ideas how to make an access token that lasts longer?
Well, the code i am using to open the window is:
table.addEventListener('click',function(e) {
// Create the new window with the link from the post
var blogWindow = Ti.UI.createWindow({
title : data.name,
modal : true,
barColor: '#050505',
backgroundColor: '#050505'
});
var webView = Ti.UI.createWebView({url:'http://www.facebook.com/events/' + data.id});
blogWindow.add(webView);
// Create the close button to go in the left area of the navbar popup
var close = Titanium.UI.createButton({
title: 'Close',
style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN
});
blogWindow.setLeftNavButton(close);
// Handle the close event
close.addEventListener('click',function() {
blogWindow.close();
});
blogWindow.open();
});
win.add(table);
win.open();
in my opinion that should open the event that is clicked on by parsing the ID from the row and putting it after the link.
Am i retarded or what is wrong?
It doesnt matter on which event i click it just open the last one all of the times.
And how can i get a thumbnail for the events?
Pls help........
When you click on table to get value from data which is not available.You can achieve it using you custom variable try to put this line of code at your row creation where you add your row in array i.e.row.data = data; and on table click event get that object using this alert(e.source.data); and check it. Best luck