标签:demo

浏览模式: 标准 | 列表 | 图文
jQuery EasyUI Demo 修正

jQuery EasyUI Demo 修正

对秀才的demo做了点简单的修正。
1、index.html中的
var _menus = { menu object };
改为
var _menus = [{xx}];
这样的好处是,如果json是生成而来的也不受影响

2、修改outlook.js
在 InitLeftMenu()方法 增加一个判断:
if( typeof _menus[0] != 'object'){
alert('左侧菜单加载失败,请检查菜单数据来源');
return ;
}
搜索 _menus,改为_menus[0]

--------------------------
理由,因为大多数时间菜单是用程序生成的。如果不用[]包住就可能会出现
var _menus = ;
function test(){}
这样,语法是错误的。用[]进行一下容错。
-------------------------
demo也不错,提供下载,但我在这个压缩包里没有进行修正【请需要的朋友自己修正吧】
作者:疯狂秀才
网站:http://hxling.cnblogs.com
Demo:4578cadd56e3069229953180fabc2c5b

JS的一些设计模式的演示

最近可能是快过年了吧,园子里的人写文章的激情开始迸发,什么样的文章都有了。这不,看到这些用JS写的设计模式,感觉还不错。转载一下看看。。。

Javascript乱弹设计模式系列(4) - 组合模式(Composite)
Javascript乱弹设计模式系列(3) - 装饰者模式(Decorator)
Javascript乱弹设计模式系列(2) - 抽象工厂以及工厂方法模式(Factory)

Javascript乱弹设计模式系列(1) - 观察者模式(Observer)
Javascript乱弹设计模式系列(0) - 面向对象基础以及接口和继承类的实现

估计以后还会有,先贴上,有的时候,我再加上

jQuery Plugins -- JQzoom

jQuery Plugins -- JQzoom

demo地址:http://www.51toria.cn/demo/JQplus/jqzoom/

使用的JS:

//**************************************************************
// jQZoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
//
// jqZoom version 1.0
// Author Doc. Ing. Renzi Marco(www.mind-projects.it)
// Released on Dec 05 2007
// i'm searching for a job,pick me up!!!
// mail: renzi.mrc@gmail.com
//**************************************************************

(function($){

$.fn.jqueryzoom = function(options){

var settings = {
xzoom: 200, //zoomed width default width
yzoom: 200, //zoomed div default width
offset: 10, //zoomed div default offset
position: "right" //zoomed div default position,offset position is to the right of the image
};

if(options) {
$.extend(settings, options);
}

$(this).hover(function(){


var imageLeft = $(this).get(0).offsetLeft;
var imageRight = $(this).get(0).offsetRight;
var imageTop = $(this).get(0).offsetTop;
var imageWidth = $(this).get(0).offsetWidth;
var imageHeight = $(this).get(0).offsetHeight;

var bigimage = $(this).attr("alt");

if($("div.zoomdiv").get().length == 0){

$(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>");

}

if(settings.position == "right"){

leftpos = imageLeft + imageWidth + settings.offset;

}else{

leftpos = imageLeft - settings.xzoom - settings.offset;

}

$("div.zoomdiv").css({ top: imageTop,left: leftpos });

$("div.zoomdiv").width(settings.xzoom);

$("div.zoomdiv").height(settings.yzoom);

$("div.zoomdiv").show();


$(document.body).mousemove(function(e){

var bigwidth = $(".bigimg").get(0).offsetWidth;

var bigheight = $(".bigimg").get(0).offsetHeight;

var scaley ='x';

var scalex= 'y';


if(isNaN(scalex)|isNaN(scaley)){

var scalex = Math.round(bigwidth/imageWidth) ;

var scaley = Math.round(bigheight/imageHeight);

}

mouse = new MouseEvent(e);



scrolly = mouse.y - imageTop - ($("div.zoomdiv").height()*1/scaley)/2 ;

$("div.zoomdiv").get(0).scrollTop = scrolly * scaley ;

scrollx = mouse.x - imageLeft - ($("div.zoomdiv").width()*1/scalex)/2 ;

$("div.zoomdiv").get(0).scrollLeft = (scrollx) * scalex ;


});
},function(){
$("div.zoomdiv").hide();
$(document.body).unbind("mousemove");
$(".lenszoom").remove();
$("div.zoomdiv").remove();
});

}

})(jQuery);

function MouseEvent(e) {
this.x = e.pageX
this.y = e.pageY
}

页面调用方法:

jQuery.noConflict();
jQuery(document).ready(function(){
$("img.jqzoom").jqueryzoom();
});