Select Active Tab By Date - jquery-ui

This question was posed about selecting the active tab by weekday https://stackoverflow.com/a/7681679/1339863.
I'm sure this can be done for the month as well, but I have searched and haven't been able to find the proper application. I'm so new to jquery I can't figure out how to alter the code to suit my needs. Please Help!

you can adapt the previous code in the stackoverflow archive, just you need to extract months from date, use this code:
var date = new Date();
var months = date.getMonth();

Related

Cannot update calendar firstWeekDay Swift 3.0

I'm trying to update the calendar firstWeekDay to something else (as far as I seen the default firstWeekDay is Sunday) but some errors occur.
private var calendar = Calendar.autoupdatingCurrent
calendar.firstWeekday = 3
// the 2nd line is here only to ask this question on StackOverFlow (is missing on my code because I am want the user to use its own calendar, not something forced by me.
Check code+errors screenshot here
Note: I managed to do this at the beginning of the project with the same simple code but after a while I updated the app on my personal iPhone to check how it looks and behave on a real device and I noticed that the the first week day is not Monday anymore as my personal iPhone calendar is set.
I managed to solve the issue. Apparently I had to define a new function and update the firstWeekDay property inside that function. :)

Sort by publish date, even if publish date is tomorrow or 2 years ago

I'm trying to make this as intuitive for my customer as possible. They already have many news articles they need moved to this new Umbraco 7 site. I want the following to happen:
If they make a news article and set the "Publish At" date to tomorrow, it will not show on the page until tomorrow.
If they do not set a "Publish At" date, it should look at the published date (you would not fill out the "Publish At" date if you want it published now)
If they edit an old article, it should not affect the sorting at all (meaning UpdateDate shouldn't work)
If there are n articles all released today, and someone publishes a news article with "Publish At" set to yesterday, it will put the news article before the 3 new ones
Is something like this possible, without creating an additional property? That's, in my opinion, just going to confuse the person.
So apparently the only way to do this, is by creating an additional field with type Date. I was hoping I could do this through the built in ones from Umbraco.
Turns out there are no "this is the exact date when this article was published" property I can access, while still getting this to work. It does give the creator a few options regarding the sorting, as it's very easy to sort them by date now.
As far as I understand your scenario, here are my replies to each of your questions
If they make a news article and set the "Publish At" date to tomorrow, it will not show on the page until tomorrow.
Ans - If they set the Publish At date to tomorrow and just save that article, then it would never be published until tomorrow. If the page is already published, then it needs to be unpublished first.
If they do not set a "Publish At" date, it should look at the published date (you would not fill out the "Publish At" date if you want it published now)
Ans - They just need to click save and publish to publish the article now.
If they edit an old article, it should not affect the sorting at all (meaning UpdateDate shouldn't work)
Ans - You can handle this in ContentService_Saving event. Refer - ContentService Events
If there are n articles all released today, and someone publishes a news article with "Publish At" set to yesterday, it will put the news article before the 3 new ones
Ans - Taken from This Umbraco forum . Adding this for everyone here as well.
I would create the property SortDate, and another true/false property PublishMode. While SortDate is self-explanatory, I would set PublishMode to true once you are done drafting and adding content to a page. So if I've written a page and only need to fix typos and reword after it has been published, this would be set to true.
I would then hook into a republish event and add some logic like so:
if (page's type alias is a post) && (PublishMode is false) {
if (DateCompare(page.CreateDate, page.UpdateDate) >= 0
{ page.SortDate = page.CreateDate }
else {page.SortDate = page.UpdateDate}
}
So then after you're done, you can have a date that will be sorted depending on the "mode" of the document while it is being republished.
As a side note, even if you don't have a date picked, the datepicker datatype automatically sets itself to something like "01/01/0011". So it would never return a null value.
Also, the datepicker datatype is not a DateTime object. So to use the DateCompare, you have to parse each date property into a DateTime object like:
DateCompare(DateTime.Parse(Page.CreateDate.ToString("r"), DateTime.Parse(Page.UpdateDate.ToString("r"))
Hope this helps!!
Thanks

Grails make one g:datePicker depend on other g:datePicker

imagine that you have an index.gsp with two dates: Starting day and Ending Day.
When the user picks the starting day, how can I calculate + 2 months in the ending day?
I know in the controller I could have something like:
use (TimeCategory) {
c = new Date() + 2.month
}
But how is the best way to change the Ending Day in the gsp? With remoteFunction?
EDIT:
Yes it worked, thank you very much lukelazarovic.
Like you said the only thing needed to change was the last line, I changed to: $("#myid_month").val(month+3);
function dateWasChanged(){
....
$("#myid_month").val(month+3);
}
EDIT2:
I also needed to increment year, for some reason they are strings so remember to do:
myInteger = parseInt(myString);
I assume you want to do it on the client - without reloading page +2 months date is set into the end date datePicker.
That means you have to do it using Javascript or Javascript-based framework (JQuery).
You can go along with the solution suggested in this SO question: Get Date value from Grails DatePicker
Only change would be to set the value of end datePicker on the last line of function dateWasChanged like this:
$("#endDatePickerId").datpicker("setDate", date);

JQuery UI / Datepicker : How to initialize datepicker with an empty year?

My problem is the following :
On my website, I use the Jquery-ui datepicker to allow my visitor to enter a date.
I have configured the datepicker such users can modify the month and the year.
However, I have noticed that they never enter the year : they leave in the default value.
In my mind, they don't see that they can edit the year value...
So, I would like to intialize the default year value to empty/blank and show an error alert if the user has not modified it.
I try to do that, but in vain....
So how can I do that ?
Maybe, there is an other way to force my users to select a correct year value. Have you got any suggestions ?
In advance, thanks for your answer.
I thought a little bit and I think what I would do is not possible...
How could the datpicker calculate the days of the month if the year is not specified?
So, Have you got any suggestions to force my users to change the year default value ?
You could identify what the default value is and then, in your onSelect callback you could see if the current year value is different than what the original was and execute whatever code seems appropriate.

Sharepoint 2007 - Displaying current date in a custom list

I have been reading blog after blog about displaying the current date in a sharepoint list and nothing seems to work. I do not have administrative rights to my sharepoint server but I was able to combine some java scripts and was able to display the current date (that change each day) in a custom list. My problem is that my success is only half full and I need someone's help to figure out the rest. Here it goes:
1. I created a column in my list called "DateField", I use the calculation field with ="<B></B>
as the calculation
2. I created a Content Edit WebPart and use the source below:
<script type="text/javascript">
var currentTime = new Date()
var month = currentTime.getMonth()+1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var CurrentDate = month + "/"+ day + "/" + year
$(document).ready(function(){
$(".ms-vb2:contains('<B')").each(function(){
var tempB = document.createElement ("B");
tempB.style.cursor = "pointer";
tempB.innerHTML = $(this).text();
$(this).text(CurrentDate);
$(this).append(tempB);
});
});
</script>
The script works and the date changes each day but I cannot use the date for anything. For some reason it only sees the HTML tags in the field but it displays the current date in the column on the list. Can someone help me figure out how I can store the actual date in the column?
Thanks
Ramon
If you want to store the current date field on the column to be reused
that means that you will have to modify all the items every day with today's date.
Is that what do you really need ? it could be achieved with some ajax call to the web services (if you have update permissions for those items).
However I don't really understand your scenario.
Could you elaborate ?
My solution was to create a custom field type for the column, which would always return the current date (and time if needed). This produced the desired effect - the current date (and time) would be displayed on the front end, but still available for use in other fields in the back end.
A quick Google for examples (my code is two jobs behind me, and I haven't touched MOSS in 6 months) gives me http://vspug.com/nicksevens/2007/08/31/create-custom-field-types-for-sharepoint/
Good luck!
Regards
Moo

Resources