• 2013-06-04

    JavaScript 类/函数继承最佳实践

    Views: 28076 | No Comments

    JavaScript 没有像 Java 等面向对象语言的 class 关键字用法, 和 class 最像的就是 function 了. 下面的代码相当于在 JavaScript 中定义了一个类:

    function Base(arg){
        var self = this;
        self.base = 1;
        self.name = 'base';
    }
    

    如果想新定义一个类 Child 继承 Base, 怎么办? JavaScript 又没有 extends. 这时, 就要利用到 prototype 了.
    Continue reading »

    Posted by ideawu at 2013-06-04 11:05:14 Tags: ,
  • 2012-11-27

    tableview的SortView有更新

    Views: 17778 | No Comments
    • 给SortView的排序按钮加上箭头, 且仅当鼠标点击箭头时才排序.
    • 修复了浮点数排序的BUG.

    Demo: http://www.ideawu.net/person/tableview/v1.1/SortView.php

    Posted by ideawu at 2012-11-27 12:36:45 Tags:
  • 2011-08-04

    强大的纯JS数据图工具-flot

    Views: 43277 | 3 Comments

    发现一个在网页中绘制数据图, 如曲线图, 柱状图的纯 JavaScript 工具: flot. 极度推荐啊! 有图和代码为证:

    *代码附后*

    以前知道的工具有 Open Flash Chart, 还有 Google 出品的 Google Chart Tool. 两者使用不同的技术, 同时也是两种截然不同的设计理念. 相比较而言, 我更认同 Google Chart 的设计理念. 原因如下:

    Continue reading »

    Posted by ideawu at 2011-08-04 01:03:09 Tags: , ,
  • 2011-07-03

    获取动态加载的图片大小的正确方法

    Views: 32298 | 2 Comments

    有一些很容易出错的获取动态加载的图片的尺寸的方法, 之所以出错, 主要原因是:

    • 你在代码在图片从网页上下载完毕之前就调用了, 这种情况在本机开发时不太容易发现.
    • jQuery load()事件处理的BUG, 当图片是从浏览器缓存取得时, 获取的是错误的尺寸.

    错误的代码是:

    Continue reading »

    Posted by ideawu at 2011-07-03 22:32:43 Tags: ,
  • 2011-05-27

    jQuery延时绑定事件(lazy-bind)

    Views: 30722 | No Comments

    有个延时绑定事件的需求, 如等待鼠标停留在某图片上面一段时间之后才展示浮动层, 以避免鼠标滑过屏幕时一片乱闪. 一时找不到合适的插件, 所以自己写了个.

    // 定义
    (function($){
        $.fn.lazybind = function(event, fn, timeout, abort){
            var timer = null;
            $(this).bind(event, function(){
                timer = setTimeout(fn, timeout);
            });
            if(abort == undefined){
                return;
            }
            $(this).bind(abort, function(){
                if(timer != null){
                    clearTimeout(timer);
                }
            });
        };
    })(jQuery);
    
    // 使用
    $('#my_img').lazybind(
        'mouseover',
        function(){
            alert(1);
        },
        240,
        'mouseout');
    
    Posted by ideawu at 2011-05-27 16:27:05 Tags: ,
  • 2010-10-23

    tableview新增单选功能

    Views: 22471 | 1 Comment

    根据用户反馈的功能需求, tableview 现新增了单选功能, 用于限制只能选择最多一行记录.

    tableview 是一组功能丰富, 接口易学易用的 javascript 控件, 包括数据表格控件, 排序控件, 分页控件, 双栏选择控件. 下载及文档: http://www.ideawu.net/person/tableview/

    Posted by ideawu at 2010-10-23 16:49:24 Tags:
|<<<123>>>| 1/3 Pages, 16 Results.