webstorm抽取函数
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抽取函数的更多相关文章
- 『Numpy学习指南』排序&索引&抽取函数介绍
排序: numpy.lexsort(): numpy.lexsort()是个排字典序函数,因为很有意思,感觉也蛮有用的,所以单独列出来讲一下: 强调一点,本函数只接受一个参数! import nump ...
- eclipse 重构代码自动抽取函数
1.选择重构代码段 2.重构 – 抽取方法 3.命名重构代码段抽取的方法 4.使用抽取的方法
- WebStorm 常用功能的使用技巧分享
WebStorm 是 JetBrain 公司开发的一款 JavaScript IDE,使用非常方便,可以使编写代码过程更加流畅. 本文在这里分享一些常用功能的使用技巧,希望能帮助大家更好的使用这款强大 ...
- WebStorm 常用功能
WebStorm 常用功能的使用技巧分享 WebStorm 是 JetBrain 公司开发的一款 JavaScript IDE,使用非常方便,可以使编写代码过程更加流畅. 本文在这里分享一些常用功能的 ...
- R语言-编写自定义函数 ZZ
一.函数构造器 每一个R函数都包括三个部分:函数名,程序主体以及参数集合,在编写自定义R函数时,需要将三个部分各自储存在一个R对象中.这里需要使用function函数,形如: my_function& ...
- intellijidea课程 intellijidea神器使用技巧 4-2 抽取
1 抽取变量 Ctrl alt V 抽取变量 Ctrl alt C 抽取静态变量 顺带创建静态方法 Crrl alt F 抽取成员变量 2 抽取方法参数 Ctrl alt P 抽取参数,到方法体中 ...
- WebStorm 使用技巧
常用快捷键 代码编辑 ctrl + d:复制行 ctrl + y:删除行 ctrl + x:剪切行 ctrl + shift + ↑: 行移动 ctrl + shift + enter: 换行 ctr ...
- 自己实现一个类似 jQuery 的函数库
假如我们有一个需求,需要给元素添加样式类,使用原生的JS很容易搞定. 1 抽取函数 function addClass(node, className){ node.classList.add(cla ...
- 使用R语言-RStudio快捷键
控制台 功能 Windows & Linux Mac 移动鼠标到控制台 Ctrl+2 Ctrl+2 控制台清屏 Ctrl+L Command+L 移动鼠标至第一行 Home Command+L ...
随机推荐
- [CareerCup] 5.7 Find Missing Integer 查找丢失的数
5.7 An array A contains all the integers from 0 to n, except for one number which is missing. In thi ...
- 千万别把WIFI玩坏了!关于WIFI的新鲜玩法和商业模式探讨
使用WIFI作为无线上网接入,也许大家都比较习以为常的.但是你们知道吗,其实WIFI还有很多种玩法:基于WIFI的身份识别,WIFI感知,WIFI Direct等等.今天我们会着重介绍一种WIFI的有 ...
- 【Python】[IO编程]文件读写,StringIO和BytesIO,操作文件和目录,序列化
IO在计算机中指Input/Output,也就是输入和输出. 1.文件读写,1,读文件[使用Python内置函数,open,传入文件名标示符] >>> f = open('/User ...
- 构建自己的 Linux 发行版
如何用 SUSE Studio 构建 Linux 发行版? (1) 进入到 www.susestudio.com,设立一个帐户 (2) 为你的设备(发行版)选择一个基本模板 -软件和软件包选择 (1) ...
- [转] 对称加密算法DES、3DES
转自:http://www.blogjava.net/amigoxie/archive/2014/07/06/415503.html 1.对称加密算法 1.1 定义 对称加密算法是应用较早的加密算法, ...
- bzoj4462: [Jsoi2013]编程作业
KMP还是有点用处的嘛qwq 对于小写字母,修改其为前一个这个小写字母和它的距离 然后跑KMP就行了 跑得飞快 #include <iostream> #include <cstdi ...
- SpringBoot源码分析:spring的基本架构
在深入了解springboot之前,我们需要了解spring,springboot本身就是基于spring而构建:是微服务架构中一个比较流行的框架:类似spring提供了一套完整的微服务方案如spri ...
- 如何将Emmet安装到到 Sublime text 3?
看清楚哦~~这是Sublime text 3不是2的版本,两者的安装还是有区别的,下面的方法是我感觉比较简单的,其他的要命令什么的感觉太复杂了,经测试是OK的. ONE:建议到官方下载Sublime ...
- Linux的inode的理解
文件名 -> inode -> device block 一.inode是什么? 理解inode,要从文件储存说起. 文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"( ...
- Pjax调用
$.pjax({container:'#content_center',url:href,data:data}); $(document).on('pjax:send', function() {// ...