var Defer = function () { this.promise = new Promise(); }; Defer.prototype = { promise: null, resolve: function (data) { this.promise.okCallbacks.forEach(function(callback) { window.setTimeout(function () { callback(data) }, 0); }); }, reject: function (error) { this.promise.koCallbacks.forEach(function(callback) { window.setTimeout(function () { callback(error) }, 0); }); } };
var result; // IE method if (window.ActiveXObject) { result = new ActiveXObject("MSXML2.DOMDocument"); xml.transformNodeToObject(xsl, result); // Other browsers } else { result = new XSLTProcessor(); result.importStylesheet(xsl); result = result.transformToDocument(xml); }
/** * Constructor. * @param window the parent scope * @param store the storage itself */ public Storage(final Window window, final Map<String, String> store) { store_ = store; setParentScope(window); setPrototype(window.getPrototype(Storage.class)); }
/** * Creates a popup window. * @see <a href="http://msdn.microsoft.com/en-us/library/ms536392.aspx">MSDN documentation</a> * @return the created popup */ public Popup jsxFunction_createPopup() { final Popup popup = new Popup(); popup.setParentScope(this); popup.setPrototype(getPrototype(Popup.class)); popup.init(this); return popup; }
/** * Allows the removal of event listeners on the event target. * @param type the event type to listen for (like "click") * @param listener the event listener * @param useCapture If <code>true</code>, indicates that the user wishes to initiate capture (not yet implemented) * @see <a href="http://developer.mozilla.org/en/docs/DOM:element.removeEventListener">Mozilla documentation</a> */ public void jsxFunction_removeEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().removeEventListener(type, listener, useCapture); }
private static Scriptable buildXSLTemplate() { final SimpleScriptable scriptable = new XSLTemplate(); addProperty(scriptable, "stylesheet", true, true); addFunction(scriptable, "createProcessor"); return scriptable; }
/** * Allows the removal of event listeners on the event target. * @param type the event type to listen for (like "load") * @param listener the event listener * @param useCapture If <code>true</code>, indicates that the user wishes to initiate capture (not yet implemented) * @see <a href="http://developer.mozilla.org/en/docs/DOM:element.removeEventListener">Mozilla documentation</a> */ public void jsxFunction_removeEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().removeEventListener(type, listener, useCapture); }
/** * Returns the onclick property (caution this is not necessary a function if something else has * been set). * @return the onclick property */ public Object jsxGet_onclick() { return getEventListenersContainer().getEventHandlerProp("click"); }
/** * Allows the registration of event listeners on the event target. * @param type the event type to listen for (like "onload") * @param listener the event listener * @param useCapture If <code>true</code>, indicates that the user wishes to initiate capture (not yet implemented) * @see <a href="http://developer.mozilla.org/en/docs/DOM:element.addEventListener">Mozilla documentation</a> */ public void jsxFunction_addEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().addEventListener(type, listener, useCapture); }
/** * {@inheritDoc} */ @Override public Object jsxGet_xml() { final Node node = jsxGet_firstChild(); if (node != null) { return node.jsxGet_xml(); } return ""; } }
/** * Allows the registration of event listeners on the event target. * @param type the event type to listen for (like "click") * @param listener the event listener * @param useCapture If <code>true</code>, indicates that the user wishes to initiate capture * @see <a href="http://developer.mozilla.org/en/docs/DOM:element.addEventListener">Mozilla documentation</a> */ public void jsxFunction_addEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().addEventListener(type, listener, useCapture); }
/** * Facility constructor. * @param window the owning window */ public Promise(final Window window) { setParentScope(window); setPrototype(window.getPrototype(Promise.class)); }
/** * Sets the start of the range to be after the node. * @param refNode the reference node */ public void jsxFunction_setStartAfter(final Node refNode) { startContainer_ = refNode.jsxGet_parentNode(); startOffset_ = getPositionInContainer(refNode) + 1; }
/** * Allows the removal of event listeners on the event target. * @param type the event type to listen for (like "click") * @param listener the event listener * @param useCapture If <code>true</code>, indicates that the user wishes to initiate capture (not yet implemented) * @see <a href="http://developer.mozilla.org/en/docs/DOM:element.removeEventListener">Mozilla documentation</a> */ public void jsxFunction_removeEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().removeEventListener(type, listener, useCapture); }
/** * {@inheritDoc} */ @Override public Object jsxGet_xml() { final Node node = jsxGet_firstChild(); if (node != null) { return node.jsxGet_xml(); } return ""; } }
new Promise(_, reject) { setTimeout(reject, 1000); });
var foo = new Promise() // no encapsulation, now anyone you pass this promise to can resolve it with whatever they want.
this.promise = new Promise(); };
this.p = new Promise();
componentWillMount() { setAsyncRouteLeaveHook(this.context.router, this.props.route, this.routerWillLeave) } ā routerWillLeave() { return new Promise((resolve, reject) => { if (!this.state.textValue) { // No unsaved changes -- leave resolve(true) } else { // Unsaved changes -- ask for confirmation vex.dialog.confirm({ message: 'There are unsaved changes. Leave anyway?' + nextLocation, callback: result => resolve(result) }) } }) }