Javascript:

$(document).ready(function() {

        $('#calendar').fullCalendar({
      theme: true   ,
      defaultView: 'month',
      header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaDay'
            },
            editable: false,
            eventLimit: true, // allow "more" link when too many events
            events: loadEvents,
      height: "parent",
      locale: "sk",
      dayClick: dayClick,
      eventAfterAllRender: attachLongPress,
      eventClick: eventClick,
      eventRender: eventRender,
      eventRenderWait: 100,
      defaultTimedEventDuration:"00:15:00"
      });
  });

  var attachLongPress = function(view) {
    if (view.name === 'agendaDay') {
      var date = view.start.format('YYYY-MM-DD');
      var tds = $('.fc-slats .ui-widget-content').not('.fc-axis');
      tds.longpress(function(evt) {
        var dateWs = date + " " + evt.target.parentElement.attributes[
'data-time'].value;
        log('Create event: ' + dateWs);
        createNewEvent(dateWs)
      }, undefined, 1000);
    } else
    if (view.name === 'month') {
      var tds = $('td.fc-day.ui-widget-content');
      tds.longpress(function(evt) {
        longPress = true;
        var dateWs = evt.target.attributes['data-date'].value;
        log('Create event: ' + dateWs);
        createNewEvent(dateWs);
        evt.stopPropagation();
        evt.preventDefault();
      }, undefined, 1000);
    }
  };


Java code:

public JSCalendarFrame(CalendarData dataProvider, TsviewExt view, final 
ListContainer lc, Date activeDate,
            int scrollToY) {
        this.dataProvider = dataProvider;
        this.view = view;
        this.lc = lc;

        setLayout(new BorderLayout());
        this.activeDate = (activeDate == null ? new Date() : activeDate);
        createBrowserComponent();
        String url = getCalendarUrl();
        bc.setURL(url);
        setupJSCallbacks();
        Log.p("Callbacks", Log.ERROR);
        revalidate();

    }


   private void createBrowserComponent() {
        this.bc = new BrowserComponent();
        this.bc.setProperty("AllowFileAccessFromFileURLs", Boolean.TRUE);
        this.bc.setProperty("AllowUniversalAccessFromFileURLs", Boolean.TRUE
);
        this.add(BorderLayout.CENTER, bc);
        bc.addWebEventListener("onLoad", new ActionListener<ActionEvent>() {
            public void actionPerformed(ActionEvent evt) {
                Log.p("onLoad", Log.DEBUG);
                setupJSCallbacks();
                bc.execute("refreshCalendar()");
            }
        });
    }


private String getCalendarUrl() {
       
        String home = DocumentHelper.getDefaultDataDirectory();
        if (!home.startsWith("file://")) {
            home = "file://" + home;
        }
        return home + "calendar/calendar.html";
    }


-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/a693e1eb-7533-4562-8512-7289c0936dd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to