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

📄 resizablecontrolbehavior.js

📁 AJAX 应用 实现页面的无刷新
💻 JS
📖 第 1 页 / 共 2 页
字号:
        // Raise the resizing event
        this.raiseResizing();
    },

    _rememberSize : function() {
        /// <summary>
        /// Save the size in ClientState
        /// </summary>
        var size = this.get_Size();
        AjaxControlToolkit.ResizableControlBehavior.callBaseMethod(this, 'set_ClientState', [ size.width+','+size.height ]);
        // Raise the resize event
        this.raiseResize();
    },

    _measurementToNumber : function(m) {
        /// <summary>
        /// Get the magnitude of a measurement
        /// </summary>
        /// <param name="m" type="String">
        /// Measurement
        /// </param>
        /// <returns type="String">
        /// Magnitude of a measurement
        /// </returns>
        return m.replace('px', '');
    },

    get_HandleCssClass : function() {
        /// <value type="String">
        /// The name of the CSS class to apply to the resize handle
        /// </value>
        return this._HandleCssClass;
    },
    set_HandleCssClass : function(value) {
        if (this._HandleCssClass) {
            throw String.format(AjaxControlToolkit.Resources.ResizableControlBehavior_CannotChangeProperty, 'HandleCssClass');
        }
        this._HandleCssClass = value;
        this.raisePropertyChanged('HandleCssClass');
    },

    get_ResizableCssClass : function() {
        /// <value type="String">
        /// name of the CSS class to apply to the element when resizing
        /// </value>
        return this._ResizableCssClass;
    },
    set_ResizableCssClass : function(value) {
        if (this._ResizableCssClass) {
            throw String.format(AjaxControlToolkit.Resources.ResizableControlBehavior_CannotChangeProperty, 'ResizableCssClass');
        }
        this._ResizableCssClass = value;
        this.raisePropertyChanged('ResizableCssClass');
    },

    get_HandleOffsetX : function() {
        /// <value type="Number" integer="true">
        /// Horizontal offset to apply to the location of the resize handle
        /// </value>
        return this._HandleOffsetX;
    },
    set_HandleOffsetX : function(value) {
        if (this._HandleOffsetX != value) {
            this._HandleOffsetX = value;
            this.raisePropertyChanged('HandleOffsetX');
        }
    },

    get_HandleOffsetY : function() {
        /// <value type="Number" integer="true">
        /// Vertical offset to apply to the location of the resize handle
        /// </value>
        return this._HandleOffsetY;
    },
    set_HandleOffsetY : function(value) {
        if (this._HandleOffsetY != value) {
            this._HandleOffsetY = value;
            this.raisePropertyChanged('HandleOffsetY');
        }
    },

    get_MinimumWidth : function() {
        /// <value type="Number" integer="true">
        /// Minimum width of the resizable element
        /// </value>
        return this._MinimumWidth;
    },
    set_MinimumWidth : function(value) {
        if (this._MinimumWidth != value) {
            this._MinimumWidth = value;
            this.raisePropertyChanged('MinimumWidth');
        }
    },

    get_MinimumHeight : function() {
        /// <value type="Number" integer="true">
        /// Minimum height of the resizable element
        /// </value>
        return this._MinimumHeight;
    },
    set_MinimumHeight : function(value) {
        if (this._MinimumHeight != value) {
            this._MinimumHeight = value;
            this.raisePropertyChanged('MinimumHeight');
        }
    },

    get_MaximumWidth : function() {
        /// <value type="Number" integer="true">
        /// Maximum width of the resizing element
        /// </value>
        return this._MaximumWidth;
    },
    set_MaximumWidth : function(value) {
        if (this._MaximumWidth != value) { 
            this._MaximumWidth = value;
            this.raisePropertyChanged('MaximumWidth');
        }
    },

    get_MaximumHeight : function() {
        /// <value type="Number" integer="true">
        /// Maximum height of the resizing element
        /// </value>
        return this._MaximumHeight;
    },
    set_MaximumHeight : function(value) {
        if (this._MaximumHeight != value) {
            this._MaximumHeight = value;
            this.raisePropertyChanged('MaximumHeight');
        }
    },

    add_resizing : function(handler) {
        /// <summary>
        /// Add a handler to the resizing event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().addHandler("resizing", handler);
    },
    remove_resizing : function(handler) {
        /// <summary>
        /// Remove a handler from the resizing event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().removeHandler("resizing", handler);
    },
    raiseResizing : function() {
        /// <summary>
        /// Raise the resizing event
        /// </summary>
        var onResizingHandler = this.get_events().getHandler("resizing");
        if (onResizingHandler) {
            onResizingHandler(this, Sys.EventArgs.Empty);
        }
    },

    get_resizing : function() {
        /// <value type="Object">
        /// Function to invoke on resizing (can a Function, name of a Function, or expression that evaluates to a Function)
        /// </value>
        return this.get_events().getHandler("resizing");
    },
    set_resizing : function(value) {
        if (value && (0 < value.length)) {
            var func = $common.resolveFunction(value);
            if (func) { 
                this.add_resizing(func);
            } else {
                throw Error.argumentType('value', typeof(value), 'Function', String.format(AjaxControlToolkit.Resources.ResizableControlBehavior_InvalidHandler, 'resizing'));
            }
        }
    },

    add_resize : function(handler) {
        /// <summary>
        /// Add a handler to the resize event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().addHandler("resize", handler);
    },
    remove_resize : function(handler) {
        /// <summary>
        /// Remove a handler from the resize event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().removeHandler("resize", handler);
    },
    raiseResize : function() {
        /// <summary>
        /// Raise the resize event
        /// </summary>
        var onResizeHandler = this.get_events().getHandler("resize");
        if (onResizeHandler) {
            onResizeHandler(this, Sys.EventArgs.Empty);
        }
    },

    get_resize : function() {
        /// <value type="Object">
        /// Function to invoke on resize (can be a Function, name of a Function, or expression that evaluates to a Function)
        /// </value>
        return this.get_events().getHandler("resize");
    },
    set_resize : function(value) {
        if (value && (0 < value.length)) {
            var func = $common.resolveFunction(value);
            if (func) { 
                this.add_resize(func);
            } else {
                throw Error.argumentType('value', typeof(value), 'Function', String.format(AjaxControlToolkit.Resources.ResizableControlBehavior_InvalidHandler, 'resize'));
            }
        }
    },

    add_resizebegin : function(handler) {
        /// <summary>
        /// Add a handler to the resizebegin event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().addHandler("resizebegin", handler);
    },
    remove_resizebegin : function(handler) {
        /// <summary>
        /// Remove a handler from the resizebegin event
        /// </summary>
        /// <param name="handler" type="Function">
        /// Handler
        /// </param>
        this.get_events().removeHandler("resizebegin", handler);
    },
    raiseResizeBegin : function() {
        /// <summary>
        /// Raise the resizebegin event
        /// </summary>
        var onresizebeginHandler = this.get_events().getHandler("resizebegin");
        if (onresizebeginHandler) {
            onresizebeginHandler(this, Sys.EventArgs.Empty);
        }
    },

    get_resizebegin : function() {
        /// <value type="Object">
        /// Function to invoke on resizebegin (can be a Function, name of a Function, or expression that evaluates to a Function)
        /// </value>
        return this.get_events().getHandler("resizebegin");
    },
    set_resizebegin : function(value) {
        if (value && (0 < value.length)) {
            var func = $common.resolveFunction(value);
            if (func) { 
                this.add_resizebegin(func);
            } else {
                throw Error.argumentType('value', typeof(value), 'Function', String.format(AjaxControlToolkit.Resources.ResizableControlBehavior_InvalidHandler, 'resizebegin'));
            }
        }
    },

    get_Size : function() {
        /// <value type="Object">
        /// Size of the target (of the form {width, height})
        /// </value>
        return { width: this._measurementToNumber($common.getCurrentStyle(this._lining, 'width')),
            height: this._measurementToNumber($common.getCurrentStyle(this._lining, 'height'))};
    },
    set_Size : function(value) {
        var deltaX = value.width-this._measurementToNumber($common.getCurrentStyle(this._lining, 'width'));
        var deltaY = value.height-this._measurementToNumber($common.getCurrentStyle(this._lining, 'height'));
        this._resizeControl(0, 0, deltaX, deltaY);
        this._rememberSize();
        this.raisePropertyChanged('Size');
    }
}
AjaxControlToolkit.ResizableControlBehavior.registerClass('AjaxControlToolkit.ResizableControlBehavior', AjaxControlToolkit.BehaviorBase);
//    getDescriptor : function() {
//        var td = AjaxControlToolkit.ResizableControlBehavior.callBaseMethod(this, 'getDescriptor');
//        td.addProperty('HandleCssClass', String);
//        td.addProperty('ResizableCssClass', String);
//        td.addProperty('HandleOffsetX', Number);
//        td.addProperty('HandleOffsetY', Number);
//        td.addProperty('MinimumWidth', Number);
//        td.addProperty('MinimumHeight', Number);
//        td.addProperty('MaximumWidth', Number);
//        td.addProperty('MaximumHeight', Number);
//        td.addProperty('Size', Object);
//        td.addEvent('onresize');
//        td.addEvent('onresizing');
//        return td;
//    },

⌨️ 快捷键说明

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