Calendar - Years restrictions with Javascript Binding

This example explains how to set max and min year to be displayed by a calendar object. This means that user won't be able to see or select a date before and after selected years. By default, limits are 1902 and maximum value will depends on platform architecture (year 2037 for 32 bits); You can read more about time functions on ctime manpage.

Next step is creating an Elementary window with Win_Standard without a parent, which is the type used for all of our examples. Here we also set the title that will appear at the top of our window and then the autohide state for it.

The autohide works automatically handling "delete,request" signals when set to true, hidding the window, instead of destroying it.

Now let's create the calendar with the JS binding method, passing our window object as parent.

To better understand, the function size_hint_weight_set for JS bindings originated from C bindings function evas_object_size_hint_weight_set, that is EFL Evas type function. With this function we set the hints for an object's weight. The parameters are:

This is not a size enforcement in any way, it's just a hint that should be used whenever appropriate.

This is a hint on how a container object should resize a given child within its area.

Containers may adhere to the simpler logic of just expanding the child object's dimensions to fit its own or the complete one of taking each child's weight hint as real weights to how much of its size to allocate for them in each axis. A container is supposed to, after normalizing the weights of its children (with weight hints), distribute the space it has to layout them by those factors – most weighted children get larger in this process than the least ones.

Default weight hint values are 0.0, for both axis.

Now we add the calendar as a resize-object to win informing that when the size of the win changes so should the calendar's size.

Straigh to the point, to set the limits for years you need only to call min_max_year_set(). First value is minimum year, second is maximum. If first value is negative, it won't apply limit for min year, if the second one is negative, won't apply for max year. Setting both to negative value will clear limits (default state):

Finally we just have to make calendar and window visible.

Our example will look like this:


See the full source code calendar_example_03.js here.