⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atlas.js

📁 《圣殿祭司的ASP.NET 2.0开发详解——使用C#》光盘内容.包含了书籍所含的源代码.非常经典的一本asp.net2.0的书籍
💻 JS
📖 第 1 页 / 共 5 页
字号:
        var pageUnloadHandler = Function.parse('pageUnload');
        if (typeof(pageUnloadHandler) == 'function') {
            pageUnloadHandler();
        }
        
        if (_disposableObjects) {
            _unloading = true;
            var count = _disposableObjects.length;
            for (var i = 0; i < count; i++) {
                _disposableObjects[i].dispose();
            }
            _disposableObjects.clear();
            _disposableObjects = null;
        }
        
        if (_markupContext) {
            _markupContext.dispose();
            _markupContext = null;
        }
        
        Web.TypeDescriptor.unload();
    }

    this._update = function(scriptDocumentNode) {
        var scriptDocumentItemNodes = scriptDocumentNode.childNodes;
        var referencesNode;
        var node;
        
        for (var i = scriptDocumentItemNodes.length - 1; i >= 0; i--) {
            node = scriptDocumentItemNodes[i];
            if (node.nodeType != 1) {
                continue;
            }
            
            if (node.baseName == 'components') {
                if (!_markupContext) {
                    _markupContext = new Web.TypeDescriptor.MarkupContext(document,  true);
                }
                else {
                    _markupContext._reopen();
                }
                Web.TypeDescriptor.processMarkupNodes(node.childNodes, _markupContext);
                _markupContext.complete();
                
                break;
            }
        }
    }
}

Type.registerSealedClass('Web._Application', null, Web.IDisposable, Web.ITypeDescriptorProvider, Web.ICustomTypeDescriptor);
Web.TypeDescriptor.addType('script', 'application', Web._Application);

Web._Application.parseFromMarkup = function(type, node, markupContext) {
    if (!markupContext.get_isGlobal()) {
        return null;
    }
    
    Web.TypeDescriptor.initializeInstance(Web.Application, node, markupContext);
    return Web.Application;
}

Web.Application = new Web._Application();
Web.INotifyPropertyChanged = function() {
    this.propertyChanged = null;
}
Type.registerInterface('Web.INotifyPropertyChanged');

Web.INotifyCollectionChanged = function() {
    this.collectionChanged = null;
}
Type.registerInterface('Web.INotifyCollectionChanged');

Web.PropertyChangedEventArgs = function(propertyName) {
    Web.PropertyChangedEventArgs.initializeBase(this);
    var _propertyName = propertyName;
    
    this.get_propertyName = function() {
        return _propertyName;
    }

    this.getDescriptor = function() {
        var td = Web.PropertyChangedEventArgs.callBaseMethod(this, 'getDescriptor');
        
        td.addProperty('propertyName', String, true);
        return td;
    }
}
Type.registerSealedClass('Web.PropertyChangedEventArgs', Web.EventArgs);

Web.NotifyCollectionChangedAction = Web.Enum.create('Add', 'Remove', 'Reset');

Web.CollectionChangedEventArgs = function(action, changedItem) {
    Web.CollectionChangedEventArgs.initializeBase(this);
    
    var _action = action;
    var _changedItem = changedItem;
    
    this.get_action = function() {
        return _action;
    }
    
    this.get_changedItem = function() {
        return _changedItem;
    }

    this.getDescriptor = function() {
        var td = Web.CollectionChangedEventArgs.callBaseMethod(this, 'getDescriptor');
        
        td.addProperty('action', Web.NotifyCollectionChangedAction, true);
        td.addProperty('changedItem', Object, true);
        return td;
    }
}
Type.registerSealedClass('Web.CollectionChangedEventArgs', Web.EventArgs);

Web.BindingDirection = Web.Enum.create('In', 'Out', 'InOut');

Web.BindingEventArgs = function(value, direction, targetPropertyType, transformerArgument) {
    Web.BindingEventArgs.initializeBase(this);
    
    var _value = value;
    var _direction = direction;
    var _targetPropertyType = targetPropertyType;
    var _transformerArgument = transformerArgument;
    
    this.get_direction = function() {
        return _direction;
    }
    
    this.get_targetPropertyType = function() {
        return _targetPropertyType;
    }
    
    this.get_transformerArgument = function() {
        return _transformerArgument;
    }
    
    this.get_value = function() {
        return _value;
    }
    this.set_value = function(value) {
        _value = value;
    }
    
    this.getDescriptor = function() {
        var td = Web.BindingEventArgs.callBaseMethod(this, 'getDescriptor');
        
        td.addProperty('direction', Web.BindingDirection, true);
        td.addProperty('targetPropertyType', Object, true);
        td.addProperty('transformerArgument', Object, true);
        td.addProperty('value', Object);
        return td;
    }
    Web.BindingEventArgs.registerBaseMethod(this, 'getDescriptor');
}
Type.registerSealedClass('Web.BindingEventArgs', Web.CancelEventArgs);

Web.Binding = function() {
    Web.Binding.initializeBase(this);
    var _id;

    var _component;
    var _componentNotificationHandler;
    
    var _dataContext;
    var _dataContextInUse;
    var _dataContextNotificationHandler;
    
    var _dataPath;
    var _dataPathParts;
    var _direction = Web.BindingDirection.In;
    var _property;
    var _propertyKey;
    var _automatic = true;
    var _transformerArgument = null;
    
    this.get_automatic = function() {
        return _automatic;
    }
    this.set_automatic = function(value) {
        if (!_dataContextInUse) {
            _automatic = value;
        }
    }
    
    this.get_dataContext = function() {
        return _dataContext;
    }
    this.set_dataContext = function(value) {
        if (!_dataContextInUse) {
            _dataContext = value;
        }
    }
    
    this.get_dataPath = function() {
        return _dataPath;
    }
    this.set_dataPath = function(value) {
        if (!_dataContextInUse) {
            _dataPath = value;
        }
    }

    this.get_direction = function() {
        return _direction;
    }
    this.set_direction = function(value) {
        if (!_dataContextInUse) {
            _direction = value;
        }
    }
    
    this.get_id = function() {
        return _id;
    }
    this.set_id = function(value) {
        _id = value;
    }
    
    this.get_property = function() {
        return _property;
    }
    this.set_property = function(value) {
        if (!_dataContextInUse) {
            _property = value;
        }
    }
    
    this.get_propertyKey = function() {
        return _propertyKey;
    }
    this.set_propertyKey = function(value) {
        if (!_dataContextInUse) {
            _propertyKey = value;
        }
    }
    
    this.get_transformerArgument = function() {
        return _transformerArgument;
    }
    this.set_transformerArgument = function(value) {
        _transformerArgument = value;
    }
    
    this.transform = new Web.Event(null);

    this.dispose = function() {
        this.transform.dispose();
        
        if (_componentNotificationHandler) {
            _component.propertyChanged.remove(_componentNotificationHandler);
            _componentNotificationHandler = null;
        }
        
        if (_dataContextNotificationHandler) {
            if (Web.INotifyPropertyChanged.isImplementedBy(_dataContextInUse)) {
                _dataContextInUse.propertyChanged.remove(_dataContextNotificationHandler);
            }
            _dataContextNotificationHandler = null;
        }
        _dataContextInUse = null;
        _dataContext = null;
        
        _component = null;
    }
    
    this.evaluate = function(direction) {
        if (direction == Web.BindingDirection.In) {
            this.evaluateIn();
        }
        else {
            this.evaluateOut();
        }
    }
    
    this.evaluateDataPath = function() {
        var object = _dataContextInUse;
        for (var i = 0; i < _dataPathParts.length - 1; i++) {
            object = Web.TypeDescriptor.getProperty(object, _dataPathParts[i]);
            if (!object) {
                return null;
            }
        }
        return object;
    }
    
    this.evaluateIn = function() {
        if (!_dataContextInUse) {
                        return;
        }
        if ((_direction == Web.BindingDirection.In) ||
            (_direction == Web.BindingDirection.InOut)) {
            var propertyObject = _dataContextInUse;
            var propertyName = _dataPath;
            
            if (_dataPathParts) {
                propertyObject = this.evaluateDataPath();
                if (propertyObject == null) {
                    return;
                }
                propertyName = _dataPathParts[_dataPathParts.length - 1];
            }

            var value = Web.TypeDescriptor.getProperty(propertyObject, propertyName);
            
            var canceled = false;
            if (this.transform.isActive()) {
                var targetPropertyType = Web.TypeDescriptor.getPropertyType(_component, _property, _propertyKey);
                var be = new Web.BindingEventArgs(value, Web.BindingDirection.In, targetPropertyType, _transformerArgument);
                
                this.transform.invoke(this, be);
                canceled = be.get_canceled();
                value = be.get_value();
            }
            
            if (!canceled) {
                Web.TypeDescriptor.setProperty(_component, _property, value, _propertyKey);
            }
        }
    }
    
    this.evaluateOut = function() {
        if (!_dataContextInUse) {
                        return;
        }
        if ((_direction == Web.BindingDirection.InOut) ||
            (_direction == Web.BindingDirection.Out)) {
            var value = Web.TypeDescriptor.getProperty(_component, _property, _propertyKey);
            var canceled = false;

            var propertyObject = _dataContextInUse;
            var propertyName = _dataPath;
            if (_dataPathParts) {
                propertyObject = this.evaluateDataPath();
                propertyName = _dataPathParts[_dataPathParts.length - 1];
            }
            
            if (this.transform.isActive()) {
                var targetPropertyType = Web.TypeDescriptor.getPropertyType(propertyObject, propertyName);
                var be = new Web.BindingEventArgs(value, Web.BindingDirection.Out, targetPropertyType, _transformerArgument);
            
                this.transform.invoke(this, be);
                canceled = be.get_canceled();
                value = be.get_value();
            }
            
            if (!canceled) {
                Web.TypeDescriptor.setProperty(propertyObject, propertyName, value);
            }
        }
    }
    
    this.getDescriptor = function() {
        var td = new Web.TypeDescriptor();
        
        td.addProperty('automatic', Boolean);
        td.addProperty('dataContext', Object);
        td.addProperty('dataPath', String);
        td.addProperty('direction', Web.BindingDirection);
        td.addProperty('id', String);
        td.addProperty('property', String);
        td.addProperty('propertyKey', String);
        td.addProperty('transformerArgument', String);
        td.addEvent('transform', false);
        td.addMethod('evaluateIn');
        td.addMethod('evaluateOut');
        
        return td;
    }

    this.initialize = function(component) {
        _component = component;
        
        _dataContextInUse = _dataContext;
        if (!_dataContextInUse) {
            _dataContextInUse = _component.get_dataContext();
        }
        
        if (_dataPath && _dataPath.indexOf('.') > 0) {
            _dataPathParts = _dataPath.split('.');
        }
        
        if (_automatic) {
            if (Web.INotifyPropertyChanged.isImplementedBy(_component)) {
                _componentNotificationHandler = Function.createDelegate(this, this._onComponentPropertyChanged);
                _component.propertyChanged.add(_componentNotificationHandler);
            }
            
            if (_dataContextInUse && Web.INotifyPropertyChanged.isImplementedBy(_dataContextInUse)) {
                _dataContextNotificationHandler = Function.createDelegate(this, this._onDataContextPropertyChanged);
                _dataContextInUse.propertyChanged.add(_dataContextNotificationHandler);
            }
            this.evaluate(Web.BindingDirection.In);
        }
    }
    
    this._onComponentPropertyChanged = function(sender, eventArgs) {
        var propertyName = eventArgs.get_propertyName();
        if (!propertyName || (propertyName == _property)) {
            this.evaluate(Web.BindingDirection.Out);
        }
    }

    this._onDataContextPropertyChanged = function(sender, eventArgs) {
        var compareProperty = _dataPath;
        if (_dataPathParts) {
            compareProperty = _dataPathParts[0];
        }
        
        var propertyName = eventArgs.get_propertyName();
        if (!propertyName || (propertyName == compareProperty)) {
            this.evaluate(Web.BindingDirection.In);
        }
    }
}
Type.registerSealedClass('Web.Binding', null, Web.IDisposable, Web.ITypeDescriptorProvider);
Web.TypeDescriptor.addType('script', 'binding', Web.Binding);

We

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -