* Add spaces after 'if' and 'for' in JavaScript * Revert to old format * Remove whitespacestags/8.2.0.alpha3
} | } | ||||
w.println(";"); | w.println(";"); | ||||
w.println("for(int i = 0 ; i < value.length; i++) {"); | |||||
w.println("for (int i = 0 ; i < value.length; i++) {"); | |||||
w.indent(); | w.indent(); | ||||
JType componentType = arrayType.getComponentType(); | JType componentType = arrayType.getComponentType(); |
elem.addEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbackFunc, false); | elem.addEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbackFunc, false); | ||||
// Store function reference for later removal | // Store function reference for later removal | ||||
if(!elem._vaadin_animationend_callbacks) { | |||||
if (!elem._vaadin_animationend_callbacks) { | |||||
elem._vaadin_animationend_callbacks = []; | elem._vaadin_animationend_callbacks = []; | ||||
} | } | ||||
elem._vaadin_animationend_callbacks.push(callbackFunc); | elem._vaadin_animationend_callbacks.push(callbackFunc); | ||||
public static native boolean removeAnimationEndListener(Element elem, | public static native boolean removeAnimationEndListener(Element elem, | ||||
AnimationEndListener animationEndListener) | AnimationEndListener animationEndListener) | ||||
/*-{ | /*-{ | ||||
if(elem._vaadin_animationend_callbacks) { | |||||
if (elem._vaadin_animationend_callbacks) { | |||||
var callbacks = elem._vaadin_animationend_callbacks; | var callbacks = elem._vaadin_animationend_callbacks; | ||||
for(var i=0; i < callbacks.length; i++) { | |||||
for (var i=0; i < callbacks.length; i++) { | |||||
if (callbacks[i].listener == animationEndListener) { | if (callbacks[i].listener == animationEndListener) { | ||||
elem.removeEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbacks[i], false); | elem.removeEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbacks[i], false); | ||||
return true; | return true; | ||||
/** For internal use only. May be removed or replaced in the future. */ | /** For internal use only. May be removed or replaced in the future. */ | ||||
public static native void removeAllAnimationEndListeners(Element elem) | public static native void removeAllAnimationEndListeners(Element elem) | ||||
/*-{ | /*-{ | ||||
if(elem._vaadin_animationend_callbacks) { | |||||
if (elem._vaadin_animationend_callbacks) { | |||||
var callbacks = elem._vaadin_animationend_callbacks; | var callbacks = elem._vaadin_animationend_callbacks; | ||||
for(var i=0; i < callbacks.length; i++) { | |||||
for (var i=0; i < callbacks.length; i++) { | |||||
elem.removeEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbacks[i], false); | elem.removeEventListener(@com.vaadin.client.AnimationUtil::ANIMATION_END_EVENT_NAME, callbacks[i], false); | ||||
} | } | ||||
} | } | ||||
/** For internal use only. May be removed or replaced in the future. */ | /** For internal use only. May be removed or replaced in the future. */ | ||||
public static native String getAnimationName(NativeEvent event) | public static native String getAnimationName(NativeEvent event) | ||||
/*-{ | /*-{ | ||||
if(event.webkitAnimationName) | |||||
if (event.webkitAnimationName) | |||||
return event.webkitAnimationName; | return event.webkitAnimationName; | ||||
else if(event.animationName) | |||||
if (event.animationName) | |||||
return event.animationName; | return event.animationName; | ||||
else if(event.mozAnimationName) | |||||
if (event.mozAnimationName) | |||||
return event.mozAnimationName; | return event.mozAnimationName; | ||||
else if(event.oAnimationName) | |||||
if (event.oAnimationName) | |||||
return event.oAnimationName; | return event.oAnimationName; | ||||
return ""; | return ""; | ||||
/*-{ | /*-{ | ||||
var cs = cstyle.@com.vaadin.client.ComputedStyle::computedStyle; | var cs = cstyle.@com.vaadin.client.ComputedStyle::computedStyle; | ||||
if(!cs.getPropertyValue) | |||||
if (!cs.getPropertyValue) | |||||
return ""; | return ""; | ||||
if(cs.getPropertyValue("-webkit-animation-name")) | |||||
if (cs.getPropertyValue("-webkit-animation-name")) | |||||
return cs.getPropertyValue("-webkit-animation-name"); | return cs.getPropertyValue("-webkit-animation-name"); | ||||
else if(cs.getPropertyValue("animation-name")) | |||||
if (cs.getPropertyValue("animation-name")) | |||||
return cs.getPropertyValue("animation-name"); | return cs.getPropertyValue("animation-name"); | ||||
else if(cs.getPropertyValue("-moz-animation-name")) | |||||
if (cs.getPropertyValue("-moz-animation-name")) | |||||
return cs.getPropertyValue("-moz-animation-name"); | return cs.getPropertyValue("-moz-animation-name"); | ||||
else if(cs.getPropertyValue("-o-animation-name")) | |||||
if (cs.getPropertyValue("-o-animation-name")) | |||||
return cs.getPropertyValue("-o-animation-name"); | return cs.getPropertyValue("-o-animation-name"); | ||||
return ""; | return ""; | ||||
'WebkitAnimation': 'webkitAnimationEnd' | 'WebkitAnimation': 'webkitAnimationEnd' | ||||
} | } | ||||
for(var a in anims){ | |||||
if( el.style[a] !== undefined ){ | |||||
for (var a in anims) { | |||||
if ( el.style[a] !== undefined ) { | |||||
return anims[a]; | return anims[a]; | ||||
} | } | ||||
} | } | ||||
'webkitAnimation' | 'webkitAnimation' | ||||
] | ] | ||||
for(var i=0; i < anims.length; i++) { | |||||
if( el.style[anims[i]] !== undefined ){ | |||||
for (var i=0; i < anims.length; i++) { | |||||
if ( el.style[anims[i]] !== undefined ) { | |||||
return anims[i]; | return anims[i]; | ||||
} | } | ||||
} | } |
private static native boolean isDebugAvailable() | private static native boolean isDebugAvailable() | ||||
/*-{ | /*-{ | ||||
if($wnd.vaadin.debug) { | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
return $wnd.vaadin.debug; | |||||
}-*/; | }-*/; | ||||
/** | /** |
* attaching js functions responsibility to create the variable like this: | * attaching js functions responsibility to create the variable like this: | ||||
* | * | ||||
* <code><pre> | * <code><pre> | ||||
* if(!vaadin.postRequestHooks) {vaadin.postRequestHooks = new Object();} | |||||
* if (!vaadin.postRequestHooks) {vaadin.postRequestHooks = new Object();} | |||||
* postRequestHooks.myHook = function(appId) { | * postRequestHooks.myHook = function(appId) { | ||||
* if(appId == "MyAppOfInterest") { | |||||
* if (appId == "MyAppOfInterest") { | |||||
* // do the staff you need on xhr activity | * // do the staff you need on xhr activity | ||||
* } | * } | ||||
* } | * } |
private native boolean detectTouchDevice() | private native boolean detectTouchDevice() | ||||
/*-{ | /*-{ | ||||
try { document.createEvent("TouchEvent");return true;} catch(e){return false;}; | |||||
try { document.createEvent("TouchEvent");return true;} catch(e) {return false;}; | |||||
}-*/; | }-*/; | ||||
private native boolean detectChromeTouchDevice() | private native boolean detectChromeTouchDevice() |
private native void fetchRule(final String selector, final boolean deep) | private native void fetchRule(final String selector, final boolean deep) | ||||
/*-{ | /*-{ | ||||
var sheets = $doc.styleSheets; | var sheets = $doc.styleSheets; | ||||
for(var i = 0; i < sheets.length; i++) { | |||||
var sheet = sheets[i]; | |||||
if(sheet.href && sheet.href.indexOf("VAADIN/themes")>-1) { | |||||
// $entry not needed as function is not exported | |||||
this.@com.vaadin.client.CSSRule::rules = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet, selector, deep); | |||||
return; | |||||
} | |||||
for (var i = 0; i < sheets.length; i++) { | |||||
var sheet = sheets[i]; | |||||
if (sheet.href && sheet.href.indexOf("VAADIN/themes")>-1) { | |||||
// $entry not needed as function is not exported | |||||
this.@com.vaadin.client.CSSRule::rules = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet, selector, deep); | |||||
return; | |||||
} | |||||
} | } | ||||
this.@com.vaadin.client.CSSRule::rules = []; | this.@com.vaadin.client.CSSRule::rules = []; | ||||
}-*/; | }-*/; | ||||
final JavaScriptObject sheet, final String selector, | final JavaScriptObject sheet, final String selector, | ||||
final boolean deep) | final boolean deep) | ||||
/*-{ | /*-{ | ||||
if(!$doc.styleSheets) | |||||
if (!$doc.styleSheets) | |||||
return null; | return null; | ||||
selector = selector.toLowerCase(); | selector = selector.toLowerCase(); | ||||
var allMatches = []; | var allMatches = []; | ||||
// IE handles imported sheet differently | // IE handles imported sheet differently | ||||
if(deep && sheet.imports && sheet.imports.length > 0) { | |||||
for(var i=0; i < sheet.imports.length; i++) { | |||||
// $entry not needed as function is not exported | |||||
var imports = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet.imports[i], selector, deep); | |||||
allMatches.concat(imports); | |||||
} | |||||
if (deep && sheet.imports && sheet.imports.length > 0) { | |||||
for (var i=0; i < sheet.imports.length; i++) { | |||||
// $entry not needed as function is not exported | |||||
var imports = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(sheet.imports[i], selector, deep); | |||||
allMatches.concat(imports); | |||||
} | |||||
} | } | ||||
var theRules = new Array(); | var theRules = new Array(); | ||||
if (sheet.cssRules) | if (sheet.cssRules) | ||||
theRules = sheet.cssRules | |||||
theRules = sheet.cssRules | |||||
else if (sheet.rules) | else if (sheet.rules) | ||||
theRules = sheet.rules | |||||
theRules = sheet.rules | |||||
var j = theRules.length; | var j = theRules.length; | ||||
for(var i=0; i<j; i++) { | |||||
var r = theRules[i]; | |||||
if(r.type == 1 || sheet.imports) { | |||||
var selectors = r.selectorText.toLowerCase().split(","); | |||||
var n = selectors.length; | |||||
for(var m=0; m<n; m++) { | |||||
if(selectors[m].replace(/^\s+|\s+$/g, "") == selector) { | |||||
allMatches.unshift(r); | |||||
break; // No need to loop other selectors for this rule | |||||
} | |||||
} | |||||
} else if(deep && r.type == 3) { | |||||
// Search @import stylesheet | |||||
// $entry not needed as function is not exported | |||||
var imports = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(r.styleSheet, selector, deep); | |||||
allMatches = allMatches.concat(imports); | |||||
} | |||||
for (var i=0; i<j; i++) { | |||||
var r = theRules[i]; | |||||
if (r.type == 1 || sheet.imports) { | |||||
var selectors = r.selectorText.toLowerCase().split(","); | |||||
var n = selectors.length; | |||||
for (var m=0; m<n; m++) { | |||||
if (selectors[m].replace(/^\s+|\s+$/g, "") == selector) { | |||||
allMatches.unshift(r); | |||||
break; // No need to loop other selectors for this rule | |||||
} | |||||
} | |||||
} else if (deep && r.type == 3) { | |||||
// Search @import stylesheet | |||||
// $entry not needed as function is not exported | |||||
var imports = @com.vaadin.client.CSSRule::searchForRule(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)(r.styleSheet, selector, deep); | |||||
allMatches = allMatches.concat(imports); | |||||
} | |||||
} | } | ||||
return allMatches; | return allMatches; | ||||
public native String getPropertyValue(final String propertyName) | public native String getPropertyValue(final String propertyName) | ||||
/*-{ | /*-{ | ||||
var j = this.@com.vaadin.client.CSSRule::rules.length; | var j = this.@com.vaadin.client.CSSRule::rules.length; | ||||
for(var i=0; i<j; i++) { | |||||
// $entry not needed as function is not exported | |||||
var value = this.@com.vaadin.client.CSSRule::rules[i].style[propertyName]; | |||||
if(value) | |||||
return value; | |||||
for (var i=0; i<j; i++) { | |||||
// $entry not needed as function is not exported | |||||
var value = this.@com.vaadin.client.CSSRule::rules[i].style[propertyName]; | |||||
if (value) | |||||
return value; | |||||
} | } | ||||
return null; | return null; | ||||
}-*/; | }-*/; |
final native int size() | final native int size() | ||||
/*-{ | /*-{ | ||||
var count = 0; | var count = 0; | ||||
for(var key in this) { | |||||
for (var key in this) { | |||||
count++; | count++; | ||||
} | } | ||||
return count; | return count; | ||||
final native void clear() | final native void clear() | ||||
/*-{ | /*-{ | ||||
for(var key in this) { | |||||
if(this.hasOwnProperty(key)) { | |||||
for (var key in this) { | |||||
if (this.hasOwnProperty(key)) { | |||||
delete this[key]; | delete this[key]; | ||||
} | } | ||||
} | } | ||||
private final native void fillWithValues(Collection<ComponentDetail> list) | private final native void fillWithValues(Collection<ComponentDetail> list) | ||||
/*-{ | /*-{ | ||||
for(var key in this) { | |||||
for (var key in this) { | |||||
// $entry not needed as function is not exported | // $entry not needed as function is not exported | ||||
list.@java.util.Collection::add(Ljava/lang/Object;)(this[key]); | list.@java.util.Collection::add(Ljava/lang/Object;)(this[key]); | ||||
} | } | ||||
public native JsArrayObject<ComponentDetail> valuesAsJsArray() | public native JsArrayObject<ComponentDetail> valuesAsJsArray() | ||||
/*-{ | /*-{ | ||||
var result = []; | var result = []; | ||||
for(var key in this) { | |||||
for (var key in this) { | |||||
if (this.hasOwnProperty(key)) { | if (this.hasOwnProperty(key)) { | ||||
result.push(this[key]); | result.push(this[key]); | ||||
} | } |
private static native JavaScriptObject getComputedStyle(Element elem) | private static native JavaScriptObject getComputedStyle(Element elem) | ||||
/*-{ | /*-{ | ||||
if(elem.nodeType != 1) { | |||||
if (elem.nodeType != 1) { | |||||
return {}; | return {}; | ||||
} | } | ||||
if($wnd.document.defaultView && $wnd.document.defaultView.getComputedStyle) { | |||||
if ($wnd.document.defaultView && $wnd.document.defaultView.getComputedStyle) { | |||||
return $wnd.document.defaultView.getComputedStyle(elem, null); | return $wnd.document.defaultView.getComputedStyle(elem, null); | ||||
} | } | ||||
if(elem.currentStyle) { | |||||
if (elem.currentStyle) { | |||||
return elem.currentStyle; | return elem.currentStyle; | ||||
} | } | ||||
}-*/; | }-*/; | ||||
// Border values need to be checked separately. The width might have a | // Border values need to be checked separately. The width might have a | ||||
// meaningful value even if the border style is "none". In that case the | // meaningful value even if the border style is "none". In that case the | ||||
// value should be 0. | // value should be 0. | ||||
if(name.indexOf("border") > -1 && name.indexOf("Width") > -1) { | |||||
if (name.indexOf("border") > -1 && name.indexOf("Width") > -1) { | |||||
var borderStyleProp = name.substring(0,name.length-5) + "Style"; | var borderStyleProp = name.substring(0,name.length-5) + "Style"; | ||||
if(cs.getPropertyValue) | |||||
if (cs.getPropertyValue) | |||||
var borderStyle = cs.getPropertyValue(borderStyleProp); | var borderStyle = cs.getPropertyValue(borderStyleProp); | ||||
else // IE | else // IE | ||||
var borderStyle = cs[borderStyleProp]; | var borderStyle = cs[borderStyleProp]; | ||||
if(borderStyle == "none") | |||||
if (borderStyle == "none") | |||||
return "0px"; | return "0px"; | ||||
} | } | ||||
if(cs.getPropertyValue) { | |||||
if (cs.getPropertyValue) { | |||||
// Convert name to dashed format | // Convert name to dashed format | ||||
name = name.replace(/([A-Z])/g, "-$1").toLowerCase(); | name = name.replace(/([A-Z])/g, "-$1").toLowerCase(); | ||||
// Normalize margin values. This is not totally valid, but in most cases | // Normalize margin values. This is not totally valid, but in most cases | ||||
// it is what the user wants to know. | // it is what the user wants to know. | ||||
if(name.indexOf("margin") > -1 && ret == "auto") { | |||||
if (name.indexOf("margin") > -1 && ret == "auto") { | |||||
return "0px"; | return "0px"; | ||||
} | } | ||||
public native JsArrayString getKeys() | public native JsArrayString getKeys() | ||||
/*-{ | /*-{ | ||||
var keys = []; | var keys = []; | ||||
for(var key in this) { | |||||
for (var key in this) { | |||||
if (Object.hasOwnProperty.call(this, key)) { | if (Object.hasOwnProperty.call(this, key)) { | ||||
keys.push(key); | keys.push(key); | ||||
} | } | ||||
public native int size() | public native int size() | ||||
/*-{ | /*-{ | ||||
var size = 0; | var size = 0; | ||||
for(var key in this) { | |||||
for (var key in this) { | |||||
if (Object.hasOwnProperty.call(this, key)) { | if (Object.hasOwnProperty.call(this, key)) { | ||||
size++; | size++; | ||||
} | } |
public native void addAll(JsArrayString array) | public native void addAll(JsArrayString array) | ||||
/*-{ | /*-{ | ||||
for(var i = 0; i < array.length; i++) { | |||||
for (var i = 0; i < array.length; i++) { | |||||
this[array[i]] = true; | this[array[i]] = true; | ||||
} | } | ||||
}-*/; | }-*/; | ||||
public native void addAll(FastStringSet set) | public native void addAll(FastStringSet set) | ||||
/*-{ | /*-{ | ||||
for(var string in set) { | |||||
for (var string in set) { | |||||
if (Object.hasOwnProperty.call(set, string)) { | if (Object.hasOwnProperty.call(set, string)) { | ||||
this[string] = true; | this[string] = true; | ||||
} | } | ||||
public native JsArrayString dump() | public native JsArrayString dump() | ||||
/*-{ | /*-{ | ||||
var array = []; | var array = []; | ||||
for(var string in this) { | |||||
for (var string in this) { | |||||
if (this.hasOwnProperty(string)) { | if (this.hasOwnProperty(string)) { | ||||
array.push(string); | array.push(string); | ||||
} | } | ||||
public native boolean isEmpty() | public native boolean isEmpty() | ||||
/*-{ | /*-{ | ||||
for(var string in this) { | |||||
for (var string in this) { | |||||
if (this.hasOwnProperty(string)) { | if (this.hasOwnProperty(string)) { | ||||
return false; | return false; | ||||
} | } | ||||
public native void addAllTo(Collection<String> target) | public native void addAllTo(Collection<String> target) | ||||
/*-{ | /*-{ | ||||
for(var string in this) { | |||||
for (var string in this) { | |||||
if (Object.hasOwnProperty.call(this, string)) { | if (Object.hasOwnProperty.call(this, string)) { | ||||
target.@java.util.Collection::add(Ljava/lang/Object;)(string); | target.@java.util.Collection::add(Ljava/lang/Object;)(string); | ||||
} | } | ||||
public native void removeAll(FastStringSet valuesToRemove) | public native void removeAll(FastStringSet valuesToRemove) | ||||
/*-{ | /*-{ | ||||
for(var string in valuesToRemove) { | |||||
for (var string in valuesToRemove) { | |||||
if (Object.hasOwnProperty.call(valuesToRemove, string)) { | if (Object.hasOwnProperty.call(valuesToRemove, string)) { | ||||
delete this[string]; | delete this[string]; | ||||
} | } |
JavaScriptObject input) | JavaScriptObject input) | ||||
/*-{ | /*-{ | ||||
// Copy all fields to existing state object | // Copy all fields to existing state object | ||||
for(var key in input) { | |||||
for (var key in input) { | |||||
if (input.hasOwnProperty(key)) { | if (input.hasOwnProperty(key)) { | ||||
state[key] = input[key]; | state[key] = input[key]; | ||||
} | } | ||||
if (!targets) { | if (!targets) { | ||||
return; | return; | ||||
} | } | ||||
for(var i = 0; i < targets.length; i++) { | |||||
for (var i = 0; i < targets.length; i++) { | |||||
var target = targets[i]; | var target = targets[i]; | ||||
target[methodName].apply(target, parameters); | target[methodName].apply(target, parameters); | ||||
} | } |
private static native int getStyleSheetLength(String url) | private static native int getStyleSheetLength(String url) | ||||
/*-{ | /*-{ | ||||
for(var i = 0; i < $doc.styleSheets.length; i++) { | |||||
for (var i = 0; i < $doc.styleSheets.length; i++) { | |||||
if ($doc.styleSheets[i].href === url) { | if ($doc.styleSheets[i].href === url) { | ||||
var sheet = $doc.styleSheets[i]; | var sheet = $doc.styleSheets[i]; | ||||
try { | try { |
private native int typeOfChild(int index) | private native int typeOfChild(int index) | ||||
/*-{ | /*-{ | ||||
var t = typeof this[index + 2]; | var t = typeof this[index + 2]; | ||||
if(t == "object") { | |||||
if(typeof(t.length) == "number") { | |||||
if (t == "object") { | |||||
if (typeof(t.length) == "number") { | |||||
return 1; | return 1; | ||||
} else { | |||||
return 2; | |||||
} | } | ||||
} else if (t == "string") { | |||||
return 2; | |||||
} | |||||
if (t == "string") { | |||||
return 0; | return 0; | ||||
} | } | ||||
return -1; | return -1; | ||||
/*-{ | /*-{ | ||||
var buf = new Array(); | var buf = new Array(); | ||||
var self = this; | var self = this; | ||||
for(j in self) { | |||||
for (j in self) { | |||||
buf.push("<"); | buf.push("<"); | ||||
buf.push(j); | buf.push(j); | ||||
buf.push(">"); | buf.push(">"); |
/*-{ | /*-{ | ||||
var a = new Array(); | var a = new Array(); | ||||
var attr = this; | var attr = this; | ||||
for(var j in attr) { | |||||
for (var j in attr) { | |||||
// workaround for the infamous chrome hosted mode hack (__gwt_ObjectId) | // workaround for the infamous chrome hosted mode hack (__gwt_ObjectId) | ||||
if(attr.hasOwnProperty(j)) | |||||
if (attr.hasOwnProperty(j)) | |||||
a.push(j); | a.push(j); | ||||
} | } | ||||
return a; | return a; |
*/ | */ | ||||
public static native void browserDebugger() | public static native void browserDebugger() | ||||
/*-{ | /*-{ | ||||
if($wnd.console) | |||||
if ($wnd.console) | |||||
debugger; | debugger; | ||||
}-*/; | }-*/; | ||||
public static native Element getElementFromPoint(int clientX, int clientY) | public static native Element getElementFromPoint(int clientX, int clientY) | ||||
/*-{ | /*-{ | ||||
var el = $wnd.document.elementFromPoint(clientX, clientY); | var el = $wnd.document.elementFromPoint(clientX, clientY); | ||||
if(el != null && el.nodeType == 3) { | |||||
if (el != null && el.nodeType == 3) { | |||||
el = el.parentNode; | el = el.parentNode; | ||||
} | } | ||||
return el; | return el; | ||||
/*-{ | /*-{ | ||||
var cs = element.ownerDocument.defaultView.getComputedStyle(element); | var cs = element.ownerDocument.defaultView.getComputedStyle(element); | ||||
var heightPx = cs.height; | var heightPx = cs.height; | ||||
if(heightPx == 'auto'){ | |||||
if (heightPx == 'auto') { | |||||
// Fallback for inline elements | // Fallback for inline elements | ||||
return @com.vaadin.client.WidgetUtil::getRequiredHeightBoundingClientRectDouble(Lcom/google/gwt/dom/client/Element;)(element); | return @com.vaadin.client.WidgetUtil::getRequiredHeightBoundingClientRectDouble(Lcom/google/gwt/dom/client/Element;)(element); | ||||
} | } | ||||
/*-{ | /*-{ | ||||
var cs = element.ownerDocument.defaultView.getComputedStyle(element); | var cs = element.ownerDocument.defaultView.getComputedStyle(element); | ||||
var widthPx = cs.width; | var widthPx = cs.width; | ||||
if(widthPx == 'auto'){ | |||||
if (widthPx == 'auto') { | |||||
// Fallback for inline elements | // Fallback for inline elements | ||||
return @com.vaadin.client.WidgetUtil::getRequiredWidthBoundingClientRectDouble(Lcom/google/gwt/dom/client/Element;)(element); | return @com.vaadin.client.WidgetUtil::getRequiredWidthBoundingClientRectDouble(Lcom/google/gwt/dom/client/Element;)(element); | ||||
} | } |
/*-{ | /*-{ | ||||
var rawEvents = wrapper.getConsumedEvents(); | var rawEvents = wrapper.getConsumedEvents(); | ||||
var events = []; | var events = []; | ||||
for(var i = 0; i < rawEvents.length; i++) { | |||||
for (var i = 0; i < rawEvents.length; i++) { | |||||
events[i] = ""+rawEvents[i]; | events[i] = ""+rawEvents[i]; | ||||
} | } | ||||
return events; | return events; |
var heightRanges = @com.vaadin.client.extensions.ResponsiveConnector::heightRangeCache; | var heightRanges = @com.vaadin.client.extensions.ResponsiveConnector::heightRangeCache; | ||||
// Can't do squat if we can't parse stylesheets | // Can't do squat if we can't parse stylesheets | ||||
if(!$doc.styleSheets) | |||||
if (!$doc.styleSheets) | |||||
return; | return; | ||||
var sheets = $doc.styleSheets; | var sheets = $doc.styleSheets; | ||||
// Loop all stylesheets on the page and process them individually | // Loop all stylesheets on the page and process them individually | ||||
for(var i = 0, len = sheets.length; i < len; i++) { | |||||
for (var i = 0, len = sheets.length; i < len; i++) { | |||||
var sheet = sheets[i]; | var sheet = sheets[i]; | ||||
@com.vaadin.client.extensions.ResponsiveConnector::searchStylesheetForBreakPoints(Lcom/google/gwt/core/client/JavaScriptObject;)(sheet); | @com.vaadin.client.extensions.ResponsiveConnector::searchStylesheetForBreakPoints(Lcom/google/gwt/core/client/JavaScriptObject;)(sheet); | ||||
} | } | ||||
} | } | ||||
// Loop through the rulesets | // Loop through the rulesets | ||||
for(var i = 0, len = theRules.length; i < len; i++) { | |||||
for (var i = 0, len = theRules.length; i < len; i++) { | |||||
var rule = theRules[i]; | var rule = theRules[i]; | ||||
if(rule.type == 3) { | |||||
if (rule.type == 3) { | |||||
// @import rule, traverse recursively | // @import rule, traverse recursively | ||||
@com.vaadin.client.extensions.ResponsiveConnector::searchStylesheetForBreakPoints(Lcom/google/gwt/core/client/JavaScriptObject;)(rule.styleSheet); | @com.vaadin.client.extensions.ResponsiveConnector::searchStylesheetForBreakPoints(Lcom/google/gwt/core/client/JavaScriptObject;)(rule.styleSheet); | ||||
} else if(rule.type == 1 || !rule.type) { | |||||
} else if (rule.type == 1 || !rule.type) { | |||||
// Regular selector rule | // Regular selector rule | ||||
// Helper function | // Helper function | ||||
var pushToCache = function(ranges, selector, min, max) { | var pushToCache = function(ranges, selector, min, max) { | ||||
// Avoid adding duplicates | // Avoid adding duplicates | ||||
var duplicate = false; | var duplicate = false; | ||||
for(var l = 0, len3 = ranges.length; l < len3; l++) { | |||||
for (var l = 0, len3 = ranges.length; l < len3; l++) { | |||||
var bp = ranges[l]; | var bp = ranges[l]; | ||||
if (selector == bp[0] && min == bp[1] && max == bp[2]) { | if (selector == bp[0] && min == bp[1] && max == bp[2]) { | ||||
duplicate = true; | duplicate = true; | ||||
var selectorRegEx = IEOrEdge ? /\[.*\]([\.|#]\S+)/ : /([\.|#]\S+?)\[.*\]/; | var selectorRegEx = IEOrEdge ? /\[.*\]([\.|#]\S+)/ : /([\.|#]\S+?)\[.*\]/; | ||||
// Loop all the selectors in this ruleset | // Loop all the selectors in this ruleset | ||||
for(var k = 0, len2 = haystack.length; k < len2; k++) { | |||||
for (var k = 0, len2 = haystack.length; k < len2; k++) { | |||||
// Split the haystack into parts. | // Split the haystack into parts. | ||||
var widthRange = haystack[k].match(/\[width-range.*?\]/); | var widthRange = haystack[k].match(/\[width-range.*?\]/); | ||||
var widthRanges = @com.vaadin.client.extensions.ResponsiveConnector::widthRangeCache; | var widthRanges = @com.vaadin.client.extensions.ResponsiveConnector::widthRangeCache; | ||||
var heightRanges = @com.vaadin.client.extensions.ResponsiveConnector::heightRangeCache; | var heightRanges = @com.vaadin.client.extensions.ResponsiveConnector::heightRangeCache; | ||||
for(var i = 0, len = widthRanges.length; i < len; i++) { | |||||
for (var i = 0, len = widthRanges.length; i < len; i++) { | |||||
var bp = widthRanges[i]; | var bp = widthRanges[i]; | ||||
for(var j = 0, len2 = selectors.length; j < len2; j++) { | |||||
if(bp[0] == selectors[j]) | |||||
for (var j = 0, len2 = selectors.length; j < len2; j++) { | |||||
if (bp[0] == selectors[j]) | |||||
widthBreakpoints.push(bp); | widthBreakpoints.push(bp); | ||||
} | } | ||||
} | } | ||||
for(var i = 0, len = heightRanges.length; i < len; i++) { | |||||
for (var i = 0, len = heightRanges.length; i < len; i++) { | |||||
var bp = heightRanges[i]; | var bp = heightRanges[i]; | ||||
for(var j = 0, len2 = selectors.length; j < len2; j++) { | |||||
if(bp[0] == selectors[j]) | |||||
for (var j = 0, len2 = selectors.length; j < len2; j++) { | |||||
if (bp[0] == selectors[j]) | |||||
heightBreakpoints.push(bp); | heightBreakpoints.push(bp); | ||||
} | } | ||||
} | } | ||||
var breakpoints = this.@com.vaadin.client.extensions.ResponsiveConnector::widthBreakpoints; | var breakpoints = this.@com.vaadin.client.extensions.ResponsiveConnector::widthBreakpoints; | ||||
// Use height breakpoints if we're measuring the height | // Use height breakpoints if we're measuring the height | ||||
if(which == "height") | |||||
if (which == "height") | |||||
breakpoints = this.@com.vaadin.client.extensions.ResponsiveConnector::heightBreakpoints; | breakpoints = this.@com.vaadin.client.extensions.ResponsiveConnector::heightBreakpoints; | ||||
// Output string that goes into either the "width-range" or "height-range" attribute in the element | // Output string that goes into either the "width-range" or "height-range" attribute in the element | ||||
var ranges = ""; | var ranges = ""; | ||||
// Loop the breakpoints | // Loop the breakpoints | ||||
for(var i = 0, len = breakpoints.length; i < len; i++) { | |||||
for (var i = 0, len = breakpoints.length; i < len; i++) { | |||||
var bp = breakpoints[i]; | var bp = breakpoints[i]; | ||||
var min = parseInt(bp[1]); | var min = parseInt(bp[1]); | ||||
var max = parseInt(bp[2]); | var max = parseInt(bp[2]); | ||||
if(!isNaN(min) && !isNaN(max)) { | |||||
if(min <= size && size <= max) { | |||||
if (!isNaN(min) && !isNaN(max)) { | |||||
if (min <= size && size <= max) { | |||||
ranges += " " + bp[1] + "-" + bp[2]; | ranges += " " + bp[1] + "-" + bp[2]; | ||||
} | } | ||||
} else if (!isNaN(min)) { | } else if (!isNaN(min)) { | ||||
if(min <= size) { | |||||
if (min <= size) { | |||||
ranges += " " + bp[1] + "-"; | ranges += " " + bp[1] + "-"; | ||||
} | } | ||||
} else if (!isNaN(max)) { | } else if (!isNaN(max)) { |
var target = $wnd; | var target = $wnd; | ||||
var parts = name.split('.'); | var parts = name.split('.'); | ||||
for(var i = 0; i < parts.length - 1; i++) { | |||||
for (var i = 0; i < parts.length - 1; i++) { | |||||
var part = parts[i]; | var part = parts[i]; | ||||
if (target[part] === undefined) { | if (target[part] === undefined) { | ||||
target[part] = {}; | target[part] = {}; | ||||
var target = $wnd; | var target = $wnd; | ||||
var parts = name.split('.'); | var parts = name.split('.'); | ||||
for(var i = 0; i < parts.length - 1; i++) { | |||||
for (var i = 0; i < parts.length - 1; i++) { | |||||
var part = parts[i]; | var part = parts[i]; | ||||
if (target[part] === undefined) { | if (target[part] === undefined) { | ||||
$wnd.console.log(part,'not defined in',target); | $wnd.console.log(part,'not defined in',target); | ||||
private static native void eval(String script) | private static native void eval(String script) | ||||
/*-{ | /*-{ | ||||
if(script) { | |||||
if (script) { | |||||
(new $wnd.Function(script)).apply($wnd); | (new $wnd.Function(script)).apply($wnd); | ||||
} | } | ||||
}-*/; | }-*/; |
String baseClassName, String superClassName) | String baseClassName, String superClassName) | ||||
/*-{ | /*-{ | ||||
var parentType = typeData[superClassName]; | var parentType = typeData[superClassName]; | ||||
if (parentType !== undefined ){ | |||||
if (parentType !== undefined ) { | |||||
var ctor = function () {}; | var ctor = function () {}; | ||||
ctor.prototype = parentType; | ctor.prototype = parentType; | ||||
typeData[baseClassName] = new ctor; | typeData[baseClassName] = new ctor; | ||||
JavaScriptObject typeData, String beanName) | JavaScriptObject typeData, String beanName) | ||||
/*-{ | /*-{ | ||||
var names = []; | var names = []; | ||||
for(var name in typeData[beanName]) { | |||||
for (var name in typeData[beanName]) { | |||||
names.push(name); | names.push(name); | ||||
} | } | ||||
return names; | return names; |
private static native void blur(Element e) | private static native void blur(Element e) | ||||
/*-{ | /*-{ | ||||
if(e.blur) { | |||||
if (e.blur) { | |||||
e.blur(); | e.blur(); | ||||
} | } | ||||
}-*/; | }-*/; | ||||
private static native void focus(Element e) | private static native void focus(Element e) | ||||
/*-{ | /*-{ | ||||
if(e.blur) { | |||||
if (e.blur) { | |||||
e.focus(); | e.focus(); | ||||
} | } | ||||
}-*/; | }-*/; |
import com.vaadin.client.WidgetUtil; | import com.vaadin.client.WidgetUtil; | ||||
import com.vaadin.client.WidgetUtil.ErrorUtil; | import com.vaadin.client.WidgetUtil.ErrorUtil; | ||||
public class VButton extends FocusWidget implements ClickHandler, | |||||
HasErrorIndicatorElement { | |||||
public class VButton extends FocusWidget | |||||
implements ClickHandler, HasErrorIndicatorElement { | |||||
public static final String CLASSNAME = "v-button"; | public static final String CLASSNAME = "v-button"; | ||||
private static final String CLASSNAME_PRESSED = "v-pressed"; | private static final String CLASSNAME_PRESSED = "v-pressed"; | ||||
var ret = 0; | var ret = 0; | ||||
var sides = ["Right","Left"]; | var sides = ["Right","Left"]; | ||||
for(var i=0; i<2; i++) { | |||||
for (var i=0; i<2; i++) { | |||||
var side = sides[i]; | var side = sides[i]; | ||||
var value; | var value; | ||||
// Border ------------------------------------------------------- | // Border ------------------------------------------------------- | ||||
if(elem.currentStyle["border"+side+"Style"] != "none") { | |||||
if (elem.currentStyle["border"+side+"Style"] != "none") { | |||||
value = elem.currentStyle["border"+side+"Width"]; | value = elem.currentStyle["border"+side+"Width"]; | ||||
if ( !/^\d+(px)?$/i.test( value ) && /^\d/.test( value ) ) { | if ( !/^\d+(px)?$/i.test( value ) && /^\d/.test( value ) ) { | ||||
ret += convertToPixel(elem, value); | ret += convertToPixel(elem, value); | ||||
} else if(value.length > 2) { | |||||
} else if (value.length > 2) { | |||||
ret += parseInt(value.substr(0, value.length-2)); | ret += parseInt(value.substr(0, value.length-2)); | ||||
} | } | ||||
} | } | ||||
value = elem.currentStyle["padding"+side]; | value = elem.currentStyle["padding"+side]; | ||||
if ( !/^\d+(px)?$/i.test( value ) && /^\d/.test( value ) ) { | if ( !/^\d+(px)?$/i.test( value ) && /^\d/.test( value ) ) { | ||||
ret += convertToPixel(elem, value); | ret += convertToPixel(elem, value); | ||||
} else if(value.length > 2) { | |||||
} else if (value.length > 2) { | |||||
ret += parseInt(value.substr(0, value.length-2)); | ret += parseInt(value.substr(0, value.length-2)); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
public native int minWidth(String captions) | public native int minWidth(String captions) | ||||
/*-{ | /*-{ | ||||
if(!captions || captions.length <= 0) | |||||
if (!captions || captions.length <= 0) | |||||
return 0; | return 0; | ||||
captions = captions.split("|"); | captions = captions.split("|"); | ||||
var d = $wnd.document.createElement("div"); | var d = $wnd.document.createElement("div"); | ||||
var html = ""; | var html = ""; | ||||
for(var i=0; i < captions.length; i++) { | |||||
for (var i=0; i < captions.length; i++) { | |||||
html += "<div>" + captions[i] + "</div>"; | html += "<div>" + captions[i] + "</div>"; | ||||
// TODO apply same CSS classname as in suggestionmenu | // TODO apply same CSS classname as in suggestionmenu | ||||
} | } |
private native boolean uriEndsWithSlash() | private native boolean uriEndsWithSlash() | ||||
/*-{ | /*-{ | ||||
var path = $wnd.location.pathname; | var path = $wnd.location.pathname; | ||||
if(path.charAt(path.length - 1) == "/") | |||||
if (path.charAt(path.length - 1) == "/") | |||||
return true; | return true; | ||||
return false; | return false; | ||||
}-*/; | }-*/; | ||||
*/ | */ | ||||
public native boolean iLayoutJS(com.google.gwt.user.client.Element el) | public native boolean iLayoutJS(com.google.gwt.user.client.Element el) | ||||
/*-{ | /*-{ | ||||
if(el && el.iLayoutJS) { | |||||
if (el && el.iLayoutJS) { | |||||
try { | try { | ||||
el.iLayoutJS(); | el.iLayoutJS(); | ||||
return true; | return true; |
private native String getText(Element element) | private native String getText(Element element) | ||||
/*-{ | /*-{ | ||||
var n = element.childNodes.length; | var n = element.childNodes.length; | ||||
if(n > 0){ | |||||
if (n > 0) { | |||||
return element.childNodes[n - 1].nodeValue; | return element.childNodes[n - 1].nodeValue; | ||||
} | } | ||||
else{ | |||||
return ""; | |||||
} | |||||
return ""; | |||||
}-*/; | }-*/; | ||||
private Element getLastChildElement(CustomMenuItem item) { | private Element getLastChildElement(CustomMenuItem item) { |
private static native void nativeBlur(Element e) | private static native void nativeBlur(Element e) | ||||
/*-{ | /*-{ | ||||
if(e && e.blur) { | |||||
if (e && e.blur) { | |||||
e.blur(); | e.blur(); | ||||
} | } | ||||
}-*/; | }-*/; |
private static native void loadAppIdListFromDOM(List<String> list) | private static native void loadAppIdListFromDOM(List<String> list) | ||||
/*-{ | /*-{ | ||||
var j; | |||||
for(j in $wnd.vaadin.vaadinConfigurations) { | |||||
for (var j in $wnd.vaadin.vaadinConfigurations) { | |||||
// $entry not needed as function is not exported | // $entry not needed as function is not exported | ||||
list.@java.util.Collection::add(Ljava/lang/Object;)(j); | list.@java.util.Collection::add(Ljava/lang/Object;)(j); | ||||
} | } |
*/ | */ | ||||
public final native String getFileAsString(int index) | public final native String getFileAsString(int index) | ||||
/*-{ | /*-{ | ||||
if(this.dataTransfer.files.length > 0 && this.dataTransfer.files[0].getAsText) { | |||||
if (this.dataTransfer.files.length > 0 && this.dataTransfer.files[0].getAsText) { | |||||
return this.dataTransfer.files[index].getAsText("UTF-8"); | return this.dataTransfer.files[index].getAsText("UTF-8"); | ||||
} | } | ||||
return null; | return null; | ||||
/*-{ | /*-{ | ||||
try { | try { | ||||
this.dataTransfer.dropEffect = effect; | this.dataTransfer.dropEffect = effect; | ||||
} catch (e){} | |||||
} catch (e) {} | |||||
}-*/; | }-*/; | ||||
public final native String getEffectAllowed() | public final native String getEffectAllowed() |
// A delta mode of 1 means we're scrolling by lines instead of pixels | // A delta mode of 1 means we're scrolling by lines instead of pixels | ||||
// We need to scale the number of lines by the default line height | // We need to scale the number of lines by the default line height | ||||
if(e.deltaMode === 1) { | |||||
if (e.deltaMode === 1) { | |||||
var brc = esc.@com.vaadin.client.widgets.Escalator::body; | var brc = esc.@com.vaadin.client.widgets.Escalator::body; | ||||
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()(); | deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()(); | ||||
} | } | ||||
// Other delta modes aren't supported | // Other delta modes aren't supported | ||||
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) { | |||||
if ((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) { | |||||
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\""; | var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\""; | ||||
// Print warning message | // Print warning message |
try { | try { | ||||
var b = $wnd.document.body; | var b = $wnd.document.body; | ||||
var cstyle = b.currentStyle ? b.currentStyle : getComputedStyle(b); | var cstyle = b.currentStyle ? b.currentStyle : getComputedStyle(b); | ||||
if(cstyle && cstyle.position == 'relative') { | |||||
if (cstyle && cstyle.position == 'relative') { | |||||
return b.getBoundingClientRect()[axis]; | return b.getBoundingClientRect()[axis]; | ||||
} | } | ||||
} catch(e){} | |||||
} catch(e) {} | |||||
return 0; | return 0; | ||||
}-*/; | }-*/; | ||||
/*-{ | /*-{ | ||||
var rawEvents = wrapper.getConsumedEvents(); | var rawEvents = wrapper.getConsumedEvents(); | ||||
var events = []; | var events = []; | ||||
for(var i = 0; i < rawEvents.length; i++) { | |||||
for (var i = 0; i < rawEvents.length; i++) { | |||||
events[i] = ""+rawEvents[i]; | events[i] = ""+rawEvents[i]; | ||||
} | } | ||||
return events; | return events; |
/*-{ | /*-{ | ||||
try { | try { | ||||
var date = new Date(2000,1,1,1); // don't use current date here | var date = new Date(2000,1,1,1); // don't use current date here | ||||
if(y && y >= 0) date.setFullYear(y); | |||||
if(m && m >= 1) date.setMonth(m-1); | |||||
if(d && d >= 0) date.setDate(d); | |||||
if(h >= 0) date.setHours(h); | |||||
if(mi >= 0) date.setMinutes(mi); | |||||
if(s >= 0) date.setSeconds(s); | |||||
if(ms >= 0) date.setMilliseconds(ms); | |||||
if (y && y >= 0) date.setFullYear(y); | |||||
if (m && m >= 1) date.setMonth(m-1); | |||||
if (d && d >= 0) date.setDate(d); | |||||
if (h >= 0) date.setHours(h); | |||||
if (mi >= 0) date.setMinutes(mi); | |||||
if (s >= 0) date.setSeconds(s); | |||||
if (ms >= 0) date.setMilliseconds(ms); | |||||
return date.getTime(); | return date.getTime(); | ||||
} catch (e) { | } catch (e) { | ||||
// TODO print some error message on the console | // TODO print some error message on the console |
*/ | */ | ||||
public native int minWidth(String captions) | public native int minWidth(String captions) | ||||
/*-{ | /*-{ | ||||
if(!captions || captions.length <= 0) | |||||
if (!captions || captions.length <= 0) | |||||
return 0; | return 0; | ||||
captions = captions.split("|"); | captions = captions.split("|"); | ||||
var d = $wnd.document.createElement("div"); | var d = $wnd.document.createElement("div"); | ||||
var html = ""; | var html = ""; | ||||
for(var i=0; i < captions.length; i++) { | |||||
for (var i=0; i < captions.length; i++) { | |||||
html += "<div>" + captions[i] + "</div>"; | html += "<div>" + captions[i] + "</div>"; | ||||
// TODO apply same CSS classname as in suggestionmenu | // TODO apply same CSS classname as in suggestionmenu | ||||
} | } |
*/ | */ | ||||
private static native JavaScriptObject getPreventTextSelectionIEHack() | private static native JavaScriptObject getPreventTextSelectionIEHack() | ||||
/*-{ | /*-{ | ||||
return function(){ return false; }; | |||||
return function() { return false; }; | |||||
}-*/; | }-*/; | ||||
public void triggerLazyColumnAdjustment(boolean now) { | public void triggerLazyColumnAdjustment(boolean now) { |
*/ | */ | ||||
private native JavaScriptObject applyDisableTextSelectionIEHack() | private native JavaScriptObject applyDisableTextSelectionIEHack() | ||||
/*-{ | /*-{ | ||||
return function(){ return false; }; | |||||
return function() { return false; }; | |||||
}-*/; | }-*/; | ||||
/** | /** |
// A delta mode of 1 means we're scrolling by lines instead of pixels | // A delta mode of 1 means we're scrolling by lines instead of pixels | ||||
// We need to scale the number of lines by the default line height | // We need to scale the number of lines by the default line height | ||||
if(e.deltaMode === 1) { | |||||
if (e.deltaMode === 1) { | |||||
var brc = esc.@com.vaadin.v7.client.widgets.Escalator::body; | var brc = esc.@com.vaadin.v7.client.widgets.Escalator::body; | ||||
deltaY *= brc.@com.vaadin.v7.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()(); | deltaY *= brc.@com.vaadin.v7.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()(); | ||||
} | } | ||||
// Other delta modes aren't supported | // Other delta modes aren't supported | ||||
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) { | |||||
if ((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) { | |||||
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\""; | var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\""; | ||||
// Print warning message | // Print warning message |
} | } | ||||
JavaScript.getCurrent() | JavaScript.getCurrent() | ||||
.execute("var x=document." + method + ";" | .execute("var x=document." + method + ";" | ||||
+ " var i; for(i=0; i < x.length; i++)" | |||||
+ " var i; for (i=0; i < x.length; i++)" | |||||
+ " {x[i].className += ' custom-menu-item'};"); | + " {x[i].className += ' custom-menu-item'};"); | ||||
} | } | ||||
}); | }); |
+ " _handleProtocol = function(a,message) {return message;};" | + " _handleProtocol = function(a,message) {return message;};" | ||||
+ " var response = {partialMessage: ''};\n" | + " var response = {partialMessage: ''};\n" | ||||
+ " var messages = [];\n" | + " var messages = [];\n" | ||||
+ " for(var i = 0; i < data.length; i++) {\n" | |||||
+ " for (var i = 0; i < data.length; i++) {\n" | |||||
+ " if (!_trackMessageSize(data[i], request, response))\n" | + " if (!_trackMessageSize(data[i], request, response))\n" | ||||
+ " messages = messages.concat(response.messages);\n" | + " messages = messages.concat(response.messages);\n" | ||||
+ " }\n" | + " }\n" |
public static void installPerformanceReporting(TextArea targetTextArea) { | public static void installPerformanceReporting(TextArea targetTextArea) { | ||||
targetTextArea.setId("performanceTestTarget"); | targetTextArea.setId("performanceTestTarget"); | ||||
JavaScript | |||||
.eval("window.reportVaadinPerformance = function(topic, serverLimit, clientLimit, bootstrapTime) {" | |||||
JavaScript.eval( | |||||
"window.reportVaadinPerformance = function(topic, serverLimit, clientLimit, bootstrapTime) {" | |||||
+ "var element = document.getElementById('performanceTestTarget');" | + "var element = document.getElementById('performanceTestTarget');" | ||||
+ "var text = topic + ': \\n';" | + "var text = topic + ': \\n';" | ||||
+ "for(var k in window.vaadin.clients) {" | |||||
+ "for (var k in window.vaadin.clients) {" | |||||
+ "var p = window.vaadin.clients[k].getProfilingData();" | + "var p = window.vaadin.clients[k].getProfilingData();" | ||||
+ "text += ' Server time: ' + (p[3] > serverLimit?'FAIL':'OK') + ' (' + p[3] +')\\n';" | + "text += ' Server time: ' + (p[3] > serverLimit?'FAIL':'OK') + ' (' + p[3] +')\\n';" | ||||
+ "text += ' Client time: ' + (p[0] > clientLimit?'FAIL':'OK') + ' (' + p[0] +')\\n';" | + "text += ' Client time: ' + (p[0] > clientLimit?'FAIL':'OK') + ' (' + p[0] +')\\n';" |
openTestURL(); | openTestURL(); | ||||
String script = "document.mutationEventCount = 0;" | String script = "document.mutationEventCount = 0;" | ||||
+ "var observer = new MutationObserver(function(mutations){" | |||||
+ "var observer = new MutationObserver(function(mutations) {" | |||||
+ "mutations.forEach(function(mutation) { document.mutationEventCount += mutation.removedNodes.length; });" | + "mutations.forEach(function(mutation) { document.mutationEventCount += mutation.removedNodes.length; });" | ||||
+ "});" | + "});" | ||||
+ "observer.observe(arguments[0].parentNode, { childList: true });"; | + "observer.observe(arguments[0].parentNode, { childList: true });"; |
openTestURL(); | openTestURL(); | ||||
String script = "document.mutationEventCount = 0;" | String script = "document.mutationEventCount = 0;" | ||||
+ "var observer = new MutationObserver(function(mutations){" | |||||
+ "var observer = new MutationObserver(function(mutations) {" | |||||
+ "mutations.forEach(function(mutation) { document.mutationEventCount += mutation.removedNodes.length; });" | + "mutations.forEach(function(mutation) { document.mutationEventCount += mutation.removedNodes.length; });" | ||||
+ "});" | + "});" | ||||
+ "observer.observe(arguments[0], { childList: true });"; | + "observer.observe(arguments[0], { childList: true });"; |