Monthly Archive for 十月, 2010

发布一个jQuery插件-Xslider – 令我着迷的jQuery(二)

算是自己写的第一个jQuery插件,js代码很早就写好了,但是因为一个css问题被困住了,直到今天才重新想起。

Xslider:基于jQuery的拉样片特效插件,也可以用作jQuery Tab选项卡,目前支持四种切换特效:X轴、Y轴、渐变和基本,这里是Demo
使用方法很简单:

$("#slider1").Xslider();

自定义选项:

$("#slider1").Xslider({
    affect: 'scrollx', //效果  有scrollx|scrolly|fade|none
    speed: 800, //动画速度
    space: 5000, //时间间隔
    auto: true, //自动滚动
    trigger: 'mouseover', //触发事件 注意用mouseover代替hover
    conbox: '.conbox', //内容容器id或class
    ctag: 'a', //内容标签 默认为a
    switcher: '.switcher', //切换触发器id或class
    stag: 'a', //切换器标签 默认为a
    current:'cur', //当前切换器样式名称
    prebtn: '.pre', //TODO 前一张按钮
    nextbtn:'.next', //TODO 下一张按钮
    recycle:true, //TODO 是否循环
    rand:false //TODO 是否随机指定首张幻灯图片
});

最后说一句,IE6很邪恶,但我爱它的盒子模型。

我常用的gVim配置和插件

这几天一直在Linux底下折腾,免不了怀着一颗装B的心,把gVim打造成一个“接近IDE的编辑器”,再怀着一颗媚俗的心,来这里写一篇《我常用的gVim配置和配置》。但本人确确实实是体会到了gVim的高效,尤其是在使用笔记本键盘的情况下,号称“让你的双手不离开打字区”,这真是个伟大的设计思路。

先上一张我的gVim截图:

怎么样,还行吧,自我感觉挺酷的:-)

下面是我的gVim配置,都写了注释的:

"gVim启动窗口位置 大小
winpos 173 162
set lines=25 columns=108 

"设定文件编码
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

syntax on

"配色风格
colorscheme desert

"文本缩进设置
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu

"如果没有下面这段就拷贝进来吧 虽然不知道干什么的
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif

"设定折叠方式
"set foldmethod=indent

"以下字符将被视为单词的一部分 (ASCII):
"set iskeyword+=33-47,58-64,91-96,123-128

"打开文件自动跳转到上次编辑的行
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

"Get out of VI's compatible mode..
set nocompatible

"Sets how many lines of history VIM har to remember
set history=400

"文件在外部被修改则自动保存
set autoread

" vim用户界面

"Turn on WiLd menu
set wildmenu

"Always show current position
set ruler

"The commandbar is 2 high
set cmdheight=2

"Show line number 显示行号
set nu

"Set backspace
set backspace=eol,start,indent

"Bbackspace and cursor keys wrap to
set whichwrap+=<,>,h,l

"show matching bracets
set showmatch

"How many tenths of a second to blink
set mat=2

filetype plugin on

"同样适用于jQuery的js语法高亮
au BufRead,BufNewFile *.js set syntax=jquery

map  :NERDTreeToggle

nmap   :TlistToggle
let Tlist_Use_Right_Window=1
set tags=tags;/

"对NERD_commenter的设置
let NERDShutUp=1
"支持单行和多行的选择,//格式
map  ,c

" phpDocumentor for VIM
inoremap  :call PhpDocSingle()
nnoremap  :call PhpDocSingle()
vnoremap  :call PhpDocRange()

"对.vimrc配置文件的修改立即生效
autocmd! bufwritepost _vimrc source %

然后是我使用的插件:
NERDTreeToggle :用于导航和打开文件,在上面截图的左边区域
TlistToggle :用于导航代码中的类、变量以及函数(方法)
OmniComplete :代码的自动补全,快捷键是Ctrl+x Ctrl+o,支持很多种语言
NERDCommenter :用于给代码加注释
phpDocumentor :用于给php类和函数加文档 按下alt+/时

非常Cool的滑块导航菜单-令我着迷的jQuery(一)

As is known to us,jQuery是一个短小精悍的javascript library。它以”Write less,do more”的宗旨,以及提供许多成熟的插件及实现,俘获了无数爱偷懒的Programmers的心。今天和大家分享我在项目中使用jQuery编写的一处页面特效,我姑且自顾自的把它称作滑块导航菜单,是一种类似LavaLamp的特效,菜单按钮的背景会有鼠标跟随、以及弹簧动画的特效,很有意思(ps:大家如果有更好的命名方式,荒淫指出,哈哈)。
全部源代码如下,此外Demo地址,荒淫指教:
javascript(除了jQuery,还使用了easing扩展):

$(function(){
	$('#nav_btn_bg').fadeIn(0.2);
	$('#nav_btn').mouseover(function(e){ //这里用到了比事件绑定更高级的事件委托机制
		if(e.target.id=='home') {
			var ml = -5;
		}else if(e.target.id=='sk') {
			var ml = 145;
		}else if(e.target.id=='lottery') {
			var ml = 290;
		}
		$('#nav_btn_bg').stop(true).animate({marginLeft:ml},{easing: 'easeOutBack'});
	});
	$('#nav_btn').mouseleave(function(){
		$('#nav_btn_bg').stop(true).animate({marginLeft:[290,'easeOutBounce'],duration: 800}); //jQuery1.4以后才能这么写
	});
});

HTML(How To Make Love):

CSS样式:

@charset "utf-8";
/* CSS Document */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,
form,fieldset,input,textarea,p,blockquote,th,td {
padding: 0;
margin: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset,img {
border: 0;
}
address,caption,cite,code,dfn,em,strong,th,var {
font-weight: normal;
font-style: normal;
}
ol,ul {
list-style: none;
}
caption,th {
text-align: left;
}
h1,h2,h3,h4,h5,h6 {
font-weight: normal;
font-size: 100%;
}
q:before,q:after {
content:”;
}
abbr,acronym { border: 0;
}
#header{
	width:100%;
	height:175px;
	background:url('head_bg.jpg') repeat-x;
}
#nav{
	width:960px;
	margin:0 auto;
	position:relative !important;
}
#logo{
	display:inline-block;
	width:325px;
	height:70px;
	margin-top:15px;
	float:left;
}
#nav_btn{
	height:60px;
	width:420px;
	float:left;
	margin-top:35px;
	margin-left:45px;
	background:url('nav_btn_bg_06.gif') no-repeat;
	position:relative;
}
#nav_bar{
	position:absolute;
	z-index:2;
}
#nav_btn a{
	display:inline-block;
	width:133px;
	height:55px;
}
#nav_btn_bg{
	width:120px;
	height:55px;
	background:#cccccc;
	-webkit-border-radius:5px;
	-moz-border-radius:5px;
	border-radius:5px;
	position:absolute;
	z-index:1;
	left:0px;
	top:2px;
	opacity:0.2;
	filter:alpha(opacity=20);
	margin-left:290px;
	display:none;
}

如何将删除的Ubuntu面板找回来

刚才因为淘气,把Ubuntu的上下面板都给删除鸟~

在网上搜索到了恢复面板到默认状态的方法如下

打开终端,终端窗口打开之后,立即在提示符后面输入下列命令:
gconftool –recursive-unset /apps/panel
(注意:每个斜杠 “/” 后面没有空格)
接下来输入下列命令:
rm -rf ~/.gconf/apps/panel

最后 重启Gnome,方法是:

Ctrl+Alt+F1登录到终端后

/etc/init.d/gdm restart