001package org.gwtbootstrap3.extras.fullcalendar.client.ui; 002 003/* 004 * #%L 005 * GwtBootstrap3 006 * %% 007 * Copyright (C) 2013 - 2014 GwtBootstrap3 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import com.google.gwt.core.client.JavaScriptObject; 024 025/** 026 * Wraps click and hover events inside a <code>JavaScriptObject</code> 027 * 028 * @author Jeff Isenhart 029 * @see http://arshaw.com/fullcalendar/docs/mouse/ 030 */ 031public class ClickAndHoverConfig implements IsJavaScriptObject { 032 private JavaScriptObject script; 033 034 public ClickAndHoverConfig(final ClickAndHoverEventCallback handler) { 035 if (handler != null) { 036 newInstance(handler); 037 } 038 } 039 040 private native void newInstance(ClickAndHoverEventCallback handler) /*-{ 041 var theInstance = this; 042 var mouseHandler = handler; 043 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverConfig::script = {}; 044 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverConfig::script.eventClick = function (calEvent, jsEvent, view) { 045 mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverEventCallback::eventClick(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/core/client/JavaScriptObject;)(calEvent, jsEvent, view); 046 }; 047 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverConfig::script.dayClick = function (moment, jsEvent, view) { 048 mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverEventCallback::dayClick(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/core/client/JavaScriptObject;)(moment, jsEvent, view); 049 }; 050 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverConfig::script.eventMouseover = function (calEvent, jsEvent, view) { 051 mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverEventCallback::eventMouseover(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/core/client/JavaScriptObject;)(calEvent, jsEvent, view); 052 }; 053 theInstance.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverConfig::script.eventMouseout = function (calEvent, jsEvent, view) { 054 mouseHandler.@org.gwtbootstrap3.extras.fullcalendar.client.ui.ClickAndHoverEventCallback::eventMouseout(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/core/client/JavaScriptObject;)(calEvent, jsEvent, view); 055 }; 056 057 }-*/; 058 059 @Override 060 public JavaScriptObject toJavaScript() { 061 return script; 062 } 063}