仿微软Office迷你工具条(简易编辑器)

源自: http://www.jankoatwarpspeed.com/post/2010/05/23/microsoft-office-minibar-jQuery-CSS3.aspx

 

 

Why and how to create Microsoft Office Minibar with jQuery and CSS3

 

 

 

Although many will argue that Microsoft products are an example of a
good design, Minibar was one of design refreshments that came out with
the Office 2007. It is a variation of a toolbar that exposes context-related
functionality
.
In case of MS Word, context is a text selection. Since Minibar always
pops up near the mouse pointer it enables users to quickly perform
actions related to a selection.

 

Check out demo

 

 

So how it works  When user makes a selection in input field Minibar
pops up, semi-transparent, above the selection. When user hovers the
Minibar it fades out. It disappears when user clicks anywhere in the
input field or performs an action by clicking on a Minibar button.

Quite simple Minibar will be shown in this tutorial – it has only bold
, underline
, italic
, and link
buttons.

 

 

 

具体情况附件:

 

 

 

 

 

ZK客户端编程之Checkbox复选框的(全选/全不选)

on June 30, 2010, I have met a question In ZK client programming, 使用 ZK的方便之处就是基于注  解”@{}”,但所有的事物都是双刃剑,当我们使用注解实现AfterCompse接口 zk自动帮我们绑定后台的对象,但当我们对同一对象重用时,我们必须还需在后台把它的实例给销毁,然后重新绑定对象.这样的一来一回会减低我们的开发效率.
        所以使用ZK注解开发人员应该考虑相应系统的复杂性和重用性后酌情处理。
        下面的例子是在开发中动态生成Component组件    并使用客户端技术JQuery 实现功能
 
         1.后台Java类中动态生成Grid 容器组件的子组件 把在这些组件创建时绑定数据然后再返回给zul页面显示数据.
 

Java代码 

package com.linktel.linkFax.web.zk.controller;  
  
import java.awt.Checkbox;  
import java.util.Iterator;  
import java.util.List;  
  
  
import org.apache.commons.lang.StringUtils;  
import org.zkoss.zk.ui.Components;  
import org.zkoss.zk.ui.event.Event;  
import org.zkoss.zk.ui.event.EventListener;  
import org.zkoss.zk.ui.ext.AfterCompose;  
import org.zkoss.zkplus.databind.AnnotateDataBinder;  
import org.zkoss.zkplus.spring.SpringUtil;  
import org.zkoss.zul.Window;  
import org.zkoss.zul.api.Combobox;  
import org.zkoss.zul.api.Div;  
import org.zkoss.zul.api.Grid;  
import org.zkoss.zul.api.Label;  
import org.zkoss.zul.api.Row;  
import org.zkoss.zul.api.Rows;  
import com.linktel.linkFax.domain.Authority;  
import com.linktel.linkFax.domain.Role;  
import com.linktel.linkFax.service.AuthorityService;  
import com.linktel.linkFax.service.RoleService;  
import com.linktel.linkFax.web.zk.util.ZkUtils;  
  
  
public class AuthorityController extends Window implements AfterCompose {  
  
      
    private static final long serialVersionUID = 1L;  
  
    private Role role = new Role();  
    private Authority authority=new Authority();  
    private List<Authority>  authorities;  
    private List<Role> roles;  
  
    protected Grid gdAuthorities;  
    protected AnnotateDataBinder binder;  
    private Combobox cbxRole;  
  
  
    public Role getRole() {  
        return role;  
    }  
  
    public void setRole(Role role) {  
        this.role = role;  
    }  
  
      
  
    public Authority getAuthority() {  
        return authority;  
    }  
  
    public void setAuthority(Authority authority) {  
        this.authority = authority;  
    }  
  
      
    public List<Authority> getAuthorities() {  
        return authorities;  
    }  
  
    public void setAuthorities(List<Authority> authorities) {  
        this.authorities = authorities;  
    }  
  
    public List<Role> getRoles() {  
        return roles;  
    }  
  
    public void setRoles(List<Role> roles) {  
        this.roles = roles;  
    }  
  
    @Override  
    public void afterCompose() {  
        Components.wireVariables(this, this);  
        Components.addForwards(this, this);  
        init();  
    }  
  
    public void onCreate() {  
        binder = (AnnotateDataBinder) this.getAttribute("binder", true);  
    }  
      
  
    /* 
    *   页面加载实现afterComposer()方法初始化 
    *   动态创建Grid组件Rows中的Checkbox 组件并绑定数据 
    */  
    @SuppressWarnings("unchecked")  
    public void init() {  
        RoleService roleService = (RoleService) SpringUtil  
                .getBean("roleService");  
        roles = roleService.getRolesAll();  
  
        AuthorityService authService = (AuthorityService) SpringUtil  
                .getBean("authorityService");  
         authorities = authService.getAuthoritiesAll();  
        Rows rows=gdAuthorities.getRowsApi();  
        List<Row> rowList=rows.getChildren();  
        for(int i=0;i<authorities.size();i++){  
              Authority authority=  authorities.get(i);  
            Row row=new org.zkoss.zul.Row();  
            Div div=new org.zkoss.zul.Div();  
            org.zkoss.zul.api.Checkbox chk=new org.zkoss.zul.Checkbox();  
            Label lblId=new org.zkoss.zul.Label();  
            lblId.setValue(authority.getId().toString());  
            Label lblDisName=new org.zkoss.zul.Label();  
            lblDisName.setValue(authority.getDisplayName());  
            chk.setParent(div);  
            lblId.setParent(div);  
            div.setParent(row);  
            lblDisName.setParent(row);  
            rowList.add(row);  
        }  
    }  

    
 以上我们实现了,动态生成组件绑定数据,下面我们来实现Zul页面(全选)Checkbox 对动态生成组件的(全选/选不选)
          
Xml代码

< xml version="1.0" encoding="utf-8" >  
< page  id="authorityPage" >  
< xel-method prefix="c" name="hasPermission"   
class="com.linktel.linkFax.web.zk.util.AuthorityTools"   
signature="com.linktel.linkFax.web.zk.util.AuthorityTools  hasPermission(java.lang.String)" >  
< init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"  root="./authorityWin" >  
<window id="authorityWin"  
    use="com.linktel.linkFax.web.zk.controller.AuthorityController" width="100%"  
    xmlns:h="http://www.w3.org/1999/xhtml"  
    xmlns:n="http://www.zkoss.org/2005/zk/native" xmlns="http://www.zkoss.org/2005/zul"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"  
    xmlns:w="http://www.zkoss.org/2005/zk/client">  
          <grid id="gdAuthorities" mold="paging" paginal="@{pagingId}"  
                        fixedLayout="true">  
                        <columns>  
                            <column>  
                                <checkbox  w:onCheck="  
                                         var allCtrl = this;  
                                      jq('@checkbox',this.parent.parent.nextSibling).each(  
                                            function(i,chk){  
                                                var c =zk.Widget.$(chk);  
                                                if(allCtrl.isChecked()){  
                                                        c.setChecked(true);  
                                                }else{    
                                                        c.setChecked(false);  
                                                }  
                                        });"></checkbox>  
                            </column>  
                            <column></column>  
                        </columns>  
                        <rows>  
                        </rows>  
                    </grid>  
</window>  

 

 

 

   首先我们客户端编程需要引入命名空间 xmlns:w=http://www.zkoss.org/2005/zk/client  

         ZK引擎是基于Jquery实现的, 我们使用zk给我们提供的JQuery类库   ZK中w:onCheck=”” 在用户选中一个复选按钮时触发一个oncheck客户端事件,jq(@window,this.parent.nextSibling).each(…);@window是checkbox组件类型,this.parent.nextSibling是找到当前组件的父组件的同级组件;each(…..)对嵌套的组件进行遍历,each(….)中定义匿名函数,function(i,chk){…} chk参数就是被迭代的子组件,zk5.0.2中checkbox其实不具有客户端checkbox的任何行(action)为,所以我们必须用zk.Widget.$(chk);转换成Widget客户端的组件这样它才真正具有了checkbox的行为(action).转换成widget的组件后我们就可以在客户端对checkbox进行

(全选/全部选).

 

以上的功能实现是在和同事(张学化)的讨论下完成的。

[转]BestjQueryPluginsof2012(2012年最佳jQuery插件)

原文地址:

http://webdesignledger.com/resources/best-jquery-plugins-of-2012

Arctext.js

Arctext.js is a jQuery plugin that let’s you do exactly that. Based on Lettering.js, it calculates the right rotation of each letter and distributes the letters equally across the imaginary arc of the given radius.

Jquery Transit

Super-smooth CSS3 transformations and transitions for jQuery — v0.1.3

SlabText

A jquery plugin for producing big, bold and responsive headlines.

stellar.js

Parallax has never been easier.

Get turn.js

Is a plugin for jQuery that adds a beautiful transition similar to real pages in a book or magazine for HTML5.

Flexslider 2.0

FlexSlider is an awesome, fully responsive jQuery slider plugin. It wasn’t released in 2012, but this year WooThemes purchased it and released the 2.0 version – making many improvements and taking it to another level. This is why it makes our 2012 list.

hammer.js

A javascript library for multi-touch gestures.

iPicture

iPicture is a jQuery Plugin to create interactive pictures with extra descriptions.

FF出现toomuchrecursion错误提示

 <script>
  function open()
  {
   window.open('update.jsp','修改','width=450px,height=250px,left=200px,status=no,menubar=no,toolbar=no,location=no,resizable=no,top=250px');
  }
  </script>	

运行这个JS在FF中会出现too much recursion错误,而在IE中会出现Stack Overflow错误,

困惑我不少时间,经过搜索得知:

原来JS的关键字不可以用来作为函数名的。

所以解决方法是:把open函数名改为其他不是关键字的就行了。

密码强度检测

function teststrength(password){
    var option = {
        'shortPass': '短',
        'badPass': '弱',
        'goodPass': '好',
        'strongPass': '强'
    };
    this.resultStyle = '';
    var score = 0;
    
    
    if (password.length < 4) {
        this.resultStyle = option.shortPass;
        return {
            'level': option.shortPass,
            'score': score
        };
    }
    
    score += password.length * 4;
    score += (checkRepetition(1, password).length - password.length) * 1;
    score += (checkRepetition(2, password).length - password.length) * 1;
    score += (checkRepetition(3, password).length - password.length) * 1;
    score += (checkRepetition(4, password).length - password.length) * 1;
    
    
    if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) {
        score += 5;
    }
    
    
    if (password.match(/(.*[!,@,#,$,%,^,&,*, ,_,~].*[!,@,#,$,%,^,&,*, ,_,~])/)) {
        score += 5;
    }
    
    
    if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
        score += 10;
    }
    
    
    if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) {
        score += 15;
    }
    
    if (password.match(/([!,@,#,$,%,^,&,*, ,_,~])/) && password.match(/([0-9])/)) {
        score += 15;
    }
    
    
    if (password.match(/([!,@,#,$,%,^,&,*, ,_,~])/) && password.match(/([a-zA-Z])/)) {
        score += 15;
    }
    
    
    if (password.match(/^\w+$/) || password.match(/^\d+$/)) {
        score -= 10;
    }
    if (score < 0) {
        score = 0;
    }
    if (score > 100) {
        score = 100;
    }
    
    if (score < 34) {
        this.resultStyle = option.badPass;
        return {
            'level': option.badPass,
            'score': score
        };
    }
    if (score < 68) {
        this.resultStyle = option.goodPass;
        return {
            'level': option.goodPass,
            'score': score
        };
    }
    
    this.resultStyle = option.strongPass;
    return {
        'level': option.strongPass,
        'score': score
    };
}

function checkRepetition(pLen, str){
    var res = "";
    for (var i = 0; i < str.length; i++) {
        var repeated = true;
        
        for (var j = 0; j < pLen && (j + i + pLen) < str.length; j++) {
            repeated = repeated && (str.charAt(j + i) == str.charAt(j + i + pLen));
        }
        if (j < pLen) {
            repeated = false;
        }
        if (repeated) {
            i += pLen - 1;
            repeated = false;
        }
        else {
            res += str.charAt(i);
            
        }
    }
    return res;
};

 抄自jquery password strength plugin

认识JQuery

学习JQuery要分辨出哪些是JQuery对象哪些是DOM对象。JQuery对象是通过JQuery包装DOM对象后产生的对象。JQuery对象是JQuery独有的。如果一个对象是JQuery对象,那么就可以使用JQuery的方法。在JQuery对象中无法使用DOM对象的任何方法。同样DOM对象也不能使用JQuery里的方法。

JQuery对象和DOM对象的相互转换。

JQuery对象->DOM对象

(1)通过[index]的方法得到相应的DOM对象

例:

var $cr = $(“#cr”); // JQuery对象

var cr = $cr[0]; // DOM对象

alert(cr.checked) // 检验checkbox是否被选中了

(2)通过get(index)方法得到相应的DOM对象

例:

var $cr = $(“#cr”); // JQuery对象

var cr = $cr.get(0); // DOM对象

alert(cr.checked) // 检验checkbox是否被选中了

DOM对象->JQuery对象

对于DOM对象只需要用$()把DOM对象包装起来,就可以获得一个JQuery对象了。方式为$(DOM对象)。

例:

var cr = document.getElementById(“cr”); // DOM对象

var $cr = $(cr); // JQuery对象

转换后可以任意使用JQuery中的方法。

注:$()函数就是一个JQuery对象的制造工厂。

table选项卡从A页面点击进入B页面指定版块

不知道,怎么搞的,昨天明天写上去的,发布成功的。早上找不到了,奇怪,差异。重新弄下吧。

jquery博客昨天又加班了,早8点去晚8点回来,赶项目没法子,细细算这个月除了清明时候休息2天,之外一直上班中。嗨……

稀里糊涂的想整个table选项卡从A页面点击进入B页面指定版块,不知道怎么描述就先这样叫吧。

两个页面间的传值,貌似暂时我用的少,不过得需要用了,先弄点例子上来,过两天用的时候看下,就一目了然了。

table切换和之前的一样,无非就增加了个取值传值的函数。

不多说了,看在线效果DEMO

注请猛击上面DEMO中的的几个分类  jquery jquery吧 前端开发 攻城狮

 

原文地址 jquery http://www.jqueryba.com/200.html