Пример #1
0
 ViewUtil.prototype.setProperty = function (view, attributeName, value, namespace) {
     if (!view || (namespace && !this.runsIn(namespace))) {
         return;
     }
     if (attributeName.indexOf(".") !== -1) {
         // Handle nested properties
         var properties = attributeName.split(".");
         attributeName = properties[properties.length - 1];
         var propMap = this.getProperties(view);
         var i = 0;
         while (i < properties.length - 1 && types_1.isDefined(view)) {
             var prop = properties[i];
             if (propMap.has(prop)) {
                 prop = propMap.get(prop);
             }
             view = view[prop];
             propMap = this.getProperties(view);
             i++;
         }
     }
     if (types_1.isDefined(view)) {
         this.setPropertyInternal(view, attributeName, value);
     }
 };
Пример #2
0
 SVGImage.prototype._createImageSourceFromSrc = function () {
     var _this = this;
     var value = this.src;
     if (types.isString(value)) {
         value = value.trim();
         this.imageSource = null;
         this["_url"] = value;
         this.isLoading = true;
         var source = new definition.ImageSourceSVG();
         var imageLoaded = function () {
             var currentValue = _this.src;
             if (!types.isString(_this.src) || value !== currentValue.trim()) {
                 return;
             }
             _this.imageSource = source;
             _this.isLoading = false;
         };
         if (utils.isDataURI(value)) {
             var base64Data = value.split(",")[1];
             if (types.isDefined(base64Data)) {
                 if (this.loadMode === SYNC) {
                     source.loadFromBase64(base64Data);
                     imageLoaded();
                 }
                 else if (this.loadMode === ASYNC) {
                     source.fromBase64(base64Data).then(imageLoaded);
                 }
             }
         }
         else if (definition.isFileOrResourcePath(value)) {
             if (value.indexOf(utils.RESOURCE_PREFIX) === 0) {
                 var resPath = value.substr(utils.RESOURCE_PREFIX.length);
                 if (this.loadMode === SYNC) {
                     source.loadFromResource(resPath);
                     imageLoaded();
                 }
                 else if (this.loadMode === ASYNC) {
                     this.imageSource = null;
                     source.fromResource(resPath).then(imageLoaded);
                 }
             }
             else {
                 if (this.loadMode === SYNC) {
                     source.loadFromFile(value);
                     imageLoaded();
                 }
                 else if (this.loadMode === ASYNC) {
                     this.imageSource = null;
                     source.fromFile(value).then(imageLoaded);
                 }
             }
         }
         else {
             this.imageSource = null;
             definition.fromUrl(value).then(function (r) {
                 if (_this["_url"] === value) {
                     _this.imageSource = r;
                     _this.isLoading = false;
                 }
             });
         }
     }
     else if (value instanceof definition.ImageSourceSVG) {
         this.imageSource = value;
         this.isLoading = false;
     }
     else {
         this.imageSource = definition.fromNativeSource(value);
         this.isLoading = false;
     }
 };