webstrom
1.extact 抽取函数:选中代码,右键,refactor-extact
 function matchPicLink() {
var $match = $('#match');
var mWidth = Math.floor($match.width());
var mWidthHalf = Math.floor(mWidth / 2);
$match.css({
"width": mWidth,
// "height": Math.floor(mWidth * 757 / 692) //按原宽高比缩放,height=mWidth* height0/width0
"height": computeHeight(mWidth, 692, 757)
});
var mHeight = $match.height();
var mHeightHalf = Math.floor(mHeight / 2);
$(".poloShirt").css({
"width": Math.floor(mHeight * 3 / 5),
"background": "rgba(9,200,200,0.5)",
"height": mHeightHalf
});
$(".poloShirt").click(function () {
window.location.href = 'https://&0&商品id';
});
$(".vest").css({
"width": mWidthHalf,
"background": "rgba(9,200,200,0.5)",
"height": mHeightHalf
});
$(".vest").click(function () {
window.location.href = 'https://&0&商品id';
});
}

抽取函数,传入参数。哪些可以传参

因为子类有多个,所有将子类作为数组传入;并且子类含有很多属性和方法,如css以及click,所有数组中每个对象是json,即{key:value},调用的时候就是obj.key,所以将key作为参数传入。综合来看,就是

 childClassObjs[i]={cName:cName,
ratioMoleculeW :ratioMoleculeW
ratioMoleculeH :ratioMoleculeH
url:url
}
 function picLinkInit(parentClassName, imgW, imgH, childClassObjs) {
var $match = $(parentClassName);
var mWidth = Math.floor($match.width()); var mHeight = computeHeight(mWidth, imgW, imgH);
$match.css({
"width": mWidth,
"height": mHeight
});
for (var i = 0; i < childClassObjs.length; i++) {
var childClassObj = childClassObjs[i]; $(childClassObj.cName).css({
"width": Math.floor(mWidth * childClassObj.ratioMoleculeW / childClassObj.ratioDenominatorW),
// "background": "rgba(9,200,200,0.5)",
"height": Math.floor(mHeight * childClassObj.ratioMoleculeH / childClassObj.ratioDenominatorH)
});
/* if (childClassObj.url) {
$(childClassObj.cName).click(function () {
window.location.href =childClassObj.url;
});
}*/
(function (i) {
if ( childClassObjs[i].url) {
$( childClassObjs[i].cName).click(function () {
window.location.href = childClassObjs[i].url;
});
}
})(i); }

调用的时候是:

 function matchPicLink4() {
picLinkInit("#match4", 692, 677, [
{
"cName": ".aca4coat1",
"ratioMoleculeW": 16,
"ratioDenominatorW": 24,
"ratioMoleculeH": 7,
"ratioDenominatorH": 24,
"url": "https://&0&0&4675"
}, {
"cName": ".aca4coat2",
"ratioMoleculeW": 10,
"ratioDenominatorW": 24,
"ratioMoleculeH": 7,
"ratioDenominatorH": 24,
"url": "https://&0&0&4675"
}
]);
}

webstorm抽取函数的更多相关文章

  1. 『Numpy学习指南』排序&索引&抽取函数介绍

    排序: numpy.lexsort(): numpy.lexsort()是个排字典序函数,因为很有意思,感觉也蛮有用的,所以单独列出来讲一下: 强调一点,本函数只接受一个参数! import nump ...

  2. eclipse 重构代码自动抽取函数

    1.选择重构代码段 2.重构 – 抽取方法 3.命名重构代码段抽取的方法 4.使用抽取的方法

  3. WebStorm 常用功能的使用技巧分享

    WebStorm 是 JetBrain 公司开发的一款 JavaScript IDE,使用非常方便,可以使编写代码过程更加流畅. 本文在这里分享一些常用功能的使用技巧,希望能帮助大家更好的使用这款强大 ...

  4. WebStorm 常用功能

    WebStorm 常用功能的使用技巧分享 WebStorm 是 JetBrain 公司开发的一款 JavaScript IDE,使用非常方便,可以使编写代码过程更加流畅. 本文在这里分享一些常用功能的 ...

  5. R语言-编写自定义函数 ZZ

    一.函数构造器 每一个R函数都包括三个部分:函数名,程序主体以及参数集合,在编写自定义R函数时,需要将三个部分各自储存在一个R对象中.这里需要使用function函数,形如: my_function& ...

  6. intellijidea课程 intellijidea神器使用技巧 4-2 抽取

    1 抽取变量 Ctrl alt V 抽取变量 Ctrl alt C 抽取静态变量  顺带创建静态方法 Crrl alt F 抽取成员变量 2 抽取方法参数 Ctrl alt P 抽取参数,到方法体中 ...

  7. WebStorm 使用技巧

    常用快捷键 代码编辑 ctrl + d:复制行 ctrl + y:删除行 ctrl + x:剪切行 ctrl + shift + ↑: 行移动 ctrl + shift + enter: 换行 ctr ...

  8. 自己实现一个类似 jQuery 的函数库

    假如我们有一个需求,需要给元素添加样式类,使用原生的JS很容易搞定. 1 抽取函数 function addClass(node, className){ node.classList.add(cla ...

  9. 使用R语言-RStudio快捷键

    控制台 功能 Windows & Linux Mac 移动鼠标到控制台 Ctrl+2 Ctrl+2 控制台清屏 Ctrl+L Command+L 移动鼠标至第一行 Home Command+L ...

随机推荐

  1. 2016年iOS笔试题

    收集了一些ios面试的一些基础的试题,其中也有一些较难的 1.请简述UIView与CALayer有什么不同.2.Block什么情况下会保留实体内引用到外部对象,什么时候要用__block或__weak ...

  2. ARM Cortex-M0权威指南高清中文版pdf免费分享下载

    版 次:1 页 数:433 字 数:655000 印刷时间:2013-8-1 开 本:16开 纸 张:胶版纸 印 次:1 包 装:平装 丛书名:清华开发者书库 国际标准书号ISBN:978730233 ...

  3. Servlet容器Tomcat中web.xml中url-pattern的配置详解[附带源码分析]

    目录 前言 现象 源码分析 实战例子 总结 参考资料 前言 今天研究了一下tomcat上web.xml配置文件中url-pattern的问题. 这个问题其实毕业前就困扰着我,当时忙于找工作. 找到工作 ...

  4. 【MVVM】模型认识理解,

     MVVM:模型-视图-视图模型(Model-View-ViewModel) 注意:它是双向绑定的 源:http://www.ruanyifeng.com/blog/2015/02/mvcmvp_mv ...

  5. C++标准库:std_map作为一个关联数组

    摘要:std::map作为一个容器存在一个典型应用就是作为关联数组来作用.在诸如Java等等语言中,关联数组广泛存在.std::map是一个容器,在它的概念框架中存在两个词:键和值,std::map把 ...

  6. ubuntu14.04 python3.*连接mysql

    先下载pymysql文件,http://webscripts.softpedia.com/script/Database-Tools/PyMySQL-71606.html 我下载的是:PyMySQL- ...

  7. [转]Hibernate延迟加载与opensessioninviewFilter

    原文地址:http://blog.csdn.net/a19881029/article/details/7916702 hibernate延迟加载: 一个person对应多个school,使用hibe ...

  8. js base64加密,后台解密

    这是为了解决页面发送post请求,传输密码,在页面的控制台可以看到密码的明文,所以先用base64把要传输的密码转换为非明文,然后在后台解密处理. base64encode.js // base64加 ...

  9. bzoj3343

    3343: 教主的魔法 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1178  Solved: 527[Submit][Status][Discus ...

  10. Ubuntu/Mint更换阿里云源

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份 sudo vim /etc/apt/sources.list #修改 sudo ...