Commit ec3e1983 by zhangyongfeng

init

parents
> 1%
last 2 versions
./src/assets/lib/tagcanvas.js
\ No newline at end of file
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "@vue/prettier"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
},
parserOptions: {
parser: "babel-eslint"
}
};
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
\ No newline at end of file
{
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
# luckydraw
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"]
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "luckydraw",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.4.3",
"element-ui": "^2.13.0",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-vuex": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.13.0",
"prettier": "^1.19.1",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>luckydraw</title>
</head>
<body>
<noscript>
<strong>We're sorry but luckydraw doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="root">
<header>
<Publicity v-show="!running" />
<el-button class="res" type="text" @click="showResult = true">
抽奖结果
</el-button>
<el-button class="con" type="text" @click="showConfig = true">
抽奖配置
</el-button>
</header>
<div id="main" :class="{ mask: showRes }"></div>
<div id="tags">
<ul v-for="item in datas" :key="item.key">
<li>
<a href="javascript:void(0);" :style="{ color: '#fff' }">
{{ item.key }}
</a>
</li>
</ul>
</div>
<div id="resbox" v-show="showRes">
<p @click="showRes = false">{{ categoryName }}抽奖结果:</p>
<span
v-for="item in resArr"
:key="item"
class="itemres"
@click="showRes = false"
>
{{ item }}
</span>
</div>
<LotteryConfig :visible.sync="showConfig" @resetconfig="reloadTagCanvas" />
<Tool @toggle="toggle" :running="running" />
<Result :visible.sync="showResult"></Result>
</div>
</template>
<script>
import LotteryConfig from '@/components/LotteryConfig';
import Publicity from '@/components/Publicity';
import Tool from '@/components/Tool';
import {
getData,
configField,
resultField,
conversionCategoryName
} from '@/helper/index';
import { luckydrawHandler } from '@/helper/algorithm';
import Result from '@/components/Result';
export default {
name: 'App',
components: { LotteryConfig, Publicity, Tool, Result },
computed: {
config: {
get() {
return this.$store.state.config;
}
},
result: {
get() {
return this.$store.state.result;
},
set(val) {
this.$store.commit('setResult', val);
}
},
allresult() {
let allresult = [];
for (const key in this.result) {
if (this.result.hasOwnProperty(key)) {
const element = this.result[key];
allresult = allresult.concat(element);
}
}
return allresult;
},
datas() {
const datas = [];
for (let index = 0; index < this.config.number; index++) {
datas.push({
key: index + 1
});
}
return datas;
},
categoryName() {
return conversionCategoryName(this.category);
}
},
created() {
const data = getData(configField);
if (data) {
this.$store.commit('setConfig', Object.assign({}, data));
}
const result = getData(resultField);
if (result) {
this.$store.commit('setResult', result);
}
},
data() {
return {
running: false,
showRes: false,
showConfig: false,
showResult: false,
resArr: [],
category: ''
};
},
mounted() {
this.startTagCanvas();
},
methods: {
speed() {
return [0.1 * Math.random() + 0.01, -(0.1 * Math.random() + 0.01)];
},
createCanvas() {
const canvas = document.createElement('canvas');
canvas.width = document.body.offsetWidth;
canvas.height = document.body.offsetHeight;
canvas.id = 'rootcanvas';
this.$el.querySelector('#main').appendChild(canvas);
},
startTagCanvas() {
this.createCanvas();
const { speed } = this;
window.TagCanvas.Start('rootcanvas', 'tags', {
textColour: null,
initial: speed(),
dragControl: 1,
textHeight: 20,
noSelect: true,
lock: 'xy'
});
},
reloadTagCanvas() {
window.TagCanvas.Reload('rootcanvas');
},
toggle(form) {
const { speed, config } = this;
if (this.running) {
window.TagCanvas.SetSpeed('rootcanvas', speed());
this.reloadTagCanvas();
setTimeout(() => {
this.showRes = true;
}, 300);
} else {
this.showRes = false;
const { number } = config;
const { category, mode, qty, remain, allin } = form;
let num = 1;
if (mode === 1 || mode === 5) {
num = mode;
} else if (mode === 0) {
num = remain;
} else if (mode === 99) {
num = qty;
}
const resArr = luckydrawHandler(
number,
allin ? [] : this.allresult,
num
);
this.resArr = resArr;
this.category = category;
const oldRes = this.result[category] || [];
this.result = {
[category]: oldRes.concat(resArr)
};
window.TagCanvas.SetSpeed('rootcanvas', [5, 1]);
}
this.running = !this.running;
}
}
};
</script>
<style lang="scss">
#root {
height: 100%;
position: relative;
background-image: url('./assets/bg.jpg');
background-size: 100% 100%;
background-position: center center;
background-repeat: no-repeat;
background-color: #121936;
.mask {
-webkit-filter: blur(5px);
filter: blur(5px);
}
header {
height: 50px;
line-height: 50px;
position: relative;
.el-button {
position: absolute;
top: 17px;
padding: 0;
&.con {
right: 20px;
}
&.res {
right: 100px;
}
}
}
}
#main {
height: 100%;
}
#resbox {
position: absolute;
top: 45%;
left: 50%;
width: 1000px;
transform: translateX(-50%) translateY(-50%);
text-align: center;
p {
color: red;
font-size: 50px;
line-height: 120px;
}
.itemres {
background: #fff;
display: inline-block;
width: 160px;
height: 160px;
border-radius: 4px;
border: 1px solid #ccc;
line-height: 160px;
font-size: 100px;
font-weight: bold;
margin-right: 20px;
margin-top: 20px;
cursor: pointer;
}
}
</style>
/* eslint-disable */
/**
* Copyright (C) 2010-2015 Graham Breach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* TagCanvas 2.9
* For more information, please contact <graham@goat1000.com>
*/
(function() {
var M, K, L = Math.abs, ah = Math.sin, w = Math.cos, s = Math.max, aD = Math.min, ap = Math.ceil, F = Math.sqrt, at = Math.pow, h = {}, l = {}, m = {
0: "0,",
1: "17,",
2: "34,",
3: "51,",
4: "68,",
5: "85,",
6: "102,",
7: "119,",
8: "136,",
9: "153,",
a: "170,",
A: "170,",
b: "187,",
B: "187,",
c: "204,",
C: "204,",
d: "221,",
D: "221,",
e: "238,",
E: "238,",
f: "255,",
F: "255,"
}, x, c, Q, aF, H, aG, aa, C = document, p, b = {};
for (M = 0; M < 256; ++M) {
K = M.toString(16);
if (M < 16) {
K = "0" + K
}
l[K] = l[K.toUpperCase()] = M.toString() + ","
}
function ai(i) {
return typeof i != "undefined"
}
function I(i) {
return typeof i == "object" && i != null
}
function av(i, j, aH) {
return isNaN(i) ? aH : aD(aH, s(j, i))
}
function aA() {
return false
}
function G() {
return new Date().valueOf()
}
function A(aH, aK) {
var j = [], aI = aH.length, aJ;
for (aJ = 0; aJ < aI; ++aJ) {
j.push(aH[aJ])
}
j.sort(aK);
return j
}
function an(j) {
var aI = j.length - 1, aH, aJ;
while (aI) {
aJ = ~~(Math.random() * aI);
aH = j[aI];
j[aI] = j[aJ];
j[aJ] = aH;
--aI
}
}
function ae(i, aH, j) {
this.x = i;
this.y = aH;
this.z = j
}
H = ae.prototype;
H.length = function() {
return F(this.x * this.x + this.y * this.y + this.z * this.z)
}
;
H.dot = function(i) {
return this.x * i.x + this.y * i.y + this.z * i.z
}
;
H.cross = function(j) {
var i = this.y * j.z - this.z * j.y
, aI = this.z * j.x - this.x * j.z
, aH = this.x * j.y - this.y * j.x;
return new ae(i,aI,aH)
}
;
H.angle = function(j) {
var i = this.dot(j), aH;
if (i == 0) {
return Math.PI / 2
}
aH = i / (this.length() * j.length());
if (aH >= 1) {
return 0
}
if (aH <= -1) {
return Math.PI
}
return Math.acos(aH)
}
;
H.unit = function() {
var i = this.length();
return new ae(this.x / i,this.y / i,this.z / i)
}
;
function aj(aH, j) {
j = j * Math.PI / 180;
aH = aH * Math.PI / 180;
var i = ah(aH) * w(j)
, aJ = -ah(j)
, aI = -w(aH) * w(j);
return new ae(i,aJ,aI)
}
function R(i) {
this[1] = {
1: i[0],
2: i[1],
3: i[2]
};
this[2] = {
1: i[3],
2: i[4],
3: i[5]
};
this[3] = {
1: i[6],
2: i[7],
3: i[8]
}
}
aF = R.prototype;
R.Identity = function() {
return new R([1, 0, 0, 0, 1, 0, 0, 0, 1])
}
;
R.Rotation = function(aI, i) {
var j = ah(aI)
, aH = w(aI)
, aJ = 1 - aH;
return new R([aH + at(i.x, 2) * aJ, i.x * i.y * aJ - i.z * j, i.x * i.z * aJ + i.y * j, i.y * i.x * aJ + i.z * j, aH + at(i.y, 2) * aJ, i.y * i.z * aJ - i.x * j, i.z * i.x * aJ - i.y * j, i.z * i.y * aJ + i.x * j, aH + at(i.z, 2) * aJ])
}
;
aF.mul = function(aH) {
var aI = [], aL, aK, aJ = (aH.xform ? 1 : 0);
for (aL = 1; aL <= 3; ++aL) {
for (aK = 1; aK <= 3; ++aK) {
if (aJ) {
aI.push(this[aL][1] * aH[1][aK] + this[aL][2] * aH[2][aK] + this[aL][3] * aH[3][aK])
} else {
aI.push(this[aL][aK] * aH)
}
}
}
return new R(aI)
}
;
aF.xform = function(aH) {
var j = {}
, i = aH.x
, aJ = aH.y
, aI = aH.z;
j.x = i * this[1][1] + aJ * this[2][1] + aI * this[3][1];
j.y = i * this[1][2] + aJ * this[2][2] + aI * this[3][2];
j.z = i * this[1][3] + aJ * this[2][3] + aI * this[3][3];
return j
}
;
function q(aI, aK, aQ, aN, aP) {
var aL, aO, j, aM, aR = [], aH = 2 / aI, aJ;
aJ = Math.PI * (3 - F(5) + (parseFloat(aP) ? parseFloat(aP) : 0));
for (aL = 0; aL < aI; ++aL) {
aO = aL * aH - 1 + (aH / 2);
j = F(1 - aO * aO);
aM = aL * aJ;
aR.push([w(aM) * j * aK, aO * aQ, ah(aM) * j * aN])
}
return aR
}
function W(aJ, aH, aM, aT, aQ, aS) {
var aR, aU = [], aI = 2 / aJ, aK, aP, aO, aN, aL;
aK = Math.PI * (3 - F(5) + (parseFloat(aS) ? parseFloat(aS) : 0));
for (aP = 0; aP < aJ; ++aP) {
aO = aP * aI - 1 + (aI / 2);
aR = aP * aK;
aN = w(aR);
aL = ah(aR);
aU.push(aH ? [aO * aM, aN * aT, aL * aQ] : [aN * aM, aO * aT, aL * aQ])
}
return aU
}
function N(aH, aI, aL, aR, aP, aN) {
var aQ, aS = [], aJ = Math.PI * 2 / aI, aO, aM, aK;
for (aO = 0; aO < aI; ++aO) {
aQ = aO * aJ;
aM = w(aQ);
aK = ah(aQ);
aS.push(aH ? [aN * aL, aM * aR, aK * aP] : [aM * aL, aN * aR, aK * aP])
}
return aS
}
function am(aJ, j, aH, aI, i) {
return W(aJ, 0, j, aH, aI, i)
}
function au(aJ, j, aH, aI, i) {
return W(aJ, 1, j, aH, aI, i)
}
function d(aJ, i, j, aH, aI) {
aI = isNaN(aI) ? 0 : aI * 1;
return N(0, aJ, i, j, aH, aI)
}
function n(aJ, i, j, aH, aI) {
aI = isNaN(aI) ? 0 : aI * 1;
return N(1, aJ, i, j, aH, aI)
}
function ao(aH) {
var j = new Image;
j.onload = function() {
var aI = j.width / 2
, i = j.height / 2;
aH.centreFunc = function(aN, aK, aL, aJ, aM) {
aN.setTransform(1, 0, 0, 1, 0, 0);
aN.globalAlpha = 1;
aN.drawImage(j, aJ - aI, aM - i)
}
}
;
j.src = aH.centreImage
}
function U(aK, i) {
var aJ = aK, aI, aH, j = (i * 1).toPrecision(3) + ")";
if (aK[0] === "#") {
if (!h[aK]) {
if (aK.length === 4) {
h[aK] = "rgba(" + m[aK[1]] + m[aK[2]] + m[aK[3]]
} else {
h[aK] = "rgba(" + l[aK.substr(1, 2)] + l[aK.substr(3, 2)] + l[aK.substr(5, 2)]
}
}
aJ = h[aK] + j
} else {
if (aK.substr(0, 4) === "rgb(" || aK.substr(0, 4) === "hsl(") {
aJ = (aK.replace("(", "a(").replace(")", "," + j))
} else {
if (aK.substr(0, 5) === "rgba(" || aK.substr(0, 5) === "hsla(") {
aI = aK.lastIndexOf(",") + 1,
aH = aK.indexOf(")");
i *= parseFloat(aK.substring(aI, aH));
aJ = aK.substr(0, aI) + i.toPrecision(3) + ")"
}
}
}
return aJ
}
function P(i, j) {
if (window.G_vmlCanvasManager) {
return null
}
var aH = C.createElement("canvas");
aH.width = i;
aH.height = j;
return aH
}
function al() {
var j = P(3, 3), aI, aH;
if (!j) {
return false
}
aI = j.getContext("2d");
aI.strokeStyle = "#000";
aI.shadowColor = "#fff";
aI.shadowBlur = 3;
aI.globalAlpha = 0;
aI.strokeRect(2, 2, 2, 2);
aI.globalAlpha = 1;
aH = aI.getImageData(2, 2, 1, 1);
j = null;
return (aH.data[0] > 0)
}
function ak(aL, j, aK, aJ) {
var aI = aL.createLinearGradient(0, 0, j, 0), aH;
for (aH in aJ) {
aI.addColorStop(1 - aH, aJ[aH])
}
aL.fillStyle = aI;
aL.fillRect(0, aK, j, 1)
}
function k(aJ, aH, j) {
var aI = 1024, aN = 1, aM = aJ.weightGradient, aL, aP, aK, aO;
if (aJ.gCanvas) {
aP = aJ.gCanvas.getContext("2d");
aN = aJ.gCanvas.height
} else {
if (I(aM[0])) {
aN = aM.length
} else {
aM = [aM]
}
aJ.gCanvas = aL = P(aI, aN);
if (!aL) {
return null
}
aP = aL.getContext("2d");
for (aK = 0; aK < aN; ++aK) {
ak(aP, aI, aK, aM[aK])
}
}
j = s(aD(j || 0, aN - 1), 0);
aO = aP.getImageData(~~((aI - 1) * aH), j, 1, 1).data;
return "rgba(" + aO[0] + "," + aO[1] + "," + aO[2] + "," + (aO[3] / 255) + ")"
}
function X(aQ, aJ, j, aU, aT, aR, aP, aL, aI, aS, aK, aO) {
var aN = aT + (aL || 0) + (aI.length && aI[0] < 0 ? L(aI[0]) : 0), aH = aR + (aL || 0) + (aI.length && aI[1] < 0 ? L(aI[1]) : 0), aM, aV;
aQ.font = aJ;
aQ.textBaseline = "top";
aQ.fillStyle = j;
aP && (aQ.shadowColor = aP);
aL && (aQ.shadowBlur = aL);
aI.length && (aQ.shadowOffsetX = aI[0],
aQ.shadowOffsetY = aI[1]);
for (aM = 0; aM < aU.length; ++aM) {
aV = 0;
if (aK) {
if ("right" == aO) {
aV = aS - aK[aM]
} else {
if ("centre" == aO) {
aV = (aS - aK[aM]) / 2
}
}
}
aQ.fillText(aU[aM], aN + aV, aH);
aH += parseInt(aJ)
}
}
function ar(aL, i, aK, j, aI, aJ, aH) {
if (aJ) {
aL.beginPath();
aL.moveTo(i, aK + aI - aJ);
aL.arcTo(i, aK, i + aJ, aK, aJ);
aL.arcTo(i + j, aK, i + j, aK + aJ, aJ);
aL.arcTo(i + j, aK + aI, i + j - aJ, aK + aI, aJ);
aL.arcTo(i, aK + aI, i, aK + aI - aJ, aJ);
aL.closePath();
aL[aH ? "stroke" : "fill"]()
} else {
aL[aH ? "strokeRect" : "fillRect"](i, aK, j, aI)
}
}
function g(aN, i, aL, aI, aM, aH, aJ, aK, j) {
this.strings = aN;
this.font = i;
this.width = aL;
this.height = aI;
this.maxWidth = aM;
this.stringWidths = aH;
this.align = aJ;
this.valign = aK;
this.scale = j
}
aa = g.prototype;
aa.SetImage = function(aK, j, aI, i, aJ, aM, aH, aL) {
this.image = aK;
this.iwidth = j * this.scale;
this.iheight = aI * this.scale;
this.ipos = i;
this.ipad = aJ * this.scale;
this.iscale = aL;
this.ialign = aM;
this.ivalign = aH
}
;
aa.Align = function(j, aH, i) {
var aI = 0;
if (i == "right" || i == "bottom") {
aI = aH - j
} else {
if (i != "left" && i != "top") {
aI = (aH - j) / 2
}
}
return aI
}
;
aa.Create = function(aU, a0, aT, a1, aZ, aY, i, aX, aP) {
var aN, aL, aV, a6, a3, a2, aJ, aI, aH, j, aM, aK, aO, aW, aS, a5 = L(i[0]), a4 = L(i[1]), aQ, aR;
aX = s(aX, a5 + aY, a4 + aY);
a3 = 2 * (aX + a1);
aJ = 2 * (aX + a1);
aL = this.width + a3;
aV = this.height + aJ;
aH = j = aX + a1;
if (this.image) {
aM = aK = aX + a1;
aO = this.iwidth;
aW = this.iheight;
if (this.ipos == "top" || this.ipos == "bottom") {
if (aO < this.width) {
aM += this.Align(aO, this.width, this.ialign)
} else {
aH += this.Align(this.width, aO, this.align)
}
if (this.ipos == "top") {
j += aW + this.ipad
} else {
aK += this.height + this.ipad
}
aL = s(aL, aO + a3);
aV += aW + this.ipad
} else {
if (aW < this.height) {
aK += this.Align(aW, this.height, this.ivalign)
} else {
j += this.Align(this.height, aW, this.valign)
}
if (this.ipos == "right") {
aM += this.width + this.ipad
} else {
aH += aO + this.ipad
}
aL += aO + this.ipad;
aV = s(aV, aW + aJ)
}
}
aN = P(aL, aV);
if (!aN) {
return null
}
a3 = aJ = a1 / 2;
a2 = aL - a1;
aI = aV - a1;
aS = aD(aP, a2 / 2, aI / 2);
a6 = aN.getContext("2d");
if (a0) {
a6.fillStyle = a0;
ar(a6, a3, aJ, a2, aI, aS)
}
if (a1) {
a6.strokeStyle = aT;
a6.lineWidth = a1;
ar(a6, a3, aJ, a2, aI, aS, true)
}
if (aY || a5 || a4) {
aQ = P(aL, aV);
if (aQ) {
aR = a6;
a6 = aQ.getContext("2d")
}
}
X(a6, this.font, aU, this.strings, aH, j, 0, 0, [], this.maxWidth, this.stringWidths, this.align);
if (this.image) {
a6.drawImage(this.image, aM, aK, aO, aW)
}
if (aR) {
a6 = aR;
aZ && (a6.shadowColor = aZ);
aY && (a6.shadowBlur = aY);
a6.shadowOffsetX = i[0];
a6.shadowOffsetY = i[1];
a6.drawImage(aQ, 0, 0)
}
return aN
}
;
function v(aI, j, aJ) {
var aH = P(j, aJ), aK;
if (!aH) {
return null
}
aK = aH.getContext("2d");
aK.drawImage(aI, (j - aI.width) / 2, (aJ - aI.height) / 2);
return aH
}
function ax(aI, j, aJ) {
var aH = P(j, aJ), aK;
if (!aH) {
return null
}
aK = aH.getContext("2d");
aK.drawImage(aI, 0, 0, j, aJ);
return aH
}
function aC(aU, aP, aV, aZ, aQ, aO, aM, aS, aK, aL) {
var aI = aP + ((2 * aS) + aO) * aZ, aR = aV + ((2 * aS) + aO) * aZ, aJ = P(aI, aR), aY, aX, aH, aW, j, a0, aT, aN;
if (!aJ) {
return null
}
aO *= aZ;
aK *= aZ;
aX = aH = aO / 2;
aW = aI - aO;
j = aR - aO;
aS = (aS * aZ) + aX;
aY = aJ.getContext("2d");
aN = aD(aK, aW / 2, j / 2);
if (aQ) {
aY.fillStyle = aQ;
ar(aY, aX, aH, aW, j, aN)
}
if (aO) {
aY.strokeStyle = aM;
aY.lineWidth = aO;
ar(aY, aX, aH, aW, j, aN, true)
}
if (aL) {
a0 = P(aI, aR);
aT = a0.getContext("2d");
aT.drawImage(aU, aS, aS, aP, aV);
aT.globalCompositeOperation = "source-in";
aT.fillStyle = aM;
aT.fillRect(0, 0, aI, aR);
aT.globalCompositeOperation = "destination-over";
aT.drawImage(aJ, 0, 0);
aT.globalCompositeOperation = "source-over";
aY.drawImage(a0, 0, 0)
} else {
aY.drawImage(aU, aS, aS, aU.width, aU.height)
}
return {
image: aJ,
width: aI / aZ,
height: aR / aZ
}
}
function aq(aK, j, aJ, aN, aO) {
var aL, aM, aH = parseFloat(j), aI = s(aJ, aN);
aL = P(aJ, aN);
if (!aL) {
return null
}
if (j.indexOf("%") > 0) {
aH = aI * aH / 100
} else {
aH = aH * aO
}
aM = aL.getContext("2d");
aM.globalCompositeOperation = "source-over";
aM.fillStyle = "#fff";
if (aH >= aI / 2) {
aH = aD(aJ, aN) / 2;
aM.beginPath();
aM.moveTo(aJ / 2, aN / 2);
aM.arc(aJ / 2, aN / 2, aH, 0, 2 * Math.PI, false);
aM.fill();
aM.closePath()
} else {
aH = aD(aJ / 2, aN / 2, aH);
ar(aM, 0, 0, aJ, aN, aH, true);
aM.fill()
}
aM.globalCompositeOperation = "source-in";
aM.drawImage(aK, 0, 0, aJ, aN);
return aL
}
function Z(aN, aT, aP, aJ, aR, aS, aI) {
var aU = L(aI[0]), aO = L(aI[1]), aK = aT + (aU > aS ? aU + aS : aS * 2) * aJ, j = aP + (aO > aS ? aO + aS : aS * 2) * aJ, aM = aJ * ((aS || 0) + (aI[0] < 0 ? aU : 0)), aH = aJ * ((aS || 0) + (aI[1] < 0 ? aO : 0)), aL, aQ;
aL = P(aK, j);
if (!aL) {
return null
}
aQ = aL.getContext("2d");
aR && (aQ.shadowColor = aR);
aS && (aQ.shadowBlur = aS * aJ);
aI && (aQ.shadowOffsetX = aI[0] * aJ,
aQ.shadowOffsetY = aI[1] * aJ);
aQ.drawImage(aN, aM, aH, aT, aP);
return {
image: aL,
width: aK / aJ,
height: j / aJ
}
}
function t(aT, aL, aR) {
var aS = parseInt(aT.toString().length * aR), aK = parseInt(aR * 2 * aT.length), aI = P(aS, aK), aO, j, aJ, aN, aQ, aP, aH, aM;
if (!aI) {
return null
}
aO = aI.getContext("2d");
aO.fillStyle = "#000";
aO.fillRect(0, 0, aS, aK);
X(aO, aR + "px " + aL, "#fff", aT, 0, 0, 0, 0, [], "centre");
j = aO.getImageData(0, 0, aS, aK);
aJ = j.width;
aN = j.height;
aM = {
min: {
x: aJ,
y: aN
},
max: {
x: -1,
y: -1
}
};
for (aP = 0; aP < aN; ++aP) {
for (aQ = 0; aQ < aJ; ++aQ) {
aH = (aP * aJ + aQ) * 4;
if (j.data[aH + 1] > 0) {
if (aQ < aM.min.x) {
aM.min.x = aQ
}
if (aQ > aM.max.x) {
aM.max.x = aQ
}
if (aP < aM.min.y) {
aM.min.y = aP
}
if (aP > aM.max.y) {
aM.max.y = aP
}
}
}
}
if (aJ != aS) {
aM.min.x *= (aS / aJ);
aM.max.x *= (aS / aJ)
}
if (aN != aK) {
aM.min.y *= (aS / aN);
aM.max.y *= (aS / aN)
}
aI = null;
return aM
}
function o(i) {
return "'" + i.replace(/(\'|\")/g, "").replace(/\s*,\s*/g, "', '") + "'"
}
function ad(i, j, aH) {
aH = aH || C;
if (aH.addEventListener) {
aH.addEventListener(i, j, false)
} else {
aH.attachEvent("on" + i, j)
}
}
function a(i, j, aH) {
aH = aH || C;
if (aH.removeEventListener) {
aH.removeEventListener(i, j)
} else {
aH.detachEvent("on" + i, j)
}
}
function aw(aL, aH, aP, aK) {
var aQ = aK.imageScale, aN, aI, aM, j, aJ, aO;
if (!aH.complete) {
return ad("load", function() {
aw(aL, aH, aP, aK)
}, aH)
}
if (!aL.complete) {
return ad("load", function() {
aw(aL, aH, aP, aK)
}, aL)
}
aH.width = aH.width;
aH.height = aH.height;
if (aQ) {
aL.width = aH.width * aQ;
aL.height = aH.height * aQ
}
aP.iw = aL.width;
aP.ih = aL.height;
if (aK.txtOpt) {
aI = aL;
aN = aK.zoomMax * aK.txtScale;
aJ = aP.iw * aN;
aO = aP.ih * aN;
if (aJ < aH.naturalWidth || aO < aH.naturalHeight) {
aI = ax(aL, aJ, aO);
if (aI) {
aP.fimage = aI
}
} else {
aJ = aP.iw;
aO = aP.ih;
aN = 1
}
if (parseFloat(aK.imageRadius)) {
aP.image = aP.fimage = aL = aq(aP.image, aK.imageRadius, aJ, aO, aN)
}
if (!aP.HasText()) {
if (aK.shadow) {
aI = Z(aP.image, aJ, aO, aN, aK.shadow, aK.shadowBlur, aK.shadowOffset);
if (aI) {
aP.fimage = aI.image;
aP.w = aI.width;
aP.h = aI.height
}
}
if (aK.bgColour || aK.bgOutlineThickness) {
aM = aK.bgColour == "tag" ? Y(aP.a, "background-color") : aK.bgColour;
j = aK.bgOutline == "tag" ? Y(aP.a, "color") : (aK.bgOutline || aK.textColour);
aJ = aP.fimage.width;
aO = aP.fimage.height;
if (aK.outlineMethod == "colour") {
aI = aC(aP.fimage, aJ, aO, aN, aM, aK.bgOutlineThickness, aP.outline.colour, aK.padding, aK.bgRadius, 1);
if (aI) {
aP.oimage = aI.image
}
}
aI = aC(aP.fimage, aJ, aO, aN, aM, aK.bgOutlineThickness, j, aK.padding, aK.bgRadius);
if (aI) {
aP.fimage = aI.image;
aP.w = aI.width;
aP.h = aI.height
}
}
if (aK.outlineMethod == "size") {
if (aK.outlineIncrease > 0) {
aP.iw += 2 * aK.outlineIncrease;
aP.ih += 2 * aK.outlineIncrease;
aJ = aN * aP.iw;
aO = aN * aP.ih;
aI = ax(aP.fimage, aJ, aO);
aP.oimage = aI;
aP.fimage = v(aP.fimage, aP.oimage.width, aP.oimage.height)
} else {
aJ = aN * (aP.iw + (2 * aK.outlineIncrease));
aO = aN * (aP.ih + (2 * aK.outlineIncrease));
aI = ax(aP.fimage, aJ, aO);
aP.oimage = v(aI, aP.fimage.width, aP.fimage.height)
}
}
}
}
aP.Init()
}
function Y(aI, aH) {
var j = C.defaultView
, i = aH.replace(/\-([a-z])/g, function(aJ) {
return aJ.charAt(1).toUpperCase()
});
return (j && j.getComputedStyle && j.getComputedStyle(aI, null).getPropertyValue(aH)) || (aI.currentStyle && aI.currentStyle[i])
}
function u(j, aI, aH) {
var i = 1, aJ;
if (aI) {
i = 1 * (j.getAttribute(aI) || aH)
} else {
if (aJ = Y(j, "font-size")) {
i = (aJ.indexOf("px") > -1 && aJ.replace("px", "") * 1) || (aJ.indexOf("pt") > -1 && aJ.replace("pt", "") * 1.25) || aJ * 3.3
}
}
return i
}
function f(i) {
return i.target && ai(i.target.id) ? i.target.id : i.srcElement.parentNode.id
}
function S(aJ, aK) {
var aI, aH, i = parseInt(Y(aK, "width")) / aK.width, j = parseInt(Y(aK, "height")) / aK.height;
if (ai(aJ.offsetX)) {
aI = {
x: aJ.offsetX,
y: aJ.offsetY
}
} else {
aH = ab(aK.id);
if (ai(aJ.changedTouches)) {
aJ = aJ.changedTouches[0]
}
if (aJ.pageX) {
aI = {
x: aJ.pageX - aH.x,
y: aJ.pageY - aH.y
}
}
}
if (aI && i && j) {
aI.x /= i;
aI.y /= j
}
return aI
}
function B(aH) {
var j = aH.target || aH.fromElement.parentNode
, i = y.tc[j.id];
if (i) {
i.mx = i.my = -1;
i.UnFreeze();
i.EndDrag()
}
}
function af(aL) {
var aI, aH = y, j, aK, aJ = f(aL);
for (aI in aH.tc) {
j = aH.tc[aI];
if (j.tttimer) {
clearTimeout(j.tttimer);
j.tttimer = null
}
}
if (aJ && aH.tc[aJ]) {
j = aH.tc[aJ];
if (aK = S(aL, j.canvas)) {
j.mx = aK.x;
j.my = aK.y;
j.Drag(aL, aK)
}
j.drawn = 0
}
}
function z(aI) {
var j = y
, i = C.addEventListener ? 0 : 1
, aH = f(aI);
if (aH && aI.button == i && j.tc[aH]) {
j.tc[aH].BeginDrag(aI)
}
}
function aE(aJ) {
var aH = y, j = C.addEventListener ? 0 : 1, aI = f(aJ), i;
if (aI && aJ.button == j && aH.tc[aI]) {
i = aH.tc[aI];
af(aJ);
if (!i.EndDrag() && !i.touchState) {
i.Clicked(aJ)
}
}
}
function T(aI) {
var j = f(aI), i = (j && y.tc[j]), aH;
if (i && aI.changedTouches) {
if (aI.touches.length == 1 && i.touchState == 0) {
i.touchState = 1;
i.BeginDrag(aI);
if (aH = S(aI, i.canvas)) {
i.mx = aH.x;
i.my = aH.y;
i.drawn = 0
}
} else {
if (aI.targetTouches.length == 2 && i.pinchZoom) {
i.touchState = 3;
i.EndDrag();
i.BeginPinch(aI)
} else {
i.EndDrag();
i.EndPinch();
i.touchState = 0
}
}
}
}
function r(aH) {
var j = f(aH)
, i = (j && y.tc[j]);
if (i && aH.changedTouches) {
switch (i.touchState) {
case 1:
i.Draw();
i.Clicked();
break;
case 2:
i.EndDrag();
break;
case 3:
i.EndPinch()
}
i.touchState = 0
}
}
function az(aL) {
var aI, aH = y, j, aK, aJ = f(aL);
for (aI in aH.tc) {
j = aH.tc[aI];
if (j.tttimer) {
clearTimeout(j.tttimer);
j.tttimer = null
}
}
j = (aJ && aH.tc[aJ]);
if (j && aL.changedTouches && j.touchState) {
switch (j.touchState) {
case 1:
case 2:
if (aK = S(aL, j.canvas)) {
j.mx = aK.x;
j.my = aK.y;
if (j.Drag(aL, aK)) {
j.touchState = 2
}
}
break;
case 3:
j.Pinch(aL)
}
j.drawn = 0
}
}
function ag(aH) {
var i = y
, j = f(aH);
if (j && i.tc[j]) {
aH.cancelBubble = true;
aH.returnValue = false;
aH.preventDefault && aH.preventDefault();
i.tc[j].Wheel((aH.wheelDelta || aH.detail) > 0)
}
}
function ac(aI) {
var aH, j = y;
clearTimeout(j.scrollTimer);
for (aH in j.tc) {
j.tc[aH].Pause()
}
j.scrollTimer = setTimeout(function() {
var aK, aJ = y;
for (aK in aJ.tc) {
aJ.tc[aK].Resume()
}
}, j.scrollPause)
}
function O() {
E(G())
}
function E(aI) {
var j = y.tc, aH;
y.NextFrame(y.interval);
aI = aI || G();
for (aH in j) {
j[aH].Draw(aI)
}
}
function ab(aH) {
var aK = C.getElementById(aH)
, i = aK.getBoundingClientRect()
, aN = C.documentElement
, aL = C.body
, aM = window
, aI = aM.pageXOffset || aN.scrollLeft
, aO = aM.pageYOffset || aN.scrollTop
, aJ = aN.clientLeft || aL.clientLeft
, j = aN.clientTop || aL.clientTop;
return {
x: i.left + aI - aJ,
y: i.top + aO - j
}
}
function V(j, aI, aJ, aH) {
var i = j.radius * j.z1 / (j.z1 + j.z2 + aI.z);
return {
x: aI.x * i * aJ,
y: aI.y * i * aH,
z: aI.z,
w: (j.z1 - aI.z) / j.z2
}
}
function aB(i) {
this.e = i;
this.br = 0;
this.line = [];
this.text = [];
this.original = i.innerText || i.textContent
}
aG = aB.prototype;
aG.Empty = function() {
for (var j = 0; j < this.text.length; ++j) {
if (this.text[j].length) {
return false
}
}
return true
}
;
aG.Lines = function(aJ) {
var aI = aJ ? 1 : 0, aK, j, aH;
aJ = aJ || this.e;
aK = aJ.childNodes;
j = aK.length;
for (aH = 0; aH < j; ++aH) {
if (aK[aH].nodeName == "BR") {
this.text.push(this.line.join(" "));
this.br = 1
} else {
if (aK[aH].nodeType == 3) {
if (this.br) {
this.line = [aK[aH].nodeValue];
this.br = 0
} else {
this.line.push(aK[aH].nodeValue)
}
} else {
this.Lines(aK[aH])
}
}
}
aI || this.br || this.text.push(this.line.join(" "));
return this.text
}
;
aG.SplitWidth = function(aH, aO, aL, aK) {
var aJ, aI, aN, aM = [];
aO.font = aK + "px " + aL;
for (aJ = 0; aJ < this.text.length; ++aJ) {
aN = this.text[aJ].split(/\s+/);
this.line = [aN[0]];
for (aI = 1; aI < aN.length; ++aI) {
if (aO.measureText(this.line.join(" ") + " " + aN[aI]).width > aH) {
aM.push(this.line.join(" "));
this.line = [aN[aI]]
} else {
this.line.push(aN[aI])
}
}
aM.push(this.line.join(" "))
}
return this.text = aM
}
;
function J(i, j) {
this.ts = null;
this.tc = i;
this.tag = j;
this.x = this.y = this.w = this.h = this.sc = 1;
this.z = 0;
this.pulse = 1;
this.pulsate = i.pulsateTo < 1;
this.colour = i.outlineColour;
this.adash = ~~i.outlineDash;
this.agap = ~~i.outlineDashSpace || this.adash;
this.aspeed = i.outlineDashSpeed * 1;
if (this.colour == "tag") {
this.colour = Y(j.a, "color")
} else {
if (this.colour == "tagbg") {
this.colour = Y(j.a, "background-color")
}
}
this.Draw = this.pulsate ? this.DrawPulsate : this.DrawSimple;
this.radius = i.outlineRadius | 0;
this.SetMethod(i.outlineMethod)
}
x = J.prototype;
x.SetMethod = function(aH) {
var j = {
block: ["PreDraw", "DrawBlock"],
colour: ["PreDraw", "DrawColour"],
outline: ["PostDraw", "DrawOutline"],
classic: ["LastDraw", "DrawOutline"],
size: ["PreDraw", "DrawSize"],
none: ["LastDraw"]
}
, i = j[aH] || j.outline;
if (aH == "none") {
this.Draw = function() {
return 1
}
} else {
this.drawFunc = this[i[1]]
}
this[i[0]] = this.Draw
}
;
x.Update = function(aN, aM, aO, aJ, aK, aL, aI, i) {
var j = this.tc.outlineOffset
, aH = 2 * j;
this.x = aK * aN + aI - j;
this.y = aK * aM + i - j;
this.w = aK * aO + aH;
this.h = aK * aJ + aH;
this.sc = aK;
this.z = aL
}
;
x.Ants = function(aM) {
if (!this.adash) {
return
}
var aJ = this.adash, aL = this.agap, aP = this.aspeed, j = aJ + aL, aK = 0, aI = aJ, i = aL, aO = 0, aN = 0, aH;
if (aP) {
aN = L(aP) * (G() - this.ts) / 50;
if (aP < 0) {
aN = 8640000 - aN
}
aP = ~~aN % j
}
if (aP) {
if (aJ >= aP) {
aK = aJ - aP;
aI = aP
} else {
i = j - aP;
aO = aL - i
}
aH = [aK, i, aI, aO]
} else {
aH = [aJ, aL]
}
aM.setLineDash(aH)
}
;
x.DrawOutline = function(aL, i, aK, j, aH, aJ) {
var aI = aD(this.radius, aH / 2, j / 2);
aL.strokeStyle = aJ;
this.Ants(aL);
ar(aL, i, aK, j, aH, aI, true)
}
;
x.DrawSize = function(aO, aR, aP, aS, aM, j, aT, aI, aQ) {
var aL = aT.w, aH = aT.h, aJ, aK, aN;
if (this.pulsate) {
if (aT.image) {
aN = (aT.image.height + this.tc.outlineIncrease) / aT.image.height
} else {
aN = aT.oscale
}
aK = aT.fimage || aT.image;
aJ = 1 + ((aN - 1) * (1 - this.pulse));
aT.h *= aJ;
aT.w *= aJ
} else {
aK = aT.oimage
}
aT.alpha = 1;
aT.Draw(aO, aI, aQ, aK);
aT.h = aH;
aT.w = aL;
return 1
}
;
x.DrawColour = function(aI, aL, aJ, aM, aH, i, aN, j, aK) {
if (aN.oimage) {
if (this.pulse < 1) {
aN.alpha = 1 - at(this.pulse, 2);
aN.Draw(aI, j, aK, aN.fimage);
aN.alpha = this.pulse
} else {
aN.alpha = 1
}
aN.Draw(aI, j, aK, aN.oimage);
return 1
}
return this[aN.image ? "DrawColourImage" : "DrawColourText"](aI, aL, aJ, aM, aH, i, aN, j, aK)
}
;
x.DrawColourText = function(aJ, aM, aK, aN, aH, i, aO, j, aL) {
var aI = aO.colour;
aO.colour = i;
aO.alpha = 1;
aO.Draw(aJ, j, aL);
aO.colour = aI;
return 1
}
;
x.DrawColourImage = function(aM, aP, aN, aQ, aL, i, aT, j, aO) {
var aR = aM.canvas, aJ = ~~s(aP, 0), aI = ~~s(aN, 0), aK = aD(aR.width - aJ, aQ) + 0.5 | 0, aS = aD(aR.height - aI, aL) + 0.5 | 0, aH;
if (p) {
p.width = aK,
p.height = aS
} else {
p = P(aK, aS)
}
if (!p) {
return this.SetMethod("outline")
}
aH = p.getContext("2d");
aH.drawImage(aR, aJ, aI, aK, aS, 0, 0, aK, aS);
aM.clearRect(aJ, aI, aK, aS);
if (this.pulsate) {
aT.alpha = 1 - at(this.pulse, 2)
} else {
aT.alpha = 1
}
aT.Draw(aM, j, aO);
aM.setTransform(1, 0, 0, 1, 0, 0);
aM.save();
aM.beginPath();
aM.rect(aJ, aI, aK, aS);
aM.clip();
aM.globalCompositeOperation = "source-in";
aM.fillStyle = i;
aM.fillRect(aJ, aI, aK, aS);
aM.restore();
aM.globalAlpha = 1;
aM.globalCompositeOperation = "destination-over";
aM.drawImage(p, 0, 0, aK, aS, aJ, aI, aK, aS);
aM.globalCompositeOperation = "source-over";
return 1
}
;
x.DrawBlock = function(aL, i, aK, j, aH, aJ) {
var aI = aD(this.radius, aH / 2, j / 2);
aL.fillStyle = aJ;
ar(aL, i, aK, j, aH, aI)
}
;
x.DrawSimple = function(aL, i, j, aI, aK, aJ) {
var aH = this.tc;
aL.setTransform(1, 0, 0, 1, 0, 0);
aL.strokeStyle = this.colour;
aL.lineWidth = aH.outlineThickness;
aL.shadowBlur = aL.shadowOffsetX = aL.shadowOffsetY = 0;
aL.globalAlpha = aJ ? aK : 1;
return this.drawFunc(aL, this.x, this.y, this.w, this.h, this.colour, i, j, aI)
}
;
x.DrawPulsate = function(aL, i, j, aI) {
var aJ = G() - this.ts
, aH = this.tc
, aK = aH.pulsateTo + ((1 - aH.pulsateTo) * (0.5 + (w(2 * Math.PI * aJ / (1000 * aH.pulsateTime)) / 2)));
this.pulse = aK = y.Smooth(1, aK);
return this.DrawSimple(aL, i, j, aI, aK, 1)
}
;
x.Active = function(aI, i, aH) {
var j = (i >= this.x && aH >= this.y && i <= this.x + this.w && aH <= this.y + this.h);
if (j) {
this.ts = this.ts || G()
} else {
this.ts = null
}
return j
}
;
x.PreDraw = x.PostDraw = x.LastDraw = aA;
function e(aI, aS, aO, aR, aP, aJ, aH, aL, aQ, aK, aN, j, aM, i) {
this.tc = aI;
this.image = null;
this.text = aS;
this.text_original = i;
this.line_widths = [];
this.title = aO.title || null;
this.a = aO;
this.position = new ae(aR[0],aR[1],aR[2]);
this.x = this.y = this.z = 0;
this.w = aP;
this.h = aJ;
this.colour = aH || aI.textColour;
this.bgColour = aL || aI.bgColour;
this.bgRadius = aQ | 0;
this.bgOutline = aK || this.colour;
this.bgOutlineThickness = aN | 0;
this.textFont = j || aI.textFont;
this.padding = aM | 0;
this.sc = this.alpha = 1;
this.weighted = !aI.weight;
this.outline = new J(aI,this)
}
c = e.prototype;
c.Init = function(j) {
var i = this.tc;
this.textHeight = i.textHeight;
if (this.HasText()) {
this.Measure(i.ctxt, i)
} else {
this.w = this.iw;
this.h = this.ih
}
this.SetShadowColour = i.shadowAlpha ? this.SetShadowColourAlpha : this.SetShadowColourFixed;
this.SetDraw(i)
}
;
c.Draw = aA;
c.HasText = function() {
return this.text && this.text[0].length > 0
}
;
c.EqualTo = function(aH) {
var j = aH.getElementsByTagName("img");
if (this.a.href != aH.href) {
return 0
}
if (j.length) {
return this.image.src == j[0].src
}
return (aH.innerText || aH.textContent) == this.text_original
}
;
c.SetImage = function(j) {
this.image = this.fimage = j
}
;
c.SetDraw = function(i) {
this.Draw = this.fimage ? (i.ie > 7 ? this.DrawImageIE : this.DrawImage) : this.DrawText;
i.noSelect && (this.CheckActive = aA)
}
;
c.MeasureText = function(aK) {
var aI, aH = this.text.length, j = 0, aJ;
for (aI = 0; aI < aH; ++aI) {
this.line_widths[aI] = aJ = aK.measureText(this.text[aI]).width;
j = s(j, aJ)
}
return j
}
;
c.Measure = function(aM, aP) {
var aN = t(this.text, this.textFont, this.textHeight), aQ, i, aJ, j, aH, aL, aO, aI, aK;
aO = aN ? aN.max.y + aN.min.y : this.textHeight;
aM.font = this.font = this.textHeight + "px " + this.textFont;
aL = this.MeasureText(aM);
if (aP.txtOpt) {
aQ = aP.txtScale;
i = aQ * this.textHeight;
aJ = i + "px " + this.textFont;
j = [aQ * aP.shadowOffset[0], aQ * aP.shadowOffset[1]];
aM.font = aJ;
aH = this.MeasureText(aM);
aK = new g(this.text,aJ,aH + aQ,(aQ * aO) + aQ,aH,this.line_widths,aP.textAlign,aP.textVAlign,aQ);
if (this.image) {
aK.SetImage(this.image, this.iw, this.ih, aP.imagePosition, aP.imagePadding, aP.imageAlign, aP.imageVAlign, aP.imageScale)
}
aI = aK.Create(this.colour, this.bgColour, this.bgOutline, aQ * this.bgOutlineThickness, aP.shadow, aQ * aP.shadowBlur, j, aQ * this.padding, aQ * this.bgRadius);
if (aP.outlineMethod == "colour") {
this.oimage = aK.Create(this.outline.colour, this.bgColour, this.outline.colour, aQ * this.bgOutlineThickness, aP.shadow, aQ * aP.shadowBlur, j, aQ * this.padding, aQ * this.bgRadius)
} else {
if (aP.outlineMethod == "size") {
aN = t(this.text, this.textFont, this.textHeight + aP.outlineIncrease);
i = aN.max.y + aN.min.y;
aJ = (aQ * (this.textHeight + aP.outlineIncrease)) + "px " + this.textFont;
aM.font = aJ;
aH = this.MeasureText(aM);
aK = new g(this.text,aJ,aH + aQ,(aQ * i) + aQ,aH,this.line_widths,aP.textAlign,aP.textVAlign,aQ);
if (this.image) {
aK.SetImage(this.image, this.iw + aP.outlineIncrease, this.ih + aP.outlineIncrease, aP.imagePosition, aP.imagePadding, aP.imageAlign, aP.imageVAlign, aP.imageScale)
}
this.oimage = aK.Create(this.colour, this.bgColour, this.bgOutline, aQ * this.bgOutlineThickness, aP.shadow, aQ * aP.shadowBlur, j, aQ * this.padding, aQ * this.bgRadius);
this.oscale = this.oimage.width / aI.width;
if (aP.outlineIncrease > 0) {
aI = v(aI, this.oimage.width, this.oimage.height)
} else {
this.oimage = v(this.oimage, aI.width, aI.height)
}
}
}
if (aI) {
this.fimage = aI;
aL = this.fimage.width / aQ;
aO = this.fimage.height / aQ
}
this.SetDraw(aP);
aP.txtOpt = !!this.fimage
}
this.h = aO;
this.w = aL
}
;
c.SetFont = function(j, aI, aH, i) {
this.textFont = j;
this.colour = aI;
this.bgColour = aH;
this.bgOutline = i;
this.Measure(this.tc.ctxt, this.tc)
}
;
c.SetWeight = function(aH) {
var j = this.tc, aJ = j.weightMode.split(/[, ]/), i, aI, aK = aH.length;
if (!this.HasText()) {
return
}
this.weighted = true;
for (aI = 0; aI < aK; ++aI) {
i = aJ[aI] || "size";
if ("both" == i) {
this.Weight(aH[aI], j.ctxt, j, "size", j.min_weight[aI], j.max_weight[aI], aI);
this.Weight(aH[aI], j.ctxt, j, "colour", j.min_weight[aI], j.max_weight[aI], aI)
} else {
this.Weight(aH[aI], j.ctxt, j, i, j.min_weight[aI], j.max_weight[aI], aI)
}
}
this.Measure(j.ctxt, j)
}
;
c.Weight = function(aH, aM, aI, j, aL, aJ, aK) {
aH = isNaN(aH) ? 1 : aH;
var i = (aH - aL) / (aJ - aL);
if ("colour" == j) {
this.colour = k(aI, i, aK)
} else {
if ("bgcolour" == j) {
this.bgColour = k(aI, i, aK)
} else {
if ("bgoutline" == j) {
this.bgOutline = k(aI, i, aK)
} else {
if ("outline" == j) {
this.outline.colour = k(aI, i, aK)
} else {
if ("size" == j) {
if (aI.weightSizeMin > 0 && aI.weightSizeMax > aI.weightSizeMin) {
this.textHeight = aI.weightSize * (aI.weightSizeMin + (aI.weightSizeMax - aI.weightSizeMin) * i)
} else {
this.textHeight = s(1, aH * aI.weightSize)
}
}
}
}
}
}
}
;
c.SetShadowColourFixed = function(aH, j, i) {
aH.shadowColor = j
}
;
c.SetShadowColourAlpha = function(aH, j, i) {
aH.shadowColor = U(j, i)
}
;
c.DrawText = function(aJ, aM, aI) {
var aN = this.tc, aL = this.x, aK = this.y, aO = this.sc, j, aH;
aJ.globalAlpha = this.alpha;
aJ.fillStyle = this.colour;
aN.shadow && this.SetShadowColour(aJ, aN.shadow, this.alpha);
aJ.font = this.font;
aL += aM / aO;
aK += (aI / aO) - (this.h / 2);
for (j = 0; j < this.text.length; ++j) {
aH = aL;
if ("right" == aN.textAlign) {
aH += this.w / 2 - this.line_widths[j]
} else {
if ("centre" == aN.textAlign) {
aH -= this.line_widths[j] / 2
} else {
aH -= this.w / 2
}
}
aJ.setTransform(aO, 0, 0, aO, aO * aH, aO * aK);
aJ.fillText(this.text[j], 0, 0);
aK += this.textHeight
}
}
;
c.DrawImage = function(aJ, aQ, aI, aL) {
var aN = this.x
, aK = this.y
, aR = this.sc
, j = aL || this.fimage
, aO = this.w
, aH = this.h
, aM = this.alpha
, aP = this.shadow;
aJ.globalAlpha = aM;
aP && this.SetShadowColour(aJ, aP, aM);
aN += (aQ / aR) - (aO / 2);
aK += (aI / aR) - (aH / 2);
aJ.setTransform(aR, 0, 0, aR, aR * aN, aR * aK);
aJ.drawImage(j, 0, 0, aO, aH)
}
;
c.DrawImageIE = function(aJ, aN, aI) {
var j = this.fimage
, aO = this.sc
, aM = j.width = this.w * aO
, aH = j.height = this.h * aO
, aL = (this.x * aO) + aN - (aM / 2)
, aK = (this.y * aO) + aI - (aH / 2);
aJ.setTransform(1, 0, 0, 1, 0, 0);
aJ.globalAlpha = this.alpha;
aJ.drawImage(j, aL, aK)
}
;
c.Calc = function(i, aH) {
var j, aK = this.tc, aJ = aK.minBrightness, aI = aK.maxBrightness, aL = aK.max_radius;
j = i.xform(this.position);
this.xformed = j;
j = V(aK, j, aK.stretchX, aK.stretchY);
this.x = j.x;
this.y = j.y;
this.z = j.z;
this.sc = j.w;
this.alpha = aH * av(aJ + (aI - aJ) * (aL - this.z) / (2 * aL), 0, 1);
return this.xformed
}
;
c.UpdateActive = function(aM, aH, aK) {
var aJ = this.outline
, j = this.w
, aI = this.h
, i = this.x - j / 2
, aL = this.y - aI / 2;
aJ.Update(i, aL, j, aI, this.sc, this.z, aH, aK);
return aJ
}
;
c.CheckActive = function(aJ, i, aI) {
var j = this.tc
, aH = this.UpdateActive(aJ, i, aI);
return aH.Active(aJ, j.mx, j.my) ? aH : null
}
;
c.Clicked = function(aK) {
var j = this.a, aH = j.target, aI = j.href, i;
if (aH != "" && aH != "_self") {
if (self.frames[aH]) {
self.frames[aH].document.location = aI
} else {
try {
if (top.frames[aH]) {
top.frames[aH].document.location = aI;
return
}
} catch (aJ) {}
window.open(aI, aH)
}
return
}
if (C.createEvent) {
i = C.createEvent("MouseEvents");
i.initMouseEvent("click", 1, 1, window, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
if (!j.dispatchEvent(i)) {
return
}
} else {
if (j.fireEvent) {
if (!j.fireEvent("onclick")) {
return
}
}
}
C.location = aI
}
;
function y(aN, j, aI) {
var aH, aK, aM = C.getElementById(aN), aJ = ["id", "class", "innerHTML"], aL;
if (!aM) {
throw 0
}
if (ai(window.G_vmlCanvasManager)) {
aM = window.G_vmlCanvasManager.initElement(aM);
this.ie = parseFloat(navigator.appVersion.split("MSIE")[1])
}
if (aM && (!aM.getContext || !aM.getContext("2d").fillText)) {
aK = C.createElement("DIV");
for (aH = 0; aH < aJ.length; ++aH) {
aK[aJ[aH]] = aM[aJ[aH]]
}
aM.parentNode.insertBefore(aK, aM);
aM.parentNode.removeChild(aM);
throw 0
}
for (aH in y.options) {
this[aH] = aI && ai(aI[aH]) ? aI[aH] : (ai(y[aH]) ? y[aH] : y.options[aH])
}
this.canvas = aM;
this.ctxt = aM.getContext("2d");
this.z1 = 250 / s(this.depth, 0.001);
this.z2 = this.z1 / this.zoom;
this.radius = aD(aM.height, aM.width) * 0.0075;
this.max_radius = 100;
this.max_weight = [];
this.min_weight = [];
this.textFont = this.textFont && o(this.textFont);
this.textHeight *= 1;
this.imageRadius = this.imageRadius.toString();
this.pulsateTo = av(this.pulsateTo, 0, 1);
this.minBrightness = av(this.minBrightness, 0, 1);
this.maxBrightness = av(this.maxBrightness, this.minBrightness, 1);
this.ctxt.textBaseline = "top";
this.lx = (this.lock + "").indexOf("x") + 1;
this.ly = (this.lock + "").indexOf("y") + 1;
this.frozen = this.dx = this.dy = this.fixedAnim = this.touchState = 0;
this.fixedAlpha = 1;
this.source = j || aN;
this.repeatTags = aD(64, ~~this.repeatTags);
this.minTags = aD(200, ~~this.minTags);
if (~~this.scrollPause > 0) {
y.scrollPause = ~~this.scrollPause
} else {
this.scrollPause = 0
}
if (this.minTags > 0 && this.repeatTags < 1 && (aH = this.GetTags().length)) {
this.repeatTags = ap(this.minTags / aH) - 1
}
this.transform = R.Identity();
this.startTime = this.time = G();
this.mx = this.my = -1;
this.centreImage && ao(this);
this.Animate = this.dragControl ? this.AnimateDrag : this.AnimatePosition;
this.animTiming = (typeof y[this.animTiming] == "function" ? y[this.animTiming] : y.Smooth);
if (this.shadowBlur || this.shadowOffset[0] || this.shadowOffset[1]) {
this.ctxt.shadowColor = this.shadow;
this.shadow = this.ctxt.shadowColor;
this.shadowAlpha = al()
} else {
delete this.shadow
}
this.Load();
if (j && this.hideTags) {
(function(i) {
if (y.loaded) {
i.HideTags()
} else {
ad("load", function() {
i.HideTags()
}, window)
}
}
)(this)
}
this.yaw = this.initial ? this.initial[0] * this.maxSpeed : 0;
this.pitch = this.initial ? this.initial[1] * this.maxSpeed : 0;
if (this.tooltip) {
this.ctitle = aM.title;
aM.title = "";
if (this.tooltip == "native") {
this.Tooltip = this.TooltipNative
} else {
this.Tooltip = this.TooltipDiv;
if (!this.ttdiv) {
this.ttdiv = C.createElement("div");
this.ttdiv.className = this.tooltipClass;
this.ttdiv.style.position = "absolute";
this.ttdiv.style.zIndex = aM.style.zIndex + 1;
ad("mouseover", function(i) {
i.target.style.display = "none"
}, this.ttdiv);
C.body.appendChild(this.ttdiv)
}
}
} else {
this.Tooltip = this.TooltipNone
}
if (!this.noMouse && !b[aN]) {
b[aN] = [["mousemove", af], ["mouseout", B], ["mouseup", aE], ["touchstart", T], ["touchend", r], ["touchcancel", r], ["touchmove", az]];
if (this.dragControl) {
b[aN].push(["mousedown", z]);
b[aN].push(["selectstart", aA])
}
if (this.wheelZoom) {
b[aN].push(["mousewheel", ag]);
b[aN].push(["DOMMouseScroll", ag])
}
if (this.scrollPause) {
b[aN].push(["scroll", ac, window])
}
for (aH = 0; aH < b[aN].length; ++aH) {
aK = b[aN][aH];
ad(aK[0], aK[1], aK[2] ? aK[2] : aM)
}
}
if (!y.started) {
aL = window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
y.NextFrame = aL ? y.NextFrameRAF : y.NextFrameTimeout;
y.interval = this.interval;
y.NextFrame(this.interval);
y.started = 1
}
}
Q = y.prototype;
Q.SourceElements = function() {
if (C.querySelectorAll) {
return C.querySelectorAll("#" + this.source)
}
return [C.getElementById(this.source)]
}
;
Q.HideTags = function() {
var aH = this.SourceElements(), j;
for (j = 0; j < aH.length; ++j) {
aH[j].style.display = "none"
}
}
;
Q.GetTags = function() {
var aM = this.SourceElements(), aL, aI = [], aK, aJ, aH;
for (aH = 0; aH <= this.repeatTags; ++aH) {
for (aK = 0; aK < aM.length; ++aK) {
aL = aM[aK].getElementsByTagName("a");
for (aJ = 0; aJ < aL.length; ++aJ) {
aI.push(aL[aJ])
}
}
}
return aI
}
;
Q.Message = function(aM) {
var aO = [], aI, j, aH = aM.split(""), aK, aN, aL, aJ;
for (aI = 0; aI < aH.length; ++aI) {
if (aH[aI] != " ") {
j = aI - aH.length / 2;
aK = C.createElement("A");
aK.href = "#";
aK.innerText = aH[aI];
aL = 100 * ah(j / 9);
aJ = -100 * w(j / 9);
aN = new e(this,aH[aI],aK,[aL, 0, aJ],2,18,"#000","#fff",0,0,0,"monospace",2,aH[aI]);
aN.Init();
aO.push(aN)
}
}
return aO
}
;
Q.CreateTag = function(aL) {
var aO, aJ, aP, aK, aN, aH, aM, aI, j = [0, 0, 0];
if ("text" != this.imageMode) {
aO = aL.getElementsByTagName("img");
if (aO.length) {
aJ = new Image;
aJ.src = aO[0].src;
if (!this.imageMode) {
aP = new e(this,"",aL,j,0,0);
aP.SetImage(aJ);
aw(aJ, aO[0], aP, this);
return aP
}
}
}
if ("image" != this.imageMode) {
aN = new aB(aL);
aK = aN.Lines();
if (!aN.Empty()) {
aH = this.textFont || o(Y(aL, "font-family"));
if (this.splitWidth) {
aK = aN.SplitWidth(this.splitWidth, this.ctxt, aH, this.textHeight)
}
aM = this.bgColour == "tag" ? Y(aL, "background-color") : this.bgColour;
aI = this.bgOutline == "tag" ? Y(aL, "color") : this.bgOutline
} else {
aN = null
}
}
if (aN || aJ) {
aP = new e(this,aK,aL,j,2,this.textHeight + 2,this.textColour || Y(aL, "color"),aM,this.bgRadius,aI,this.bgOutlineThickness,aH,this.padding,aN && aN.original);
if (aJ) {
aP.SetImage(aJ);
aw(aJ, aO[0], aP, this)
} else {
aP.Init()
}
return aP
}
}
;
Q.UpdateTag = function(aH, i) {
var aK = this.textColour || Y(i, "color")
, j = this.textFont || o(Y(i, "font-family"))
, aJ = this.bgColour == "tag" ? Y(i, "background-color") : this.bgColour
, aI = this.bgOutline == "tag" ? Y(i, "color") : this.bgOutline;
aH.a = i;
aH.title = i.title;
if (aH.colour != aK || aH.textFont != j || aH.bgColour != aJ || aH.bgOutline != aI) {
aH.SetFont(j, aK, aJ, aI)
}
}
;
Q.Weight = function(aN) {
var aJ = aN.length, aL, aH, aO, aK = [], j, aI = this.weightFrom ? this.weightFrom.split(/[, ]/) : [null], aM = aI.length;
for (aH = 0; aH < aJ; ++aH) {
aK[aH] = [];
for (aO = 0; aO < aM; ++aO) {
aL = u(aN[aH].a, aI[aO], this.textHeight);
if (!this.max_weight[aO] || aL > this.max_weight[aO]) {
this.max_weight[aO] = aL
}
if (!this.min_weight[aO] || aL < this.min_weight[aO]) {
this.min_weight[aO] = aL
}
aK[aH][aO] = aL
}
}
for (aO = 0; aO < aM; ++aO) {
if (this.max_weight[aO] > this.min_weight[aO]) {
j = 1
}
}
if (j) {
for (aH = 0; aH < aJ; ++aH) {
aN[aH].SetWeight(aK[aH])
}
}
}
;
Q.Load = function() {
var aR = this.GetTags(), aM = [], aP, aQ, aL, aI, aH, j, aJ, aO, aK = [], aN = {
sphere: q,
vcylinder: am,
hcylinder: au,
vring: d,
hring: n
};
if (aR.length) {
aK.length = aR.length;
for (aO = 0; aO < aR.length; ++aO) {
aK[aO] = aO
}
this.shuffleTags && an(aK);
aI = 100 * this.radiusX;
aH = 100 * this.radiusY;
j = 100 * this.radiusZ;
this.max_radius = s(aI, s(aH, j));
for (aO = 0; aO < aR.length; ++aO) {
aQ = this.CreateTag(aR[aK[aO]]);
if (aQ) {
aM.push(aQ)
}
}
this.weight && this.Weight(aM, true);
if (this.shapeArgs) {
this.shapeArgs[0] = aM.length
} else {
aL = this.shape.toString().split(/[(),]/);
aP = aL.shift();
if (typeof window[aP] === "function") {
this.shape = window[aP]
} else {
this.shape = aN[aP] || aN.sphere
}
this.shapeArgs = [aM.length, aI, aH, j].concat(aL)
}
aJ = this.shape.apply(this, this.shapeArgs);
this.listLength = aM.length;
for (aO = 0; aO < aM.length; ++aO) {
aM[aO].position = new ae(aJ[aO][0],aJ[aO][1],aJ[aO][2])
}
}
if (this.noTagsMessage && !aM.length) {
aO = (this.imageMode && this.imageMode != "both" ? this.imageMode + " " : "");
aM = this.Message("No " + aO + "tags")
}
this.taglist = aM
}
;
Q.Update = function() {
var aQ = this.GetTags(), aP = [], aK = this.taglist, aR, aO = [], aM = [], aI, aN, aH, aL, aJ;
if (!this.shapeArgs) {
return this.Load()
}
if (aQ.length) {
aH = this.listLength = aQ.length;
aN = aK.length;
for (aL = 0; aL < aN; ++aL) {
aP.push(aK[aL]);
aM.push(aL)
}
for (aL = 0; aL < aH; ++aL) {
for (aJ = 0,
aR = 0; aJ < aN; ++aJ) {
if (aK[aJ].EqualTo(aQ[aL])) {
this.UpdateTag(aP[aJ], aQ[aL]);
aR = aM[aJ] = -1
}
}
if (!aR) {
aO.push(aL)
}
}
for (aL = 0,
aJ = 0; aL < aN; ++aL) {
if (aM[aJ] == -1) {
aM.splice(aJ, 1)
} else {
++aJ
}
}
if (aM.length) {
an(aM);
while (aM.length && aO.length) {
aL = aM.shift();
aJ = aO.shift();
aP[aL] = this.CreateTag(aQ[aJ])
}
aM.sort(function(j, i) {
return j - i
});
while (aM.length) {
aP.splice(aM.pop(), 1)
}
}
aJ = aP.length / (aO.length + 1);
aL = 0;
while (aO.length) {
aP.splice(ap(++aL * aJ), 0, this.CreateTag(aQ[aO.shift()]))
}
this.shapeArgs[0] = aH = aP.length;
aI = this.shape.apply(this, this.shapeArgs);
for (aL = 0; aL < aH; ++aL) {
aP[aL].position = new ae(aI[aL][0],aI[aL][1],aI[aL][2])
}
this.weight && this.Weight(aP)
}
this.taglist = aP
}
;
Q.SetShadow = function(i) {
i.shadowBlur = this.shadowBlur;
i.shadowOffsetX = this.shadowOffset[0];
i.shadowOffsetY = this.shadowOffset[1]
}
;
Q.Draw = function(aR) {
if (this.paused) {
return
}
var aL = this.canvas, aJ = aL.width, aQ = aL.height, aT = 0, aI = (aR - this.time) * y.interval / 1000, aP = aJ / 2 + this.offsetX, aO = aQ / 2 + this.offsetY, aX = this.ctxt, aN, aY, aV, aH = -1, aK = this.taglist, aU = aK.length, j = this.frontSelect, aS = (this.centreFunc == aA), aM;
this.time = aR;
if (this.frozen && this.drawn) {
return this.Animate(aJ, aQ, aI)
}
aM = this.AnimateFixed();
aX.setTransform(1, 0, 0, 1, 0, 0);
for (aV = 0; aV < aU; ++aV) {
aK[aV].Calc(this.transform, this.fixedAlpha)
}
aK = A(aK, function(aZ, i) {
return i.z - aZ.z
});
if (aM && this.fixedAnim.active) {
aN = this.fixedAnim.tag.UpdateActive(aX, aP, aO)
} else {
this.active = null;
for (aV = 0; aV < aU; ++aV) {
aY = this.mx >= 0 && this.my >= 0 && this.taglist[aV].CheckActive(aX, aP, aO);
if (aY && aY.sc > aT && (!j || aY.z <= 0)) {
aN = aY;
aH = aV;
aN.tag = this.taglist[aV];
aT = aY.sc
}
}
this.active = aN
}
this.txtOpt || (this.shadow && this.SetShadow(aX));
aX.clearRect(0, 0, aJ, aQ);
for (aV = 0; aV < aU; ++aV) {
if (!aS && aK[aV].z <= 0) {
try {
this.centreFunc(aX, aJ, aQ, aP, aO)
} catch (aW) {
alert(aW);
this.centreFunc = aA
}
aS = true
}
if (!(aN && aN.tag == aK[aV] && aN.PreDraw(aX, aK[aV], aP, aO))) {
aK[aV].Draw(aX, aP, aO)
}
aN && aN.tag == aK[aV] && aN.PostDraw(aX)
}
if (this.freezeActive && aN) {
this.Freeze()
} else {
this.UnFreeze();
this.drawn = (aU == this.listLength)
}
if (this.fixedCallback) {
this.fixedCallback(this, this.fixedCallbackTag);
this.fixedCallback = null
}
aM || this.Animate(aJ, aQ, aI);
aN && aN.LastDraw(aX);
aL.style.cursor = aN ? this.activeCursor : "";
this.Tooltip(aN, this.taglist[aH])
}
;
Q.TooltipNone = function() {}
;
Q.TooltipNative = function(j, i) {
if (j) {
this.canvas.title = i && i.title ? i.title : ""
} else {
this.canvas.title = this.ctitle
}
}
;
Q.SetTTDiv = function(aI, j) {
var i = this
, aH = i.ttdiv.style;
if (aI != i.ttdiv.innerHTML) {
aH.display = "none"
}
i.ttdiv.innerHTML = aI;
j && (j.title = i.ttdiv.innerHTML);
if (aH.display == "none" && !i.tttimer) {
i.tttimer = setTimeout(function() {
var aJ = ab(i.canvas.id);
aH.display = "block";
aH.left = aJ.x + i.mx + "px";
aH.top = aJ.y + i.my + 24 + "px";
i.tttimer = null
}, i.tooltipDelay)
}
}
;
Q.TooltipDiv = function(j, i) {
if (j && i && i.title) {
this.SetTTDiv(i.title, i)
} else {
if (!j && this.mx != -1 && this.my != -1 && this.ctitle.length) {
this.SetTTDiv(this.ctitle)
} else {
this.ttdiv.style.display = "none"
}
}
}
;
Q.Transform = function(aK, i, aM) {
if (i || aM) {
var j = ah(i)
, aL = w(i)
, aN = ah(aM)
, aJ = w(aM)
, aH = new R([aJ, 0, aN, 0, 1, 0, -aN, 0, aJ])
, aI = new R([1, 0, 0, 0, aL, -j, 0, j, aL]);
aK.transform = aK.transform.mul(aH.mul(aI))
}
}
;
Q.AnimateFixed = function() {
var aH, j, aJ, i, aI;
if (this.fadeIn) {
j = G() - this.startTime;
if (j >= this.fadeIn) {
this.fadeIn = 0;
this.fixedAlpha = 1
} else {
this.fixedAlpha = j / this.fadeIn
}
}
if (this.fixedAnim) {
if (!this.fixedAnim.transform) {
this.fixedAnim.transform = this.transform
}
aH = this.fixedAnim,
j = G() - aH.t0,
aJ = aH.angle,
i,
aI = this.animTiming(aH.t, j);
this.transform = aH.transform;
if (j >= aH.t) {
this.fixedCallbackTag = aH.tag;
this.fixedCallback = aH.cb;
this.fixedAnim = this.yaw = this.pitch = 0
} else {
aJ *= aI
}
i = R.Rotation(aJ, aH.axis);
this.transform = this.transform.mul(i);
return (this.fixedAnim != 0)
}
return false
}
;
Q.AnimatePosition = function(aH, aK, aI) {
var j = this, i = j.mx, aM = j.my, aJ, aL;
if (!j.frozen && i >= 0 && aM >= 0 && i < aH && aM < aK) {
aJ = j.maxSpeed,
aL = j.reverse ? -1 : 1;
j.lx || (j.yaw = ((i * 2 * aJ / aH) - aJ) * aL * aI);
j.ly || (j.pitch = ((aM * 2 * aJ / aK) - aJ) * -aL * aI);
j.initial = null
} else {
if (!j.initial) {
if (j.frozen && !j.freezeDecel) {
j.yaw = j.pitch = 0
} else {
j.Decel(j)
}
}
}
this.Transform(j, j.pitch, j.yaw)
}
;
Q.AnimateDrag = function(j, aJ, aI) {
var i = this
, aH = 100 * aI * i.maxSpeed / i.max_radius / i.zoom;
if (i.dx || i.dy) {
i.lx || (i.yaw = i.dx * aH / i.stretchX);
i.ly || (i.pitch = i.dy * -aH / i.stretchY);
i.dx = i.dy = 0;
i.initial = null
} else {
if (!i.initial) {
i.Decel(i)
}
}
this.Transform(i, i.pitch, i.yaw)
}
;
Q.Freeze = function() {
if (!this.frozen) {
this.preFreeze = [this.yaw, this.pitch];
this.frozen = 1;
this.drawn = 0
}
}
;
Q.UnFreeze = function() {
if (this.frozen) {
this.yaw = this.preFreeze[0];
this.pitch = this.preFreeze[1];
this.frozen = 0
}
}
;
Q.Decel = function(i) {
var aH = i.minSpeed
, aI = L(i.yaw)
, j = L(i.pitch);
if (!i.lx && aI > aH) {
i.yaw = aI > i.z0 ? i.yaw * i.decel : 0
}
if (!i.ly && j > aH) {
i.pitch = j > i.z0 ? i.pitch * i.decel : 0
}
}
;
Q.Zoom = function(i) {
this.z2 = this.z1 * (1 / i);
this.drawn = 0
}
;
Q.Clicked = function(aH) {
var i = this.active;
try {
if (i && i.tag) {
if (this.clickToFront === false || this.clickToFront === null) {
i.tag.Clicked(aH)
} else {
this.TagToFront(i.tag, this.clickToFront, function() {
i.tag.Clicked(aH)
}, true)
}
}
} catch (j) {}
}
;
Q.Wheel = function(j) {
var aH = this.zoom + this.zoomStep * (j ? 1 : -1);
this.zoom = aD(this.zoomMax, s(this.zoomMin, aH));
this.Zoom(this.zoom)
}
;
Q.BeginDrag = function(i) {
this.down = S(i, this.canvas);
i.cancelBubble = true;
i.returnValue = false;
i.preventDefault && i.preventDefault()
}
;
Q.Drag = function(aJ, aI) {
if (this.dragControl && this.down) {
var aH = this.dragThreshold * this.dragThreshold
, j = aI.x - this.down.x
, i = aI.y - this.down.y;
if (this.dragging || j * j + i * i > aH) {
this.dx = j;
this.dy = i;
this.dragging = 1;
this.down = aI
}
}
return this.dragging
}
;
Q.EndDrag = function() {
var i = this.dragging;
this.dragging = this.down = null;
return i
}
;
function D(aH) {
var j = aH.targetTouches[0]
, i = aH.targetTouches[1];
return F(at(i.pageX - j.pageX, 2) + at(i.pageY - j.pageY, 2))
}
Q.BeginPinch = function(i) {
this.pinched = [D(i), this.zoom];
i.preventDefault && i.preventDefault()
}
;
Q.Pinch = function(j) {
var aI, aH, i = this.pinched;
if (!i) {
return
}
aH = D(j);
aI = i[1] * aH / i[0];
this.zoom = aD(this.zoomMax, s(this.zoomMin, aI));
this.Zoom(this.zoom)
}
;
Q.EndPinch = function(i) {
this.pinched = null
}
;
Q.Pause = function() {
this.paused = true
}
;
Q.Resume = function() {
this.paused = false
}
;
Q.SetSpeed = function(j) {
this.initial = j;
this.yaw = j[0] * this.maxSpeed;
this.pitch = j[1] * this.maxSpeed
}
;
Q.FindTag = function(aH) {
if (!ai(aH)) {
return null
}
ai(aH.index) && (aH = aH.index);
if (!I(aH)) {
return this.taglist[aH]
}
var aI, aJ, j;
if (ai(aH.id)) {
aI = "id",
aJ = aH.id
} else {
if (ai(aH.text)) {
aI = "innerText",
aJ = aH.text
}
}
for (j = 0; j < this.taglist.length; ++j) {
if (this.taglist[j].a[aI] == aJ) {
return this.taglist[j]
}
}
}
;
Q.RotateTag = function(aP, aI, aO, i, aM, aH) {
var aN = aP.Calc(this.transform, 1)
, aK = new ae(aN.x,aN.y,aN.z)
, aJ = aj(aO, aI)
, j = aK.angle(aJ)
, aL = aK.cross(aJ).unit();
if (j == 0) {
this.fixedCallbackTag = aP;
this.fixedCallback = aM
} else {
this.fixedAnim = {
angle: -j,
axis: aL,
t: i,
t0: G(),
cb: aM,
tag: aP,
active: aH
}
}
}
;
Q.TagToFront = function(i, aH, aI, j) {
this.RotateTag(i, 0, 0, aH, aI, j)
}
;
y.Start = function(aH, i, j) {
y.Delete(aH);
y.tc[aH] = new y(aH,i,j)
}
;
function ay(i, j) {
y.tc[j] && y.tc[j][i]()
}
y.Linear = function(i, j) {
return j / i
}
;
y.Smooth = function(i, j) {
return 0.5 - w(j * Math.PI / i) / 2
}
;
y.Pause = function(i) {
ay("Pause", i)
}
;
y.Resume = function(i) {
ay("Resume", i)
}
;
y.Reload = function(i) {
ay("Load", i)
}
;
y.Update = function(i) {
ay("Update", i)
}
;
y.SetSpeed = function(j, i) {
if (I(i) && y.tc[j] && !isNaN(i[0]) && !isNaN(i[1])) {
y.tc[j].SetSpeed(i);
return true
}
return false
}
;
y.TagToFront = function(j, i) {
if (!I(i)) {
return false
}
i.lat = i.lng = 0;
return y.RotateTag(j, i)
}
;
y.RotateTag = function(aH, i) {
if (I(i) && y.tc[aH]) {
if (isNaN(i.time)) {
i.time = 500
}
var j = y.tc[aH].FindTag(i);
if (j) {
y.tc[aH].RotateTag(j, i.lat, i.lng, i.time, i.callback, i.active);
return true
}
}
return false
}
;
y.Delete = function(aI) {
var j, aH;
if (b[aI]) {
aH = C.getElementById(aI);
if (aH) {
for (j = 0; j < b[aI].length; ++j) {
a(b[aI][j][0], b[aI][j][1], aH)
}
}
}
delete b[aI];
delete y.tc[aI]
}
;
y.NextFrameRAF = function() {
requestAnimationFrame(E)
}
;
y.NextFrameTimeout = function(i) {
setTimeout(O, i)
}
;
y.tc = {};
y.options = {
z1: 20000,
z2: 20000,
z0: 0.0002,
freezeActive: false,
freezeDecel: false,
activeCursor: "pointer",
pulsateTo: 1,
pulsateTime: 3,
reverse: false,
depth: 0.5,
maxSpeed: 0.05,
minSpeed: 0,
decel: 0.95,
interval: 20,
minBrightness: 0.1,
maxBrightness: 1,
outlineColour: "#ffff99",
outlineThickness: 2,
outlineOffset: 5,
outlineMethod: "outline",
outlineRadius: 0,
textColour: "#ff99ff",
textHeight: 15,
textFont: "Helvetica, Arial, sans-serif",
shadow: "#000",
shadowBlur: 0,
shadowOffset: [0, 0],
initial: null,
hideTags: true,
zoom: 1,
weight: false,
weightMode: "size",
weightFrom: null,
weightSize: 1,
weightSizeMin: null,
weightSizeMax: null,
weightGradient: {
0: "#f00",
0.33: "#ff0",
0.66: "#0f0",
1: "#00f"
},
txtOpt: true,
txtScale: 2,
frontSelect: false,
wheelZoom: true,
zoomMin: 0.3,
zoomMax: 3,
zoomStep: 0.05,
shape: "sphere",
lock: null,
tooltip: null,
tooltipDelay: 300,
tooltipClass: "tctooltip",
radiusX: 1,
radiusY: 1,
radiusZ: 1,
stretchX: 1,
stretchY: 1,
offsetX: 0,
offsetY: 0,
shuffleTags: false,
noSelect: false,
noMouse: false,
imageScale: 1,
paused: false,
dragControl: false,
dragThreshold: 4,
centreFunc: aA,
splitWidth: 0,
animTiming: "Smooth",
clickToFront: false,
fadeIn: 0,
padding: 0,
bgColour: null,
bgRadius: 0,
bgOutline: null,
bgOutlineThickness: 0,
outlineIncrease: 4,
textAlign: "centre",
textVAlign: "middle",
imageMode: null,
imagePosition: null,
imagePadding: 2,
imageAlign: "centre",
imageVAlign: "middle",
noTagsMessage: true,
centreImage: null,
pinchZoom: false,
repeatTags: 0,
minTags: 0,
imageRadius: 0,
scrollPause: false,
outlineDash: 0,
outlineDashSpace: 0,
outlineDashSpeed: 1
};
for (M in y.options) {
y[M] = y.options[M]
}
window.TagCanvas = y;
ad("load", function() {
y.loaded = 1
}, window)
}
)();
/* Zepto v1.1.2-5-g4c456f6 - zepto ajax event fx fx_methods selector touch - zeptojs.com/license */
var Zepto = (function() {
var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
document = window.document,
elementDisplay = {}, classCache = {},
cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
fragmentRE = /^\s*<(\w+|!)[^>]*>/,
singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rootNodeRE = /^(?:body|html)$/i,
capitalRE = /([A-Z])/g,
// special attributes that should be get/set via method calls
methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'],
adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
table = document.createElement('table'),
tableRow = document.createElement('tr'),
containers = {
'tr': document.createElement('tbody'),
'tbody': table, 'thead': table, 'tfoot': table,
'td': tableRow, 'th': tableRow,
'*': document.createElement('div')
},
readyRE = /complete|loaded|interactive/,
classSelectorRE = /^\.([\w-]+)$/,
idSelectorRE = /^#([\w-]*)$/,
simpleSelectorRE = /^[\w-]*$/,
class2type = {},
toString = class2type.toString,
zepto = {},
camelize, uniq,
tempParent = document.createElement('div'),
propMap = {
'tabindex': 'tabIndex',
'readonly': 'readOnly',
'for': 'htmlFor',
'class': 'className',
'maxlength': 'maxLength',
'cellspacing': 'cellSpacing',
'cellpadding': 'cellPadding',
'rowspan': 'rowSpan',
'colspan': 'colSpan',
'usemap': 'useMap',
'frameborder': 'frameBorder',
'contenteditable': 'contentEditable'
}
zepto.matches = function(element, selector) {
if (!selector || !element || element.nodeType !== 1) return false
var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
element.oMatchesSelector || element.matchesSelector
if (matchesSelector) return matchesSelector.call(element, selector)
// fall back to performing a selector:
var match, parent = element.parentNode, temp = !parent
if (temp) (parent = tempParent).appendChild(element)
match = ~zepto.qsa(parent, selector).indexOf(element)
temp && tempParent.removeChild(element)
return match
}
function type(obj) {
return obj == null ? String(obj) :
class2type[toString.call(obj)] || "object"
}
function isFunction(value) { return type(value) == "function" }
function isWindow(obj) { return obj != null && obj == obj.window }
function isDocument(obj) { return obj != null && obj.nodeType == obj.DOCUMENT_NODE }
function isObject(obj) { return type(obj) == "object" }
function isPlainObject(obj) {
return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype
}
function isArray(value) { return value instanceof Array }
function likeArray(obj) { return typeof obj.length == 'number' }
function compact(array) { return filter.call(array, function(item){ return item != null }) }
function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
function dasherize(str) {
return str.replace(/::/g, '/')
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/_/g, '-')
.toLowerCase()
}
uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) }
function classRE(name) {
return name in classCache ?
classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
}
function maybeAddPx(name, value) {
return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
}
function defaultDisplay(nodeName) {
var element, display
if (!elementDisplay[nodeName]) {
element = document.createElement(nodeName)
document.body.appendChild(element)
display = getComputedStyle(element, '').getPropertyValue("display")
element.parentNode.removeChild(element)
display == "none" && (display = "block")
elementDisplay[nodeName] = display
}
return elementDisplay[nodeName]
}
function children(element) {
return 'children' in element ?
slice.call(element.children) :
$.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
}
// `$.zepto.fragment` takes a html string and an optional tag name
// to generate DOM nodes nodes from the given html string.
// The generated DOM nodes are returned as an array.
// This function can be overriden in plugins for example to make
// it compatible with browsers that don't support the DOM fully.
zepto.fragment = function(html, name, properties) {
var dom, nodes, container
// A special case optimization for a single tag
if (singleTagRE.test(html)) dom = $(document.createElement(RegExp.$1))
if (!dom) {
if (html.replace) html = html.replace(tagExpanderRE, "<$1></$2>")
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
container = containers[name]
container.innerHTML = '' + html
dom = $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
})
}
if (isPlainObject(properties)) {
nodes = $(dom)
$.each(properties, function(key, value) {
if (methodAttributes.indexOf(key) > -1) nodes[key](value)
else nodes.attr(key, value)
})
}
return dom
}
// `$.zepto.Z` swaps out the prototype of the given `dom` array
// of nodes with `$.fn` and thus supplying all the Zepto functions
// to the array. Note that `__proto__` is not supported on Internet
// Explorer. This method can be overriden in plugins.
zepto.Z = function(dom, selector) {
dom = dom || []
dom.__proto__ = $.fn
dom.selector = selector || ''
return dom
}
// `$.zepto.isZ` should return `true` if the given object is a Zepto
// collection. This method can be overriden in plugins.
zepto.isZ = function(object) {
return object instanceof zepto.Z
}
// `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
// takes a CSS selector and an optional context (and handles various
// special cases).
// This method can be overriden in plugins.
zepto.init = function(selector, context) {
var dom
// If nothing given, return an empty Zepto collection
if (!selector) return zepto.Z()
// Optimize for string selectors
else if (typeof selector == 'string') {
selector = selector.trim()
// If it's a html fragment, create nodes from it
// Note: In both Chrome 21 and Firefox 15, DOM error 12
// is thrown if the fragment doesn't begin with <
if (selector[0] == '<' && fragmentRE.test(selector))
dom = zepto.fragment(selector, RegExp.$1, context), selector = null
// If there's a context, create a collection on that context first, and select
// nodes from there
else if (context !== undefined) return $(context).find(selector)
// If it's a CSS selector, use it to select nodes.
else dom = zepto.qsa(document, selector)
}
// If a function is given, call it when the DOM is ready
else if (isFunction(selector)) return $(document).ready(selector)
// If a Zepto collection is given, just return it
else if (zepto.isZ(selector)) return selector
else {
// normalize array if an array of nodes is given
if (isArray(selector)) dom = compact(selector)
// Wrap DOM nodes.
else if (isObject(selector))
dom = [selector], selector = null
// If it's a html fragment, create nodes from it
else if (fragmentRE.test(selector))
dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null
// If there's a context, create a collection on that context first, and select
// nodes from there
else if (context !== undefined) return $(context).find(selector)
// And last but no least, if it's a CSS selector, use it to select nodes.
else dom = zepto.qsa(document, selector)
}
// create a new Zepto collection from the nodes found
return zepto.Z(dom, selector)
}
// `$` will be the base `Zepto` object. When calling this
// function just call `$.zepto.init, which makes the implementation
// details of selecting nodes and creating Zepto collections
// patchable in plugins.
$ = function(selector, context){
return zepto.init(selector, context)
}
function extend(target, source, deep) {
for (key in source)
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
if (isPlainObject(source[key]) && !isPlainObject(target[key]))
target[key] = {}
if (isArray(source[key]) && !isArray(target[key]))
target[key] = []
extend(target[key], source[key], deep)
}
else if (source[key] !== undefined) target[key] = source[key]
}
// Copy all but undefined properties from one or more
// objects to the `target` object.
$.extend = function(target){
var deep, args = slice.call(arguments, 1)
if (typeof target == 'boolean') {
deep = target
target = args.shift()
}
args.forEach(function(arg){ extend(target, arg, deep) })
return target
}
// `$.zepto.qsa` is Zepto's CSS selector implementation which
// uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
// This method can be overriden in plugins.
zepto.qsa = function(element, selector){
var found,
maybeID = selector[0] == '#',
maybeClass = !maybeID && selector[0] == '.',
nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked
isSimple = simpleSelectorRE.test(nameOnly)
return (isDocument(element) && isSimple && maybeID) ?
( (found = element.getElementById(nameOnly)) ? [found] : [] ) :
(element.nodeType !== 1 && element.nodeType !== 9) ? [] :
slice.call(
isSimple && !maybeID ?
maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class
element.getElementsByTagName(selector) : // Or a tag
element.querySelectorAll(selector) // Or it's not simple, and we need to query all
)
}
function filtered(nodes, selector) {
return selector == null ? $(nodes) : $(nodes).filter(selector)
}
$.contains = function(parent, node) {
return parent !== node && parent.contains(node)
}
function funcArg(context, arg, idx, payload) {
return isFunction(arg) ? arg.call(context, idx, payload) : arg
}
function setAttribute(node, name, value) {
value == null ? node.removeAttribute(name) : node.setAttribute(name, value)
}
// access className property while respecting SVGAnimatedString
function className(node, value){
var klass = node.className,
svg = klass && klass.baseVal !== undefined
if (value === undefined) return svg ? klass.baseVal : klass
svg ? (klass.baseVal = value) : (node.className = value)
}
// "true" => true
// "false" => false
// "null" => null
// "42" => 42
// "42.5" => 42.5
// "08" => "08"
// JSON => parse if valid
// String => self
function deserializeValue(value) {
var num
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
!/^0/.test(value) && !isNaN(num = Number(value)) ? num :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} catch(e) {
return value
}
}
$.type = type
$.isFunction = isFunction
$.isWindow = isWindow
$.isArray = isArray
$.isPlainObject = isPlainObject
$.isEmptyObject = function(obj) {
var name
for (name in obj) return false
return true
}
$.inArray = function(elem, array, i){
return emptyArray.indexOf.call(array, elem, i)
}
$.camelCase = camelize
$.trim = function(str) {
return str == null ? "" : String.prototype.trim.call(str)
}
// plugin compatibility
$.uuid = 0
$.support = { }
$.expr = { }
$.map = function(elements, callback){
var value, values = [], i, key
if (likeArray(elements))
for (i = 0; i < elements.length; i++) {
value = callback(elements[i], i)
if (value != null) values.push(value)
}
else
for (key in elements) {
value = callback(elements[key], key)
if (value != null) values.push(value)
}
return flatten(values)
}
$.each = function(elements, callback){
var i, key
if (likeArray(elements)) {
for (i = 0; i < elements.length; i++)
if (callback.call(elements[i], i, elements[i]) === false) return elements
} else {
for (key in elements)
if (callback.call(elements[key], key, elements[key]) === false) return elements
}
return elements
}
$.grep = function(elements, callback){
return filter.call(elements, callback)
}
if (window.JSON) $.parseJSON = JSON.parse
// Populate the class2type map
$.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase()
})
// Define methods that will be available on all
// Zepto collections
$.fn = {
// Because a collection acts like an array
// copy over these useful array functions.
forEach: emptyArray.forEach,
reduce: emptyArray.reduce,
push: emptyArray.push,
sort: emptyArray.sort,
indexOf: emptyArray.indexOf,
concat: emptyArray.concat,
// `map` and `slice` in the jQuery API work differently
// from their array counterparts
map: function(fn){
return $($.map(this, function(el, i){ return fn.call(el, i, el) }))
},
slice: function(){
return $(slice.apply(this, arguments))
},
ready: function(callback){
// need to check if document.body exists for IE as that browser reports
// document ready when it hasn't yet created the body element
if (readyRE.test(document.readyState) && document.body) callback($)
else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
return this
},
get: function(idx){
return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length]
},
toArray: function(){ return this.get() },
size: function(){
return this.length
},
remove: function(){
return this.each(function(){
if (this.parentNode != null)
this.parentNode.removeChild(this)
})
},
each: function(callback){
emptyArray.every.call(this, function(el, idx){
return callback.call(el, idx, el) !== false
})
return this
},
filter: function(selector){
if (isFunction(selector)) return this.not(this.not(selector))
return $(filter.call(this, function(element){
return zepto.matches(element, selector)
}))
},
add: function(selector,context){
return $(uniq(this.concat($(selector,context))))
},
is: function(selector){
return this.length > 0 && zepto.matches(this[0], selector)
},
not: function(selector){
var nodes=[]
if (isFunction(selector) && selector.call !== undefined)
this.each(function(idx){
if (!selector.call(this,idx)) nodes.push(this)
})
else {
var excludes = typeof selector == 'string' ? this.filter(selector) :
(likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
this.forEach(function(el){
if (excludes.indexOf(el) < 0) nodes.push(el)
})
}
return $(nodes)
},
has: function(selector){
return this.filter(function(){
return isObject(selector) ?
$.contains(this, selector) :
$(this).find(selector).size()
})
},
eq: function(idx){
return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
},
first: function(){
var el = this[0]
return el && !isObject(el) ? el : $(el)
},
last: function(){
var el = this[this.length - 1]
return el && !isObject(el) ? el : $(el)
},
find: function(selector){
var result, $this = this
if (typeof selector == 'object')
result = $(selector).filter(function(){
var node = this
return emptyArray.some.call($this, function(parent){
return $.contains(parent, node)
})
})
else if (this.length == 1) result = $(zepto.qsa(this[0], selector))
else result = this.map(function(){ return zepto.qsa(this, selector) })
return result
},
closest: function(selector, context){
var node = this[0], collection = false
if (typeof selector == 'object') collection = $(selector)
while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector)))
node = node !== context && !isDocument(node) && node.parentNode
return $(node)
},
parents: function(selector){
var ancestors = [], nodes = this
while (nodes.length > 0)
nodes = $.map(nodes, function(node){
if ((node = node.parentNode) && !isDocument(node) && ancestors.indexOf(node) < 0) {
ancestors.push(node)
return node
}
})
return filtered(ancestors, selector)
},
parent: function(selector){
return filtered(uniq(this.pluck('parentNode')), selector)
},
children: function(selector){
return filtered(this.map(function(){ return children(this) }), selector)
},
contents: function() {
return this.map(function() { return slice.call(this.childNodes) })
},
siblings: function(selector){
return filtered(this.map(function(i, el){
return filter.call(children(el.parentNode), function(child){ return child!==el })
}), selector)
},
empty: function(){
return this.each(function(){ this.innerHTML = '' })
},
// `pluck` is borrowed from Prototype.js
pluck: function(property){
return $.map(this, function(el){ return el[property] })
},
show: function(){
return this.each(function(){
this.style.display == "none" && (this.style.display = '')
if (getComputedStyle(this, '').getPropertyValue("display") == "none")
this.style.display = defaultDisplay(this.nodeName)
})
},
replaceWith: function(newContent){
return this.before(newContent).remove()
},
wrap: function(structure){
var func = isFunction(structure)
if (this[0] && !func)
var dom = $(structure).get(0),
clone = dom.parentNode || this.length > 1
return this.each(function(index){
$(this).wrapAll(
func ? structure.call(this, index) :
clone ? dom.cloneNode(true) : dom
)
})
},
wrapAll: function(structure){
if (this[0]) {
$(this[0]).before(structure = $(structure))
var children
// drill down to the inmost element
while ((children = structure.children()).length) structure = children.first()
$(structure).append(this)
}
return this
},
wrapInner: function(structure){
var func = isFunction(structure)
return this.each(function(index){
var self = $(this), contents = self.contents(),
dom = func ? structure.call(this, index) : structure
contents.length ? contents.wrapAll(dom) : self.append(dom)
})
},
unwrap: function(){
this.parent().each(function(){
$(this).replaceWith($(this).children())
})
return this
},
clone: function(){
return this.map(function(){ return this.cloneNode(true) })
},
hide: function(){
return this.css("display", "none")
},
toggle: function(setting){
return this.each(function(){
var el = $(this)
;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide()
})
},
prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
html: function(html){
return arguments.length === 0 ?
(this.length > 0 ? this[0].innerHTML : null) :
this.each(function(idx){
var originHtml = this.innerHTML
$(this).empty().append( funcArg(this, html, idx, originHtml) )
})
},
text: function(text){
return arguments.length === 0 ?
(this.length > 0 ? this[0].textContent : null) :
this.each(function(){ this.textContent = (text === undefined) ? '' : ''+text })
},
attr: function(name, value){
var result
return (typeof name == 'string' && value === undefined) ?
(this.length == 0 || this[0].nodeType !== 1 ? undefined :
(name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
(!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
) :
this.each(function(idx){
if (this.nodeType !== 1) return
if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name)))
})
},
removeAttr: function(name){
return this.each(function(){ this.nodeType === 1 && setAttribute(this, name) })
},
prop: function(name, value){
name = propMap[name] || name
return (value === undefined) ?
(this[0] && this[0][name]) :
this.each(function(idx){
this[name] = funcArg(this, value, idx, this[name])
})
},
data: function(name, value){
var data = this.attr('data-' + name.replace(capitalRE, '-$1').toLowerCase(), value)
return data !== null ? deserializeValue(data) : undefined
},
val: function(value){
return arguments.length === 0 ?
(this[0] && (this[0].multiple ?
$(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
this[0].value)
) :
this.each(function(idx){
this.value = funcArg(this, value, idx, this.value)
})
},
offset: function(coordinates){
if (coordinates) return this.each(function(index){
var $this = $(this),
coords = funcArg(this, coordinates, index, $this.offset()),
parentOffset = $this.offsetParent().offset(),
props = {
top: coords.top - parentOffset.top,
left: coords.left - parentOffset.left
}
if ($this.css('position') == 'static') props['position'] = 'relative'
$this.css(props)
})
if (this.length==0) return null
var obj = this[0].getBoundingClientRect()
return {
left: obj.left + window.pageXOffset,
top: obj.top + window.pageYOffset,
width: Math.round(obj.width),
height: Math.round(obj.height)
}
},
css: function(property, value){
if (arguments.length < 2) {
var element = this[0], computedStyle = getComputedStyle(element, '')
if(!element) return
if (typeof property == 'string')
return element.style[camelize(property)] || computedStyle.getPropertyValue(property)
else if (isArray(property)) {
var props = {}
$.each(isArray(property) ? property: [property], function(_, prop){
props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop))
})
return props
}
}
var css = ''
if (type(property) == 'string') {
if (!value && value !== 0)
this.each(function(){ this.style.removeProperty(dasherize(property)) })
else
css = dasherize(property) + ":" + maybeAddPx(property, value)
} else {
for (key in property)
if (!property[key] && property[key] !== 0)
this.each(function(){ this.style.removeProperty(dasherize(key)) })
else
css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
}
return this.each(function(){ this.style.cssText += ';' + css })
},
index: function(element){
return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
},
hasClass: function(name){
if (!name) return false
return emptyArray.some.call(this, function(el){
return this.test(className(el))
}, classRE(name))
},
addClass: function(name){
if (!name) return this
return this.each(function(idx){
classList = []
var cls = className(this), newName = funcArg(this, name, idx, cls)
newName.split(/\s+/g).forEach(function(klass){
if (!$(this).hasClass(klass)) classList.push(klass)
}, this)
classList.length && className(this, cls + (cls ? " " : "") + classList.join(" "))
})
},
removeClass: function(name){
return this.each(function(idx){
if (name === undefined) return className(this, '')
classList = className(this)
funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
classList = classList.replace(classRE(klass), " ")
})
className(this, classList.trim())
})
},
toggleClass: function(name, when){
if (!name) return this
return this.each(function(idx){
var $this = $(this), names = funcArg(this, name, idx, className(this))
names.split(/\s+/g).forEach(function(klass){
(when === undefined ? !$this.hasClass(klass) : when) ?
$this.addClass(klass) : $this.removeClass(klass)
})
})
},
scrollTop: function(value){
if (!this.length) return
var hasScrollTop = 'scrollTop' in this[0]
if (value === undefined) return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset
return this.each(hasScrollTop ?
function(){ this.scrollTop = value } :
function(){ this.scrollTo(this.scrollX, value) })
},
scrollLeft: function(value){
if (!this.length) return
var hasScrollLeft = 'scrollLeft' in this[0]
if (value === undefined) return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset
return this.each(hasScrollLeft ?
function(){ this.scrollLeft = value } :
function(){ this.scrollTo(value, this.scrollY) })
},
position: function() {
if (!this.length) return
var elem = this[0],
// Get *real* offsetParent
offsetParent = this.offsetParent(),
// Get correct offsets
offset = this.offset(),
parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset()
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset.top -= parseFloat( $(elem).css('margin-top') ) || 0
offset.left -= parseFloat( $(elem).css('margin-left') ) || 0
// Add offsetParent borders
parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0
parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0
// Subtract the two offsets
return {
top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left
}
},
offsetParent: function() {
return this.map(function(){
var parent = this.offsetParent || document.body
while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static")
parent = parent.offsetParent
return parent
})
}
}
// for now
$.fn.detach = $.fn.remove
// Generate the `width` and `height` functions
;['width', 'height'].forEach(function(dimension){
var dimensionProperty =
dimension.replace(/./, function(m){ return m[0].toUpperCase() })
$.fn[dimension] = function(value){
var offset, el = this[0]
if (value === undefined) return isWindow(el) ? el['inner' + dimensionProperty] :
isDocument(el) ? el.documentElement['scroll' + dimensionProperty] :
(offset = this.offset()) && offset[dimension]
else return this.each(function(idx){
el = $(this)
el.css(dimension, funcArg(this, value, idx, el[dimension]()))
})
}
})
function traverseNode(node, fun) {
fun(node)
for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)
}
// Generate the `after`, `prepend`, `before`, `append`,
// `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
adjacencyOperators.forEach(function(operator, operatorIndex) {
var inside = operatorIndex % 2 //=> prepend, append
$.fn[operator] = function(){
// arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
var argType, nodes = $.map(arguments, function(arg) {
argType = type(arg)
return argType == "object" || argType == "array" || arg == null ?
arg : zepto.fragment(arg)
}),
parent, copyByClone = this.length > 1
if (nodes.length < 1) return this
return this.each(function(_, target){
parent = inside ? target : target.parentNode
// convert all methods to a "before" operation
target = operatorIndex == 0 ? target.nextSibling :
operatorIndex == 1 ? target.firstChild :
operatorIndex == 2 ? target :
null
nodes.forEach(function(node){
if (copyByClone) node = node.cloneNode(true)
else if (!parent) return $(node).remove()
traverseNode(parent.insertBefore(node, target), function(el){
if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
(!el.type || el.type === 'text/javascript') && !el.src)
window['eval'].call(window, el.innerHTML)
})
})
})
}
// after => insertAfter
// prepend => prependTo
// before => insertBefore
// append => appendTo
$.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){
$(html)[operator](this)
return this
}
})
zepto.Z.prototype = $.fn
// Export internal API functions in the `$.zepto` namespace
zepto.uniq = uniq
zepto.deserializeValue = deserializeValue
$.zepto = zepto
return $
})()
window.Zepto = Zepto
window.$ === undefined && (window.$ = Zepto)
;(function($){
var jsonpID = 0,
document = window.document,
key,
name,
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
scriptTypeRE = /^(?:text|application)\/javascript/i,
xmlTypeRE = /^(?:text|application)\/xml/i,
jsonType = 'application/json',
htmlType = 'text/html',
blankRE = /^\s*$/
// trigger a custom event and return false if it was cancelled
function triggerAndReturn(context, eventName, data) {
var event = $.Event(eventName)
$(context).trigger(event, data)
return !event.isDefaultPrevented()
}
// trigger an Ajax "global" event
function triggerGlobal(settings, context, eventName, data) {
if (settings.global) return triggerAndReturn(context || document, eventName, data)
}
// Number of active Ajax requests
$.active = 0
function ajaxStart(settings) {
if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart')
}
function ajaxStop(settings) {
if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop')
}
// triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable
function ajaxBeforeSend(xhr, settings) {
var context = settings.context
if (settings.beforeSend.call(context, xhr, settings) === false ||
triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)
return false
triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])
}
function ajaxSuccess(data, xhr, settings, deferred) {
var context = settings.context, status = 'success'
settings.success.call(context, data, status, xhr)
if (deferred) deferred.resolveWith(context, [data, status, xhr])
triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])
ajaxComplete(status, xhr, settings)
}
// type: "timeout", "error", "abort", "parsererror"
function ajaxError(error, type, xhr, settings, deferred) {
var context = settings.context
settings.error.call(context, xhr, type, error)
if (deferred) deferred.rejectWith(context, [xhr, type, error])
triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type])
ajaxComplete(type, xhr, settings)
}
// status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
function ajaxComplete(status, xhr, settings) {
var context = settings.context
settings.complete.call(context, xhr, status)
triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])
ajaxStop(settings)
}
// Empty function, used as default callback
function empty() {}
$.ajaxJSONP = function(options, deferred){
if (!('type' in options)) return $.ajax(options)
var _callbackName = options.jsonpCallback,
callbackName = ($.isFunction(_callbackName) ?
_callbackName() : _callbackName) || ('jsonp' + (++jsonpID)),
script = document.createElement('script'),
originalCallback = window[callbackName],
responseData,
abort = function(errorType) {
$(script).triggerHandler('error', errorType || 'abort')
},
xhr = { abort: abort }, abortTimeout
if (deferred) deferred.promise(xhr)
$(script).on('load error', function(e, errorType){
clearTimeout(abortTimeout)
$(script).off().remove()
if (e.type == 'error' || !responseData) {
ajaxError(null, errorType || 'error', xhr, options, deferred)
} else {
ajaxSuccess(responseData[0], xhr, options, deferred)
}
window[callbackName] = originalCallback
if (responseData && $.isFunction(originalCallback))
originalCallback(responseData[0])
originalCallback = responseData = undefined
})
if (ajaxBeforeSend(xhr, options) === false) {
abort('abort')
return xhr
}
window[callbackName] = function(){
responseData = arguments
}
script.src = options.url.replace(/=\?/, '=' + callbackName)
document.head.appendChild(script)
if (options.timeout > 0) abortTimeout = setTimeout(function(){
abort('timeout')
}, options.timeout)
return xhr
}
$.ajaxSettings = {
// Default type of request
type: 'GET',
// Callback that is executed before request
beforeSend: empty,
// Callback that is executed if the request succeeds
success: empty,
// Callback that is executed the the server drops error
error: empty,
// Callback that is executed on request complete (both: error and success)
complete: empty,
// The context for the callbacks
context: null,
// Whether to trigger "global" Ajax events
global: true,
// Transport
xhr: function () {
return new window.XMLHttpRequest()
},
// MIME types mapping
// IIS returns Javascript as "application/x-javascript"
accepts: {
script: 'text/javascript, application/javascript, application/x-javascript',
json: jsonType,
xml: 'application/xml, text/xml',
html: htmlType,
text: 'text/plain'
},
// Whether the request is to another domain
crossDomain: false,
// Default timeout
timeout: 0,
// Whether data should be serialized to string
processData: true,
// Whether the browser should be allowed to cache GET responses
cache: true
}
function mimeToDataType(mime) {
if (mime) mime = mime.split(';', 2)[0]
return mime && ( mime == htmlType ? 'html' :
mime == jsonType ? 'json' :
scriptTypeRE.test(mime) ? 'script' :
xmlTypeRE.test(mime) && 'xml' ) || 'text'
}
function appendQuery(url, query) {
if (query == '') return url
return (url + '&' + query).replace(/[&?]{1,2}/, '?')
}
// serialize payload and append it to the URL for GET requests
function serializeData(options) {
if (options.processData && options.data && $.type(options.data) != "string")
options.data = $.param(options.data, options.traditional)
if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
options.url = appendQuery(options.url, options.data), options.data = undefined
}
$.ajax = function(options){
var settings = $.extend({}, options || {}),
deferred = $.Deferred && $.Deferred()
for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
ajaxStart(settings)
if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) &&
RegExp.$2 != window.location.host
if (!settings.url) settings.url = window.location.toString()
serializeData(settings)
if (settings.cache === false) settings.url = appendQuery(settings.url, '_=' + Date.now())
var dataType = settings.dataType, hasPlaceholder = /=\?/.test(settings.url)
if (dataType == 'jsonp' || hasPlaceholder) {
if (!hasPlaceholder)
settings.url = appendQuery(settings.url,
settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?')
return $.ajaxJSONP(settings, deferred)
}
var mime = settings.accepts[dataType],
headers = { },
setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] },
protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
xhr = settings.xhr(),
nativeSetHeader = xhr.setRequestHeader,
abortTimeout
if (deferred) deferred.promise(xhr)
if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest')
setHeader('Accept', mime || '*/*')
if (mime = settings.mimeType || mime) {
if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]
xhr.overrideMimeType && xhr.overrideMimeType(mime)
}
if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET'))
setHeader('Content-Type', settings.contentType || 'application/x-www-form-urlencoded')
if (settings.headers) for (name in settings.headers) setHeader(name, settings.headers[name])
xhr.setRequestHeader = setHeader
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
xhr.onreadystatechange = empty
clearTimeout(abortTimeout)
var result, error = false
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'))
result = xhr.responseText
try {
// http://perfectionkills.com/global-eval-what-are-the-options/
if (dataType == 'script') (1,eval)(result)
else if (dataType == 'xml') result = xhr.responseXML
else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
} catch (e) { error = e }
if (error) ajaxError(error, 'parsererror', xhr, settings, deferred)
else ajaxSuccess(result, xhr, settings, deferred)
} else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred)
}
}
}
if (ajaxBeforeSend(xhr, settings) === false) {
xhr.abort()
ajaxError(null, 'abort', xhr, settings, deferred)
return xhr
}
if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]
var async = 'async' in settings ? settings.async : true
xhr.open(settings.type, settings.url, async, settings.username, settings.password)
for (name in headers) nativeSetHeader.apply(xhr, headers[name])
if (settings.timeout > 0) abortTimeout = setTimeout(function(){
xhr.onreadystatechange = empty
xhr.abort()
ajaxError(null, 'timeout', xhr, settings, deferred)
}, settings.timeout)
// avoid sending empty string (#319)
xhr.send(settings.data ? settings.data : null)
return xhr
}
// handle optional data/success arguments
function parseArguments(url, data, success, dataType) {
var hasData = !$.isFunction(data)
return {
url: url,
data: hasData ? data : undefined,
success: !hasData ? data : $.isFunction(success) ? success : undefined,
dataType: hasData ? dataType || success : success
}
}
$.get = function(url, data, success, dataType){
return $.ajax(parseArguments.apply(null, arguments))
}
$.post = function(url, data, success, dataType){
var options = parseArguments.apply(null, arguments)
options.type = 'POST'
return $.ajax(options)
}
$.getJSON = function(url, data, success){
var options = parseArguments.apply(null, arguments)
options.dataType = 'json'
return $.ajax(options)
}
$.fn.load = function(url, data, success){
if (!this.length) return this
var self = this, parts = url.split(/\s/), selector,
options = parseArguments(url, data, success),
callback = options.success
if (parts.length > 1) options.url = parts[0], selector = parts[1]
options.success = function(response){
self.html(selector ?
$('<div>').html(response.replace(rscript, "")).find(selector)
: response)
callback && callback.apply(self, arguments)
}
$.ajax(options)
return this
}
var escape = encodeURIComponent
function serialize(params, obj, traditional, scope){
var type, array = $.isArray(obj), hash = $.isPlainObject(obj)
$.each(obj, function(key, value) {
type = $.type(value)
if (scope) key = traditional ? scope :
scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']'
// handle data in serializeArray() format
if (!scope && array) params.add(value.name, value.value)
// recurse into nested objects
else if (type == "array" || (!traditional && type == "object"))
serialize(params, value, traditional, key)
else params.add(key, value)
})
}
$.param = function(obj, traditional){
var params = []
params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }
serialize(params, obj, traditional)
return params.join('&').replace(/%20/g, '+')
}
})(Zepto)
;(function($){
var $$ = $.zepto.qsa, _zid = 1, undefined,
slice = Array.prototype.slice,
isFunction = $.isFunction,
isString = function(obj){ return typeof obj == 'string' },
handlers = {},
specialEvents={},
focusinSupported = 'onfocusin' in window,
focus = { focus: 'focusin', blur: 'focusout' },
hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }
specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'
function zid(element) {
return element._zid || (element._zid = _zid++)
}
function findHandlers(element, event, fn, selector) {
event = parse(event)
if (event.ns) var matcher = matcherFor(event.ns)
return (handlers[zid(element)] || []).filter(function(handler) {
return handler
&& (!event.e || handler.e == event.e)
&& (!event.ns || matcher.test(handler.ns))
&& (!fn || zid(handler.fn) === zid(fn))
&& (!selector || handler.sel == selector)
})
}
function parse(event) {
var parts = ('' + event).split('.')
return {e: parts[0], ns: parts.slice(1).sort().join(' ')}
}
function matcherFor(ns) {
return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')
}
function eventCapture(handler, captureSetting) {
return handler.del &&
(!focusinSupported && (handler.e in focus)) ||
!!captureSetting
}
function realEvent(type) {
return hover[type] || (focusinSupported && focus[type]) || type
}
function add(element, events, fn, data, selector, delegator, capture){
var id = zid(element), set = (handlers[id] || (handlers[id] = []))
events.split(/\s/).forEach(function(event){
if (event == 'ready') return $(document).ready(fn)
var handler = parse(event)
handler.fn = fn
handler.sel = selector
// emulate mouseenter, mouseleave
if (handler.e in hover) fn = function(e){
var related = e.relatedTarget
if (!related || (related !== this && !$.contains(this, related)))
return handler.fn.apply(this, arguments)
}
handler.del = delegator
var callback = delegator || fn
handler.proxy = function(e){
e = compatible(e)
if (e.isImmediatePropagationStopped()) return
e.data = data
var result = callback.apply(element, e._args == undefined ? [e] : [e].concat(e._args))
if (result === false) e.preventDefault(), e.stopPropagation()
return result
}
handler.i = set.length
set.push(handler)
if ('addEventListener' in element)
element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
})
}
function remove(element, events, fn, selector, capture){
var id = zid(element)
;(events || '').split(/\s/).forEach(function(event){
findHandlers(element, event, fn, selector).forEach(function(handler){
delete handlers[id][handler.i]
if ('removeEventListener' in element)
element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
})
})
}
$.event = { add: add, remove: remove }
$.proxy = function(fn, context) {
if (isFunction(fn)) {
var proxyFn = function(){ return fn.apply(context, arguments) }
proxyFn._zid = zid(fn)
return proxyFn
} else if (isString(context)) {
return $.proxy(fn[context], fn)
} else {
throw new TypeError("expected function")
}
}
$.fn.bind = function(event, data, callback){
return this.on(event, data, callback)
}
$.fn.unbind = function(event, callback){
return this.off(event, callback)
}
$.fn.one = function(event, selector, data, callback){
return this.on(event, selector, data, callback, 1)
}
var returnTrue = function(){return true},
returnFalse = function(){return false},
ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/,
eventMethods = {
preventDefault: 'isDefaultPrevented',
stopImmediatePropagation: 'isImmediatePropagationStopped',
stopPropagation: 'isPropagationStopped'
}
function compatible(event, source) {
if (source || !event.isDefaultPrevented) {
source || (source = event)
$.each(eventMethods, function(name, predicate) {
var sourceMethod = source[name]
event[name] = function(){
this[predicate] = returnTrue
return sourceMethod && sourceMethod.apply(source, arguments)
}
event[predicate] = returnFalse
})
if (source.defaultPrevented !== undefined ? source.defaultPrevented :
'returnValue' in source ? source.returnValue === false :
source.getPreventDefault && source.getPreventDefault())
event.isDefaultPrevented = returnTrue
}
return event
}
function createProxy(event) {
var key, proxy = { originalEvent: event }
for (key in event)
if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key]
return compatible(proxy, event)
}
$.fn.delegate = function(selector, event, callback){
return this.on(event, selector, callback)
}
$.fn.undelegate = function(selector, event, callback){
return this.off(event, selector, callback)
}
$.fn.live = function(event, callback){
$(document.body).delegate(this.selector, event, callback)
return this
}
$.fn.die = function(event, callback){
$(document.body).undelegate(this.selector, event, callback)
return this
}
$.fn.on = function(event, selector, data, callback, one){
var autoRemove, delegator, $this = this
if (event && !isString(event)) {
$.each(event, function(type, fn){
$this.on(type, selector, data, fn, one)
})
return $this
}
if (!isString(selector) && !isFunction(callback) && callback !== false)
callback = data, data = selector, selector = undefined
if (isFunction(data) || data === false)
callback = data, data = undefined
if (callback === false) callback = returnFalse
return $this.each(function(_, element){
if (one) autoRemove = function(e){
remove(element, e.type, callback)
return callback.apply(this, arguments)
}
if (selector) delegator = function(e){
var evt, match = $(e.target).closest(selector, element).get(0)
if (match && match !== element) {
evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
return (autoRemove || callback).apply(match, [evt].concat(slice.call(arguments, 1)))
}
}
add(element, event, callback, data, selector, delegator || autoRemove)
})
}
$.fn.off = function(event, selector, callback){
var $this = this
if (event && !isString(event)) {
$.each(event, function(type, fn){
$this.off(type, selector, fn)
})
return $this
}
if (!isString(selector) && !isFunction(callback) && callback !== false)
callback = selector, selector = undefined
if (callback === false) callback = returnFalse
return $this.each(function(){
remove(this, event, callback, selector)
})
}
$.fn.trigger = function(event, args){
event = (isString(event) || $.isPlainObject(event)) ? $.Event(event) : compatible(event)
event._args = args
return this.each(function(){
// items in the collection might not be DOM elements
if('dispatchEvent' in this) this.dispatchEvent(event)
else $(this).triggerHandler(event, args)
})
}
// triggers event handlers on current element just as if an event occurred,
// doesn't trigger an actual event, doesn't bubble
$.fn.triggerHandler = function(event, args){
var e, result
this.each(function(i, element){
e = createProxy(isString(event) ? $.Event(event) : event)
e._args = args
e.target = element
$.each(findHandlers(element, event.type || event), function(i, handler){
result = handler.proxy(e)
if (e.isImmediatePropagationStopped()) return false
})
})
return result
}
// shortcut methods for `.bind(event, fn)` for each event type
;('focusin focusout load resize scroll unload click dblclick '+
'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+
'change select keydown keypress keyup error').split(' ').forEach(function(event) {
$.fn[event] = function(callback) {
return callback ?
this.bind(event, callback) :
this.trigger(event)
}
})
;['focus', 'blur'].forEach(function(name) {
$.fn[name] = function(callback) {
if (callback) this.bind(name, callback)
else this.each(function(){
try { this[name]() }
catch(e) {}
})
return this
}
})
$.Event = function(type, props) {
if (!isString(type)) props = type, type = props.type
var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
event.initEvent(type, bubbles, true)
return compatible(event)
}
})(Zepto)
;(function($, undefined){
var prefix = '', eventPrefix, endEventName, endAnimationName,
vendors = { Webkit: 'webkit', Moz: '', O: 'o' },
document = window.document, testEl = document.createElement('div'),
supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,
transform,
transitionProperty, transitionDuration, transitionTiming, transitionDelay,
animationName, animationDuration, animationTiming, animationDelay,
cssReset = {}
function dasherize(str) { return str.replace(/([a-z])([A-Z])/, '$1-$2').toLowerCase() }
function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : name.toLowerCase() }
$.each(vendors, function(vendor, event){
if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
prefix = '-' + vendor.toLowerCase() + '-'
eventPrefix = event
return false
}
})
transform = prefix + 'transform'
cssReset[transitionProperty = prefix + 'transition-property'] =
cssReset[transitionDuration = prefix + 'transition-duration'] =
cssReset[transitionDelay = prefix + 'transition-delay'] =
cssReset[transitionTiming = prefix + 'transition-timing-function'] =
cssReset[animationName = prefix + 'animation-name'] =
cssReset[animationDuration = prefix + 'animation-duration'] =
cssReset[animationDelay = prefix + 'animation-delay'] =
cssReset[animationTiming = prefix + 'animation-timing-function'] = ''
$.fx = {
off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
speeds: { _default: 400, fast: 200, slow: 600 },
cssPrefix: prefix,
transitionEnd: normalizeEvent('TransitionEnd'),
animationEnd: normalizeEvent('AnimationEnd')
}
$.fn.animate = function(properties, duration, ease, callback, delay){
if ($.isFunction(duration))
callback = duration, ease = undefined, duration = undefined
if ($.isFunction(ease))
callback = ease, ease = undefined
if ($.isPlainObject(duration))
ease = duration.easing, callback = duration.complete, delay = duration.delay, duration = duration.duration
if (duration) duration = (typeof duration == 'number' ? duration :
($.fx.speeds[duration] || $.fx.speeds._default)) / 1000
if (delay) delay = parseFloat(delay) / 1000
return this.anim(properties, duration, ease, callback, delay)
}
$.fn.anim = function(properties, duration, ease, callback, delay){
var key, cssValues = {}, cssProperties, transforms = '',
that = this, wrappedCallback, endEvent = $.fx.transitionEnd,
fired = false
if (duration === undefined) duration = $.fx.speeds._default / 1000
if (delay === undefined) delay = 0
if ($.fx.off) duration = 0
if (typeof properties == 'string') {
// keyframe animation
cssValues[animationName] = properties
cssValues[animationDuration] = duration + 's'
cssValues[animationDelay] = delay + 's'
cssValues[animationTiming] = (ease || 'linear')
endEvent = $.fx.animationEnd
} else {
cssProperties = []
// CSS transitions
for (key in properties)
if (supportedTransforms.test(key)) transforms += key + '(' + properties[key] + ') '
else cssValues[key] = properties[key], cssProperties.push(dasherize(key))
if (transforms) cssValues[transform] = transforms, cssProperties.push(transform)
if (duration > 0 && typeof properties === 'object') {
cssValues[transitionProperty] = cssProperties.join(', ')
cssValues[transitionDuration] = duration + 's'
cssValues[transitionDelay] = delay + 's'
cssValues[transitionTiming] = (ease || 'linear')
}
}
wrappedCallback = function(event){
if (typeof event !== 'undefined') {
if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below"
$(event.target).unbind(endEvent, wrappedCallback)
} else
$(this).unbind(endEvent, wrappedCallback) // triggered by setTimeout
fired = true
$(this).css(cssReset)
callback && callback.call(this)
}
if (duration > 0){
this.bind(endEvent, wrappedCallback)
// transitionEnd is not always firing on older Android phones
// so make sure it gets fired
setTimeout(function(){
if (fired) return
wrappedCallback.call(that)
}, (duration * 1000) + 25)
}
// trigger page reflow so new elements can animate
this.size() && this.get(0).clientLeft
this.css(cssValues)
if (duration <= 0) setTimeout(function() {
that.each(function(){ wrappedCallback.call(this) })
}, 0)
return this
}
testEl = null
})(Zepto)
;(function($, undefined){
var document = window.document, docElem = document.documentElement,
origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle
function anim(el, speed, opacity, scale, callback) {
if (typeof speed == 'function' && !callback) callback = speed, speed = undefined
var props = { opacity: opacity }
if (scale) {
props.scale = scale
el.css($.fx.cssPrefix + 'transform-origin', '0 0')
}
return el.animate(props, speed, null, callback)
}
function hide(el, speed, scale, callback) {
return anim(el, speed, 0, scale, function(){
origHide.call($(this))
callback && callback.call(this)
})
}
$.fn.show = function(speed, callback) {
origShow.call(this)
if (speed === undefined) speed = 0
else this.css('opacity', 0)
return anim(this, speed, 1, '1,1', callback)
}
$.fn.hide = function(speed, callback) {
if (speed === undefined) return origHide.call(this)
else return hide(this, speed, '0,0', callback)
}
$.fn.toggle = function(speed, callback) {
if (speed === undefined || typeof speed == 'boolean')
return origToggle.call(this, speed)
else return this.each(function(){
var el = $(this)
el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback)
})
}
$.fn.fadeTo = function(speed, opacity, callback) {
return anim(this, speed, opacity, null, callback)
}
$.fn.fadeIn = function(speed, callback) {
var target = this.css('opacity')
if (target > 0) this.css('opacity', 0)
else target = 1
return origShow.call(this).fadeTo(speed, target, callback)
}
$.fn.fadeOut = function(speed, callback) {
return hide(this, speed, null, callback)
}
$.fn.fadeToggle = function(speed, callback) {
return this.each(function(){
var el = $(this)
el[
(el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut'
](speed, callback)
})
}
})(Zepto)
;(function($){
var zepto = $.zepto, oldQsa = zepto.qsa, oldMatches = zepto.matches
function visible(elem){
elem = $(elem)
return !!(elem.width() || elem.height()) && elem.css("display") !== "none"
}
// Implements a subset from:
// http://api.jquery.com/category/selectors/jquery-selector-extensions/
//
// Each filter function receives the current index, all nodes in the
// considered set, and a value if there were parentheses. The value
// of `this` is the node currently being considered. The function returns the
// resulting node(s), null, or undefined.
//
// Complex selectors are not supported:
// li:has(label:contains("foo")) + li:has(label:contains("bar"))
// ul.inner:first > li
var filters = $.expr[':'] = {
visible: function(){ if (visible(this)) return this },
hidden: function(){ if (!visible(this)) return this },
selected: function(){ if (this.selected) return this },
checked: function(){ if (this.checked) return this },
parent: function(){ return this.parentNode },
first: function(idx){ if (idx === 0) return this },
last: function(idx, nodes){ if (idx === nodes.length - 1) return this },
eq: function(idx, _, value){ if (idx === value) return this },
contains: function(idx, _, text){ if ($(this).text().indexOf(text) > -1) return this },
has: function(idx, _, sel){ if (zepto.qsa(this, sel).length) return this }
}
var filterRe = new RegExp('(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*'),
childRe = /^\s*>/,
classTag = 'Zepto' + (+new Date())
function process(sel, fn) {
// quote the hash in `a[href^=#]` expression
sel = sel.replace(/=#\]/g, '="#"]')
var filter, arg, match = filterRe.exec(sel)
if (match && match[2] in filters) {
filter = filters[match[2]], arg = match[3]
sel = match[1]
if (arg) {
var num = Number(arg)
if (isNaN(num)) arg = arg.replace(/^["']|["']$/g, '')
else arg = num
}
}
return fn(sel, filter, arg)
}
zepto.qsa = function(node, selector) {
return process(selector, function(sel, filter, arg){
try {
var taggedParent
if (!sel && filter) sel = '*'
else if (childRe.test(sel))
// support "> *" child queries by tagging the parent node with a
// unique class and prepending that classname onto the selector
taggedParent = $(node).addClass(classTag), sel = '.'+classTag+' '+sel
var nodes = oldQsa(node, sel)
} catch(e) {
console.error('error performing selector: %o', selector)
throw e
} finally {
if (taggedParent) taggedParent.removeClass(classTag)
}
return !filter ? nodes :
zepto.uniq($.map(nodes, function(n, i){ return filter.call(n, i, nodes, arg) }))
})
}
zepto.matches = function(node, selector){
return process(selector, function(sel, filter, arg){
return (!sel || oldMatches(node, sel)) &&
(!filter || filter.call(node, null, arg) === node)
})
}
})(Zepto)
;(function($){
var touch = {},
touchTimeout, tapTimeout, swipeTimeout, longTapTimeout,
longTapDelay = 750,
gesture
function swipeDirection(x1, x2, y1, y2) {
return Math.abs(x1 - x2) >=
Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
}
function longTap() {
longTapTimeout = null
if (touch.last) {
touch.el.trigger('longTap')
touch = {}
}
}
function cancelLongTap() {
if (longTapTimeout) clearTimeout(longTapTimeout)
longTapTimeout = null
}
function cancelAll() {
if (touchTimeout) clearTimeout(touchTimeout)
if (tapTimeout) clearTimeout(tapTimeout)
if (swipeTimeout) clearTimeout(swipeTimeout)
if (longTapTimeout) clearTimeout(longTapTimeout)
touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null
touch = {}
}
function isPrimaryTouch(event){
return (event.pointerType == 'touch' ||
event.pointerType == event.MSPOINTER_TYPE_TOUCH)
&& event.isPrimary
}
function isPointerEventType(e, type){
return (e.type == 'pointer'+type ||
e.type.toLowerCase() == 'mspointer'+type)
}
$(document).ready(function(){
var now, delta, deltaX = 0, deltaY = 0, firstTouch, _isPointerType
if ('MSGesture' in window) {
gesture = new MSGesture()
gesture.target = document.body
}
$(document)
.bind('MSGestureEnd', function(e){
var swipeDirectionFromVelocity =
e.velocityX > 1 ? 'Right' : e.velocityX < -1 ? 'Left' : e.velocityY > 1 ? 'Down' : e.velocityY < -1 ? 'Up' : null;
if (swipeDirectionFromVelocity) {
touch.el.trigger('swipe')
touch.el.trigger('swipe'+ swipeDirectionFromVelocity)
}
})
.on('touchstart MSPointerDown pointerdown', function(e){
if((_isPointerType = isPointerEventType(e, 'down')) &&
!isPrimaryTouch(e)) return
firstTouch = _isPointerType ? e : e.touches[0]
if (e.touches && e.touches.length === 1 && touch.x2) {
// Clear out touch movement data if we have it sticking around
// This can occur if touchcancel doesn't fire due to preventDefault, etc.
touch.x2 = undefined
touch.y2 = undefined
}
now = Date.now()
delta = now - (touch.last || now)
touch.el = $('tagName' in firstTouch.target ?
firstTouch.target : firstTouch.target.parentNode)
touchTimeout && clearTimeout(touchTimeout)
touch.x1 = firstTouch.pageX
touch.y1 = firstTouch.pageY
if (delta > 0 && delta <= 250) touch.isDoubleTap = true
touch.last = now
longTapTimeout = setTimeout(longTap, longTapDelay)
// adds the current touch contact for IE gesture recognition
if (gesture && _isPointerType) gesture.addPointer(e.pointerId);
})
.on('touchmove MSPointerMove pointermove', function(e){
if((_isPointerType = isPointerEventType(e, 'move')) &&
!isPrimaryTouch(e)) return
firstTouch = _isPointerType ? e : e.touches[0]
cancelLongTap()
touch.x2 = firstTouch.pageX
touch.y2 = firstTouch.pageY
deltaX += Math.abs(touch.x1 - touch.x2)
deltaY += Math.abs(touch.y1 - touch.y2)
})
.on('touchend MSPointerUp pointerup', function(e){
if((_isPointerType = isPointerEventType(e, 'up')) &&
!isPrimaryTouch(e)) return
cancelLongTap()
// swipe
if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||
(touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
swipeTimeout = setTimeout(function() {
touch.el.trigger('swipe')
touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
touch = {}
}, 0)
// normal tap
else if ('last' in touch)
// don't fire tap when delta position changed by more than 30 pixels,
// for instance when moving to a point and back to origin
if (deltaX < 30 && deltaY < 30) {
// delay by one tick so we can cancel the 'tap' event if 'scroll' fires
// ('tap' fires before 'scroll')
tapTimeout = setTimeout(function() {
// trigger universal 'tap' with the option to cancelTouch()
// (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
var event = $.Event('tap')
event.cancelTouch = cancelAll
touch.el.trigger(event)
// trigger double tap immediately
if (touch.isDoubleTap) {
if (touch.el) touch.el.trigger('doubleTap')
touch = {}
}
// trigger single tap after 250ms of inactivity
else {
touchTimeout = setTimeout(function(){
touchTimeout = null
if (touch.el) touch.el.trigger('singleTap')
touch = {}
}, 250)
}
}, 0)
} else {
touch = {}
}
deltaX = deltaY = 0
})
// when the browser window loses focus,
// for example when a modal dialog is shown,
// cancel all ongoing events
.on('touchcancel MSPointerCancel pointercancel', cancelAll)
// scrolling the window indicates intention of the user
// to scroll, not tap or swipe, so cancel all ongoing events
$(window).on('scroll', cancelAll)
})
;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown',
'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
$.fn[eventName] = function(callback){ return this.on(eventName, callback) }
})
})(Zepto)
@-webkit-keyframes slowMovingToLeft {
from {
left: 1000px;
}
to {
left: -1500px;
}
}
@keyframes slowMovingToLeft {
from {
left: 1000px;
}
to {
left: -1500px;
}
}
body,
html {
height: 100%;
font-size: 14px;
font-family: 'PingFang SC', Microsoft YaHei, '微软雅黑', Tahoma, Arial, HeiTi,
'黑体', sans-serif;
}
li {
list-style: none;
}
a {
text-decoration: none;
color: #333;
}
i {
font-style: normal;
}
p,
body,
ul,
figure {
padding: 0px;
margin: 0px;
}
input {
outline: none;
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
background-color: transparent;
}
body {
overflow: hidden;
}
.el-form-item {
margin-bottom: 5px !important;
}
.el-dialog__body {
padding-top: 20px !important;
padding-bottom: 20px !important;
}
@import './base.scss';
@import './animation.scss';
<template>
<el-dialog
:visible="visible"
:append-to-body="true"
title="抽奖配置"
width="400px"
:lock-scroll="true"
@close="$emit('update:visible', false)"
class="c-LotteryConfig"
>
<el-form ref="form" :model="form" label-width="100px" size="mini">
<el-form-item label="抽奖标题">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="抽奖总人数">
<el-input v-model="form.number"></el-input>
</el-form-item>
<el-form-item label="特等奖人数">
<el-input v-model="form.specialAward"></el-input>
</el-form-item>
<el-form-item label="一等奖人数">
<el-input v-model="form.firstPrize"></el-input>
</el-form-item>
<el-form-item label="二等奖人数">
<el-input v-model="form.secondPrize"></el-input>
</el-form-item>
<el-form-item label="三等奖人数">
<el-input v-model="form.thirdPrize"></el-input>
</el-form-item>
<el-form-item label="四等奖人数">
<el-input v-model="form.fourthPrize"></el-input>
</el-form-item>
<el-form-item label="五等奖人数">
<el-input v-model="form.fifthPrize"></el-input>
</el-form-item>
<el-form-item label="追加奖(1)人数">
<el-input v-model="form.additionalPrize1"></el-input>
</el-form-item>
<el-form-item label="追加奖(2)人数">
<el-input v-model="form.additionalPrize2"></el-input>
</el-form-item>
<el-form-item label="追加奖(3)人数">
<el-input v-model="form.additionalPrize3"></el-input>
</el-form-item>
<el-form-item label="追加奖(4)人数">
<el-input v-model="form.additionalPrize4"></el-input>
</el-form-item>
<el-form-item label="追加奖(5)人数">
<el-input v-model="form.additionalPrize5"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">保存配置</el-button>
<el-button @click="$emit('update:visible', false)">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script>
import { setData, configField } from '@/helper/index';
export default {
name: 'LotteryConfig',
props: {
visible: Boolean
},
computed: {
form: {
get() {
return this.$store.state.config;
},
set(val) {
this.$store.commit('setConfig', val);
}
}
},
methods: {
onSubmit() {
setData(configField, this.form);
this.$emit('update:visible', false);
this.$emit('resetconfig');
this.$message({
message: '保存成功',
type: 'success'
});
}
}
};
</script>
<style lang="scss">
.c-LotteryConfig {
}
</style>
<template>
<div class="c-Publicity">
<div class="message">
<span class="title">
{{ config.name }}
</span>
<span v-html="message"> </span>
</div>
</div>
</template>
<script>
import { conversionCategoryName } from '@/helper/index';
export default {
name: 'Publicity',
computed: {
config() {
return this.$store.state.config;
},
result() {
return this.$store.state.result;
},
message() {
const {
specialAward,
additionalPrize1,
additionalPrize2,
additionalPrize3
} = this.config;
const fields = [
'firstPrize',
'secondPrize',
'thirdPrize',
'fourthPrize',
'fifthPrize'
];
if (specialAward > 0) {
fields.unshift('specialAward');
}
if (additionalPrize1 > 0) {
fields.push('additionalPrize1');
}
if (additionalPrize2 > 0) {
fields.push('additionalPrize2');
}
if (additionalPrize3 > 0) {
fields.push('additionalPrize3');
}
const { result } = this;
let message = '';
fields.forEach(item => {
let label = conversionCategoryName(item);
message += `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${label}抽奖结果: ${
result[item].length > 0 ? result[item].join('、') : '暂未抽取'
}`;
});
return message;
}
}
};
</script>
<style lang="scss">
.c-Publicity {
height: 100%;
width: 1000px;
background-color: rgba(0, 0, 0, 0.2);
margin: 0 auto;
position: relative;
overflow: hidden;
.message {
font-size: 16px;
color: #fff;
position: absolute;
left: 500px;
animation-name: slowMovingToLeft;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-direction: normal;
animation-duration: 40s;
.title {
color: #ff2200;
}
}
}
</style>
<template>
<el-dialog
:visible="visible"
@close="$emit('update:visible', false)"
title="抽奖结果"
width="600px"
class="c-Result"
>
<div
v-for="(item, index) in resultList"
:key="index"
class="listrow"
@click="
event => {
deleteRes(event, item);
}
"
>
<span class="name">
{{ item.name }}
</span>
<span class="value">
<span v-if="item.value && item.value.length === 0">
暂未抽奖
</span>
<span
class="card"
v-for="(data, j) in item.value"
:key="j"
:data-res="data"
>
{{ data }}
</span>
</span>
</div>
</el-dialog>
</template>
<script>
import { conversionCategoryName, getDomData } from '@/helper/index';
export default {
name: 'c-Result',
props: {
visible: Boolean
},
computed: {
result: {
get() {
return this.$store.state.result;
},
set(val) {
this.$store.commit('setResult', val);
}
},
resultList() {
const list = [];
for (const key in this.result) {
if (this.result.hasOwnProperty(key)) {
const element = this.result[key];
let name = conversionCategoryName(key);
list.push({
label: key,
name,
value: element
});
}
}
return list;
}
},
methods: {
deleteRes(event, row) {
this.$confirm('此操作将移除该中奖号码,确认删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
const Index = getDomData(event.target, 'res');
if (Index) {
const result = this.result;
result[row.label] = this.result[row.label].filter(
item => item !== Number(Index)
);
this.result = result;
this.$message({
type: 'success',
message: '删除成功!'
});
}
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
}
}
};
</script>
<style lang="scss">
.c-Result {
.listrow {
display: flex;
line-height: 30px;
.name {
width: 80px;
font-weight: bold;
}
.value {
flex: 1;
}
.card {
display: inline-block;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 18px;
font-weight: bold;
border-radius: 4px;
border: 1px solid #ccc;
background-color: #f2f2f2;
margin-left: 5px;
margin-top: 5px;
position: relative;
cursor: pointer;
&:hover {
&::before {
content: '删除';
width: 100%;
height: 100%;
background-color: #ccc;
position: absolute;
left: 0;
top: 0;
color: red;
}
}
}
}
}
</style>
<template>
<div id="tool">
<el-button @click="startHandler" size="mini">{{
running ? '停止' : '开始'
}}</el-button>
<el-button size="mini" @click="resetConfig">
重置
</el-button>
<el-dialog
:append-to-body="true"
:visible.sync="showSetwat"
class="setwat-dialog"
width="400px"
>
<el-form ref="form" :model="form" label-width="80px" size="mini">
<el-form-item label="抽取奖项">
<el-select v-model="form.category" placeholder="请选取本次抽取的奖项">
<el-option
:label="item.label"
:value="item.value"
v-for="(item, index) in categorys"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label=" " v-if="form.category">
<span>
<span class="colorred">{{ config[form.category] }}</span
>
</span>
<span :style="{ marginLeft: '20px' }">
剩余<span class="colorred">{{ remain }}</span
>
</span>
</el-form-item>
<el-form-item label="抽取方式">
<el-select v-model="form.mode" placeholder="请选取本次抽取方式">
<el-option label="抽1人" :value="1"></el-option>
<el-option label="抽5人" :value="5"></el-option>
<el-option label="一次抽取完" :value="0"></el-option>
<el-option label="自定义" :value="99"></el-option>
</el-select>
</el-form-item>
<el-form-item label="抽取人数" v-if="form.mode === 99">
<el-input
v-model="form.qty"
type="number"
:clearable="true"
:min="1"
:max="remain ? remain : 100"
:step="1"
></el-input>
</el-form-item>
<el-form-item label="全员参与">
<el-switch v-model="form.allin"></el-switch>
<span :style="{ fontSize: '12px' }">
(开启后将在全体成员[无论有无中奖]中抽奖)
</span>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">立即抽奖</el-button>
<el-button @click="showSetwat = false">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { clearData, conversionCategoryName } from '@/helper/index';
export default {
props: {
running: Boolean
},
computed: {
config: {
get() {
return this.$store.state.config;
}
},
remain() {
return (
this.config[this.form.category] -
(this.result[this.form.category]
? this.result[this.form.category].length
: 0)
);
},
result() {
return this.$store.state.result;
},
categorys() {
const options = [];
for (const key in this.config) {
if (this.config.hasOwnProperty(key)) {
const item = this.config[key];
if (item > 0) {
let name = conversionCategoryName(key);
name &&
options.push({
label: name,
value: key
});
}
}
}
return options;
}
},
data() {
return {
showSetwat: false,
form: {
category: '',
mode: 1,
qty: 1,
allin: false
}
};
},
methods: {
resetConfig() {
this.$confirm('此操作将重置所有数据,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
clearData();
this.$message({
type: 'success',
message: '重置成功!'
});
setTimeout(() => {
window.location.reload();
}, 3000);
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
onSubmit() {
if (!this.form.category) {
return this.$message.error('请选择本次抽取的奖项');
}
if (this.remain <= 0) {
return this.$message.error('该奖项剩余人数不足');
}
if (this.form.mode === 99) {
if (this.form.qty <= 0) {
return this.$message.error('必须输入本次抽取人数');
}
if (this.form.qty > this.remain) {
return this.$message.error('本次抽奖人数已超过本奖项的剩余人数');
}
}
if (this.form.mode === 1 || this.form.mode === 5) {
if (this.form.mode > this.remain) {
return this.$message.error('本次抽奖人数已超过本奖项的剩余人数');
}
}
this.showSetwat = false;
this.$emit(
'toggle',
Object.assign({}, this.form, { remain: this.remain })
);
},
startHandler() {
if (this.running) {
this.$emit('toggle');
} else {
this.showSetwat = true;
}
}
}
};
</script>
<style lang="scss">
#tool {
position: fixed;
width: 60px;
height: 500px;
top: 50%;
right: 20px;
transform: translateY(-50%);
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.el-button + .el-button {
margin-top: 10px;
margin-left: 0px;
}
}
.setwat-dialog {
.colorred {
color: red;
font-weight: bold;
}
}
</style>
/**
* 取范围内随机整数
* @param {number} minNum
* @param {number} maxNum
*/
function randomNum(minNum = 1, maxNum) {
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
}
/**
* 单次抽奖
* @param {number} total 总人数
* @param {array} won 已中奖
* @param {number} num 本次抽取人数
*/
export function luckydrawHandler(total, won = [], num) {
const peolist = [];
for (let i = 1; i <= total; i++) {
peolist.push(i);
}
const wons = won;
const res = [];
for (let j = 0; j < num; j++) {
const nodraws = peolist.filter(item => !wons.includes(item));
const current = nodraws[randomNum(1, nodraws.length) - 1];
res.push(current);
wons.push(current);
}
return res;
}
export function setData(key, value) {
if (typeof value === 'string') {
return localStorage.setItem(key, value);
}
try {
localStorage.setItem(key, JSON.stringify(value));
} catch (err) {
return err;
}
}
export function getData(key) {
const value = localStorage.getItem(key);
try {
return JSON.parse(value);
} catch (err) {
return value;
}
}
export function removeData(key) {
return localStorage.removeItem(key);
}
export function clearData() {
return localStorage.clear();
}
export function getDomData(element, dataName) {
if (!element || !dataName || !element.getAttribute) {
return;
}
return element.getAttribute('data-' + dataName);
}
export const configField = 'config'; // 配置数据
export const resultField = 'result'; // 抽奖结果
export function conversionCategoryName(key) {
let name = '';
switch (key) {
case 'specialAward':
name = '特等奖';
break;
case 'firstPrize':
name = '一等奖';
break;
case 'secondPrize':
name = '二等奖';
break;
case 'thirdPrize':
name = '三等奖';
break;
case 'fourthPrize':
name = '四等奖';
break;
case 'fifthPrize':
name = '五等奖';
break;
case 'additionalPrize1':
name = '追加奖(1)';
break;
case 'additionalPrize2':
name = '追加奖(2)';
break;
case 'additionalPrize3':
name = '追加奖(3)';
break;
case 'additionalPrize4':
name = '追加奖(4)';
break;
case 'additionalPrize5':
name = '追加奖(5)';
break;
default:
break;
}
return name;
}
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import Element from 'element-ui';
import '@/assets/style/index.scss';
import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/lib/tagcanvas.js';
Vue.config.productionTip = false;
Vue.use(Element);
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app');
import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/Home.vue';
Vue.use(VueRouter);
const routes = [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () =>
import(/* webpackChunkName: "about" */ '../views/About.vue')
}
];
const router = new VueRouter({
base: process.env.BASE_URL,
routes
});
export default router;
import Vue from 'vue';
import Vuex from 'vuex';
import { setData, resultField } from '@/helper/index';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
config: {
name: '年会抽奖',
number: 70,
specialAward: 0,
firstPrize: 1,
secondPrize: 5,
thirdPrize: 8,
fourthPrize: 10,
fifthPrize: 20,
additionalPrize1: 0,
additionalPrize2: 0,
additionalPrize3: 0,
additionalPrize4: 0,
additionalPrize5: 0
},
result: {
specialAward: [],
firstPrize: [],
secondPrize: [],
thirdPrize: [],
fourthPrize: [],
fifthPrize: [],
additionalPrize1: [],
additionalPrize2: [],
additionalPrize3: [],
additionalPrize4: [],
additionalPrize5: []
}
},
mutations: {
setConfig(state, config) {
state.config = config;
},
setResult(state, result = {}) {
Object.assign(state.result, result);
setData(resultField, state.result);
}
},
actions: {},
modules: {}
});
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png" />
</div>
</template>
<script>
export default {
name: 'home'
};
</script>
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/lucky-draw' : '/'
};
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment