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. JS获取屏幕高度(转)

    IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...

  2. 2016-2017-1 《信息安全系统设计基础》 学生博客及Git@OSC 链接

    2016-2017-1 <信息安全系统设计基础> 学生博客及Git@OSC 链接 博客 1452 20145201李子璇 20145202马 超 20145203盖泽双 20145204张 ...

  3. yii获取当前url和域名

    <?php //当前域名 echo Yii::app()->request->hostInfo; //除域名外的URL echo Yii::app()->request-> ...

  4. jQuery1.9之后使用on()绑定 动态生成元素的 事件无效

    来自互联网: 需要绑定a的父级元素(此元素必须为静态元素,不是后来动态生成的),然后设定on()方法的selector参数才行: $('p').on('mouseenter', 'a', functi ...

  5. redis-介绍与比较

    <一>. NoSQL简介:    NoSQL是Not-Only-SQL的缩写,是被设计用来替换传统的关系型数据库在某些领域的用,特别针对web2.0站点以及大型的SNS网站,用来满足高并发 ...

  6. Win10 PC一周年更新正式版14393.447 32位/64位更新补丁KB3200970下载 Flash补丁Kb3202790下载

    微软在今天凌晨推送了Win10 PC一周年更新正式版14393.447,本次更新补丁代号为KB3200970,面向Win10一周年更新正式版的PC用户. 更新日志 • 提升了多媒体音频.远程桌面以及I ...

  7. 【BZOJ-3643】Phi的反函数 数论 + 搜索

    3643: Phi的反函数 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 141  Solved: 96[Submit][Status][Discuss ...

  8. 【bzoj4517】 Sdoi2016—排列计数

    http://www.lydsy.com/JudgeOnline/problem.php?id=4517 (题目链接) 题意 求n个数中正好m个数位置不变的排列数. Solution $${错排公式: ...

  9. 面试题目——《CC150》排序与查找

    面试题11.1:给定两个排序后的数组A和B,其中A的末端有足够的缓冲空间容纳B.编写一个方法,将B合并入A并排序. package cc150.sort_search; public class Me ...

  10. c语言求数组长度

    在定义数组的函数内 int arr[] = {12.12}; int length; length = ]; 在别的函数中作为引用数据类型引入时,以上方法失效: 解决方法1:再传一个int 类型的长度 ...