From: Manuel Carrasco MoƱino Date: Sun, 26 Jan 2014 16:18:59 +0000 (+0000) Subject: merge with master X-Git-Tag: gwtquery-project-1.4.3~44^2~5^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2b45e352a6e115915944a164eb14cc677630d3f0;p=gwtquery.git merge with master --- 2b45e352a6e115915944a164eb14cc677630d3f0 diff --cc gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java index 985e3a03,1ccc04d6..dd67bd1a --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/ConsoleBrowser.java @@@ -43,52 -43,35 +43,52 @@@ public class ConsoleBrowser implements * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object */ private static class ConsoleIe9 extends ConsoleImpl { -- ++ + private boolean initialized = false; - ++ public ConsoleIe9(){ init(); } -- ++ protected native void init()/*-{ try { [ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ] .forEach(function(method) { $wnd.console[method] = this.call($wnd.console[method], $wnd.console); }, Function.prototype.bind); + this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initialized = true; } catch(e) { - this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initFallBack()(); - } - }-*/; - - /** - * Dummy implementation of console if IE8 or IE9 fail using dev tools. - */ - private native void initFallBack() /*-{ - if (!$wnd.console || !$wnd.console.log) { - $wnd.console = {}; - [ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ] - .forEach(function(method) { - $wnd.console[method] = function(){}; - }); } }-*/; - + + @Override + public void clear() { + if (initialized) super.clear(); + } + @Override + public void dir(Object arg) { + if (initialized) super.dir(arg); + } + @Override + public void error(Object arg) { + if (initialized) super.error(arg); + } + @Override + public void info(Object arg) { + if (initialized) super.info(arg); + } + @Override + public void profile(String title) { + if (initialized) super.profile(title); + } + @Override + public void profileEnd(String title) { + if (initialized) super.profileEnd(title); + } + @Override + public void warn(Object arg) { + if (initialized) super.warn(arg); + } @Override public void group(Object arg) {} @Override @@@ -102,7 -85,7 +102,7 @@@ @Override public void timeEnd(String title) {} } -- ++ /** * Default implementation: webkit, opera, FF, ie10 */ @@@ -163,9 -146,9 +163,9 @@@ $wnd.console.warn(arg); }-*/; } -- ++ private ConsoleImpl impl; -- ++ public ConsoleBrowser() { impl = GQuery.browser.ie8? new ConsoleIe8(): GQuery.browser.ie9? new ConsoleIe9(): new ConsoleImpl(); } @@@ -239,7 -222,7 +239,7 @@@ public void warn(Object arg) { impl.warn(toJs(arg)); } -- ++ /** * Don't pass GWT Objects to JS methods */ diff --cc gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java index 79d3fa8d,8ec7cc7a..8591ca38 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseReqBuilder.java @@@ -35,7 -36,7 +35,7 @@@ import com.google.gwt.xhr.client.XMLHtt *
   *        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://127.0.0.1:8888/whatever");
   *        PromiseRequest gettingResponse = new PromiseReqBuilder(builder);
-- *        
++ *
   *        gettingResponse.fail(new Function() {
   *          public void f() {
   *            Throwable exception = arguments(0);
@@@ -48,7 -49,7 +48,7 @@@
   * 
*/ public class PromiseReqBuilder extends DeferredPromiseImpl implements RequestCallback { -- ++ public PromiseReqBuilder(RequestBuilder builder) { builder.setCallback(this); try { @@@ -57,19 -58,13 +57,19 @@@ onError(null, e); } } -- ++ /** * Using this constructor we access to some things in the xmlHttpRequest * which are not available in GWT, like adding progress handles or sending * javascript data (like forms in modern html5 file api) */ - public PromiseReqBuilder(Settings settings, String httpMethod, String url, Object data) { + public PromiseReqBuilder(Settings settings) { + String httpMethod = settings.getType(); + String url = settings.getUrl(); + Binder data = settings.getData(); + String ctype = settings.getContentType(); + Boolean isFormData = data != null && data.getBound() instanceof JavaScriptObject && JsUtils.isFormData(data.getBound()); - ++ XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create(); try { if (settings.getUsername() != null && settings.getPassword() != null) { @@@ -85,7 -80,7 +85,7 @@@ onError(null, e); return; } -- ++ JsUtils.prop(xmlHttpRequest, "onprogress", JsUtils.wrapFunction(new Function() { public void f() { JsCache p = arguments(0); @@@ -95,7 -90,7 +95,7 @@@ dfd.notify(total, loaded, percent, "download"); } })); -- ++ JavaScriptObject upload = JsUtils.prop(xmlHttpRequest, "upload"); JsUtils.prop(upload, "onprogress", JsUtils.wrapFunction(new Function() { public void f() { @@@ -106,24 -101,35 +106,24 @@@ dfd.notify(total, loaded, percent, "upload"); } })); -- - Properties headers = settings.getHeaders(); ++ + Binder headers = settings.getHeaders(); if (headers != null) { - for (String headerKey : headers.keys()) { - xmlHttpRequest.setRequestHeader(headerKey, headers.getStr(headerKey)); + for (String headerKey : headers.getFieldNames()) { + xmlHttpRequest.setRequestHeader(headerKey, String.valueOf(headers.get(headerKey))); } } -- - if (data != null && !"GET".equalsIgnoreCase(httpMethod)) { - String ctype = settings.getContentType(); - if (data instanceof JavaScriptObject && JsUtils.isFormData((JavaScriptObject)data)) { - ctype = FormPanel.ENCODING_MULTIPART;; - } else if (ctype == null) { - String type = settings.getDataType(); - if (type != null && type.toLowerCase().startsWith("json")) { - ctype = "application/json; charset=utf-8"; - } else { - ctype = FormPanel.ENCODING_URLENCODED; - } - } ++ + if (data != null && !isFormData && !"GET".equalsIgnoreCase(httpMethod)) { xmlHttpRequest.setRequestHeader("Content-Type", ctype); } // Using gQuery to set credentials since this method was added in 2.5.1 // xmlHttpRequest.setWithCredentials(true); JsUtils.prop(xmlHttpRequest, "withCredentials", true); -- ++ final Request request = createRequestVltr(xmlHttpRequest, settings.getTimeout(), this); -- ++ xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() { public void onReadyStateChange(XMLHttpRequest xhr) { if (xhr.getReadyState() == XMLHttpRequest.DONE) { @@@ -153,14 -159,14 +153,14 @@@ dfd.resolve(response, request); } } -- ++ /** * Using violator pattern to execute private method */ private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb) /*-{ rq.@com.google.gwt.http.client.Request::fireOnResponseReceived(Lcom/google/gwt/http/client/RequestCallback;)(cb); }-*/; -- ++ /** * Using violator pattern to use protected constructor */