Example #1
0
 KeyEventsPlugin.parseEventName = function (eventName) {
     var parts = eventName.toLowerCase().split('.');
     var domEventName = parts.shift();
     if ((parts.length === 0) ||
         !(lang_1.StringWrapper.equals(domEventName, 'keydown') ||
             lang_1.StringWrapper.equals(domEventName, 'keyup'))) {
         return null;
     }
     var key = KeyEventsPlugin._normalizeKey(parts.pop());
     var fullKey = '';
     modifierKeys.forEach(function (modifierName) {
         if (collection_1.ListWrapper.contains(parts, modifierName)) {
             collection_1.ListWrapper.remove(parts, modifierName);
             fullKey += modifierName + '.';
         }
     });
     fullKey += key;
     if (parts.length != 0 || key.length === 0) {
         // returning null instead of throwing to let another plugin process the event
         return null;
     }
     var result = collection_1.StringMapWrapper.create();
     collection_1.StringMapWrapper.set(result, 'domEventName', domEventName);
     collection_1.StringMapWrapper.set(result, 'fullKey', fullKey);
     return result;
 };
Example #2
0
 createHtmlDocument() {
     var newDoc = treeAdapter.createDocument();
     newDoc.title = "fake title";
     var head = treeAdapter.createElement("head", null, []);
     var body = treeAdapter.createElement("body", 'http://www.w3.org/1999/xhtml', []);
     this.appendChild(newDoc, head);
     this.appendChild(newDoc, body);
     StringMapWrapper.set(newDoc, "head", head);
     StringMapWrapper.set(newDoc, "body", body);
     StringMapWrapper.set(newDoc, "_window", StringMapWrapper.create());
     return newDoc;
 }
function parsePathString(route) {
    // normalize route as not starting with a "/". Recognition will
    // also normalize.
    if (StringWrapper.startsWith(route, "/")) {
        route = StringWrapper.substring(route, 1);
    }
    var segments = splitBySlash(route);
    var results = [];
    var specificity = 0;
    // The "specificity" of a path is used to determine which route is used when multiple routes match
    // a URL.
    // Static segments (like "/foo") are the most specific, followed by dynamic segments (like
    // "/:id"). Star segments
    // add no specificity. Segments at the start of the path are more specific than proceeding ones.
    // The code below uses place values to combine the different types of segments into a single
    // integer that we can
    // sort later. Each static segment is worth hundreds of points of specificity (10000, 9900, ...,
    // 200), and each
    // dynamic segment is worth single points of specificity (100, 99, ... 2).
    if (segments.length > 98) {
        throw new BaseException(`'${route}' has more than the maximum supported number of segments.`);
    }
    var limit = segments.length - 1;
    for (var i = 0; i <= limit; i++) {
        var segment = segments[i], match;
        if (isPresent(match = RegExpWrapper.firstMatch(paramMatcher, segment))) {
            results.push(new DynamicSegment(match[1]));
            specificity += (100 - i);
        }
        else if (isPresent(match = RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
            results.push(new StarSegment(match[1]));
        }
        else if (segment == '...') {
            if (i < limit) {
                // TODO (matsko): setup a proper error here `
                throw new BaseException(`Unexpected "..." before the end of the path for "${route}".`);
            }
            results.push(new ContinuationSegment());
        }
        else {
            results.push(new StaticSegment(segment));
            specificity += 100 * (100 - i);
        }
    }
    var result = StringMapWrapper.create();
    StringMapWrapper.set(result, 'segments', results);
    StringMapWrapper.set(result, 'specificity', specificity);
    return result;
}
 function buildMap(values) {
     var res = StringMapWrapper.create();
     for (var i = 0; i < keys.length; ++i) {
         StringMapWrapper.set(res, keys[i], values[i]);
     }
     return res;
 }
Example #5
0
 get(name) {
     var cached = StringMapWrapper.get(this._config, name);
     if (isPresent(cached))
         return cached;
     var p = this.proto.get(name);
     var transform = this.injector.instantiateResolved(p);
     var res = new cd.SelectedPipe(transform, p.pure);
     if (p.pure) {
         StringMapWrapper.set(this._config, name, res);
     }
     return res;
 }
Example #6
0
 Pipes.prototype.get = function (name) {
     var cached = collection_1.StringMapWrapper.get(this._config, name);
     if (lang_1.isPresent(cached))
         return cached;
     var p = this.proto.get(name);
     var transform = this.injector.instantiateResolved(p);
     var res = new cd.SelectedPipe(transform, p.pure);
     if (p.pure) {
         collection_1.StringMapWrapper.set(this._config, name, res);
     }
     return res;
 };
Example #7
0
 on(el, evt, listener) {
     var listenersMap = el._eventListenersMap;
     if (isBlank(listenersMap)) {
         var listenersMap = StringMapWrapper.create();
         el._eventListenersMap = listenersMap;
     }
     var listeners = StringMapWrapper.get(listenersMap, evt);
     if (isBlank(listeners)) {
         listeners = [];
     }
     listeners.push(listener);
     StringMapWrapper.set(listenersMap, evt, listeners);
 }
Example #8
0
 /** @internal */
 _buildRules(parsedRules, css) {
     var rules = [];
     for (var i = 0; i < parsedRules.length; i++) {
         var parsedRule = parsedRules[i];
         var rule = StringMapWrapper.create();
         StringMapWrapper.set(rule, "cssText", css);
         StringMapWrapper.set(rule, "style", { content: "", cssText: "" });
         if (parsedRule.type == "rule") {
             StringMapWrapper.set(rule, "type", 1);
             StringMapWrapper.set(rule, "selectorText", parsedRule.selectors.join(", ")
                 .replace(/\s{2,}/g, " ")
                 .replace(/\s*~\s*/g, " ~ ")
                 .replace(/\s*\+\s*/g, " + ")
                 .replace(/\s*>\s*/g, " > ")
                 .replace(/\[(\w+)=(\w+)\]/g, '[$1="$2"]'));
             if (isBlank(parsedRule.declarations)) {
                 continue;
             }
             for (var j = 0; j < parsedRule.declarations.length; j++) {
                 var declaration = parsedRule.declarations[j];
                 StringMapWrapper.set(StringMapWrapper.get(rule, "style"), declaration.property, declaration.value);
                 StringMapWrapper.get(rule, "style").cssText +=
                     declaration.property + ": " + declaration.value + ";";
             }
         }
         else if (parsedRule.type == "media") {
             StringMapWrapper.set(rule, "type", 4);
             StringMapWrapper.set(rule, "media", { mediaText: parsedRule.media });
             if (parsedRule.rules) {
                 StringMapWrapper.set(rule, "cssRules", this._buildRules(parsedRule.rules));
             }
         }
         rules.push(rule);
     }
     return rules;
 }
Example #9
0
 EventDispatcher.prototype.dispatchRenderEvent = function (elementIndex, eventName, locals) {
     var e = locals.get('$event');
     var serializedEvent;
     // TODO (jteplitz602): support custom events #3350
     switch (e.type) {
         case "click":
         case "mouseup":
         case "mousedown":
         case "dblclick":
         case "contextmenu":
         case "mouseenter":
         case "mouseleave":
         case "mousemove":
         case "mouseout":
         case "mouseover":
         case "show":
             serializedEvent = event_serializer_1.serializeMouseEvent(e);
             break;
         case "keydown":
         case "keypress":
         case "keyup":
             serializedEvent = event_serializer_1.serializeKeyboardEvent(e);
             break;
         case "input":
         case "change":
         case "blur":
             serializedEvent = event_serializer_1.serializeEventWithTarget(e);
             break;
         case "abort":
         case "afterprint":
         case "beforeprint":
         case "cached":
         case "canplay":
         case "canplaythrough":
         case "chargingchange":
         case "chargingtimechange":
         case "close":
         case "dischargingtimechange":
         case "DOMContentLoaded":
         case "downloading":
         case "durationchange":
         case "emptied":
         case "ended":
         case "error":
         case "fullscreenchange":
         case "fullscreenerror":
         case "invalid":
         case "languagechange":
         case "levelfchange":
         case "loadeddata":
         case "loadedmetadata":
         case "obsolete":
         case "offline":
         case "online":
         case "open":
         case "orientatoinchange":
         case "pause":
         case "pointerlockchange":
         case "pointerlockerror":
         case "play":
         case "playing":
         case "ratechange":
         case "readystatechange":
         case "reset":
         case "seeked":
         case "seeking":
         case "stalled":
         case "submit":
         case "success":
         case "suspend":
         case "timeupdate":
         case "updateready":
         case "visibilitychange":
         case "volumechange":
         case "waiting":
             serializedEvent = event_serializer_1.serializeGenericEvent(e);
             break;
         default:
             throw new exceptions_1.BaseException(eventName + " not supported on WebWorkers");
     }
     var serializedLocals = collection_1.StringMapWrapper.create();
     collection_1.StringMapWrapper.set(serializedLocals, '$event', serializedEvent);
     async_1.ObservableWrapper.callNext(this._sink, {
         "viewRef": this._serializer.serialize(this._viewRef, api_1.RenderViewRef),
         "elementIndex": elementIndex,
         "eventName": eventName,
         "locals": serializedLocals
     });
     // TODO(kegluneq): Eventually, we want the user to indicate from the UI side whether the event
     // should be canceled, but for now just call `preventDefault` on the original DOM event.
     return false;
 };
Example #10
0
 ControlGroup.prototype.exclude = function (controlName) {
     collection_1.StringMapWrapper.set(this._optionals, controlName, false);
     this.updateValueAndValidity();
 };
Example #11
0
 exclude(controlName) {
     StringMapWrapper.set(this._optionals, controlName, false);
     this.updateValueAndValidity();
 }