1/** 2 * jQuery.browser.mobile (http://detectmobilebrowser.com/) 3 * 4 * jQuery.browser.mobile will be true if the browser is a mobile device 5 * 6 **/ 7(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera); 8// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 9// â Raphaël 2.1.2 - JavaScript Vector Library â \\ 10// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 11// â Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) â \\ 12// â Copyright © 2008-2012 Sencha Labs (http://sencha.com) â \\ 13// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 14// â Licensed under the MIT (http://raphaeljs.com/license.html) license.â \\ 15// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 16// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. 17// 18// Licensed under the Apache License, Version 2.0 (the "License"); 19// you may not use this file except in compliance with the License. 20// You may obtain a copy of the License at 21// 22// http://www.apache.org/licenses/LICENSE-2.0 23// 24// Unless required by applicable law or agreed to in writing, software 25// distributed under the License is distributed on an "AS IS" BASIS, 26// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27// See the License for the specific language governing permissions and 28// limitations under the License. 29// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 30// â Eve 0.4.2 - JavaScript Events Library â \\ 31// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\
32// â Author Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) â \\ 33// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 34 35(function (glob) { 36 var version = "0.4.2", 37 has = "hasOwnProperty", 38 separator = /[\.\/]/, 39 wildcard = "*", 40 fun = function () {}, 41 numsort = function (a, b) { 42 return a - b; 43 }, 44 current_event, 45 stop, 46 events = {n: {}}, 47 /*\ 48 * eve 49 [ method ] 50 51 * Fires event with given `name`, given scope and other parameters. 52 53 > Arguments 54 55 - name (string) name of the *event*, dot (`.`) or slash (`/`) separated 56 - scope (object) context for the event handlers 57 - varargs (...) the rest of arguments will be sent to event handlers 58 59 = (object) array of returned values from the listeners 60 \*/ 61 eve = function (name, scope) { 62 name = String(name); 63 var e = events, 64 oldstop = stop, 65 args = Array.prototype.slice.call(arguments, 2), 66 listeners = eve.listeners(name), 67 z = 0, 68 f = false, 69 l, 70 indexed = [], 71 queue = {}, 72 out = [], 73 ce = current_event, 74 errors = []; 75 current_event = name; 76 stop = 0; 77 for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) { 78 indexed.push(listeners[i].zIndex); 79 if (listeners[i].zIndex < 0) { 80 queue[listeners[i].zIndex] = listeners[i]; 81 } 82 } 83 indexed.sort(numsort); 84 while (indexed[z] < 0) { 85 l = queue[indexed[z++]]; 86 out.push(l.apply(scope, args)); 87 if (stop) { 88 stop = oldstop; 89 return out; 90 } 91 } 92 for (i = 0; i < ii; i++) { 93 l = listeners[i]; 94 if ("zIndex" in l) { 95 if (l.zIndex == indexed[z]) { 96 out.push(l.apply(scope, args)); 97 if (stop) { 98 break; 99 } 100 do { 101 z++; 102 l = queue[indexed[z]]; 103 l && out.push(l.apply(scope, args)); 104 if (stop) { 105 break; 106 } 107 } while (l) 108 } else { 109 queue[l.zIndex] = l; 110 } 111 } else { 112 out.push(l.apply(scope, args)); 113 if (stop) { 114 break; 115 } 116 } 117 } 118 stop = oldstop; 119 current_event = ce; 120 return out.length ? out : null; 121 }; 122 // Undocumented. Debug only. 123 eve._events = events; 124 /*\ 125 * eve.listeners 126 [ method ] 127 128 * Internal method which gives you array of all event handlers that will be triggered by the given `name`. 129 130 > Arguments 131 132 - name (string) name of the event, dot (`.`) or slash (`/`) separated 133 134 = (array) array of event handlers 135 \*/ 136 eve.listeners = function (name) { 137 var names = name.split(separator), 138 e = events, 139 item, 140 items, 141 k, 142 i, 143 ii, 144 j, 145 jj, 146 nes, 147 es = [e], 148 out = []; 149 for (i = 0, ii = names.length; i < ii; i++) { 150 nes = []; 151 for (j = 0, jj = es.length; j < jj; j++) { 152 e = es[j].n; 153 items = [e[names[i]], e[wildcard]]; 154 k = 2; 155 while (k--) { 156 item = items[k]; 157 if (item) { 158 nes.push(item); 159 out = out.concat(item.f || []); 160 } 161 } 162 } 163 es = nes; 164 } 165 return out; 166 }; 167 168 /*\ 169 * eve.on 170 [ method ] 171 ** 172 * Binds given event handler with a given name. You can use wildcards â`*`â for the names: 173 | eve.on("*.under.*", f); 174 | eve("mouse.under.floor"); // triggers f 175 * Use @eve to trigger the listener. 176 ** 177 > Arguments 178 ** 179 - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards 180 - f (function) event handler function 181 ** 182 = (function) returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment. 183 > Example: 184 | eve.on("mouse", eatIt)(2); 185 | eve.on("mouse", scream); 186 | eve.on("mouse", catchIt)(1); 187 * This will ensure that `catchIt()` function will be called before `eatIt()`. 188 * 189 * If you want to put your handler before non-indexed handlers, specify a negative value. 190 * Note: I assume most of the time you donât need to worry about z-index, but itâs nice to have this feature âjust in caseâ. 191 \*/ 192 eve.on = function (name, f) { 193 name = String(name); 194 if (typeof f != "function") { 195 return function () {}; 196 } 197 var names = name.split(separator), 198 e = events; 199 for (var i = 0, ii = names.length; i < ii; i++) { 200 e = e.n; 201 e = e.hasOwnProperty(names[i]) && e[names[i]] || (e[names[i]] = {n: {}}); 202 } 203 e.f = e.f || []; 204 for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) { 205 return fun; 206 } 207 e.f.push(f); 208 return function (zIndex) { 209 if (+zIndex == +zIndex) { 210 f.zIndex = +zIndex; 211 } 212 }; 213 }; 214 /*\ 215 * eve.f 216 [ method ] 217 ** 218 * Returns function that will fire given event with optional arguments. 219 * Arguments that will be passed to the result function will be also 220 * concated to the list of final arguments. 221 | el.onclick = eve.f("click", 1, 2); 222 | eve.on("click", function (a, b, c) { 223 | console.log(a, b, c); // 1, 2, [event object] 224 | }); 225 > Arguments 226 - event (string) event name 227 - varargs (â¦) and any other arguments 228 = (function) possible event handler function 229 \*/ 230 eve.f = function (event) { 231 var attrs = [].slice.call(arguments, 1); 232 return function () { 233 eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0))); 234 }; 235 }; 236 /*\ 237 * eve.stop 238 [ method ] 239 ** 240 * Is used inside an event handler to stop the event, preventing any subsequent listeners from firing. 241 \*/ 242 eve.stop = function () { 243 stop = 1; 244 }; 245 /*\ 246 * eve.nt 247 [ method ] 248 ** 249 * Could be used inside event handler to figure out actual name of the event. 250 ** 251 > Arguments 252 ** 253 - subname (string) #optional subname of the event 254 ** 255 = (string) name of the event, if `subname` is not specified 256 * or 257 = (boolean) `true`, if current eventâs name contains `subname` 258 \*/
259 eve.nt = function (subname) { 260 if (subname) { 261 return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); 262 } 263 return current_event; 264 }; 265 /*\ 266 * eve.nts 267 [ method ] 268 ** 269 * Could be used inside event handler to figure out actual name of the event. 270 ** 271 ** 272 = (array) names of the event 273 \*/ 274 eve.nts = function () { 275 return current_event.split(separator); 276 }; 277 /*\ 278 * eve.off 279 [ method ] 280 ** 281 * Removes given function from the list of event listeners assigned to given name. 282 * If no arguments specified all the events will be cleared. 283 ** 284 > Arguments 285 ** 286 - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards 287 - f (function) event handler function 288 \*/ 289 /*\ 290 * eve.unbind 291 [ method ] 292 ** 293 * See @eve.off 294 \*/ 295 eve.off = eve.unbind = function (name, f) { 296 if (!name) { 297 eve._events = events = {n: {}}; 298 return; 299 } 300 var names = name.split(separator), 301 e, 302 key, 303 splice, 304 i, ii, j, jj, 305 cur = [events]; 306 for (i = 0, ii = names.length; i < ii; i++) { 307 for (j = 0; j < cur.length; j += splice.length - 2) { 308 splice = [j, 1]; 309 e = cur[j].n; 310 if (names[i] != wildcard) { 311 if (e[names[i]]) { 312 splice.push(e[names[i]]); 313 } 314 } else { 315 for (key in e) if (e[has](key)) { 316 splice.push(e[key]); 317 } 318 } 319 cur.splice.apply(cur, splice); 320 } 321 } 322 for (i = 0, ii = cur.length; i < ii; i++) { 323 e = cur[i]; 324 while (e.n) { 325 if (f) { 326 if (e.f) { 327 for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) { 328 e.f.splice(j, 1); 329 break; 330 } 331 !e.f.length && delete e.f; 332 } 333 for (key in e.n) if (e.n[has](key) && e.n[key].f) { 334 var funcs = e.n[key].f; 335 for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) { 336 funcs.splice(j, 1); 337 break; 338 } 339 !funcs.length && delete e.n[key].f; 340 } 341 } else { 342 delete e.f; 343 for (key in e.n) if (e.n[has](key) && e.n[key].f) { 344 delete e.n[key].f; 345 } 346 } 347 e = e.n; 348 } 349 } 350 }; 351 /*\ 352 * eve.once 353 [ method ] 354 ** 355 * Binds given event handler with a given name to only run once then unbind itself. 356 | eve.once("login", f); 357 | eve("login"); // triggers f 358 | eve("login"); // no listeners 359 * Use @eve to trigger the listener. 360 ** 361 > Arguments 362 ** 363 - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards 364 - f (function) event handler function 365 ** 366 = (function) same return function as @eve.on 367 \*/ 368 eve.once = function (name, f) { 369 var f2 = function () { 370 eve.unbind(name, f2); 371 return f.apply(this, arguments); 372 }; 373 return eve.on(name, f2); 374 }; 375 /*\ 376 * eve.version 377 [ property (string) ] 378 ** 379 * Current version of the library. 380 \*/ 381 eve.version = version; 382 eve.toString = function () { 383 return "You are running Eve " + version; 384 }; 385 (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define != "undefined" ? (define("eve", [], function() { return eve; })) : (glob.eve = eve)); 386})(this); 387// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 388// â "Raphaël 2.1.2" - JavaScript Vector Library â \\ 389// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 390// â Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) â \\ 391// â Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) â \\ 392// â Licensed under the MIT (http://raphaeljs.com/license.html) license. â \\ 393// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 394 395(function (glob, factory) { 396 // AMD support 397 if (typeof define === "function" && define.amd) { 398 // Define as an anonymous module 399 define(["eve"], function( eve ) { 400 return factory(glob, eve); 401 }); 402 } else { 403 // Browser globals (glob is window) 404 // Raphael adds itself to window 405 factory(glob, glob.eve); 406 } 407}(this, function (window, eve) { 408 /*\ 409 * Raphael 410 [ method ] 411 ** 412 * Creates a canvas object on which to draw. 413 * You must do this first, as all future calls to drawing methods 414 * from this instance will be bound to this canvas. 415 > Parameters 416 ** 417 - container (HTMLElement|string) DOM element or its ID which is going to be a parent for drawing surface 418 - width (number)
419 - height (number) 420 - callback (function) #optional callback function which is going to be executed in the context of newly created paper 421 * or 422 - x (number) 423 - y (number) 424 - width (number) 425 - height (number) 426 - callback (function) #optional callback function which is going to be executed in the context of newly created paper 427 * or 428 - all (array) (first 3 or 4 elements in the array are equal to [containerID, width, height] or [x, y, width, height]. The rest are element descriptions in format {type: type, <attributes>}). See @Paper.add. 429 - callback (function) #optional callback function which is going to be executed in the context of newly created paper 430 * or 431 - onReadyCallback (function) function that is going to be called on DOM ready event. You can also subscribe to this event via Eveâs âDOMLoadâ event. In this case method returns `undefined`. 432 = (object) @Paper 433 > Usage 434 | // Each of the following examples create a canvas 435 | // that is 320px wide by 200px high. 436 | // Canvas is created at the viewportâs 10,50 coordinate. 437 | var paper = Raphael(10, 50, 320, 200); 438 | // Canvas is created at the top left corner of the #notepad element 439 | // (or its top right corner in dir="rtl" elements) 440 | var paper = Raphael(document.getElementById("notepad"), 320, 200); 441 | // Same as above 442 | var paper = Raphael("notepad", 320, 200); 443 | // Image dump 444 | var set = Raphael(["notepad", 320, 200, { 445 | type: "rect", 446 | x: 10, 447 | y: 10, 448 | width: 25, 449 | height: 25, 450 | stroke: "#f00" 451 | }, { 452 | type: "text", 453 | x: 30, 454 | y: 40, 455 | text: "Dump" 456 | }]); 457 \*/ 458 function R(first) { 459 if (R.is(first, "function")) { 460 return loaded ? first() : eve.on("raphael.DOMload", first); 461 } else if (R.is(first, array)) { 462 return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first); 463 } else { 464 var args = Array.prototype.slice.call(arguments, 0); 465 if (R.is(args[args.length - 1], "function")) { 466 var f = args.pop(); 467 return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on("raphael.DOMload", function () { 468 f.call(R._engine.create[apply](R, args)); 469 }); 470 } else { 471 return R._engine.create[apply](R, arguments); 472 } 473 } 474 } 475 R.version = "2.1.2"; 476 R.eve = eve; 477 var loaded, 478 separator = /[, ]+/, 479 elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1}, 480 formatrg = /\{(\d+)\}/g, 481 proto = "prototype", 482 has = "hasOwnProperty", 483 g = { 484 doc: document, 485 win: window 486 }, 487 oldRaphael = { 488 was: Object.prototype[has].call(g.win, "Raphael"), 489 is: g.win.Raphael 490 }, 491 Paper = function () { 492 /*\ 493 * Paper.ca 494 [ property (object) ] 495 ** 496 * Shortcut for @Paper.customAttributes 497 \*/ 498 /*\ 499 * Paper.customAttributes 500 [ property (object) ] 501 ** 502 * If you have a set of attributes that you would like to represent 503 * as a function of some number you can do it easily with custom attributes: 504 > Usage 505 | paper.customAttributes.hue = function (num) { 506 | num = num % 1; 507 | return {fill: "hsb(" + num + ", 0.75, 1)"}; 508 | }; 509 | // Custom attribute âhueâ will change fill 510 | // to be given hue with fixed saturation and brightness. 511 | // Now you can use it like this: 512 | var c = paper.circle(10, 10, 10).attr({hue: .45}); 513 | // or even like this: 514 | c.animate({hue: 1}, 1e3); 515 | 516 | // You could also create custom attribute 517 | // with multiple parameters: 518 | paper.customAttributes.hsb = function (h, s, b) { 519 | return {fill: "hsb(" + [h, s, b].join(",") + ")"}; 520 | }; 521 | c.attr({hsb: "0.5 .8 1"}); 522 | c.animate({hsb: [1, 0, 0.5]}, 1e3); 523 \*/ 524 this.ca = this.customAttributes = {}; 525 }, 526 paperproto, 527 appendChild = "appendChild", 528 apply = "apply", 529 concat = "concat", 530 supportsTouch = ('ontouchstart' in g.win) || g.win.DocumentTouch && g.doc instanceof DocumentTouch, //taken from Modernizr touch test 531 E = "", 532 S = " ", 533 Str = String, 534 split = "split", 535 events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[split](S), 536 touchMap = { 537 mousedown: "touchstart", 538 mousemove: "touchmove", 539 mouseup: "touchend" 540 }, 541 lowerCase = Str.prototype.toLowerCase, 542 math = Math, 543 mmax = math.max, 544 mmin = math.min, 545 abs = math.abs, 546 pow = math.pow, 547 PI = math.PI, 548 nu = "number",
vendor: 35,156 bytes, lines 549-1544
549 string = "string", 550 array = "array", 551 toString = "toString", 552 fillString = "fill", 553 objectToString = Object.prototype.toString, 554 paper = {}, 555 push = "push", 556 ISURL = R._ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i, 557 colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i, 558 isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1}, 559 bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/, 560 round = math.round, 561 setAttribute = "setAttribute", 562 toFloat = parseFloat, 563 toInt = parseInt, 564 upperCase = Str.prototype.toUpperCase, 565 availableAttrs = R._availableAttrs = { 566 "arrow-end": "none", 567 "arrow-start": "none", 568 blur: 0, 569 "clip-rect": "0 0 1e9 1e9", 570 cursor: "default", 571 cx: 0, 572 cy: 0, 573 fill: "#fff", 574 "fill-opacity": 1, 575 font: '10px "Arial"', 576 "font-family": '"Arial"', 577 "font-size": "10", 578 "font-style": "normal", 579 "font-weight": 400, 580 gradient: 0, 581 height: 0, 582 href: "http://raphaeljs.com/", 583 "letter-spacing": 0, 584 opacity: 1, 585 path: "M0,0", 586 r: 0, 587 rx: 0, 588 ry: 0, 589 src: "", 590 stroke: "#000", 591 "stroke-dasharray": "", 592 "stroke-linecap": "butt", 593 "stroke-linejoin": "butt", 594 "stroke-miterlimit": 0, 595 "stroke-opacity": 1, 596 "stroke-width": 1, 597 target: "_blank", 598 "text-anchor": "middle", 599 title: "Raphael", 600 transform: "", 601 width: 0, 602 x: 0, 603 y: 0 604 }, 605 availableAnimAttrs = R._availableAnimAttrs = { 606 blur: nu, 607 "clip-rect": "csv", 608 cx: nu, 609 cy: nu, 610 fill: "colour", 611 "fill-opacity": nu, 612 "font-size": nu, 613 height: nu, 614 opacity: nu, 615 path: "path", 616 r: nu, 617 rx: nu, 618 ry: nu, 619 stroke: "colour", 620 "stroke-opacity": nu, 621 "stroke-width": nu, 622 transform: "transform", 623 width: nu, 624 x: nu, 625 y: nu 626 }, 627 whitespace = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]/g, 628 commaSpaces = /[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/, 629 hsrg = {hs: 1, rg: 1}, 630 p2s = /,?([achlmqrstvxz]),?/gi, 631 pathCommand = /([achlmrqstvz])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig, 632 tCommand = /([rstm])[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*)+)/ig, 633 pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,?[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*/ig, 634 radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*,[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029]*([^\)]+?)\))?/, 635 eldata = {}, 636 sortByKey = function (a, b) { 637 return a.key - b.key; 638 }, 639 sortByNumber = function (a, b) { 640 return toFloat(a) - toFloat(b); 641 }, 642 fun = function () {}, 643 pipe = function (x) { 644 return x; 645 }, 646 rectPath = R._rectPath = function (x, y, w, h, r) { 647 if (r) { 648 return [["M", x + r, y], ["l", w - r * 2, 0], ["a", r, r, 0, 0, 1, r, r], ["l", 0, h - r * 2], ["a", r, r, 0, 0, 1, -r, r], ["l", r * 2 - w, 0], ["a", r, r, 0, 0, 1, -r, -r], ["l", 0, r * 2 - h], ["a", r, r, 0, 0, 1, r, -r], ["z"]]; 649 } 650 return [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]]; 651 }, 652 ellipsePath = function (x, y, rx, ry) { 653 if (ry == null) { 654 ry = rx; 655 } 656 return [["M", x, y], ["m", 0, -ry], ["a", rx, ry, 0, 1, 1, 0, 2 * ry], ["a", rx, ry, 0, 1, 1, 0, -2 * ry], ["z"]]; 657 }, 658 getPath = R._getPath = { 659 path: function (el) { 660 return el.attr("path"); 661 }, 662 circle: function (el) { 663 var a = el.attrs; 664 return ellipsePath(a.cx, a.cy, a.r); 665 }, 666 ellipse: function (el) { 667 var a = el.attrs; 668 return ellipsePath(a.cx, a.cy, a.rx, a.ry); 669 }, 670 rect: function (el) { 671 var a = el.attrs; 672 return rectPath(a.x, a.y, a.width, a.height, a.r); 673 }, 674 image: function (el) { 675 var a = el.attrs; 676 return rectPath(a.x, a.y, a.width, a.height); 677 }, 678 text: function (el) { 679 var bbox = el._getBBox(); 680 return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); 681 }, 682 set : function(el) { 683 var bbox = el._getBBox(); 684 return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); 685 } 686 }, 687 /*\ 688 * Raphael.mapPath 689 [ method ] 690 ** 691 * Transform the path string with given matrix. 692 > Parameters 693 - path (string) path string 694 - matrix (object) see @Matrix 695 = (string) transformed path string 696 \*/ 697 mapPath = R.mapPath = function (path, matrix) { 698 if (!matrix) { 699 return path; 700 } 701 var x, y, i, j, ii, jj, pathi; 702 path = path2curve(path); 703 for (i = 0, ii = path.length; i < ii; i++) { 704 pathi = path[i]; 705 for (j = 1, jj = pathi.length; j < jj; j += 2) { 706 x = matrix.x(pathi[j], pathi[j + 1]); 707 y = matrix.y(pathi[j], pathi[j + 1]); 708 pathi[j] = x; 709 pathi[j + 1] = y; 710 } 711 } 712 return path; 713 }; 714 715 R._g = g; 716 /*\ 717 * Raphael.type 718 [ property (string) ] 719 ** 720 * Can be âSVGâ, âVMLâ or empty, depending on browser support. 721 \*/ 722 R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); 723 if (R.type == "VML") { 724 var d = g.doc.createElement("div"), 725 b; 726 d.innerHTML = '<v:shape adj="1"/>'; 727 b = d.firstChild; 728 b.style.behavior = "url(#default#VML)"; 729 if (!(b && typeof b.adj == "object")) { 730 return (R.type = E); 731 } 732 d = null; 733 } 734 /*\ 735 * Raphael.svg 736 [ property (boolean) ] 737 ** 738 * `true` if browser supports SVG. 739 \*/ 740 /*\ 741 * Raphael.vml 742 [ property (boolean) ] 743 ** 744 * `true` if browser supports VML. 745 \*/ 746 R.svg = !(R.vml = R.type == "VML"); 747 R._Paper = Paper; 748 /*\ 749 * Raphael.fn 750 [ property (object) ] 751 ** 752 * You can add your own method to the canvas. For example if you want to draw a pie chart, 753 * you can create your own pie chart function and ship it as a Raphaël plugin. To do this 754 * you need to extend the `Raphael.fn` object. You should modify the `fn` object before a 755 * Raphaël instance is created, otherwise it will take no effect. Please note that the 756 * ability for namespaced plugins was removed in Raphael 2.0. It is up to the plugin to 757 * ensure any namespacing ensures proper context. 758 > Usage 759 | Raphael.fn.arrow = function (x1, y1, x2, y2, size) { 760 | return this.path( ... ); 761 | }; 762 | // or create namespace 763 | Raphael.fn.mystuff = { 764 | arrow: function () {â¦}, 765 | star: function () {â¦}, 766 | // etc⦠767 | }; 768 | var paper = Raphael(10, 10, 630, 480); 769 | // then use it 770 | paper.arrow(10, 10, 30, 30, 5).attr({fill: "#f00"}); 771 | paper.mystuff.arrow(); 772 | paper.mystuff.star(); 773 \*/ 774 R.fn = paperproto = Paper.prototype = R.prototype; 775 R._id = 0; 776 R._oid = 0; 777 /*\ 778 * Raphael.is 779 [ method ] 780 ** 781 * Handfull replacement for `typeof` operator. 782 > Parameters 783 - o (â¦) any object or primitive 784 - type (string) name of the type, i.e. âstringâ, âfunctionâ, ânumberâ, etc. 785 = (boolean) is given value is of given type 786 \*/ 787 R.is = function (o, type) { 788 type = lowerCase.call(type); 789 if (type == "finite") { 790 return !isnan[has](+o); 791 } 792 if (type == "array") { 793 return o instanceof Array; 794 } 795 return (type == "null" && o === null) || 796 (type == typeof o && o !== null) || 797 (type == "object" && o === Object(o)) || 798 (type == "array" && Array.isArray && Array.isArray(o)) || 799 objectToString.call(o).slice(8, -1).toLowerCase() == type; 800 }; 801 802 function clone(obj) { 803 if (typeof obj == "function" || Object(obj) !== obj) { 804 return obj; 805 } 806 var res = new obj.constructor; 807 for (var key in obj) if (obj[has](key)) { 808 res[key] = clone(obj[key]); 809 } 810 return res; 811 } 812 813 /*\ 814 * Raphael.angle 815 [ method ] 816 ** 817 * Returns angle between two or three points 818 > Parameters 819 - x1 (number) x coord of first point 820 - y1 (number) y coord of first point 821 - x2 (number) x coord of second point 822 - y2 (number) y coord of second point 823 - x3 (number) #optional x coord of third point 824 - y3 (number) #optional y coord of third point 825 = (number) angle in degrees. 826 \*/ 827 R.angle = function (x1, y1, x2, y2, x3, y3) { 828 if (x3 == null) { 829 var x = x1 - x2, 830 y = y1 - y2; 831 if (!x && !y) { 832 return 0; 833 } 834 return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360; 835 } else { 836 return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); 837 } 838 }; 839 /*\ 840 * Raphael.rad 841 [ method ] 842 ** 843 * Transform angle to radians 844 > Parameters 845 - deg (number) angle in degrees 846 = (number) angle in radians. 847 \*/ 848 R.rad = function (deg) { 849 return deg % 360 * PI / 180; 850 }; 851 /*\ 852 * Raphael.deg 853 [ method ] 854 ** 855 * Transform angle to degrees 856 > Parameters 857 - deg (number) angle in radians 858 = (number) angle in degrees. 859 \*/ 860 R.deg = function (rad) { 861 return rad * 180 / PI % 360; 862 }; 863 /*\ 864 * Raphael.snapTo 865 [ method ] 866 ** 867 * Snaps given value to given grid. 868 > Parameters 869 - values (array|number) given array of values or step of the grid 870 - value (number) value to adjust 871 - tolerance (number) #optional tolerance for snapping. Default is `10`. 872 = (number) adjusted value. 873 \*/ 874 R.snapTo = function (values, value, tolerance) { 875 tolerance = R.is(tolerance, "finite") ? tolerance : 10; 876 if (R.is(values, array)) { 877 var i = values.length; 878 while (i--) if (abs(values[i] - value) <= tolerance) { 879 return values[i]; 880 } 881 } else { 882 values = +values; 883 var rem = value % values; 884 if (rem < tolerance) { 885 return value - rem; 886 } 887 if (rem > values - tolerance) { 888 return value - rem + values; 889 } 890 } 891 return value; 892 }; 893 894 /*\ 895 * Raphael.createUUID 896 [ method ] 897 ** 898 * Returns RFC4122, version 4 ID 899 \*/ 900 var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { 901 return function () { 902 return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); 903 }; 904 })(/[xy]/g, function (c) { 905 var r = math.random() * 16 | 0, 906 v = c == "x" ? r : (r & 3 | 8); 907 return v.toString(16); 908 }); 909 910 /*\ 911 * Raphael.setWindow 912 [ method ] 913 ** 914 * Used when you need to draw in `<iframe>`. Switched window to the iframe one. 915 > Parameters 916 - newwin (window) new window object 917 \*/ 918 R.setWindow = function (newwin) { 919 eve("raphael.setWindow", R, g.win, newwin); 920 g.win = newwin; 921 g.doc = g.win.document; 922 if (R._engine.initWin) { 923 R._engine.initWin(g.win); 924 } 925 }; 926 var toHex = function (color) { 927 if (R.vml) { 928 // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/ 929 var trim = /^\s+|\s+$/g; 930 var bod; 931 try { 932 var docum = new ActiveXObject("htmlfile"); 933 docum.write("<body>"); 934 docum.close(); 935 bod = docum.body; 936 } catch(e) { 937 bod = createPopup().document.body; 938 } 939 var range = bod.createTextRange(); 940 toHex = cacher(function (color) { 941 try { 942 bod.style.color = Str(color).replace(trim, E); 943 var value = range.queryCommandValue("ForeColor"); 944 value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16); 945 return "#" + ("000000" + value.toString(16)).slice(-6); 946 } catch(e) { 947 return "none"; 948 } 949 }); 950 } else { 951 var i = g.doc.createElement("i"); 952 i.title = "Rapha\xebl Colour Picker"; 953 i.style.display = "none"; 954 g.doc.body.appendChild(i); 955 toHex = cacher(function (color) { 956 i.style.color = color; 957 return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color"); 958 }); 959 } 960 return toHex(color); 961 }, 962 hsbtoString = function () { 963 return "hsb(" + [this.h, this.s, this.b] + ")"; 964 }, 965 hsltoString = function () { 966 return "hsl(" + [this.h, this.s, this.l] + ")"; 967 }, 968 rgbtoString = function () { 969 return this.hex; 970 }, 971 prepareRGB = function (r, g, b) { 972 if (g == null && R.is(r, "object") && "r" in r && "g" in r && "b" in r) { 973 b = r.b; 974 g = r.g; 975 r = r.r; 976 } 977 if (g == null && R.is(r, string)) { 978 var clr = R.getRGB(r); 979 r = clr.r; 980 g = clr.g; 981 b = clr.b; 982 } 983 if (r > 1 || g > 1 || b > 1) { 984 r /= 255; 985 g /= 255; 986 b /= 255; 987 } 988 989 return [r, g, b]; 990 }, 991 packageRGB = function (r, g, b, o) { 992 r *= 255; 993 g *= 255; 994 b *= 255; 995 var rgb = { 996 r: r, 997 g: g, 998 b: b, 999 hex: R.rgb(r, g, b), 1000 toString: rgbtoString 1001 }; 1002 R.is(o, "finite") && (rgb.opacity = o); 1003 return rgb; 1004 }; 1005 1006 /*\ 1007 * Raphael.color 1008 [ method ] 1009 ** 1010 * Parses the color string and returns object with all values for the given color. 1011 > Parameters 1012 - clr (string) color string in one of the supported formats (see @Raphael.getRGB) 1013 = (object) Combined RGB & HSB object in format: 1014 o { 1015 o r (number) red, 1016 o g (number) green, 1017 o b (number) blue, 1018 o hex (string) color in HTML/CSS format: #â¢â¢â¢â¢â¢â¢, 1019 o error (boolean) `true` if string canât be parsed, 1020 o h (number) hue, 1021 o s (number) saturation, 1022 o v (number) value (brightness), 1023 o l (number) lightness 1024 o } 1025 \*/ 1026 R.color = function (clr) { 1027 var rgb; 1028 if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { 1029 rgb = R.hsb2rgb(clr); 1030 clr.r = rgb.r; 1031 clr.g = rgb.g; 1032 clr.b = rgb.b; 1033 clr.hex = rgb.hex; 1034 } else if (R.is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) { 1035 rgb = R.hsl2rgb(clr); 1036 clr.r = rgb.r; 1037 clr.g = rgb.g; 1038 clr.b = rgb.b; 1039 clr.hex = rgb.hex; 1040 } else { 1041 if (R.is(clr, "string")) { 1042 clr = R.getRGB(clr); 1043 } 1044 if (R.is(clr, "object") && "r" in clr && "g" in clr && "b" in clr) { 1045 rgb = R.rgb2hsl(clr); 1046 clr.h = rgb.h; 1047 clr.s = rgb.s; 1048 clr.l = rgb.l; 1049 rgb = R.rgb2hsb(clr); 1050 clr.v = rgb.b; 1051 } else { 1052 clr = {hex: "none"}; 1053 clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1; 1054 } 1055 } 1056 clr.toString = rgbtoString; 1057 return clr; 1058 }; 1059 /*\ 1060 * Raphael.hsb2rgb 1061 [ method ] 1062 ** 1063 * Converts HSB values to RGB object. 1064 > Parameters 1065 - h (number) hue 1066 - s (number) saturation 1067 - v (number) value or brightness 1068 = (object) RGB object in format: 1069 o { 1070 o r (number) red, 1071 o g (number) green, 1072 o b (number) blue, 1073 o hex (string) color in HTML/CSS format: #â¢â¢â¢â¢â¢â¢ 1074 o } 1075 \*/ 1076 R.hsb2rgb = function (h, s, v, o) { 1077 if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { 1078 v = h.b; 1079 s = h.s; 1080 h = h.h; 1081 o = h.o; 1082 } 1083 h *= 360; 1084 var R, G, B, X, C; 1085 h = (h % 360) / 60; 1086 C = v * s; 1087 X = C * (1 - abs(h % 2 - 1)); 1088 R = G = B = v - C; 1089 1090 h = ~~h; 1091 R += [C, X, 0, 0, X, C][h]; 1092 G += [X, C, C, X, 0, 0][h]; 1093 B += [0, 0, X, C, C, X][h]; 1094 return packageRGB(R, G, B, o); 1095 }; 1096 /*\ 1097 * Raphael.hsl2rgb 1098 [ method ] 1099 ** 1100 * Converts HSL values to RGB object. 1101 > Parameters 1102 - h (number) hue 1103 - s (number) saturation 1104 - l (number) luminosity 1105 = (object) RGB object in format: 1106 o { 1107 o r (number) red, 1108 o g (number) green, 1109 o b (number) blue, 1110 o hex (string) color in HTML/CSS format: #â¢â¢â¢â¢â¢â¢ 1111 o } 1112 \*/ 1113 R.hsl2rgb = function (h, s, l, o) { 1114 if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { 1115 l = h.l; 1116 s = h.s; 1117 h = h.h; 1118 } 1119 if (h > 1 || s > 1 || l > 1) { 1120 h /= 360; 1121 s /= 100; 1122 l /= 100; 1123 } 1124 h *= 360; 1125 var R, G, B, X, C; 1126 h = (h % 360) / 60; 1127 C = 2 * s * (l < .5 ? l : 1 - l); 1128 X = C * (1 - abs(h % 2 - 1)); 1129 R = G = B = l - C / 2; 1130 1131 h = ~~h; 1132 R += [C, X, 0, 0, X, C][h]; 1133 G += [X, C, C, X, 0, 0][h]; 1134 B += [0, 0, X, C, C, X][h]; 1135 return packageRGB(R, G, B, o); 1136 }; 1137 /*\ 1138 * Raphael.rgb2hsb 1139 [ method ] 1140 ** 1141 * Converts RGB values to HSB object. 1142 > Parameters 1143 - r (number) red 1144 - g (number) green 1145 - b (number) blue 1146 = (object) HSB object in format: 1147 o { 1148 o h (number) hue 1149 o s (number) saturation 1150 o b (number) brightness 1151 o } 1152 \*/ 1153 R.rgb2hsb = function (r, g, b) { 1154 b = prepareRGB(r, g, b); 1155 r = b[0]; 1156 g = b[1]; 1157 b = b[2]; 1158 1159 var H, S, V, C; 1160 V = mmax(r, g, b); 1161 C = V - mmin(r, g, b); 1162 H = (C == 0 ? null : 1163 V == r ? (g - b) / C : 1164 V == g ? (b - r) / C + 2 : 1165 (r - g) / C + 4 1166 ); 1167 H = ((H + 360) % 6) * 60 / 360; 1168 S = C == 0 ? 0 : C / V; 1169 return {h: H, s: S, b: V, toString: hsbtoString}; 1170 }; 1171 /*\ 1172 * Raphael.rgb2hsl 1173 [ method ] 1174 ** 1175 * Converts RGB values to HSL object. 1176 > Parameters 1177 - r (number) red 1178 - g (number) green 1179 - b (number) blue 1180 = (object) HSL object in format: 1181 o { 1182 o h (number) hue 1183 o s (number) saturation 1184 o l (number) luminosity 1185 o } 1186 \*/ 1187 R.rgb2hsl = function (r, g, b) { 1188 b = prepareRGB(r, g, b); 1189 r = b[0]; 1190 g = b[1]; 1191 b = b[2]; 1192 1193 var H, S, L, M, m, C; 1194 M = mmax(r, g, b); 1195 m = mmin(r, g, b); 1196 C = M - m; 1197 H = (C == 0 ? null : 1198 M == r ? (g - b) / C : 1199 M == g ? (b - r) / C + 2 : 1200 (r - g) / C + 4); 1201 H = ((H + 360) % 6) * 60 / 360; 1202 L = (M + m) / 2; 1203 S = (C == 0 ? 0 : 1204 L < .5 ? C / (2 * L) : 1205 C / (2 - 2 * L)); 1206 return {h: H, s: S, l: L, toString: hsltoString}; 1207 }; 1208 R._path2string = function () { 1209 return this.join(",").replace(p2s, "$1"); 1210 }; 1211 function repush(array, item) { 1212 for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) { 1213 return array.push(array.splice(i, 1)[0]); 1214 } 1215 } 1216 function cacher(f, scope, postprocessor) { 1217 function newf() { 1218 var arg = Array.prototype.slice.call(arguments, 0), 1219 args = arg.join("\u2400"), 1220 cache = newf.cache = newf.cache || {}, 1221 count = newf.count = newf.count || []; 1222 if (cache[has](args)) { 1223 repush(count, args); 1224 return postprocessor ? postprocessor(cache[args]) : cache[args]; 1225 } 1226 count.length >= 1e3 && delete cache[count.shift()]; 1227 count.push(args); 1228 cache[args] = f[apply](scope, arg); 1229 return postprocessor ? postprocessor(cache[args]) : cache[args]; 1230 } 1231 return newf; 1232 } 1233 1234 var preload = R._preload = function (src, f) { 1235 var img = g.doc.createElement("img"); 1236 img.style.cssText = "position:absolute;left:-9999em;top:-9999em"; 1237 img.onload = function () { 1238 f.call(this); 1239 this.onload = null; 1240 g.doc.body.removeChild(this); 1241 }; 1242 img.onerror = function () { 1243 g.doc.body.removeChild(this); 1244 }; 1245 g.doc.body.appendChild(img); 1246 img.src = src; 1247 }; 1248 1249 function clrToString() { 1250 return this.hex; 1251 } 1252 1253 /*\ 1254 * Raphael.getRGB 1255 [ method ] 1256 ** 1257 * Parses colour string as RGB object 1258 > Parameters 1259 - colour (string) colour string in one of formats: 1260 # <ul> 1261 # <li>Colour name (â<code>red</code>â, â<code>green</code>â, â<code>cornflowerblue</code>â, etc)</li> 1262 # <li>#â¢â¢â¢ â shortened HTML colour: (â<code>#000</code>â, â<code>#fc0</code>â, etc)</li> 1263 # <li>#â¢â¢â¢â¢â¢â¢ â full length HTML colour: (â<code>#000000</code>â, â<code>#bd2300</code>â)</li> 1264 # <li>rgb(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â red, green and blue channelsâ values: (â<code>rgb(200, 100, 0)</code>â)</li> 1265 # <li>rgb(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %: (â<code>rgb(100%, 175%, 0%)</code>â)</li> 1266 # <li>hsb(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â hue, saturation and brightness values: (â<code>hsb(0.5, 0.25, 1)</code>â)</li> 1267 # <li>hsb(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %</li> 1268 # <li>hsl(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â same as hsb</li> 1269 # <li>hsl(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as hsb</li> 1270 # </ul> 1271 = (object) RGB object in format: 1272 o { 1273 o r (number) red, 1274 o g (number) green, 1275 o b (number) blue 1276 o hex (string) color in HTML/CSS format: #â¢â¢â¢â¢â¢â¢, 1277 o error (boolean) true if string canât be parsed 1278 o } 1279 \*/ 1280 R.getRGB = cacher(function (colour) { 1281 if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { 1282 return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; 1283 } 1284 if (colour == "none") { 1285 return {r: -1, g: -1, b: -1, hex: "none", toString: clrToString}; 1286 } 1287 !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour)); 1288 var res, 1289 red, 1290 green, 1291 blue, 1292 opacity, 1293 t, 1294 values, 1295 rgb = colour.match(colourRegExp); 1296 if (rgb) { 1297 if (rgb[2]) { 1298 blue = toInt(rgb[2].substring(5), 16); 1299 green = toInt(rgb[2].substring(3, 5), 16); 1300 red = toInt(rgb[2].substring(1, 3), 16); 1301 } 1302 if (rgb[3]) { 1303 blue = toInt((t = rgb[3].charAt(3)) + t, 16); 1304 green = toInt((t = rgb[3].charAt(2)) + t, 16); 1305 red = toInt((t = rgb[3].charAt(1)) + t, 16); 1306 } 1307 if (rgb[4]) { 1308 values = rgb[4][split](commaSpaces); 1309 red = toFloat(values[0]); 1310 values[0].slice(-1) == "%" && (red *= 2.55); 1311 green = toFloat(values[1]); 1312 values[1].slice(-1) == "%" && (green *= 2.55); 1313 blue = toFloat(values[2]); 1314 values[2].slice(-1) == "%" && (blue *= 2.55); 1315 rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3])); 1316 values[3] && values[3].slice(-1) == "%" && (opacity /= 100); 1317 } 1318 if (rgb[5]) { 1319 values = rgb[5][split](commaSpaces); 1320 red = toFloat(values[0]); 1321 values[0].slice(-1) == "%" && (red *= 2.55); 1322 green = toFloat(values[1]); 1323 values[1].slice(-1) == "%" && (green *= 2.55); 1324 blue = toFloat(values[2]); 1325 values[2].slice(-1) == "%" && (blue *= 2.55); 1326 (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360); 1327 rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3])); 1328 values[3] && values[3].slice(-1) == "%" && (opacity /= 100); 1329 return R.hsb2rgb(red, green, blue, opacity); 1330 } 1331 if (rgb[6]) { 1332 values = rgb[6][split](commaSpaces); 1333 red = toFloat(values[0]); 1334 values[0].slice(-1) == "%" && (red *= 2.55); 1335 green = toFloat(values[1]); 1336 values[1].slice(-1) == "%" && (green *= 2.55); 1337 blue = toFloat(values[2]); 1338 values[2].slice(-1) == "%" && (blue *= 2.55); 1339 (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360); 1340 rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3])); 1341 values[3] && values[3].slice(-1) == "%" && (opacity /= 100); 1342 return R.hsl2rgb(red, green, blue, opacity); 1343 } 1344 rgb = {r: red, g: green, b: blue, toString: clrToString}; 1345 rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1); 1346 R.is(opacity, "finite") && (rgb.opacity = opacity); 1347 return rgb; 1348 } 1349 return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; 1350 }, R); 1351 /*\ 1352 * Raphael.hsb 1353 [ method ] 1354 ** 1355 * Converts HSB values to hex representation of the colour. 1356 > Parameters 1357 - h (number) hue 1358 - s (number) saturation 1359 - b (number) value or brightness 1360 = (string) hex representation of the colour. 1361 \*/ 1362 R.hsb = cacher(function (h, s, b) { 1363 return R.hsb2rgb(h, s, b).hex; 1364 }); 1365 /*\ 1366 * Raphael.hsl 1367 [ method ] 1368 ** 1369 * Converts HSL values to hex representation of the colour. 1370 > Parameters 1371 - h (number) hue 1372 - s (number) saturation 1373 - l (number) luminosity 1374 = (string) hex representation of the colour. 1375 \*/ 1376 R.hsl = cacher(function (h, s, l) { 1377 return R.hsl2rgb(h, s, l).hex; 1378 }); 1379 /*\ 1380 * Raphael.rgb 1381 [ method ] 1382 ** 1383 * Converts RGB values to hex representation of the colour. 1384 > Parameters 1385 - r (number) red 1386 - g (number) green 1387 - b (number) blue 1388 = (string) hex representation of the colour. 1389 \*/ 1390 R.rgb = cacher(function (r, g, b) { 1391 return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); 1392 }); 1393 /*\ 1394 * Raphael.getColor 1395 [ method ] 1396 ** 1397 * On each call returns next colour in the spectrum. To reset it back to red call @Raphael.getColor.reset 1398 > Parameters 1399 - value (number) #optional brightness, default is `0.75` 1400 = (string) hex representation of the colour. 1401 \*/ 1402 R.getColor = function (value) { 1403 var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, 1404 rgb = this.hsb2rgb(start.h, start.s, start.b); 1405 start.h += .075; 1406 if (start.h > 1) { 1407 start.h = 0; 1408 start.s -= .2; 1409 start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b}); 1410 } 1411 return rgb.hex; 1412 }; 1413 /*\ 1414 * Raphael.getColor.reset 1415 [ method ] 1416 ** 1417 * Resets spectrum position for @Raphael.getColor back to red. 1418 \*/ 1419 R.getColor.reset = function () { 1420 delete this.start; 1421 }; 1422 1423 // http://schepers.cc/getting-to-the-point 1424 function catmullRom2bezier(crp, z) { 1425 var d = []; 1426 for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) { 1427 var p = [ 1428 {x: +crp[i - 2], y: +crp[i - 1]}, 1429 {x: +crp[i], y: +crp[i + 1]}, 1430 {x: +crp[i + 2], y: +crp[i + 3]}, 1431 {x: +crp[i + 4], y: +crp[i + 5]} 1432 ]; 1433 if (z) { 1434 if (!i) { 1435 p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]}; 1436 } else if (iLen - 4 == i) { 1437 p[3] = {x: +crp[0], y: +crp[1]}; 1438 } else if (iLen - 2 == i) { 1439 p[2] = {x: +crp[0], y: +crp[1]}; 1440 p[3] = {x: +crp[2], y: +crp[3]}; 1441 } 1442 } else { 1443 if (iLen - 4 == i) { 1444 p[3] = p[2]; 1445 } else if (!i) { 1446 p[0] = {x: +crp[i], y: +crp[i + 1]}; 1447 } 1448 } 1449 d.push(["C", 1450 (-p[0].x + 6 * p[1].x + p[2].x) / 6, 1451 (-p[0].y + 6 * p[1].y + p[2].y) / 6, 1452 (p[1].x + 6 * p[2].x - p[3].x) / 6, 1453 (p[1].y + 6*p[2].y - p[3].y) / 6, 1454 p[2].x, 1455 p[2].y 1456 ]); 1457 } 1458 1459 return d; 1460 } 1461 /*\ 1462 * Raphael.parsePathString 1463 [ method ] 1464 ** 1465 * Utility method 1466 ** 1467 * Parses given path string into an array of arrays of path segments. 1468 > Parameters 1469 - pathString (string|array) path string or array of segments (in the last case it will be returned straight away) 1470 = (array) array of segments. 1471 \*/ 1472 R.parsePathString = function (pathString) { 1473 if (!pathString) { 1474 return null; 1475 } 1476 var pth = paths(pathString); 1477 if (pth.arr) { 1478 return pathClone(pth.arr); 1479 } 1480 1481 var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, 1482 data = []; 1483 if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption 1484 data = pathClone(pathString); 1485 } 1486 if (!data.length) { 1487 Str(pathString).replace(pathCommand, function (a, b, c) { 1488 var params = [], 1489 name = b.toLowerCase(); 1490 c.replace(pathValues, function (a, b) { 1491 b && params.push(+b); 1492 }); 1493 if (name == "m" && params.length > 2) { 1494 data.push([b][concat](params.splice(0, 2))); 1495 name = "l"; 1496 b = b == "m" ? "l" : "L"; 1497 } 1498 if (name == "r") { 1499 data.push([b][concat](params)); 1500 } else while (params.length >= paramCounts[name]) { 1501 data.push([b][concat](params.splice(0, paramCounts[name]))); 1502 if (!paramCounts[name]) { 1503 break; 1504 } 1505 } 1506 }); 1507 } 1508 data.toString = R._path2string; 1509 pth.arr = pathClone(data); 1510 return data; 1511 }; 1512 /*\ 1513 * Raphael.parseTransformString 1514 [ method ] 1515 ** 1516 * Utility method 1517 ** 1518 * Parses given path string into an array of transformations. 1519 > Parameters 1520 - TString (string|array) transform string or array of transformations (in the last case it will be returned straight away) 1521 = (array) array of transformations. 1522 \*/ 1523 R.parseTransformString = cacher(function (TString) { 1524 if (!TString) { 1525 return null; 1526 } 1527 var paramCounts = {r: 3, s: 4, t: 2, m: 6}, 1528 data = []; 1529 if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption 1530 data = pathClone(TString); 1531 } 1532 if (!data.length) { 1533 Str(TString).replace(tCommand, function (a, b, c) { 1534 var params = [], 1535 name = lowerCase.call(b); 1536 c.replace(pathValues, function (a, b) { 1537 b && params.push(+b); 1538 }); 1539 data.push([b][concat](params)); 1540 }); 1541 } 1542 data.toString = R._path2string; 1543 return data; 1544 }
vendor: 31,254 bytes, lines 1544-2372
1544); 1545 // PATHS 1546 var paths = function (ps) { 1547 var p = paths.ps = paths.ps || {}; 1548 if (p[ps]) { 1549 p[ps].sleep = 100; 1550 } else { 1551 p[ps] = { 1552 sleep: 100 1553 }; 1554 } 1555 setTimeout(function () { 1556 for (var key in p) if (p[has](key) && key != ps) { 1557 p[key].sleep--; 1558 !p[key].sleep && delete p[key]; 1559 } 1560 }); 1561 return p[ps]; 1562 }; 1563 /*\ 1564 * Raphael.findDotsAtSegment 1565 [ method ] 1566 ** 1567 * Utility method 1568 ** 1569 * Find dot coordinates on the given cubic bezier curve at the given t. 1570 > Parameters 1571 - p1x (number) x of the first point of the curve 1572 - p1y (number) y of the first point of the curve 1573 - c1x (number) x of the first anchor of the curve 1574 - c1y (number) y of the first anchor of the curve 1575 - c2x (number) x of the second anchor of the curve 1576 - c2y (number) y of the second anchor of the curve 1577 - p2x (number) x of the second point of the curve 1578 - p2y (number) y of the second point of the curve 1579 - t (number) position on the curve (0..1) 1580 = (object) point information in format: 1581 o { 1582 o x: (number) x coordinate of the point 1583 o y: (number) y coordinate of the point 1584 o m: { 1585 o x: (number) x coordinate of the left anchor 1586 o y: (number) y coordinate of the left anchor 1587 o } 1588 o n: { 1589 o x: (number) x coordinate of the right anchor 1590 o y: (number) y coordinate of the right anchor 1591 o } 1592 o start: { 1593 o x: (number) x coordinate of the start of the curve 1594 o y: (number) y coordinate of the start of the curve 1595 o } 1596 o end: { 1597 o x: (number) x coordinate of the end of the curve 1598 o y: (number) y coordinate of the end of the curve 1599 o } 1600 o alpha: (number) angle of the curve derivative at the point 1601 o } 1602 \*/ 1603 R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { 1604 var t1 = 1 - t, 1605 t13 = pow(t1, 3), 1606 t12 = pow(t1, 2), 1607 t2 = t * t, 1608 t3 = t2 * t, 1609 x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x, 1610 y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y, 1611 mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x), 1612 my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y), 1613 nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x), 1614 ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y), 1615 ax = t1 * p1x + t * c1x, 1616 ay = t1 * p1y + t * c1y, 1617 cx = t1 * c2x + t * p2x, 1618 cy = t1 * c2y + t * p2y, 1619 alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI); 1620 (mx > nx || my < ny) && (alpha += 180); 1621 return { 1622 x: x, 1623 y: y, 1624 m: {x: mx, y: my}, 1625 n: {x: nx, y: ny}, 1626 start: {x: ax, y: ay}, 1627 end: {x: cx, y: cy}, 1628 alpha: alpha 1629 }; 1630 }; 1631 /*\ 1632 * Raphael.bezierBBox 1633 [ method ] 1634 ** 1635 * Utility method 1636 ** 1637 * Return bounding box of a given cubic bezier curve 1638 > Parameters 1639 - p1x (number) x of the first point of the curve 1640 - p1y (number) y of the first point of the curve 1641 - c1x (number) x of the first anchor of the curve 1642 - c1y (number) y of the first anchor of the curve 1643 - c2x (number) x of the second anchor of the curve 1644 - c2y (number) y of the second anchor of the curve 1645 - p2x (number) x of the second point of the curve 1646 - p2y (number) y of the second point of the curve 1647 * or 1648 - bez (array) array of six points for bezier curve 1649 = (object) point information in format: 1650 o { 1651 o min: { 1652 o x: (number) x coordinate of the left point 1653 o y: (number) y coordinate of the top point 1654 o } 1655 o max: { 1656 o x: (number) x coordinate of the right point 1657 o y: (number) y coordinate of the bottom point 1658 o } 1659 o } 1660 \*/ 1661 R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { 1662 if (!R.is(p1x, "array")) { 1663 p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; 1664 } 1665 var bbox = curveDim.apply(null, p1x); 1666 return { 1667 x: bbox.min.x, 1668 y: bbox.min.y, 1669 x2: bbox.max.x, 1670 y2: bbox.max.y, 1671 width: bbox.max.x - bbox.min.x, 1672 height: bbox.max.y - bbox.min.y 1673 }; 1674 }; 1675 /*\ 1676 * Raphael.isPointInsideBBox 1677 [ method ] 1678 ** 1679 * Utility method 1680 ** 1681 * Returns `true` if given point is inside bounding boxes. 1682 > Parameters 1683 - bbox (string) bounding box 1684 - x (string) x coordinate of the point 1685 - y (string) y coordinate of the point 1686 = (boolean) `true` if point inside 1687 \*/ 1688 R.isPointInsideBBox = function (bbox, x, y) { 1689 return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; 1690 }; 1691 /*\ 1692 * Raphael.isBBoxIntersect 1693 [ method ] 1694 ** 1695 * Utility method 1696 ** 1697 * Returns `true` if two bounding boxes intersect 1698 > Parameters 1699 - bbox1 (string) first bounding box 1700 - bbox2 (string) second bounding box 1701 = (boolean) `true` if they intersect 1702 \*/ 1703 R.isBBoxIntersect = function (bbox1, bbox2) { 1704 var i = R.isPointInsideBBox; 1705 return i(bbox2, bbox1.x, bbox1.y) 1706 || i(bbox2, bbox1.x2, bbox1.y) 1707 || i(bbox2, bbox1.x, bbox1.y2) 1708 || i(bbox2, bbox1.x2, bbox1.y2) 1709 || i(bbox1, bbox2.x, bbox2.y) 1710 || i(bbox1, bbox2.x2, bbox2.y) 1711 || i(bbox1, bbox2.x, bbox2.y2) 1712 || i(bbox1, bbox2.x2, bbox2.y2) 1713 || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) 1714 && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y); 1715 }; 1716 function base3(t, p1, p2, p3, p4) { 1717 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4, 1718 t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3; 1719 return t * t2 - 3 * p1 + 3 * p2; 1720 } 1721 function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) { 1722 if (z == null) { 1723 z = 1; 1724 } 1725 z = z > 1 ? 1 : z < 0 ? 0 : z; 1726 var z2 = z / 2, 1727 n = 12, 1728 Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816], 1729 Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472], 1730 sum = 0; 1731 for (var i = 0; i < n; i++) { 1732 var ct = z2 * Tvalues[i] + z2, 1733 xbase = base3(ct, x1, x2, x3, x4), 1734 ybase = base3(ct, y1, y2, y3, y4), 1735 comb = xbase * xbase + ybase * ybase; 1736 sum += Cvalues[i] * math.sqrt(comb); 1737 } 1738 return z2 * sum; 1739 } 1740 function getTatLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) { 1741 if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) { 1742 return; 1743 } 1744 var t = 1, 1745 step = t / 2, 1746 t2 = t - step, 1747 l, 1748 e = .01; 1749 l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2); 1750 while (abs(l - ll) > e) { 1751 step /= 2; 1752 t2 += (l < ll ? 1 : -1) * step; 1753 l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2); 1754 } 1755 return t2; 1756 } 1757 function intersect(x1, y1, x2, y2, x3, y3, x4, y4) { 1758 if ( 1759 mmax(x1, x2) < mmin(x3, x4) || 1760 mmin(x1, x2) > mmax(x3, x4) || 1761 mmax(y1, y2) < mmin(y3, y4) || 1762 mmin(y1, y2) > mmax(y3, y4) 1763 ) { 1764 return; 1765 } 1766 var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4), 1767 ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4), 1768 denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); 1769 1770 if (!denominator) { 1771 return; 1772 } 1773 var px = nx / denominator, 1774 py = ny / denominator, 1775 px2 = +px.toFixed(2), 1776 py2 = +py.toFixed(2); 1777 if ( 1778 px2 < +mmin(x1, x2).toFixed(2) || 1779 px2 > +mmax(x1, x2).toFixed(2) || 1780 px2 < +mmin(x3, x4).toFixed(2) || 1781 px2 > +mmax(x3, x4).toFixed(2) || 1782 py2 < +mmin(y1, y2).toFixed(2) || 1783 py2 > +mmax(y1, y2).toFixed(2) || 1784 py2 < +mmin(y3, y4).toFixed(2) || 1785 py2 > +mmax(y3, y4).toFixed(2) 1786 ) { 1787 return; 1788 } 1789 return {x: px, y: py}; 1790 } 1791 function inter(bez1, bez2) { 1792 return interHelper(bez1, bez2); 1793 } 1794 function interCount(bez1, bez2) { 1795 return interHelper(bez1, bez2, 1); 1796 } 1797 function interHelper(bez1, bez2, justCount) { 1798 var bbox1 = R.bezierBBox(bez1), 1799 bbox2 = R.bezierBBox(bez2); 1800 if (!R.isBBoxIntersect(bbox1, bbox2)) { 1801 return justCount ? 0 : []; 1802 } 1803 var l1 = bezlen.apply(0, bez1), 1804 l2 = bezlen.apply(0, bez2), 1805 n1 = mmax(~~(l1 / 5), 1), 1806 n2 = mmax(~~(l2 / 5), 1), 1807 dots1 = [], 1808 dots2 = [], 1809 xy = {}, 1810 res = justCount ? 0 : []; 1811 for (var i = 0; i < n1 + 1; i++) { 1812 var p = R.findDotsAtSegment.apply(R, bez1.concat(i / n1)); 1813 dots1.push({x: p.x, y: p.y, t: i / n1}); 1814 } 1815 for (i = 0; i < n2 + 1; i++) { 1816 p = R.findDotsAtSegment.apply(R, bez2.concat(i / n2)); 1817 dots2.push({x: p.x, y: p.y, t: i / n2}); 1818 } 1819 for (i = 0; i < n1; i++) { 1820 for (var j = 0; j < n2; j++) { 1821 var di = dots1[i], 1822 di1 = dots1[i + 1], 1823 dj = dots2[j], 1824 dj1 = dots2[j + 1], 1825 ci = abs(di1.x - di.x) < .001 ? "y" : "x", 1826 cj = abs(dj1.x - dj.x) < .001 ? "y" : "x", 1827 is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y); 1828 if (is) { 1829 if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) { 1830 continue; 1831 } 1832 xy[is.x.toFixed(4)] = is.y.toFixed(4); 1833 var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t), 1834 t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t); 1835 if (t1 >= 0 && t1 <= 1.001 && t2 >= 0 && t2 <= 1.001) { 1836 if (justCount) { 1837 res++; 1838 } else { 1839 res.push({ 1840 x: is.x, 1841 y: is.y, 1842 t1: mmin(t1, 1), 1843 t2: mmin(t2, 1) 1844 }); 1845 } 1846 } 1847 } 1848 } 1849 } 1850 return res; 1851 } 1852 /*\ 1853 * Raphael.pathIntersection 1854 [ method ] 1855 ** 1856 * Utility method 1857 ** 1858 * Finds intersections of two paths 1859 > Parameters 1860 - path1 (string) path string 1861 - path2 (string) path string 1862 = (array) dots of intersection 1863 o [ 1864 o { 1865 o x: (number) x coordinate of the point 1866 o y: (number) y coordinate of the point 1867 o t1: (number) t value for segment of path1 1868 o t2: (number) t value for segment of path2 1869 o segment1: (number) order number for segment of path1 1870 o segment2: (number) order number for segment of path2 1871 o bez1: (array) eight coordinates representing beziér curve for the segment of path1 1872 o bez2: (array) eight coordinates representing beziér curve for the segment of path2 1873 o } 1874 o ] 1875 \*/ 1876 R.pathIntersection = function (path1, path2) { 1877 return interPathHelper(path1, path2); 1878 }; 1879 R.pathIntersectionNumber = function (path1, path2) { 1880 return interPathHelper(path1, path2, 1); 1881 }; 1882 function interPathHelper(path1, path2, justCount) { 1883 path1 = R._path2curve(path1); 1884 path2 = R._path2curve(path2); 1885 var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2, 1886 res = justCount ? 0 : []; 1887 for (var i = 0, ii = path1.length; i < ii; i++) { 1888 var pi = path1[i]; 1889 if (pi[0] == "M") { 1890 x1 = x1m = pi[1]; 1891 y1 = y1m = pi[2]; 1892 } else { 1893 if (pi[0] == "C") { 1894 bez1 = [x1, y1].concat(pi.slice(1)); 1895 x1 = bez1[6]; 1896 y1 = bez1[7]; 1897 } else { 1898 bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m]; 1899 x1 = x1m; 1900 y1 = y1m; 1901 } 1902 for (var j = 0, jj = path2.length; j < jj; j++) { 1903 var pj = path2[j]; 1904 if (pj[0] == "M") { 1905 x2 = x2m = pj[1]; 1906 y2 = y2m = pj[2]; 1907 } else { 1908 if (pj[0] == "C") { 1909 bez2 = [x2, y2].concat(pj.slice(1)); 1910 x2 = bez2[6]; 1911 y2 = bez2[7]; 1912 } else { 1913 bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m]; 1914 x2 = x2m; 1915 y2 = y2m; 1916 } 1917 var intr = interHelper(bez1, bez2, justCount); 1918 if (justCount) { 1919 res += intr; 1920 } else { 1921 for (var k = 0, kk = intr.length; k < kk; k++) { 1922 intr[k].segment1 = i; 1923 intr[k].segment2 = j; 1924 intr[k].bez1 = bez1; 1925 intr[k].bez2 = bez2; 1926 } 1927 res = res.concat(intr); 1928 } 1929 } 1930 } 1931 } 1932 } 1933 return res; 1934 } 1935 /*\ 1936 * Raphael.isPointInsidePath 1937 [ method ] 1938 ** 1939 * Utility method 1940 ** 1941 * Returns `true` if given point is inside a given closed path. 1942 > Parameters 1943 - path (string) path string 1944 - x (number) x of the point 1945 - y (number) y of the point 1946 = (boolean) true, if point is inside the path 1947 \*/ 1948 R.isPointInsidePath = function (path, x, y) { 1949 var bbox = R.pathBBox(path); 1950 return R.isPointInsideBBox(bbox, x, y) && 1951 interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1; 1952 }; 1953 R._removedFactory = function (methodname) { 1954 return function () { 1955 eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); 1956 }; 1957 }; 1958 /*\ 1959 * Raphael.pathBBox 1960 [ method ] 1961 ** 1962 * Utility method 1963 ** 1964 * Return bounding box of a given path 1965 > Parameters 1966 - path (string) path string 1967 = (object) bounding box 1968 o { 1969 o x: (number) x coordinate of the left top point of the box 1970 o y: (number) y coordinate of the left top point of the box 1971 o x2: (number) x coordinate of the right bottom point of the box 1972 o y2: (number) y coordinate of the right bottom point of the box 1973 o width: (number) width of the box 1974 o height: (number) height of the box 1975 o cx: (number) x coordinate of the center of the box 1976 o cy: (number) y coordinate of the center of the box 1977 o } 1978 \*/ 1979 var pathDimensions = R.pathBBox = function (path) { 1980 var pth = paths(path); 1981 if (pth.bbox) { 1982 return clone(pth.bbox); 1983 } 1984 if (!path) { 1985 return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; 1986 } 1987 path = path2curve(path); 1988 var x = 0, 1989 y = 0, 1990 X = [], 1991 Y = [], 1992 p; 1993 for (var i = 0, ii = path.length; i < ii; i++) { 1994 p = path[i]; 1995 if (p[0] == "M") { 1996 x = p[1]; 1997 y = p[2]; 1998 X.push(x); 1999 Y.push(y); 2000 } else { 2001 var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); 2002 X = X[concat](dim.min.x, dim.max.x); 2003 Y = Y[concat](dim.min.y, dim.max.y); 2004 x = p[5]; 2005 y = p[6]; 2006 } 2007 } 2008 var xmin = mmin[apply](0, X), 2009 ymin = mmin[apply](0, Y), 2010 xmax = mmax[apply](0, X), 2011 ymax = mmax[apply](0, Y), 2012 width = xmax - xmin, 2013 height = ymax - ymin, 2014 bb = { 2015 x: xmin, 2016 y: ymin, 2017 x2: xmax, 2018 y2: ymax, 2019 width: width, 2020 height: height, 2021 cx: xmin + width / 2, 2022 cy: ymin + height / 2 2023 }; 2024 pth.bbox = clone(bb); 2025 return bb; 2026 }, 2027 pathClone = function (pathArray) { 2028 var res = clone(pathArray); 2029 res.toString = R._path2string; 2030 return res; 2031 }, 2032 pathToRelative = R._pathToRelative = function (pathArray) { 2033 var pth = paths(pathArray); 2034 if (pth.rel) { 2035 return pathClone(pth.rel); 2036 } 2037 if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption 2038 pathArray = R.parsePathString(pathArray); 2039 } 2040 var res = [], 2041 x = 0, 2042 y = 0, 2043 mx = 0, 2044 my = 0, 2045 start = 0; 2046 if (pathArray[0][0] == "M") { 2047 x = pathArray[0][1]; 2048 y = pathArray[0][2]; 2049 mx = x; 2050 my = y; 2051 start++; 2052 res.push(["M", x, y]); 2053 } 2054 for (var i = start, ii = pathArray.length; i < ii; i++) { 2055 var r = res[i] = [], 2056 pa = pathArray[i]; 2057 if (pa[0] != lowerCase.call(pa[0])) { 2058 r[0] = lowerCase.call(pa[0]); 2059 switch (r[0]) { 2060 case "a": 2061 r[1] = pa[1]; 2062 r[2] = pa[2]; 2063 r[3] = pa[3]; 2064 r[4] = pa[4]; 2065 r[5] = pa[5]; 2066 r[6] = +(pa[6] - x).toFixed(3); 2067 r[7] = +(pa[7] - y).toFixed(3); 2068 break; 2069 case "v": 2070 r[1] = +(pa[1] - y).toFixed(3); 2071 break; 2072 case "m": 2073 mx = pa[1]; 2074 my = pa[2]; 2075 default: 2076 for (var j = 1, jj = pa.length; j < jj; j++) { 2077 r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3); 2078 } 2079 } 2080 } else { 2081 r = res[i] = []; 2082 if (pa[0] == "m") { 2083 mx = pa[1] + x; 2084 my = pa[2] + y; 2085 } 2086 for (var k = 0, kk = pa.length; k < kk; k++) { 2087 res[i][k] = pa[k]; 2088 } 2089 } 2090 var len = res[i].length; 2091 switch (res[i][0]) { 2092 case "z": 2093 x = mx; 2094 y = my; 2095 break; 2096 case "h": 2097 x += +res[i][len - 1]; 2098 break; 2099 case "v": 2100 y += +res[i][len - 1]; 2101 break; 2102 default: 2103 x += +res[i][len - 2]; 2104 y += +res[i][len - 1]; 2105 } 2106 } 2107 res.toString = R._path2string; 2108 pth.rel = pathClone(res); 2109 return res; 2110 }, 2111 pathToAbsolute = R._pathToAbsolute = function (pathArray) { 2112 var pth = paths(pathArray); 2113 if (pth.abs) { 2114 return pathClone(pth.abs); 2115 } 2116 if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption 2117 pathArray = R.parsePathString(pathArray); 2118 } 2119 if (!pathArray || !pathArray.length) { 2120 return [["M", 0, 0]]; 2121 } 2122 var res = [], 2123 x = 0, 2124 y = 0, 2125 mx = 0, 2126 my = 0, 2127 start = 0; 2128 if (pathArray[0][0] == "M") { 2129 x = +pathArray[0][1]; 2130 y = +pathArray[0][2]; 2131 mx = x; 2132 my = y; 2133 start++; 2134 res[0] = ["M", x, y]; 2135 } 2136 var crz = pathArray.length == 3 && pathArray[0][0] == "M" && pathArray[1][0].toUpperCase() == "R" && pathArray[2][0].toUpperCase() == "Z"; 2137 for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) { 2138 res.push(r = []); 2139 pa = pathArray[i]; 2140 if (pa[0] != upperCase.call(pa[0])) { 2141 r[0] = upperCase.call(pa[0]); 2142 switch (r[0]) { 2143 case "A": 2144 r[1] = pa[1]; 2145 r[2] = pa[2]; 2146 r[3] = pa[3]; 2147 r[4] = pa[4]; 2148 r[5] = pa[5]; 2149 r[6] = +(pa[6] + x); 2150 r[7] = +(pa[7] + y); 2151 break; 2152 case "V": 2153 r[1] = +pa[1] + y; 2154 break; 2155 case "H": 2156 r[1] = +pa[1] + x; 2157 break; 2158 case "R": 2159 var dots = [x, y][concat](pa.slice(1)); 2160 for (var j = 2, jj = dots.length; j < jj; j++) { 2161 dots[j] = +dots[j] + x; 2162 dots[++j] = +dots[j] + y; 2163 } 2164 res.pop(); 2165 res = res[concat](catmullRom2bezier(dots, crz)); 2166 break; 2167 case "M": 2168 mx = +pa[1] + x; 2169 my = +pa[2] + y; 2170 default: 2171 for (j = 1, jj = pa.length; j < jj; j++) { 2172 r[j] = +pa[j] + ((j % 2) ? x : y); 2173 } 2174 } 2175 } else if (pa[0] == "R") { 2176 dots = [x, y][concat](pa.slice(1)); 2177 res.pop(); 2178 res = res[concat](catmullRom2bezier(dots, crz)); 2179 r = ["R"][concat](pa.slice(-2)); 2180 } else { 2181 for (var k = 0, kk = pa.length; k < kk; k++) { 2182 r[k] = pa[k]; 2183 } 2184 } 2185 switch (r[0]) { 2186 case "Z": 2187 x = mx; 2188 y = my; 2189 break; 2190 case "H": 2191 x = r[1]; 2192 break; 2193 case "V": 2194 y = r[1]; 2195 break; 2196 case "M": 2197 mx = r[r.length - 2]; 2198 my = r[r.length - 1]; 2199 default: 2200 x = r[r.length - 2]; 2201 y = r[r.length - 1]; 2202 } 2203 } 2204 res.toString = R._path2string; 2205 pth.abs = pathClone(res); 2206 return res; 2207 }, 2208 l2c = function (x1, y1, x2, y2) { 2209 return [x1, y1, x2, y2, x2, y2]; 2210 }, 2211 q2c = function (x1, y1, ax, ay, x2, y2) { 2212 var _13 = 1 / 3, 2213 _23 = 2 / 3; 2214 return [ 2215 _13 * x1 + _23 * ax, 2216 _13 * y1 + _23 * ay, 2217 _13 * x2 + _23 * ax, 2218 _13 * y2 + _23 * ay, 2219 x2, 2220 y2 2221 ]; 2222 }, 2223 a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) { 2224 // for more information of where this math came from visit: 2225 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes 2226 var _120 = PI * 120 / 180, 2227 rad = PI / 180 * (+angle || 0), 2228 res = [], 2229 xy, 2230 rotate = cacher(function (x, y, rad) { 2231 var X = x * math.cos(rad) - y * math.sin(rad), 2232 Y = x * math.sin(rad) + y * math.cos(rad); 2233 return {x: X, y: Y}; 2234 }); 2235 if (!recursive) { 2236 xy = rotate(x1, y1, -rad); 2237 x1 = xy.x; 2238 y1 = xy.y; 2239 xy = rotate(x2, y2, -rad); 2240 x2 = xy.x; 2241 y2 = xy.y; 2242 var cos = math.cos(PI / 180 * angle), 2243 sin = math.sin(PI / 180 * angle), 2244 x = (x1 - x2) / 2, 2245 y = (y1 - y2) / 2; 2246 var h = (x * x) / (rx * rx) + (y * y) / (ry * ry); 2247 if (h > 1) { 2248 h = math.sqrt(h); 2249 rx = h * rx; 2250 ry = h * ry; 2251 } 2252 var rx2 = rx * rx, 2253 ry2 = ry * ry, 2254 k = (large_arc_flag == sweep_flag ? -1 : 1) * 2255 math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))), 2256 cx = k * rx * y / ry + (x1 + x2) / 2, 2257 cy = k * -ry * x / rx + (y1 + y2) / 2, 2258 f1 = math.asin(((y1 - cy) / ry).toFixed(9)), 2259 f2 = math.asin(((y2 - cy) / ry).toFixed(9)); 2260 2261 f1 = x1 < cx ? PI - f1 : f1; 2262 f2 = x2 < cx ? PI - f2 : f2; 2263 f1 < 0 && (f1 = PI * 2 + f1); 2264 f2 < 0 && (f2 = PI * 2 + f2); 2265 if (sweep_flag && f1 > f2) { 2266 f1 = f1 - PI * 2; 2267 } 2268 if (!sweep_flag && f2 > f1) { 2269 f2 = f2 - PI * 2; 2270 } 2271 } else { 2272 f1 = recursive[0]; 2273 f2 = recursive[1]; 2274 cx = recursive[2]; 2275 cy = recursive[3]; 2276 } 2277 var df = f2 - f1; 2278 if (abs(df) > _120) { 2279 var f2old = f2, 2280 x2old = x2, 2281 y2old = y2; 2282 f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1); 2283 x2 = cx + rx * math.cos(f2); 2284 y2 = cy + ry * math.sin(f2); 2285 res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]); 2286 } 2287 df = f2 - f1; 2288 var c1 = math.cos(f1), 2289 s1 = math.sin(f1), 2290 c2 = math.cos(f2), 2291 s2 = math.sin(f2), 2292 t = math.tan(df / 4), 2293 hx = 4 / 3 * rx * t, 2294 hy = 4 / 3 * ry * t, 2295 m1 = [x1, y1], 2296 m2 = [x1 + hx * s1, y1 - hy * c1], 2297 m3 = [x2 + hx * s2, y2 - hy * c2], 2298 m4 = [x2, y2]; 2299 m2[0] = 2 * m1[0] - m2[0]; 2300 m2[1] = 2 * m1[1] - m2[1]; 2301 if (recursive) { 2302 return [m2, m3, m4][concat](res); 2303 } else { 2304 res = [m2, m3, m4][concat](res).join()[split](","); 2305 var newres = []; 2306 for (var i = 0, ii = res.length; i < ii; i++) { 2307 newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x; 2308 } 2309 return newres; 2310 } 2311 }, 2312 findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { 2313 var t1 = 1 - t; 2314 return { 2315 x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x, 2316 y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y 2317 }; 2318 }, 2319 curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { 2320 var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x), 2321 b = 2 * (c1x - p1x) - 2 * (c2x - c1x), 2322 c = p1x - c1x, 2323 t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a, 2324 t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a, 2325 y = [p1y, p2y], 2326 x = [p1x, p2x], 2327 dot; 2328 abs(t1) > "1e12" && (t1 = .5); 2329 abs(t2) > "1e12" && (t2 = .5); 2330 if (t1 > 0 && t1 < 1) { 2331 dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); 2332 x.push(dot.x); 2333 y.push(dot.y); 2334 } 2335 if (t2 > 0 && t2 < 1) { 2336 dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); 2337 x.push(dot.x); 2338 y.push(dot.y); 2339 } 2340 a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y); 2341 b = 2 * (c1y - p1y) - 2 * (c2y - c1y); 2342 c = p1y - c1y; 2343 t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a; 2344 t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a; 2345 abs(t1) > "1e12" && (t1 = .5); 2346 abs(t2) > "1e12" && (t2 = .5); 2347 if (t1 > 0 && t1 < 1) { 2348 dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); 2349 x.push(dot.x); 2350 y.push(dot.y); 2351 } 2352 if (t2 > 0 && t2 < 1) { 2353 dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); 2354 x.push(dot.x); 2355 y.push(dot.y); 2356 } 2357 return { 2358 min: {x: mmin[apply](0, x), y: mmin[apply](0, y)}, 2359 max: {x: mmax[apply](0, x), y: mmax[apply](0, y)} 2360 }; 2361 }), 2362 path2curve = R._path2curve = cacher(function (path, path2) { 2363 var pth = !path2 && paths(path); 2364 if (!path2 && pth.curve) { 2365 return pathClone(pth.curve); 2366 } 2367 var p = pathToAbsolute(path), 2368 p2 = path2 && pathToAbsolute(path2), 2369 attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, 2370 attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, 2371 processPath = function (path, d, pcom) { 2372 var nx, ny
vendor: 5,400 bytes, lines 2372-2481
2372; 2373 if (!path) { 2374 return ["C", d.x, d.y, d.x, d.y, d.x, d.y]; 2375 } 2376 !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null); 2377 switch (path[0]) { 2378 case "M": 2379 d.X = path[1]; 2380 d.Y = path[2]; 2381 break; 2382 case "A": 2383 path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1)))); 2384 break; 2385 case "S": 2386 if (pcom == "C" || pcom == "S") { // In "S" case we have to take into account, if the previous command is C/S. 2387 nx = d.x * 2 - d.bx; // And reflect the previous 2388 ny = d.y * 2 - d.by; // command's control point relative to the current point. 2389 } 2390 else { // or some else or nothing 2391 nx = d.x; 2392 ny = d.y; 2393 } 2394 path = ["C", nx, ny][concat](path.slice(1)); 2395 break; 2396 case "T": 2397 if (pcom == "Q" || pcom == "T") { // In "T" case we have to take into account, if the previous command is Q/T. 2398 d.qx = d.x * 2 - d.qx; // And make a reflection similar 2399 d.qy = d.y * 2 - d.qy; // to case "S". 2400 } 2401 else { // or something else or nothing 2402 d.qx = d.x; 2403 d.qy = d.y; 2404 } 2405 path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2])); 2406 break; 2407 case "Q": 2408 d.qx = path[1]; 2409 d.qy = path[2]; 2410 path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4])); 2411 break; 2412 case "L": 2413 path = ["C"][concat](l2c(d.x, d.y, path[1], path[2])); 2414 break; 2415 case "H": 2416 path = ["C"][concat](l2c(d.x, d.y, path[1], d.y)); 2417 break; 2418 case "V": 2419 path = ["C"][concat](l2c(d.x, d.y, d.x, path[1])); 2420 break; 2421 case "Z": 2422 path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y)); 2423 break; 2424 } 2425 return path; 2426 }, 2427 fixArc = function (pp, i) { 2428 if (pp[i].length > 7) { 2429 pp[i].shift(); 2430 var pi = pp[i]; 2431 while (pi.length) { 2432 pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6))); 2433 } 2434 pp.splice(i, 1); 2435 ii = mmax(p.length, p2 && p2.length || 0); 2436 } 2437 }, 2438 fixM = function (path1, path2, a1, a2, i) { 2439 if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") { 2440 path2.splice(i, 0, ["M", a2.x, a2.y]); 2441 a1.bx = 0; 2442 a1.by = 0; 2443 a1.x = path1[i][1]; 2444 a1.y = path1[i][2]; 2445 ii = mmax(p.length, p2 && p2.length || 0); 2446 } 2447 }; 2448 for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) { 2449 p[i] = processPath(p[i], attrs); 2450 fixArc(p, i); 2451 p2 && (p2[i] = processPath(p2[i], attrs2)); 2452 p2 && fixArc(p2, i); 2453 fixM(p, p2, attrs, attrs2, i); 2454 fixM(p2, p, attrs2, attrs, i); 2455 var seg = p[i], 2456 seg2 = p2 && p2[i], 2457 seglen = seg.length, 2458 seg2len = p2 && seg2.length; 2459 attrs.x = seg[seglen - 2]; 2460 attrs.y = seg[seglen - 1]; 2461 attrs.bx = toFloat(seg[seglen - 4]) || attrs.x; 2462 attrs.by = toFloat(seg[seglen - 3]) || attrs.y; 2463 attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x); 2464 attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y); 2465 attrs2.x = p2 && seg2[seg2len - 2]; 2466 attrs2.y = p2 && seg2[seg2len - 1]; 2467 } 2468 if (!p2) { 2469 pth.curve = pathClone(p); 2470 } 2471 return p2 ? [p, p2] : p; 2472 }, null, pathClone), 2473 parseDots = R._parseDots = cacher(function (gradient) { 2474 var dots = []; 2475 for (var i = 0, ii = gradient.length; i < ii; i++) { 2476 var dot = {}, 2477 par = gradient[i].match(/^([^:]*):?([\d\.]*)/); 2478 dot.color = R.getRGB(par[1]); 2479 if (dot.color.error) { 2480 return null; 2481 }
vendor: 19,475 bytes, lines 2481-3061
2481 2482 dot.color = dot.color.hex; 2483 par[2] && (dot.offset = par[2] + "%"); 2484 dots.push(dot); 2485 } 2486 for (i = 1, ii = dots.length - 1; i < ii; i++) { 2487 if (!dots[i].offset) { 2488 var start = toFloat(dots[i - 1].offset || 0), 2489 end = 0; 2490 for (var j = i + 1; j < ii; j++) { 2491 if (dots[j].offset) { 2492 end = dots[j].offset; 2493 break; 2494 } 2495 } 2496 if (!end) { 2497 end = 100; 2498 j = ii; 2499 } 2500 end = toFloat(end); 2501 var d = (end - start) / (j - i + 1); 2502 for (; i < j; i++) { 2503 start += d; 2504 dots[i].offset = start + "%"; 2505 } 2506 } 2507 } 2508 return dots; 2509 }), 2510 tear = R._tear = function (el, paper) { 2511 el == paper.top && (paper.top = el.prev); 2512 el == paper.bottom && (paper.bottom = el.next); 2513 el.next && (el.next.prev = el.prev); 2514 el.prev && (el.prev.next = el.next); 2515 }, 2516 tofront = R._tofront = function (el, paper) { 2517 if (paper.top === el) { 2518 return; 2519 } 2520 tear(el, paper); 2521 el.next = null; 2522 el.prev = paper.top; 2523 paper.top.next = el; 2524 paper.top = el; 2525 }, 2526 toback = R._toback = function (el, paper) { 2527 if (paper.bottom === el) { 2528 return; 2529 } 2530 tear(el, paper); 2531 el.next = paper.bottom; 2532 el.prev = null; 2533 paper.bottom.prev = el; 2534 paper.bottom = el; 2535 }, 2536 insertafter = R._insertafter = function (el, el2, paper) { 2537 tear(el, paper); 2538 el2 == paper.top && (paper.top = el); 2539 el2.next && (el2.next.prev = el); 2540 el.next = el2.next; 2541 el.prev = el2; 2542 el2.next = el; 2543 }, 2544 insertbefore = R._insertbefore = function (el, el2, paper) { 2545 tear(el, paper); 2546 el2 == paper.bottom && (paper.bottom = el); 2547 el2.prev && (el2.prev.next = el); 2548 el.prev = el2.prev; 2549 el2.prev = el; 2550 el.next = el2; 2551 }, 2552 /*\ 2553 * Raphael.toMatrix 2554 [ method ] 2555 ** 2556 * Utility method 2557 ** 2558 * Returns matrix of transformations applied to a given path 2559 > Parameters 2560 - path (string) path string 2561 - transform (string|array) transformation string 2562 = (object) @Matrix 2563 \*/ 2564 toMatrix = R.toMatrix = function (path, transform) { 2565 var bb = pathDimensions(path), 2566 el = { 2567 _: { 2568 transform: E 2569 }, 2570 getBBox: function () { 2571 return bb; 2572 } 2573 }; 2574 extractTransform(el, transform); 2575 return el.matrix; 2576 }, 2577 /*\ 2578 * Raphael.transformPath 2579 [ method ] 2580 ** 2581 * Utility method 2582 ** 2583 * Returns path transformed by a given transformation 2584 > Parameters 2585 - path (string) path string 2586 - transform (string|array) transformation string 2587 = (string) path 2588 \*/ 2589 transformPath = R.transformPath = function (path, transform) { 2590 return mapPath(path, toMatrix(path, transform)); 2591 }, 2592 extractTransform = R._extractTransform = function (el, tstr) { 2593 if (tstr == null) { 2594 return el._.transform; 2595 } 2596 tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E); 2597 var tdata = R.parseTransformString(tstr), 2598 deg = 0, 2599 dx = 0, 2600 dy = 0, 2601 sx = 1, 2602 sy = 1, 2603 _ = el._, 2604 m = new Matrix; 2605 _.transform = tdata || []; 2606 if (tdata) { 2607 for (var i = 0, ii = tdata.length; i < ii; i++) { 2608 var t = tdata[i], 2609 tlen = t.length, 2610 command = Str(t[0]).toLowerCase(), 2611 absolute = t[0] != command, 2612 inver = absolute ? m.invert() : 0, 2613 x1, 2614 y1, 2615 x2, 2616 y2, 2617 bb; 2618 if (command == "t" && tlen == 3) { 2619 if (absolute) { 2620 x1 = inver.x(0, 0); 2621 y1 = inver.y(0, 0); 2622 x2 = inver.x(t[1], t[2]); 2623 y2 = inver.y(t[1], t[2]); 2624 m.translate(x2 - x1, y2 - y1); 2625 } else { 2626 m.translate(t[1], t[2]); 2627 } 2628 } else if (command == "r") { 2629 if (tlen == 2) { 2630 bb = bb || el.getBBox(1); 2631 m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2); 2632 deg += t[1]; 2633 } else if (tlen == 4) { 2634 if (absolute) { 2635 x2 = inver.x(t[2], t[3]); 2636 y2 = inver.y(t[2], t[3]); 2637 m.rotate(t[1], x2, y2); 2638 } else { 2639 m.rotate(t[1], t[2], t[3]); 2640 } 2641 deg += t[1]; 2642 } 2643 } else if (command == "s") { 2644 if (tlen == 2 || tlen == 3) { 2645 bb = bb || el.getBBox(1); 2646 m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2); 2647 sx *= t[1]; 2648 sy *= t[tlen - 1]; 2649 } else if (tlen == 5) { 2650 if (absolute) { 2651 x2 = inver.x(t[3], t[4]); 2652 y2 = inver.y(t[3], t[4]); 2653 m.scale(t[1], t[2], x2, y2); 2654 } else { 2655 m.scale(t[1], t[2], t[3], t[4]); 2656 } 2657 sx *= t[1]; 2658 sy *= t[2]; 2659 } 2660 } else if (command == "m" && tlen == 7) { 2661 m.add(t[1], t[2], t[3], t[4], t[5], t[6]); 2662 } 2663 _.dirtyT = 1; 2664 el.matrix = m; 2665 } 2666 } 2667 2668 /*\ 2669 * Element.matrix 2670 [ property (object) ] 2671 ** 2672 * Keeps @Matrix object, which represents element transformation 2673 \*/ 2674 el.matrix = m; 2675 2676 _.sx = sx; 2677 _.sy = sy; 2678 _.deg = deg; 2679 _.dx = dx = m.e; 2680 _.dy = dy = m.f; 2681 2682 if (sx == 1 && sy == 1 && !deg && _.bbox) { 2683 _.bbox.x += +dx; 2684 _.bbox.y += +dy; 2685 } else { 2686 _.dirtyT = 1; 2687 } 2688 }, 2689 getEmpty = function (item) { 2690 var l = item[0]; 2691 switch (l.toLowerCase()) { 2692 case "t": return [l, 0, 0]; 2693 case "m": return [l, 1, 0, 0, 1, 0, 0]; 2694 case "r": if (item.length == 4) { 2695 return [l, 0, item[2], item[3]]; 2696 } else { 2697 return [l, 0]; 2698 } 2699 case "s": if (item.length == 5) { 2700 return [l, 1, 1, item[3], item[4]]; 2701 } else if (item.length == 3) { 2702 return [l, 1, 1]; 2703 } else { 2704 return [l, 1]; 2705 } 2706 } 2707 }, 2708 equaliseTransform = R._equaliseTransform = function (t1, t2) { 2709 t2 = Str(t2).replace(/\.{3}|\u2026/g, t1); 2710 t1 = R.parseTransformString(t1) || []; 2711 t2 = R.parseTransformString(t2) || []; 2712 var maxlength = mmax(t1.length, t2.length), 2713 from = [], 2714 to = [], 2715 i = 0, j, jj, 2716 tt1, tt2; 2717 for (; i < maxlength; i++) { 2718 tt1 = t1[i] || getEmpty(t2[i]); 2719 tt2 = t2[i] || getEmpty(tt1); 2720 if ((tt1[0] != tt2[0]) || 2721 (tt1[0].toLowerCase() == "r" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) || 2722 (tt1[0].toLowerCase() == "s" && (tt1[3] != tt2[3] || tt1[4] != tt2[4])) 2723 ) { 2724 return; 2725 } 2726 from[i] = []; 2727 to[i] = []; 2728 for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) { 2729 j in tt1 && (from[i][j] = tt1[j]); 2730 j in tt2 && (to[i][j] = tt2[j]); 2731 } 2732 } 2733 return { 2734 from: from, 2735 to: to 2736 }; 2737 }; 2738 R._getContainer = function (x, y, w, h) { 2739 var container; 2740 container = h == null && !R.is(x, "object") ? g.doc.getElementById(x) : x; 2741 if (container == null) { 2742 return; 2743 } 2744 if (container.tagName) { 2745 if (y == null) { 2746 return { 2747 container: container, 2748 width: container.style.pixelWidth || container.offsetWidth, 2749 height: container.style.pixelHeight || container.offsetHeight 2750 }; 2751 } else { 2752 return { 2753 container: container, 2754 width: y, 2755 height: w 2756 }; 2757 } 2758 } 2759 return { 2760 container: 1, 2761 x: x, 2762 y: y, 2763 width: w, 2764 height: h 2765 }; 2766 }; 2767 /*\ 2768 * Raphael.pathToRelative 2769 [ method ] 2770 ** 2771 * Utility method 2772 ** 2773 * Converts path to relative form 2774 > Parameters 2775 - pathString (string|array) path string or array of segments 2776 = (array) array of segments. 2777 \*/ 2778 R.pathToRelative = pathToRelative; 2779 R._engine = {}; 2780 /*\ 2781 * Raphael.path2curve 2782 [ method ] 2783 ** 2784 * Utility method 2785 ** 2786 * Converts path to a new path where all segments are cubic bezier curves. 2787 > Parameters 2788 - pathString (string|array) path string or array of segments 2789 = (array) array of segments. 2790 \*/ 2791 R.path2curve = path2curve; 2792 /*\ 2793 * Raphael.matrix 2794 [ method ] 2795 ** 2796 * Utility method 2797 ** 2798 * Returns matrix based on given parameters. 2799 > Parameters 2800 - a (number) 2801 - b (number) 2802 - c (number) 2803 - d (number) 2804 - e (number) 2805 - f (number) 2806 = (object) @Matrix 2807 \*/ 2808 R.matrix = function (a, b, c, d, e, f) { 2809 return new Matrix(a, b, c, d, e, f); 2810 }; 2811 function Matrix(a, b, c, d, e, f) { 2812 if (a != null) { 2813 this.a = +a; 2814 this.b = +b; 2815 this.c = +c; 2816 this.d = +d; 2817 this.e = +e; 2818 this.f = +f; 2819 } else { 2820 this.a = 1; 2821 this.b = 0; 2822 this.c = 0; 2823 this.d = 1; 2824 this.e = 0; 2825 this.f = 0; 2826 } 2827 } 2828 (function (matrixproto) { 2829 /*\ 2830 * Matrix.add 2831 [ method ] 2832 ** 2833 * Adds given matrix to existing one. 2834 > Parameters 2835 - a (number) 2836 - b (number) 2837 - c (number) 2838 - d (number) 2839 - e (number) 2840 - f (number) 2841 or 2842 - matrix (object) @Matrix 2843 \*/ 2844 matrixproto.add = function (a, b, c, d, e, f) { 2845 var out = [[], [], []], 2846 m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], 2847 matrix = [[a, c, e], [b, d, f], [0, 0, 1]], 2848 x, y, z, res; 2849 2850 if (a && a instanceof Matrix) { 2851 matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]]; 2852 } 2853 2854 for (x = 0; x < 3; x++) { 2855 for (y = 0; y < 3; y++) { 2856 res = 0; 2857 for (z = 0; z < 3; z++) { 2858 res += m[x][z] * matrix[z][y]; 2859 } 2860 out[x][y] = res; 2861 } 2862 } 2863 this.a = out[0][0]; 2864 this.b = out[1][0]; 2865 this.c = out[0][1]; 2866 this.d = out[1][1]; 2867 this.e = out[0][2]; 2868 this.f = out[1][2]; 2869 }; 2870 /*\ 2871 * Matrix.invert 2872 [ method ] 2873 ** 2874 * Returns inverted version of the matrix 2875 = (object) @Matrix 2876 \*/ 2877 matrixproto.invert = function () { 2878 var me = this, 2879 x = me.a * me.d - me.b * me.c; 2880 return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); 2881 }; 2882 /*\ 2883 * Matrix.clone 2884 [ method ] 2885 ** 2886 * Returns copy of the matrix 2887 = (object) @Matrix 2888 \*/ 2889 matrixproto.clone = function () { 2890 return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); 2891 }; 2892 /*\ 2893 * Matrix.translate 2894 [ method ] 2895 ** 2896 * Translate the matrix 2897 > Parameters 2898 - x (number) 2899 - y (number) 2900 \*/ 2901 matrixproto.translate = function (x, y) { 2902 this.add(1, 0, 0, 1, x, y); 2903 }; 2904 /*\ 2905 * Matrix.scale 2906 [ method ] 2907 ** 2908 * Scales the matrix 2909 > Parameters 2910 - x (number) 2911 - y (number) #optional 2912 - cx (number) #optional 2913 - cy (number) #optional 2914 \*/ 2915 matrixproto.scale = function (x, y, cx, cy) { 2916 y == null && (y = x); 2917 (cx || cy) && this.add(1, 0, 0, 1, cx, cy); 2918 this.add(x, 0, 0, y, 0, 0); 2919 (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); 2920 }; 2921 /*\ 2922 * Matrix.rotate 2923 [ method ] 2924 ** 2925 * Rotates the matrix 2926 > Parameters 2927 - a (number) 2928 - x (number) 2929 - y (number) 2930 \*/ 2931 matrixproto.rotate = function (a, x, y) { 2932 a = R.rad(a); 2933 x = x || 0; 2934 y = y || 0; 2935 var cos = +math.cos(a).toFixed(9), 2936 sin = +math.sin(a).toFixed(9); 2937 this.add(cos, sin, -sin, cos, x, y); 2938 this.add(1, 0, 0, 1, -x, -y); 2939 }; 2940 /*\ 2941 * Matrix.x 2942 [ method ] 2943 ** 2944 * Return x coordinate for given point after transformation described by the matrix. See also @Matrix.y 2945 > Parameters 2946 - x (number) 2947 - y (number) 2948 = (number) x 2949 \*/ 2950 matrixproto.x = function (x, y) { 2951 return x * this.a + y * this.c + this.e; 2952 }; 2953 /*\ 2954 * Matrix.y 2955 [ method ] 2956 ** 2957 * Return y coordinate for given point after transformation described by the matrix. See also @Matrix.x 2958 > Parameters 2959 - x (number) 2960 - y (number) 2961 = (number) y 2962 \*/ 2963 matrixproto.y = function (x, y) { 2964 return x * this.b + y * this.d + this.f; 2965 }; 2966 matrixproto.get = function (i) { 2967 return +this[Str.fromCharCode(97 + i)].toFixed(4); 2968 }; 2969 matrixproto.toString = function () { 2970 return R.svg ? 2971 "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")" : 2972 [this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join(); 2973 }; 2974 matrixproto.toFilter = function () { 2975 return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.get(0) + 2976 ", M12=" + this.get(2) + ", M21=" + this.get(1) + ", M22=" + this.get(3) + 2977 ", Dx=" + this.get(4) + ", Dy=" + this.get(5) + ", sizingmethod='auto expand')"; 2978 }; 2979 matrixproto.offset = function () { 2980 return [this.e.toFixed(4), this.f.toFixed(4)]; 2981 }; 2982 function norm(a) { 2983 return a[0] * a[0] + a[1] * a[1]; 2984 } 2985 function normalize(a) { 2986 var mag = math.sqrt(norm(a)); 2987 a[0] && (a[0] /= mag); 2988 a[1] && (a[1] /= mag); 2989 } 2990 /*\ 2991 * Matrix.split 2992 [ method ] 2993 ** 2994 * Splits matrix into primitive transformations 2995 = (object) in format: 2996 o dx (number) translation by x 2997 o dy (number) translation by y 2998 o scalex (number) scale by x 2999 o scaley (number) scale by y 3000 o shear (number) shear 3001 o rotate (number) rotation in deg 3002 o isSimple (boolean) could it be represented via simple transformations 3003 \*/ 3004 matrixproto.split = function () { 3005 var out = {}; 3006 // translation 3007 out.dx = this.e; 3008 out.dy = this.f; 3009 3010 // scale and shear 3011 var row = [[this.a, this.c], [this.b, this.d]]; 3012 out.scalex = math.sqrt(norm(row[0])); 3013 normalize(row[0]); 3014 3015 out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1]; 3016 row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear]; 3017 3018 out.scaley = math.sqrt(norm(row[1])); 3019 normalize(row[1]); 3020 out.shear /= out.scaley; 3021 3022 // rotation 3023 var sin = -row[0][1], 3024 cos = row[1][1]; 3025 if (cos < 0) { 3026 out.rotate = R.deg(math.acos(cos)); 3027 if (sin < 0) { 3028 out.rotate = 360 - out.rotate; 3029 } 3030 } else { 3031 out.rotate = R.deg(math.asin(sin)); 3032 } 3033 3034 out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate); 3035 out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate; 3036 out.noRotation = !+out.shear.toFixed(9) && !out.rotate; 3037 return out; 3038 }; 3039 /*\ 3040 * Matrix.toTransformString 3041 [ method ] 3042 ** 3043 * Return transform string that represents given matrix 3044 = (string) transform string 3045 \*/ 3046 matrixproto.toTransformString = function (shorter) { 3047 var s = shorter || this[split](); 3048 if (s.isSimple) { 3049 s.scalex = +s.scalex.toFixed(4); 3050 s.scaley = +s.scaley.toFixed(4); 3051 s.rotate = +s.rotate.toFixed(4); 3052 return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + 3053 (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + 3054 (s.rotate ? "r" + [s.rotate, 0, 0] : E); 3055 } else { 3056 return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)]; 3057 } 3058 }; 3059 })(Matrix.prototype); 3060 3061
3061// WebKit rendering bug workaround method 3062 var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); 3063 if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || 3064 (navigator.vendor == "Google Inc." && version && version[1] < 8)) { 3065 /*\
vendor: 16,384 bytes, lines 3066-3585
3066 * Paper.safari 3067 [ method ] 3068 ** 3069 * There is an inconvenient rendering bug in Safari (WebKit): 3070 * sometimes the rendering should be forced. 3071 * This method should help with dealing with this bug. 3072 \*/ 3073 paperproto.safari = function () { 3074 var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); 3075 setTimeout(function () {rect.remove();}); 3076 }; 3077 } else { 3078 paperproto.safari = fun; 3079 } 3080 3081 var preventDefault = function () { 3082 this.returnValue = false; 3083 }, 3084 preventTouch = function () { 3085 return this.originalEvent.preventDefault(); 3086 }, 3087 stopPropagation = function () { 3088 this.cancelBubble = true; 3089 }, 3090 stopTouch = function () { 3091 return this.originalEvent.stopPropagation(); 3092 }, 3093 getEventPosition = function (e) { 3094 var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, 3095 scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft; 3096 3097 return { 3098 x: e.clientX + scrollX, 3099 y: e.clientY + scrollY 3100 }; 3101 }, 3102 addEvent = (function () { 3103 if (g.doc.addEventListener) { 3104 return function (obj, type, fn, element) { 3105 var f = function (e) { 3106 var pos = getEventPosition(e); 3107 return fn.call(element, e, pos.x, pos.y); 3108 }; 3109 obj.addEventListener(type, f, false); 3110 3111 if (supportsTouch && touchMap[type]) { 3112 var _f = function (e) { 3113 var pos = getEventPosition(e), 3114 olde = e; 3115 3116 for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) { 3117 if (e.targetTouches[i].target == obj) { 3118 e = e.targetTouches[i]; 3119 e.originalEvent = olde; 3120 e.preventDefault = preventTouch; 3121 e.stopPropagation = stopTouch; 3122 break; 3123 } 3124 } 3125 3126 return fn.call(element, e, pos.x, pos.y); 3127 }; 3128 obj.addEventListener(touchMap[type], _f, false); 3129 } 3130 3131 return function () { 3132 obj.removeEventListener(type, f, false); 3133 3134 if (supportsTouch && touchMap[type]) 3135 obj.removeEventListener(touchMap[type], f, false); 3136 3137 return true; 3138 }; 3139 }; 3140 } else if (g.doc.attachEvent) { 3141 return function (obj, type, fn, element) { 3142 var f = function (e) { 3143 e = e || g.win.event; 3144 var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, 3145 scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft, 3146 x = e.clientX + scrollX, 3147 y = e.clientY + scrollY; 3148 e.preventDefault = e.preventDefault || preventDefault; 3149 e.stopPropagation = e.stopPropagation || stopPropagation; 3150 return fn.call(element, e, x, y); 3151 }; 3152 obj.attachEvent("on" + type, f); 3153 var detacher = function () { 3154 obj.detachEvent("on" + type, f); 3155 return true; 3156 }; 3157 return detacher; 3158 }; 3159 } 3160 })(), 3161 drag = [], 3162 dragMove = function (e) { 3163 var x = e.clientX, 3164 y = e.clientY, 3165 scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, 3166 scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft, 3167 dragi, 3168 j = drag.length; 3169 while (j--) { 3170 dragi = drag[j]; 3171 if (supportsTouch && e.touches) { 3172 var i = e.touches.length, 3173 touch; 3174 while (i--) { 3175 touch = e.touches[i]; 3176 if (touch.identifier == dragi.el._drag.id) { 3177 x = touch.clientX; 3178 y = touch.clientY; 3179 (e.originalEvent ? e.originalEvent : e).preventDefault(); 3180 break; 3181 } 3182 } 3183 } else { 3184 e.preventDefault(); 3185 } 3186 var node = dragi.el.node, 3187 o, 3188 next = node.nextSibling, 3189 parent = node.parentNode, 3190 display = node.style.display; 3191 g.win.opera && parent.removeChild(node); 3192 node.style.display = "none"; 3193 o = dragi.el.paper.getElementByPoint(x, y); 3194 node.style.display = display; 3195 g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node)); 3196 o && eve("raphael.drag.over." + dragi.el.id, dragi.el, o); 3197 x += scrollX; 3198 y += scrollY; 3199 eve("raphael.drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e); 3200 } 3201 }, 3202 dragUp = function (e) { 3203 R.unmousemove(dragMove).unmouseup(dragUp); 3204 var i = drag.length, 3205 dragi; 3206 while (i--) { 3207 dragi = drag[i]; 3208 dragi.el._drag = {}; 3209 eve("raphael.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e); 3210 } 3211 drag = []; 3212 }, 3213 /*\ 3214 * Raphael.el 3215 [ property (object) ] 3216 ** 3217 * You can add your own method to elements. This is usefull when you want to hack default functionality or 3218 * want to wrap some common transformation or attributes in one method. In difference to canvas methods, 3219 * you can redefine element method at any time. Expending element methods wouldnât affect set. 3220 > Usage 3221 | Raphael.el.red = function () { 3222 | this.attr({fill: "#f00"}); 3223 | }; 3224 | // then use it 3225 | paper.circle(100, 100, 20).red(); 3226 \*/ 3227 elproto = R.el = {}; 3228 /*\ 3229 * Element.click 3230 [ method ] 3231 ** 3232 * Adds event handler for click for the element. 3233 > Parameters 3234 - handler (function) handler for the event 3235 = (object) @Element 3236 \*/ 3237 /*\ 3238 * Element.unclick 3239 [ method ] 3240 ** 3241 * Removes event handler for click for the element. 3242 > Parameters 3243 - handler (function) #optional handler for the event 3244 = (object) @Element 3245 \*/ 3246 3247 /*\ 3248 * Element.dblclick 3249 [ method ] 3250 ** 3251 * Adds event handler for double click for the element. 3252 > Parameters 3253 - handler (function) handler for the event 3254 = (object) @Element 3255 \*/ 3256 /*\ 3257 * Element.undblclick 3258 [ method ] 3259 ** 3260 * Removes event handler for double click for the element. 3261 > Parameters 3262 - handler (function) #optional handler for the event 3263 = (object) @Element 3264 \*/ 3265 3266 /*\ 3267 * Element.mousedown 3268 [ method ] 3269 ** 3270 * Adds event handler for mousedown for the element. 3271 > Parameters 3272 - handler (function) handler for the event 3273 = (object) @Element 3274 \*/ 3275 /*\ 3276 * Element.unmousedown 3277 [ method ] 3278 ** 3279 * Removes event handler for mousedown for the element. 3280 > Parameters 3281 - handler (function) #optional handler for the event 3282 = (object) @Element 3283 \*/ 3284 3285 /*\ 3286 * Element.mousemove 3287 [ method ] 3288 ** 3289 * Adds event handler for mousemove for the element. 3290 > Parameters 3291 - handler (function) handler for the event 3292 = (object) @Element 3293 \*/ 3294 /*\ 3295 * Element.unmousemove 3296 [ method ] 3297 ** 3298 * Removes event handler for mousemove for the element. 3299 > Parameters 3300 - handler (function) #optional handler for the event 3301 = (object) @Element 3302 \*/ 3303 3304 /*\ 3305 * Element.mouseout 3306 [ method ] 3307 ** 3308 * Adds event handler for mouseout for the element. 3309 > Parameters 3310 - handler (function) handler for the event 3311 = (object) @Element 3312 \*/ 3313 /*\ 3314 * Element.unmouseout 3315 [ method ] 3316 ** 3317 * Removes event handler for mouseout for the element. 3318 > Parameters 3319 - handler (function) #optional handler for the event 3320 = (object) @Element 3321 \*/ 3322 3323 /*\ 3324 * Element.mouseover 3325 [ method ] 3326 ** 3327 * Adds event handler for mouseover for the element. 3328 > Parameters 3329 - handler (function) handler for the event 3330 = (object) @Element 3331 \*/ 3332 /*\ 3333 * Element.unmouseover 3334 [ method ] 3335 ** 3336 * Removes event handler for mouseover for the element. 3337 > Parameters 3338 - handler (function) #optional handler for the event 3339 = (object) @Element 3340 \*/ 3341 3342 /*\ 3343 * Element.mouseup 3344 [ method ] 3345 ** 3346 * Adds event handler for mouseup for the element. 3347 > Parameters 3348 - handler (function) handler for the event 3349 = (object) @Element 3350 \*/ 3351 /*\ 3352 * Element.unmouseup 3353 [ method ] 3354 ** 3355 * Removes event handler for mouseup for the element. 3356 > Parameters 3357 - handler (function) #optional handler for the event 3358 = (object) @Element 3359 \*/ 3360 3361 /*\ 3362 * Element.touchstart 3363 [ method ] 3364 ** 3365 * Adds event handler for touchstart for the element. 3366 > Parameters 3367 - handler (function) handler for the event 3368 = (object) @Element 3369 \*/ 3370 /*\ 3371 * Element.untouchstart 3372 [ method ] 3373 ** 3374 * Removes event handler for touchstart for the element. 3375 > Parameters 3376 - handler (function) #optional handler for the event 3377 = (object) @Element 3378 \*/ 3379 3380 /*\ 3381 * Element.touchmove 3382 [ method ] 3383 ** 3384 * Adds event handler for touchmove for the element. 3385 > Parameters 3386 - handler (function) handler for the event 3387 = (object) @Element 3388 \*/ 3389 /*\ 3390 * Element.untouchmove 3391 [ method ] 3392 ** 3393 * Removes event handler for touchmove for the element. 3394 > Parameters 3395 - handler (function) #optional handler for the event 3396 = (object) @Element 3397 \*/ 3398 3399 /*\ 3400 * Element.touchend 3401 [ method ] 3402 ** 3403 * Adds event handler for touchend for the element. 3404 > Parameters 3405 - handler (function) handler for the event 3406 = (object) @Element 3407 \*/ 3408 /*\ 3409 * Element.untouchend 3410 [ method ] 3411 ** 3412 * Removes event handler for touchend for the element. 3413 > Parameters 3414 - handler (function) #optional handler for the event 3415 = (object) @Element 3416 \*/ 3417 3418 /*\ 3419 * Element.touchcancel 3420 [ method ] 3421 ** 3422 * Adds event handler for touchcancel for the element. 3423 > Parameters 3424 - handler (function) handler for the event 3425 = (object) @Element 3426 \*/ 3427 /*\ 3428 * Element.untouchcancel 3429 [ method ] 3430 ** 3431 * Removes event handler for touchcancel for the element. 3432 > Parameters 3433 - handler (function) #optional handler for the event 3434 = (object) @Element 3435 \*/ 3436 for (var i = events.length; i--;) { 3437 (function (eventName) { 3438 R[eventName] = elproto[eventName] = function (fn, scope) { 3439 if (R.is(fn, "function")) { 3440 this.events = this.events || []; 3441 this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)}); 3442 } 3443 return this; 3444 }; 3445 R["un" + eventName] = elproto["un" + eventName] = function (fn) { 3446 var events = this.events || [], 3447 l = events.length; 3448 while (l--){ 3449 if (events[l].name == eventName && (R.is(fn, "undefined") || events[l].f == fn)) { 3450 events[l].unbind(); 3451 events.splice(l, 1); 3452 !events.length && delete this.events; 3453 } 3454 } 3455 return this; 3456 }; 3457 })(events[i]); 3458 } 3459 3460 /*\ 3461 * Element.data 3462 [ method ] 3463 ** 3464 * Adds or retrieves given value asociated with given key. 3465 ** 3466 * See also @Element.removeData 3467 > Parameters 3468 - key (string) key to store data 3469 - value (any) #optional value to store 3470 = (object) @Element 3471 * or, if value is not specified: 3472 = (any) value 3473 * or, if key and value are not specified: 3474 = (object) Key/value pairs for all the data associated with the element. 3475 > Usage 3476 | for (var i = 0, i < 5, i++) { 3477 | paper.circle(10 + 15 * i, 10, 10) 3478 | .attr({fill: "#000"}) 3479 | .data("i", i) 3480 | .click(function () { 3481 | alert(this.data("i")); 3482 | }); 3483 | } 3484 \*/ 3485 elproto.data = function (key, value) { 3486 var data = eldata[this.id] = eldata[this.id] || {}; 3487 if (arguments.length == 0) { 3488 return data; 3489 } 3490 if (arguments.length == 1) { 3491 if (R.is(key, "object")) { 3492 for (var i in key) if (key[has](i)) { 3493 this.data(i, key[i]); 3494 } 3495 return this; 3496 } 3497 eve("raphael.data.get." + this.id, this, data[key], key); 3498 return data[key]; 3499 } 3500 data[key] = value; 3501 eve("raphael.data.set." + this.id, this, value, key); 3502 return this; 3503 }; 3504 /*\ 3505 * Element.removeData 3506 [ method ] 3507 ** 3508 * Removes value associated with an element by given key. 3509 * If key is not provided, removes all the data of the element. 3510 > Parameters 3511 - key (string) #optional key 3512 = (object) @Element 3513 \*/ 3514 elproto.removeData = function (key) { 3515 if (key == null) { 3516 eldata[this.id] = {}; 3517 } else { 3518 eldata[this.id] && delete eldata[this.id][key]; 3519 } 3520 return this; 3521 }; 3522 /*\ 3523 * Element.getData 3524 [ method ] 3525 ** 3526 * Retrieves the element data 3527 = (object) data 3528 \*/ 3529 elproto.getData = function () { 3530 return clone(eldata[this.id] || {}); 3531 }; 3532 /*\ 3533 * Element.hover 3534 [ method ] 3535 ** 3536 * Adds event handlers for hover for the element. 3537 > Parameters 3538 - f_in (function) handler for hover in 3539 - f_out (function) handler for hover out 3540 - icontext (object) #optional context for hover in handler 3541 - ocontext (object) #optional context for hover out handler 3542 = (object) @Element 3543 \*/ 3544 elproto.hover = function (f_in, f_out, scope_in, scope_out) { 3545 return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); 3546 }; 3547 /*\ 3548 * Element.unhover 3549 [ method ] 3550 ** 3551 * Removes event handlers for hover for the element. 3552 > Parameters 3553 - f_in (function) handler for hover in 3554 - f_out (function) handler for hover out 3555 = (object) @Element 3556 \*/ 3557 elproto.unhover = function (f_in, f_out) { 3558 return this.unmouseover(f_in).unmouseout(f_out); 3559 }; 3560 var draggable = []; 3561 /*\ 3562 * Element.drag 3563 [ method ] 3564 ** 3565 * Adds event handlers for drag of the element. 3566 > Parameters 3567 - onmove (function) handler for moving 3568 - onstart (function) handler for drag start 3569 - onend (function) handler for drag end 3570 - mcontext (object) #optional context for moving handler 3571 - scontext (object) #optional context for drag start handler 3572 - econtext (object) #optional context for drag end handler 3573 * Additionaly following `drag` events will be triggered: `drag.start.<id>` on start, 3574 * `drag.end.<id>` on end and `drag.move.<id>` on every move. When element will be dragged over another element 3575 * `drag.over.<id>` will be fired as well. 3576 * 3577 * Start event and start handler will be called in specified context or in context of the element with following parameters: 3578 o x (number) x position of the mouse 3579 o y (number) y position of the mouse 3580 o event (object) DOM event object 3581 * Move event and move handler will be called in specified context or in context of the element with following parameters: 3582 o dx (number) shift by x from the start point 3583 o dy (number) shift by y from the start point 3584 o x (number) x position of the mouse 3585 o y (number) y position of th
3585e mouse 3586 o event (object) DOM event object 3587 * End event and end handler will be called in specified context or in context of the element with following parameters: 3588 o event (object) DOM event object 3589 = (object) @Element 3590 \*/ 3591 elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { 3592 function start(e) { 3593 (e.originalEvent || e).preventDefault(); 3594 var x = e.clientX, 3595 y = e.clientY, 3596 scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, 3597 scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft; 3598 this._drag.id = e.identifier; 3599 if (supportsTouch && e.touches) { 3600 var i = e.touches.length, touch; 3601 while (i--) { 3602 touch = e.touches[i]; 3603 this._drag.id = touch.identifier; 3604 if (touch.identifier == this._drag.id) { 3605 x = touch.clientX; 3606 y = touch.clientY; 3607 break; 3608 } 3609 } 3610 } 3611 this._drag.x = x + scrollX; 3612 this._drag.y = y + scrollY; 3613 !drag.length && R.mousemove(dragMove).mouseup(dragUp); 3614 drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope}); 3615 onstart && eve.on("raphael.drag.start." + this.id, onstart); 3616 onmove && eve.on("raphael.drag.move." + this.id, onmove); 3617 onend && eve.on("raphael.drag.end." + this.id, onend); 3618 eve("raphael.drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY
vendor: 8,715 bytes, lines 3618-3859
3618, e); 3619 } 3620 this._drag = {}; 3621 draggable.push({el: this, start: start}); 3622 this.mousedown(start); 3623 return this; 3624 }; 3625 /*\ 3626 * Element.onDragOver 3627 [ method ] 3628 ** 3629 * Shortcut for assigning event handler for `drag.over.<id>` event, where id is id of the element (see @Element.id). 3630 > Parameters 3631 - f (function) handler for event, first argument would be the element you are dragging over 3632 \*/ 3633 elproto.onDragOver = function (f) { 3634 f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); 3635 }; 3636 /*\ 3637 * Element.undrag 3638 [ method ] 3639 ** 3640 * Removes all drag event handlers from given element. 3641 \*/ 3642 elproto.undrag = function () { 3643 var i = draggable.length; 3644 while (i--) if (draggable[i].el == this) { 3645 this.unmousedown(draggable[i].start); 3646 draggable.splice(i, 1); 3647 eve.unbind("raphael.drag.*." + this.id); 3648 } 3649 !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); 3650 drag = []; 3651 }; 3652 /*\ 3653 * Paper.circle 3654 [ method ] 3655 ** 3656 * Draws a circle. 3657 ** 3658 > Parameters 3659 ** 3660 - x (number) x coordinate of the centre 3661 - y (number) y coordinate of the centre 3662 - r (number) radius 3663 = (object) Raphaël element object with type âcircleâ 3664 ** 3665 > Usage 3666 | var c = paper.circle(50, 50, 40); 3667 \*/ 3668 paperproto.circle = function (x, y, r) { 3669 var out = R._engine.circle(this, x || 0, y || 0, r || 0); 3670 this.__set__ && this.__set__.push(out); 3671 return out; 3672 }; 3673 /*\ 3674 * Paper.rect 3675 [ method ] 3676 * 3677 * Draws a rectangle. 3678 ** 3679 > Parameters 3680 ** 3681 - x (number) x coordinate of the top left corner 3682 - y (number) y coordinate of the top left corner 3683 - width (number) width 3684 - height (number) height 3685 - r (number) #optional radius for rounded corners, default is 0 3686 = (object) Raphaël element object with type ârectâ 3687 ** 3688 > Usage 3689 | // regular rectangle 3690 | var c = paper.rect(10, 10, 50, 50); 3691 | // rectangle with rounded corners 3692 | var c = paper.rect(40, 40, 50, 50, 10); 3693 \*/ 3694 paperproto.rect = function (x, y, w, h, r) { 3695 var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); 3696 this.__set__ && this.__set__.push(out); 3697 return out; 3698 }; 3699 /*\ 3700 * Paper.ellipse 3701 [ method ] 3702 ** 3703 * Draws an ellipse. 3704 ** 3705 > Parameters 3706 ** 3707 - x (number) x coordinate of the centre 3708 - y (number) y coordinate of the centre 3709 - rx (number) horizontal radius 3710 - ry (number) vertical radius 3711 = (object) Raphaël element object with type âellipseâ 3712 ** 3713 > Usage 3714 | var c = paper.ellipse(50, 50, 40, 20); 3715 \*/ 3716 paperproto.ellipse = function (x, y, rx, ry) { 3717 var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); 3718 this.__set__ && this.__set__.push(out); 3719 return out; 3720 }; 3721 /*\ 3722 * Paper.path 3723 [ method ] 3724 ** 3725 * Creates a path element by given path data string. 3726 > Parameters 3727 - pathString (string) #optional path string in SVG format. 3728 * Path string consists of one-letter commands, followed by comma seprarated arguments in numercal form. Example: 3729 | "M10,20L30,40" 3730 * Here we can see two commands: âMâ, with arguments `(10, 20)` and âLâ with arguments `(30, 40)`. Upper case letter mean command is absolute, lower caseârelative. 3731 * 3732 # <p>Here is short list of commands available, for more details see <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path's data attribute's format are described in the SVG specification.">SVG path string format</a>.</p> 3733 # <table><thead><tr><th>Command</th><th>Name</th><th>Parameters</th></tr></thead><tbody> 3734 # <tr><td>M</td><td>moveto</td><td>(x y)+</td></tr> 3735 # <tr><td>Z</td><td>closepath</td><td>(none)</td></tr> 3736 # <tr><td>L</td><td>lineto</td><td>(x y)+</td></tr> 3737 # <tr><td>H</td><td>horizontal lineto</td><td>x+</td></tr> 3738 # <tr><td>V</td><td>vertical lineto</td><td>y+</td></tr> 3739 # <tr><td>C</td><td>curveto</td><td>(x1 y1 x2 y2 x y)+</td></tr> 3740 # <tr><td>S</td><td>smooth curveto</td><td>(x2 y2 x y)+</td></tr> 3741 # <tr><td>Q</td><td>quadratic Bézier curveto</td><td>(x1 y1 x y)+</td></tr> 3742 # <tr><td>T</td><td>smooth quadratic Bézier curveto</td><td>(x y)+</td></tr> 3743 # <tr><td>A</td><td>elliptical arc</td><td>(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+</td></tr> 3744 # <tr><td>R</td><td><a href="http://en.wikipedia.org/wiki/CatmullâRom_spline#Catmull.E2.80.93Rom_spline">Catmull-Rom curveto</a>*</td><td>x1 y1 (x y)+</td></tr></tbody></table> 3745 * * âCatmull-Rom curvetoâ is a not standard SVG command and added in 2.0 to make life easier. 3746 * Note: there is a special case when path consist of just three commands: âM10,10Râ¦zâ. In this case path will smoothly connects to its beginning. 3747 > Usage 3748 | var c = paper.path("M10 10L90 90"); 3749 | // draw a diagonal line: 3750 | // move to 10,10, line to 90,90 3751 * For example of path strings, check out these icons: http://raphaeljs.com/icons/ 3752 \*/ 3753 paperproto.path = function (pathString) { 3754 pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); 3755 var out = R._engine.path(R.format[apply](R, arguments), this); 3756 this.__set__ && this.__set__.push(out); 3757 return out; 3758 }; 3759 /*\ 3760 * Paper.image 3761 [ method ] 3762 ** 3763 * Embeds an image into the surface. 3764 ** 3765 > Parameters 3766 ** 3767 - src (string) URI of the source image 3768 - x (number) x coordinate position 3769 - y (number) y coordinate position 3770 - width (number) width of the image 3771 - height (number) height of the image 3772 = (object) Raphaël element object with type âimageâ 3773 ** 3774 > Usage 3775 | var c = paper.image("apple.png", 10, 10, 80, 80); 3776 \*/ 3777 paperproto.image = function (src, x, y, w, h) { 3778 var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); 3779 this.__set__ && this.__set__.push(out); 3780 return out; 3781 }; 3782 /*\ 3783 * Paper.text 3784 [ method ] 3785 ** 3786 * Draws a text string. If you need line breaks, put â\nâ in the string. 3787 ** 3788 > Parameters 3789 ** 3790 - x (number) x coordinate position 3791 - y (number) y coordinate position 3792 - text (string) The text string to draw 3793 = (object) Raphaël element object with type âtextâ 3794 ** 3795 > Usage 3796 | var t = paper.text(50, 50, "Raphaël\nkicks\nbutt!"); 3797 \*/ 3798 paperproto.text = function (x, y, text) { 3799 var out = R._engine.text(this, x || 0, y || 0, Str(text)); 3800 this.__set__ && this.__set__.push(out); 3801 return out; 3802 }; 3803 /*\ 3804 * Paper.set 3805 [ method ] 3806 ** 3807 * Creates array-like object to keep and operate several elements at once. 3808 * Warning: it doesnât create any elements for itself in the page, it just groups existing elements. 3809 * Sets act as pseudo elements â all methods available to an element can be used on a set. 3810 = (object) array-like object that represents set of elements 3811 ** 3812 > Usage 3813 | var st = paper.set(); 3814 | st.push( 3815 | paper.circle(10, 10, 5), 3816 | paper.circle(30, 10, 5) 3817 | ); 3818 | st.attr({fill: "red"}); // changes the fill of both circles 3819 \*/ 3820 paperproto.set = function (itemsArray) { 3821 !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); 3822 var out = new Set(itemsArray); 3823 this.__set__ && this.__set__.push(out); 3824 out["paper"] = this; 3825 out["type"] = "set"; 3826 return out; 3827 }; 3828 /*\ 3829 * Paper.setStart 3830 [ method ] 3831 ** 3832 * Creates @Paper.set. All elements that will be created after calling this method and before calling 3833 * @Paper.setFinish will be added to the set. 3834 ** 3835 > Usage 3836 | paper.setStart(); 3837 | paper.circle(10, 10, 5), 3838 | paper.circle(30, 10, 5) 3839 | var st = paper.setFinish(); 3840 | st.attr({fill: "red"}); // changes the fill of both circles 3841 \*/ 3842 paperproto.setStart = function (set) { 3843 this.__set__ = set || this.set(); 3844 }; 3845 /*\ 3846 * Paper.setFinish 3847 [ method ] 3848 ** 3849 * See @Paper.setStart. This method finishes catching and returns resulting set. 3850 ** 3851 = (object) set 3852 \*/ 3853 paperproto.setFinish = function (set) { 3854 var out = this.__set__; 3855 delete this.__set__; 3856 return out; 3857 }; 3858 /*\ 3859 * Paper.
3859setSize 3860 [ method ] 3861 ** 3862 * If you need to change dimensions of the canvas call this method 3863 ** 3864 > Parameters 3865 ** 3866 - width (number) new width of the canvas
vendor: 27,031 bytes, lines 3867-4636
3867 - height (number) new height of the canvas 3868 \*/ 3869 paperproto.setSize = function (width, height) { 3870 return R._engine.setSize.call(this, width, height); 3871 }; 3872 /*\ 3873 * Paper.setViewBox 3874 [ method ] 3875 ** 3876 * Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by 3877 * specifying new boundaries. 3878 ** 3879 > Parameters 3880 ** 3881 - x (number) new x position, default is `0` 3882 - y (number) new y position, default is `0` 3883 - w (number) new width of the canvas 3884 - h (number) new height of the canvas 3885 - fit (boolean) `true` if you want graphics to fit into new boundary box 3886 \*/ 3887 paperproto.setViewBox = function (x, y, w, h, fit) { 3888 return R._engine.setViewBox.call(this, x, y, w, h, fit); 3889 }; 3890 /*\ 3891 * Paper.top 3892 [ property ] 3893 ** 3894 * Points to the topmost element on the paper 3895 \*/ 3896 /*\ 3897 * Paper.bottom 3898 [ property ] 3899 ** 3900 * Points to the bottom element on the paper 3901 \*/ 3902 paperproto.top = paperproto.bottom = null; 3903 /*\ 3904 * Paper.raphael 3905 [ property ] 3906 ** 3907 * Points to the @Raphael object/function 3908 \*/ 3909 paperproto.raphael = R; 3910 var getOffset = function (elem) { 3911 var box = elem.getBoundingClientRect(), 3912 doc = elem.ownerDocument, 3913 body = doc.body, 3914 docElem = doc.documentElement, 3915 clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, 3916 top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop, 3917 left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft; 3918 return { 3919 y: top, 3920 x: left 3921 }; 3922 }; 3923 /*\ 3924 * Paper.getElementByPoint 3925 [ method ] 3926 ** 3927 * Returns you topmost element under given point. 3928 ** 3929 = (object) Raphaël element object 3930 > Parameters 3931 ** 3932 - x (number) x coordinate from the top left corner of the window 3933 - y (number) y coordinate from the top left corner of the window 3934 > Usage 3935 | paper.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"}); 3936 \*/ 3937 paperproto.getElementByPoint = function (x, y) { 3938 var paper = this, 3939 svg = paper.canvas, 3940 target = g.doc.elementFromPoint(x, y); 3941 if (g.win.opera && target.tagName == "svg") { 3942 var so = getOffset(svg), 3943 sr = svg.createSVGRect(); 3944 sr.x = x - so.x; 3945 sr.y = y - so.y; 3946 sr.width = sr.height = 1; 3947 var hits = svg.getIntersectionList(sr, null); 3948 if (hits.length) { 3949 target = hits[hits.length - 1]; 3950 } 3951 } 3952 if (!target) { 3953 return null; 3954 } 3955 while (target.parentNode && target != svg.parentNode && !target.raphael) { 3956 target = target.parentNode; 3957 } 3958 target == paper.canvas.parentNode && (target = svg); 3959 target = target && target.raphael ? paper.getById(target.raphaelid) : null; 3960 return target; 3961 }; 3962 3963 /*\ 3964 * Paper.getElementsByBBox 3965 [ method ] 3966 ** 3967 * Returns set of elements that have an intersecting bounding box 3968 ** 3969 > Parameters 3970 ** 3971 - bbox (object) bbox to check with 3972 = (object) @Set 3973 \*/ 3974 paperproto.getElementsByBBox = function (bbox) { 3975 var set = this.set(); 3976 this.forEach(function (el) { 3977 if (R.isBBoxIntersect(el.getBBox(), bbox)) { 3978 set.push(el); 3979 } 3980 }); 3981 return set; 3982 }; 3983 3984 /*\ 3985 * Paper.getById 3986 [ method ] 3987 ** 3988 * Returns you element by its internal ID. 3989 ** 3990 > Parameters 3991 ** 3992 - id (number) id 3993 = (object) Raphaël element object 3994 \*/ 3995 paperproto.getById = function (id) { 3996 var bot = this.bottom; 3997 while (bot) { 3998 if (bot.id == id) { 3999 return bot; 4000 } 4001 bot = bot.next; 4002 } 4003 return null; 4004 }; 4005 /*\ 4006 * Paper.forEach 4007 [ method ] 4008 ** 4009 * Executes given function for each element on the paper 4010 * 4011 * If callback function returns `false` it will stop loop running. 4012 ** 4013 > Parameters 4014 ** 4015 - callback (function) function to run 4016 - thisArg (object) context object for the callback 4017 = (object) Paper object 4018 > Usage 4019 | paper.forEach(function (el) { 4020 | el.attr({ stroke: "blue" }); 4021 | }); 4022 \*/ 4023 paperproto.forEach = function (callback, thisArg) { 4024 var bot = this.bottom; 4025 while (bot) { 4026 if (callback.call(thisArg, bot) === false) { 4027 return this; 4028 } 4029 bot = bot.next; 4030 } 4031 return this; 4032 }; 4033 /*\ 4034 * Paper.getElementsByPoint 4035 [ method ] 4036 ** 4037 * Returns set of elements that have common point inside 4038 ** 4039 > Parameters 4040 ** 4041 - x (number) x coordinate of the point 4042 - y (number) y coordinate of the point 4043 = (object) @Set 4044 \*/ 4045 paperproto.getElementsByPoint = function (x, y) { 4046 var set = this.set(); 4047 this.forEach(function (el) { 4048 if (el.isPointInside(x, y)) { 4049 set.push(el); 4050 } 4051 }); 4052 return set; 4053 }; 4054 function x_y() { 4055 return this.x + S + this.y; 4056 } 4057 function x_y_w_h() { 4058 return this.x + S + this.y + S + this.width + " \xd7 " + this.height; 4059 } 4060 /*\ 4061 * Element.isPointInside 4062 [ method ] 4063 ** 4064 * Determine if given point is inside this elementâs shape 4065 ** 4066 > Parameters 4067 ** 4068 - x (number) x coordinate of the point 4069 - y (number) y coordinate of the point 4070 = (boolean) `true` if point inside the shape 4071 \*/ 4072 elproto.isPointInside = function (x, y) { 4073 var rp = this.realPath = getPath[this.type](this); 4074 if (this.attr('transform') && this.attr('transform').length) { 4075 rp = R.transformPath(rp, this.attr('transform')); 4076 } 4077 return R.isPointInsidePath(rp, x, y); 4078 }; 4079 /*\ 4080 * Element.getBBox 4081 [ method ] 4082 ** 4083 * Return bounding box for a given element 4084 ** 4085 > Parameters 4086 ** 4087 - isWithoutTransform (boolean) flag, `true` if you want to have bounding box before transformations. Default is `false`. 4088 = (object) Bounding box object: 4089 o { 4090 o x: (number) top left corner x 4091 o y: (number) top left corner y 4092 o x2: (number) bottom right corner x 4093 o y2: (number) bottom right corner y 4094 o width: (number) width 4095 o height: (number) height 4096 o } 4097 \*/ 4098 elproto.getBBox = function (isWithoutTransform) { 4099 if (this.removed) { 4100 return {}; 4101 } 4102 var _ = this._; 4103 if (isWithoutTransform) { 4104 if (_.dirty || !_.bboxwt) { 4105 this.realPath = getPath[this.type](this); 4106 _.bboxwt = pathDimensions(this.realPath); 4107 _.bboxwt.toString = x_y_w_h; 4108 _.dirty = 0; 4109 } 4110 return _.bboxwt; 4111 } 4112 if (_.dirty || _.dirtyT || !_.bbox) { 4113 if (_.dirty || !this.realPath) { 4114 _.bboxwt = 0; 4115 this.realPath = getPath[this.type](this); 4116 } 4117 _.bbox = pathDimensions(mapPath(this.realPath, this.matrix)); 4118 _.bbox.toString = x_y_w_h; 4119 _.dirty = _.dirtyT = 0; 4120 } 4121 return _.bbox; 4122 }; 4123 /*\ 4124 * Element.clone 4125 [ method ] 4126 ** 4127 = (object) clone of a given element 4128 ** 4129 \*/ 4130 elproto.clone = function () { 4131 if (this.removed) { 4132 return null; 4133 } 4134 var out = this.paper[this.type]().attr(this.attr()); 4135 this.__set__ && this.__set__.push(out); 4136 return out; 4137 }; 4138 /*\ 4139 * Element.glow 4140 [ method ] 4141 ** 4142 * Return set of elements that create glow-like effect around given element. See @Paper.set. 4143 * 4144 * Note: Glow is not connected to the element. If you change element attributes it wonât adjust itself. 4145 ** 4146 > Parameters 4147 ** 4148 - glow (object) #optional parameters object with all properties optional: 4149 o { 4150 o width (number) size of the glow, default is `10` 4151 o fill (boolean) will it be filled, default is `false` 4152 o opacity (number) opacity, default is `0.5` 4153 o offsetx (number) horizontal offset, default is `0` 4154 o offsety (number) vertical offset, default is `0` 4155 o color (string) glow colour, default is `black` 4156 o } 4157 = (object) @Paper.set of elements that represents glow 4158 \*/ 4159 elproto.glow = function (glow) { 4160 if (this.type == "text") { 4161 return null; 4162 } 4163 glow = glow || {}; 4164 var s = { 4165 width: (glow.width || 10) + (+this.attr("stroke-width") || 1), 4166 fill: glow.fill || false, 4167 opacity: glow.opacity || .5, 4168 offsetx: glow.offsetx || 0, 4169 offsety: glow.offsety || 0, 4170 color: glow.color || "#000" 4171 }, 4172 c = s.width / 2, 4173 r = this.paper, 4174 out = r.set(), 4175 path = this.realPath || getPath[this.type](this); 4176 path = this.matrix ? mapPath(path, this.matrix) : path; 4177 for (var i = 1; i < c + 1; i++) { 4178 out.push(r.path(path).attr({ 4179 stroke: s.color, 4180 fill: s.fill ? s.color : "none", 4181 "stroke-linejoin": "round", 4182 "stroke-linecap": "round", 4183 "stroke-width": +(s.width / c * i).toFixed(3), 4184 opacity: +(s.opacity / c).toFixed(3) 4185 })); 4186 } 4187 return out.insertBefore(this).translate(s.offsetx, s.offsety); 4188 }; 4189 var curveslengths = {}, 4190 getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) { 4191 if (length == null) { 4192 return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y); 4193 } else { 4194 return R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, getTatLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length)); 4195 } 4196 }, 4197 getLengthFactory = function (istotal, subpath) { 4198 return function (path, length, onlystart) { 4199 path = path2curve(path); 4200 var x, y, p, l, sp = "", subpaths = {}, point, 4201 len = 0; 4202 for (var i = 0, ii = path.length; i < ii; i++) { 4203 p = path[i]; 4204 if (p[0] == "M") { 4205 x = +p[1]; 4206 y = +p[2]; 4207 } else { 4208 l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); 4209 if (len + l > length) { 4210 if (subpath && !subpaths.start) { 4211 point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); 4212 sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y]; 4213 if (onlystart) {return sp;} 4214 subpaths.start = sp; 4215 sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join(); 4216 len += l; 4217 x = +p[5]; 4218 y = +p[6]; 4219 continue; 4220 } 4221 if (!istotal && !subpath) { 4222 point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); 4223 return {x: point.x, y: point.y, alpha: point.alpha}; 4224 } 4225 } 4226 len += l; 4227 x = +p[5]; 4228 y = +p[6]; 4229 } 4230 sp += p.shift() + p; 4231 } 4232 subpaths.end = sp; 4233 point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1); 4234 point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha}); 4235 return point; 4236 }; 4237 }; 4238 var getTotalLength = getLengthFactory(1), 4239 getPointAtLength = getLengthFactory(), 4240 getSubpathsAtLength = getLengthFactory(0, 1); 4241 /*\ 4242 * Raphael.getTotalLength 4243 [ method ] 4244 ** 4245 * Returns length of the given path in pixels. 4246 ** 4247 > Parameters 4248 ** 4249 - path (string) SVG path string. 4250 ** 4251 = (number) length. 4252 \*/ 4253 R.getTotalLength = getTotalLength; 4254 /*\ 4255 * Raphael.getPointAtLength 4256 [ method ] 4257 ** 4258 * Return coordinates of the point located at the given length on the given path. 4259 ** 4260 > Parameters 4261 ** 4262 - path (string) SVG path string 4263 - length (number) 4264 ** 4265 = (object) representation of the point: 4266 o { 4267 o x: (number) x coordinate 4268 o y: (number) y coordinate 4269 o alpha: (number) angle of derivative 4270 o } 4271 \*/ 4272 R.getPointAtLength = getPointAtLength; 4273 /*\ 4274 * Raphael.getSubpath 4275 [ method ] 4276 ** 4277 * Return subpath of a given path from given length to given length. 4278 ** 4279 > Parameters 4280 ** 4281 - path (string) SVG path string 4282 - from (number) position of the start of the segment 4283 - to (number) position of the end of the segment 4284 ** 4285 = (string) pathstring for the segment 4286 \*/ 4287 R.getSubpath = function (path, from, to) { 4288 if (this.getTotalLength(path) - to < 1e-6) { 4289 return getSubpathsAtLength(path, from).end; 4290 } 4291 var a = getSubpathsAtLength(path, to, 1); 4292 return from ? getSubpathsAtLength(a, from).end : a; 4293 }; 4294 /*\ 4295 * Element.getTotalLength 4296 [ method ] 4297 ** 4298 * Returns length of the path in pixels. Only works for element of âpathâ type. 4299 = (number) length. 4300 \*/ 4301 elproto.getTotalLength = function () { 4302 var path = this.getPath(); 4303 if (!path) { 4304 return; 4305 } 4306 4307 if (this.node.getTotalLength) { 4308 return this.node.getTotalLength(); 4309 } 4310 4311 return getTotalLength(path); 4312 }; 4313 /*\ 4314 * Element.getPointAtLength 4315 [ method ] 4316 ** 4317 * Return coordinates of the point located at the given length on the given path. Only works for element of âpathâ type. 4318 ** 4319 > Parameters 4320 ** 4321 - length (number) 4322 ** 4323 = (object) representation of the point: 4324 o { 4325 o x: (number) x coordinate 4326 o y: (number) y coordinate 4327 o alpha: (number) angle of derivative 4328 o } 4329 \*/ 4330 elproto.getPointAtLength = function (length) { 4331 var path = this.getPath(); 4332 if (!path) { 4333 return; 4334 } 4335 4336 return getPointAtLength(path, length); 4337 }; 4338 /*\ 4339 * Element.getPath 4340 [ method ] 4341 ** 4342 * Returns path of the element. Only works for elements of âpathâ type and simple elements like circle. 4343 = (object) path 4344 ** 4345 \*/ 4346 elproto.getPath = function () { 4347 var path, 4348 getPath = R._getPath[this.type]; 4349 4350 if (this.type == "text" || this.type == "set") { 4351 return; 4352 } 4353 4354 if (getPath) { 4355 path = getPath(this); 4356 } 4357 4358 return path; 4359 }; 4360 /*\ 4361 * Element.getSubpath 4362 [ method ] 4363 ** 4364 * Return subpath of a given element from given length to given length. Only works for element of âpathâ type. 4365 ** 4366 > Parameters 4367 ** 4368 - from (number) position of the start of the segment 4369 - to (number) position of the end of the segment 4370 ** 4371 = (string) pathstring for the segment 4372 \*/ 4373 elproto.getSubpath = function (from, to) { 4374 var path = this.getPath(); 4375 if (!path) { 4376 return; 4377 } 4378 4379 return R.getSubpath(path, from, to); 4380 }; 4381 /*\ 4382 * Raphael.easing_formulas 4383 [ property ] 4384 ** 4385 * Object that contains easing formulas for animation. You could extend it with your own. By default it has following list of easing: 4386 # <ul> 4387 # <li>âlinearâ</li> 4388 # <li>â<â or âeaseInâ or âease-inâ</li> 4389 # <li>â>â or âeaseOutâ or âease-outâ</li> 4390 # <li>â<>â or âeaseInOutâ or âease-in-outâ</li> 4391 # <li>âbackInâ or âback-inâ</li> 4392 # <li>âbackOutâ or âback-outâ</li> 4393 # <li>âelasticâ</li> 4394 # <li>âbounceâ</li> 4395 # </ul> 4396 # <p>See also <a href="http://raphaeljs.com/easing.html">Easing demo</a>.</p> 4397 \*/ 4398 var ef = R.easing_formulas = { 4399 linear: function (n) { 4400 return n; 4401 }, 4402 "<": function (n) { 4403 return pow(n, 1.7); 4404 }, 4405 ">": function (n) { 4406 return pow(n, .48); 4407 }, 4408 "<>": function (n) { 4409 var q = .48 - n / 1.04, 4410 Q = math.sqrt(.1734 + q * q), 4411 x = Q - q, 4412 X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1), 4413 y = -Q - q, 4414 Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1), 4415 t = X + Y + .5; 4416 return (1 - t) * 3 * t * t + t * t * t; 4417 }, 4418 backIn: function (n) { 4419 var s = 1.70158; 4420 return n * n * ((s + 1) * n - s); 4421 }, 4422 backOut: function (n) { 4423 n = n - 1; 4424 var s = 1.70158; 4425 return n * n * ((s + 1) * n + s) + 1; 4426 }, 4427 elastic: function (n) { 4428 if (n == !!n) { 4429 return n; 4430 } 4431 return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1; 4432 }, 4433 bounce: function (n) { 4434 var s = 7.5625, 4435 p = 2.75, 4436 l; 4437 if (n < (1 / p)) { 4438 l = s * n * n; 4439 } else { 4440 if (n < (2 / p)) { 4441 n -= (1.5 / p); 4442 l = s * n * n + .75; 4443 } else { 4444 if (n < (2.5 / p)) { 4445 n -= (2.25 / p); 4446 l = s * n * n + .9375; 4447 } else { 4448 n -= (2.625 / p); 4449 l = s * n * n + .984375; 4450 } 4451 } 4452 } 4453 return l; 4454 } 4455 }; 4456 ef.easeIn = ef["ease-in"] = ef["<"]; 4457 ef.easeOut = ef["ease-out"] = ef[">"]; 4458 ef.easeInOut = ef["ease-in-out"] = ef["<>"]; 4459 ef["back-in"] = ef.backIn; 4460 ef["back-out"] = ef.backOut; 4461 4462 var animationElements = [], 4463 requestAnimFrame = window.requestAnimationFrame || 4464 window.webkitRequestAnimationFrame || 4465 window.mozRequestAnimationFrame || 4466 window.oRequestAnimationFrame || 4467 window.msRequestAnimationFrame || 4468 function (callback) { 4469 setTimeout(callback, 16); 4470 }, 4471 animation = function () { 4472 var Now = +new Date, 4473 l = 0; 4474 for (; l < animationElements.length; l++) { 4475 var e = animationElements[l]; 4476 if (e.el.removed || e.paused) { 4477 continue; 4478 } 4479 var time = Now - e.start, 4480 ms = e.ms, 4481 easing = e.easing, 4482 from = e.from, 4483 diff = e.diff, 4484 to = e.to, 4485 t = e.t, 4486 that = e.el, 4487 set = {}, 4488 now, 4489 init = {}, 4490 key; 4491 if (e.initstatus) { 4492 time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms; 4493 e.status = e.initstatus; 4494 delete e.initstatus; 4495 e.stop && animationElements.splice(l--, 1); 4496 } else { 4497 e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top; 4498 } 4499 if (time < 0) { 4500 continue; 4501 } 4502 if (time < ms) { 4503 var pos = easing(time / ms); 4504 for (var attr in from) if (from[has](attr)) { 4505 switch (availableAnimAttrs[attr]) { 4506 case nu: 4507 now = +from[attr] + pos * ms * diff[attr]; 4508 break; 4509 case "colour": 4510 now = "rgb(" + [ 4511 upto255(round(from[attr].r + pos * ms * diff[attr].r)), 4512 upto255(round(from[attr].g + pos * ms * diff[attr].g)), 4513 upto255(round(from[attr].b + pos * ms * diff[attr].b)) 4514 ].join(",") + ")"; 4515 break; 4516 case "path": 4517 now = []; 4518 for (var i = 0, ii = from[attr].length; i < ii; i++) { 4519 now[i] = [from[attr][i][0]]; 4520 for (var j = 1, jj = from[attr][i].length; j < jj; j++) { 4521 now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j]; 4522 } 4523 now[i] = now[i].join(S); 4524 } 4525 now = now.join(S); 4526 break; 4527 case "transform": 4528 if (diff[attr].real) { 4529 now = []; 4530 for (i = 0, ii = from[attr].length; i < ii; i++) { 4531 now[i] = [from[attr][i][0]]; 4532 for (j = 1, jj = from[attr][i].length; j < jj; j++) { 4533 now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j]; 4534 } 4535 } 4536 } else { 4537 var get = function (i) { 4538 return +from[attr][i] + pos * ms * diff[attr][i]; 4539 }; 4540 // now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]]; 4541 now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]]; 4542 } 4543 break; 4544 case "csv": 4545 if (attr == "clip-rect") { 4546 now = []; 4547 i = 4; 4548 while (i--) { 4549 now[i] = +from[attr][i] + pos * ms * diff[attr][i]; 4550 } 4551 } 4552 break; 4553 default: 4554 var from2 = [][concat](from[attr]); 4555 now = []; 4556 i = that.paper.customAttributes[attr].length; 4557 while (i--) { 4558 now[i] = +from2[i] + pos * ms * diff[attr][i]; 4559 } 4560 break; 4561 } 4562 set[attr] = now; 4563 } 4564 that.attr(set); 4565 (function (id, that, anim) { 4566 setTimeout(function () { 4567 eve("raphael.anim.frame." + id, that, anim); 4568 }); 4569 })(that.id, that, e.anim); 4570 } else { 4571 (function(f, el, a) { 4572 setTimeout(function() { 4573 eve("raphael.anim.frame." + el.id, el, a); 4574 eve("raphael.anim.finish." + el.id, el, a); 4575 R.is(f, "function") && f.call(el); 4576 }); 4577 })(e.callback, that, e.anim); 4578 that.attr(to); 4579 animationElements.splice(l--, 1); 4580 if (e.repeat > 1 && !e.next) { 4581 for (key in to) if (to[has](key)) { 4582 init[key] = e.totalOrigin[key]; 4583 } 4584 e.el.attr(init); 4585 runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1); 4586 } 4587 if (e.next && !e.stop) { 4588 runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat); 4589 } 4590 } 4591 } 4592 R.svg && that && that.paper && that.paper.safari(); 4593 animationElements.length && requestAnimFrame(animation); 4594 }, 4595 upto255 = function (color) { 4596 return color > 255 ? 255 : color < 0 ? 0 : color; 4597 }; 4598 /*\ 4599 * Element.animateWith 4600 [ method ] 4601 ** 4602 * Acts similar to @Element.animate, but ensure that given animation runs in sync with another given element. 4603 ** 4604 > Parameters 4605 ** 4606 - el (object) element to sync with 4607 - anim (object) animation to sync with 4608 - params (object) #optional final attributes for the element, see also @Element.attr 4609 - ms (number) #optional number of milliseconds for animation to run 4610 - easing (string) #optional easing type. Accept on of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)` 4611 - callback (function) #optional callback function. Will be called at the end of animation. 4612 * or 4613 - element (object) element to sync with 4614 - anim (object) animation to sync with 4615 - animation (object) #optional animation object, see @Raphael.animation 4616 ** 4617 = (object) original element 4618 \*/ 4619 elproto.animateWith = function (el, anim, params, ms, easing, callback) { 4620 var element = this; 4621 if (element.removed) { 4622 callback && callback.call(element); 4623 return element; 4624 } 4625 var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback), 4626 x, y; 4627 runAnimation(a, element, a.percents[0], null, element.attr()); 4628 for (var i = 0, ii = animationElements.length; i < ii; i++) { 4629 if (animationElements[i].anim == anim && animationElements[i].el == el) { 4630 animationElements[ii - 1].start = animationElements[i].start; 4631 break; 4632 } 4633 } 4634 return element; 4635 // 4636 //
vendor: 14,290 bytes, lines 4636-4992
4636 4637 // var a = params ? R.animation(params, ms, easing, callback) : anim, 4638 // status = element.status(anim); 4639 // return this.animate(a).status(a, status * anim.ms / a.ms); 4640 }; 4641 function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) { 4642 var cx = 3 * p1x, 4643 bx = 3 * (p2x - p1x) - cx, 4644 ax = 1 - cx - bx, 4645 cy = 3 * p1y, 4646 by = 3 * (p2y - p1y) - cy, 4647 ay = 1 - cy - by; 4648 function sampleCurveX(t) { 4649 return ((ax * t + bx) * t + cx) * t; 4650 } 4651 function solve(x, epsilon) { 4652 var t = solveCurveX(x, epsilon); 4653 return ((ay * t + by) * t + cy) * t; 4654 } 4655 function solveCurveX(x, epsilon) { 4656 var t0, t1, t2, x2, d2, i; 4657 for(t2 = x, i = 0; i < 8; i++) { 4658 x2 = sampleCurveX(t2) - x; 4659 if (abs(x2) < epsilon) { 4660 return t2; 4661 } 4662 d2 = (3 * ax * t2 + 2 * bx) * t2 + cx; 4663 if (abs(d2) < 1e-6) { 4664 break; 4665 } 4666 t2 = t2 - x2 / d2; 4667 } 4668 t0 = 0; 4669 t1 = 1; 4670 t2 = x; 4671 if (t2 < t0) { 4672 return t0; 4673 } 4674 if (t2 > t1) { 4675 return t1; 4676 } 4677 while (t0 < t1) { 4678 x2 = sampleCurveX(t2); 4679 if (abs(x2 - x) < epsilon) { 4680 return t2; 4681 } 4682 if (x > x2) { 4683 t0 = t2; 4684 } else { 4685 t1 = t2; 4686 } 4687 t2 = (t1 - t0) / 2 + t0; 4688 } 4689 return t2; 4690 } 4691 return solve(t, 1 / (200 * duration)); 4692 } 4693 elproto.onAnimation = function (f) { 4694 f ? eve.on("raphael.anim.frame." + this.id, f) : eve.unbind("raphael.anim.frame." + this.id); 4695 return this; 4696 }; 4697 function Animation(anim, ms) { 4698 var percents = [], 4699 newAnim = {}; 4700 this.ms = ms; 4701 this.times = 1; 4702 if (anim) { 4703 for (var attr in anim) if (anim[has](attr)) { 4704 newAnim[toFloat(attr)] = anim[attr]; 4705 percents.push(toFloat(attr)); 4706 } 4707 percents.sort(sortByNumber); 4708 } 4709 this.anim = newAnim; 4710 this.top = percents[percents.length - 1]; 4711 this.percents = percents; 4712 } 4713 /*\ 4714 * Animation.delay 4715 [ method ] 4716 ** 4717 * Creates a copy of existing animation object with given delay. 4718 ** 4719 > Parameters 4720 ** 4721 - delay (number) number of ms to pass between animation start and actual animation 4722 ** 4723 = (object) new altered Animation object 4724 | var anim = Raphael.animation({cx: 10, cy: 20}, 2e3); 4725 | circle1.animate(anim); // run the given animation immediately 4726 | circle2.animate(anim.delay(500)); // run the given animation after 500 ms 4727 \*/ 4728 Animation.prototype.delay = function (delay) { 4729 var a = new Animation(this.anim, this.ms); 4730 a.times = this.times; 4731 a.del = +delay || 0; 4732 return a; 4733 }; 4734 /*\ 4735 * Animation.repeat 4736 [ method ] 4737 ** 4738 * Creates a copy of existing animation object with given repetition. 4739 ** 4740 > Parameters 4741 ** 4742 - repeat (number) number iterations of animation. For infinite animation pass `Infinity` 4743 ** 4744 = (object) new altered Animation object 4745 \*/ 4746 Animation.prototype.repeat = function (times) { 4747 var a = new Animation(this.anim, this.ms); 4748 a.del = this.del; 4749 a.times = math.floor(mmax(times, 0)) || 1; 4750 return a; 4751 }; 4752 function runAnimation(anim, element, percent, status, totalOrigin, times) { 4753 percent = toFloat(percent); 4754 var params, 4755 isInAnim, 4756 isInAnimSet, 4757 percents = [], 4758 next, 4759 prev, 4760 timestamp, 4761 ms = anim.ms, 4762 from = {}, 4763 to = {}, 4764 diff = {}; 4765 if (status) { 4766 for (i = 0, ii = animationElements.length; i < ii; i++) { 4767 var e = animationElements[i]; 4768 if (e.el.id == element.id && e.anim == anim) { 4769 if (e.percent != percent) { 4770 animationElements.splice(i, 1); 4771 isInAnimSet = 1; 4772 } else { 4773 isInAnim = e; 4774 } 4775 element.attr(e.totalOrigin); 4776 break; 4777 } 4778 } 4779 } else { 4780 status = +to; // NaN 4781 } 4782 for (var i = 0, ii = anim.percents.length; i < ii; i++) { 4783 if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) { 4784 percent = anim.percents[i]; 4785 prev = anim.percents[i - 1] || 0; 4786 ms = ms / anim.top * (percent - prev); 4787 next = anim.percents[i + 1]; 4788 params = anim.anim[percent]; 4789 break; 4790 } else if (status) { 4791 element.attr(anim.anim[anim.percents[i]]); 4792 } 4793 } 4794 if (!params) { 4795 return; 4796 } 4797 if (!isInAnim) { 4798 for (var attr in params) if (params[has](attr)) { 4799 if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) { 4800 from[attr] = element.attr(attr); 4801 (from[attr] == null) && (from[attr] = availableAttrs[attr]); 4802 to[attr] = params[attr]; 4803 switch (availableAnimAttrs[attr]) { 4804 case nu: 4805 diff[attr] = (to[attr] - from[attr]) / ms; 4806 break; 4807 case "colour": 4808 from[attr] = R.getRGB(from[attr]); 4809 var toColour = R.getRGB(to[attr]); 4810 diff[attr] = { 4811 r: (toColour.r - from[attr].r) / ms, 4812 g: (toColour.g - from[attr].g) / ms, 4813 b: (toColour.b - from[attr].b) / ms 4814 }; 4815 break; 4816 case "path": 4817 var pathes = path2curve(from[attr], to[attr]), 4818 toPath = pathes[1]; 4819 from[attr] = pathes[0]; 4820 diff[attr] = []; 4821 for (i = 0, ii = from[attr].length; i < ii; i++) { 4822 diff[attr][i] = [0]; 4823 for (var j = 1, jj = from[attr][i].length; j < jj; j++) { 4824 diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms; 4825 } 4826 } 4827 break; 4828 case "transform": 4829 var _ = element._, 4830 eq = equaliseTransform(_[attr], to[attr]); 4831 if (eq) { 4832 from[attr] = eq.from; 4833 to[attr] = eq.to; 4834 diff[attr] = []; 4835 diff[attr].real = true; 4836 for (i = 0, ii = from[attr].length; i < ii; i++) { 4837 diff[attr][i] = [from[attr][i][0]]; 4838 for (j = 1, jj = from[attr][i].length; j < jj; j++) { 4839 diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms; 4840 } 4841 } 4842 } else { 4843 var m = (element.matrix || new Matrix), 4844 to2 = { 4845 _: {transform: _.transform}, 4846 getBBox: function () { 4847 return element.getBBox(1); 4848 } 4849 }; 4850 from[attr] = [ 4851 m.a, 4852 m.b, 4853 m.c, 4854 m.d, 4855 m.e, 4856 m.f 4857 ]; 4858 extractTransform(to2, to[attr]); 4859 to[attr] = to2._.transform; 4860 diff[attr] = [ 4861 (to2.matrix.a - m.a) / ms, 4862 (to2.matrix.b - m.b) / ms, 4863 (to2.matrix.c - m.c) / ms, 4864 (to2.matrix.d - m.d) / ms, 4865 (to2.matrix.e - m.e) / ms, 4866 (to2.matrix.f - m.f) / ms 4867 ]; 4868 // from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy]; 4869 // var to2 = {_:{}, getBBox: function () { return element.getBBox(); }}; 4870 // extractTransform(to2, to[attr]); 4871 // diff[attr] = [ 4872 // (to2._.sx - _.sx) / ms, 4873 // (to2._.sy - _.sy) / ms, 4874 // (to2._.deg - _.deg) / ms, 4875 // (to2._.dx - _.dx) / ms, 4876 // (to2._.dy - _.dy) / ms 4877 // ]; 4878 } 4879 break; 4880 case "csv": 4881 var values = Str(params[attr])[split](separator), 4882 from2 = Str(from[attr])[split](separator); 4883 if (attr == "clip-rect") { 4884 from[attr] = from2; 4885 diff[attr] = []; 4886 i = from2.length; 4887 while (i--) { 4888 diff[attr][i] = (values[i] - from[attr][i]) / ms; 4889 } 4890 } 4891 to[attr] = values; 4892 break; 4893 default: 4894 values = [][concat](params[attr]); 4895 from2 = [][concat](from[attr]); 4896 diff[attr] = []; 4897 i = element.paper.customAttributes[attr].length; 4898 while (i--) { 4899 diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms; 4900 } 4901 break; 4902 } 4903 } 4904 } 4905 var easing = params.easing, 4906 easyeasy = R.easing_formulas[easing]; 4907 if (!easyeasy) { 4908 easyeasy = Str(easing).match(bezierrg); 4909 if (easyeasy && easyeasy.length == 5) { 4910 var curve = easyeasy; 4911 easyeasy = function (t) { 4912 return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms); 4913 }; 4914 } else { 4915 easyeasy = pipe; 4916 } 4917 } 4918 timestamp = params.start || anim.start || +new Date; 4919 e = { 4920 anim: anim, 4921 percent: percent, 4922 timestamp: timestamp, 4923 start: timestamp + (anim.del || 0), 4924 status: 0, 4925 initstatus: status || 0, 4926 stop: false, 4927 ms: ms, 4928 easing: easyeasy, 4929 from: from, 4930 diff: diff, 4931 to: to, 4932 el: element, 4933 callback: params.callback, 4934 prev: prev, 4935 next: next, 4936 repeat: times || anim.times, 4937 origin: element.attr(), 4938 totalOrigin: totalOrigin 4939 }; 4940 animationElements.push(e); 4941 if (status && !isInAnim && !isInAnimSet) { 4942 e.stop = true; 4943 e.start = new Date - ms * status; 4944 if (animationElements.length == 1) { 4945 return animation(); 4946 } 4947 } 4948 if (isInAnimSet) { 4949 e.start = new Date - e.ms * status; 4950 } 4951 animationElements.length == 1 && requestAnimFrame(animation); 4952 } else { 4953 isInAnim.initstatus = status; 4954 isInAnim.start = new Date - isInAnim.ms * status; 4955 } 4956 eve("raphael.anim.start." + element.id, element, anim); 4957 } 4958 /*\ 4959 * Raphael.animation 4960 [ method ] 4961 ** 4962 * Creates an animation object that can be passed to the @Element.animate or @Element.animateWith methods. 4963 * See also @Animation.delay and @Animation.repeat methods. 4964 ** 4965 > Parameters 4966 ** 4967 - params (object) final attributes for the element, see also @Element.attr 4968 - ms (number) number of milliseconds for animation to run 4969 - easing (string) #optional easing type. Accept one of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)` 4970 - callback (function) #optional callback function. Will be called at the end of animation. 4971 ** 4972 = (object) @Animation 4973 \*/ 4974 R.animation = function (params, ms, easing, callback) { 4975 if (params instanceof Animation) { 4976 return params; 4977 } 4978 if (R.is(easing, "function") || !easing) { 4979 callback = callback || easing || null; 4980 easing = null; 4981 } 4982 params = Object(params); 4983 ms = +ms || 0; 4984 var p = {}, 4985 json, 4986 attr; 4987 for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + "%" != attr) { 4988 json = true; 4989 p[attr] = params[attr]; 4990 } 4991 if (!json) { 4992
vendor: 12,690 bytes, lines 4992-5397
4992return new Animation(params, ms); 4993 } else { 4994 easing && (p.easing = easing); 4995 callback && (p.callback = callback); 4996 return new Animation({100: p}, ms); 4997 } 4998 }; 4999 /*\ 5000 * Element.animate 5001 [ method ] 5002 ** 5003 * Creates and starts animation for given element. 5004 ** 5005 > Parameters 5006 ** 5007 - params (object) final attributes for the element, see also @Element.attr 5008 - ms (number) number of milliseconds for animation to run 5009 - easing (string) #optional easing type. Accept one of @Raphael.easing_formulas or CSS format: `cubic‐bezier(XX, XX, XX, XX)` 5010 - callback (function) #optional callback function. Will be called at the end of animation. 5011 * or 5012 - animation (object) animation object, see @Raphael.animation 5013 ** 5014 = (object) original element 5015 \*/ 5016 elproto.animate = function (params, ms, easing, callback) { 5017 var element = this; 5018 if (element.removed) { 5019 callback && callback.call(element); 5020 return element; 5021 } 5022 var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback); 5023 runAnimation(anim, element, anim.percents[0], null, element.attr()); 5024 return element; 5025 }; 5026 /*\ 5027 * Element.setTime 5028 [ method ] 5029 ** 5030 * Sets the status of animation of the element in milliseconds. Similar to @Element.status method. 5031 ** 5032 > Parameters 5033 ** 5034 - anim (object) animation object 5035 - value (number) number of milliseconds from the beginning of the animation 5036 ** 5037 = (object) original element if `value` is specified 5038 * Note, that during animation following events are triggered: 5039 * 5040 * On each animation frame event `anim.frame.<id>`, on start `anim.start.<id>` and on end `anim.finish.<id>`. 5041 \*/ 5042 elproto.setTime = function (anim, value) { 5043 if (anim && value != null) { 5044 this.status(anim, mmin(value, anim.ms) / anim.ms); 5045 } 5046 return this; 5047 }; 5048 /*\ 5049 * Element.status 5050 [ method ] 5051 ** 5052 * Gets or sets the status of animation of the element. 5053 ** 5054 > Parameters 5055 ** 5056 - anim (object) #optional animation object 5057 - value (number) #optional 0 â 1. If specified, method works like a setter and sets the status of a given animation to the value. This will cause animation to jump to the given position. 5058 ** 5059 = (number) status 5060 * or 5061 = (array) status if `anim` is not specified. Array of objects in format: 5062 o { 5063 o anim: (object) animation object 5064 o status: (number) status 5065 o } 5066 * or 5067 = (object) original element if `value` is specified 5068 \*/ 5069 elproto.status = function (anim, value) { 5070 var out = [], 5071 i = 0, 5072 len, 5073 e; 5074 if (value != null) { 5075 runAnimation(anim, this, -1, mmin(value, 1)); 5076 return this; 5077 } else { 5078 len = animationElements.length; 5079 for (; i < len; i++) { 5080 e = animationElements[i]; 5081 if (e.el.id == this.id && (!anim || e.anim == anim)) { 5082 if (anim) { 5083 return e.status; 5084 } 5085 out.push({ 5086 anim: e.anim, 5087 status: e.status 5088 }); 5089 } 5090 } 5091 if (anim) { 5092 return 0; 5093 } 5094 return out; 5095 } 5096 }; 5097 /*\ 5098 * Element.pause 5099 [ method ] 5100 ** 5101 * Stops animation of the element with ability to resume it later on. 5102 ** 5103 > Parameters 5104 ** 5105 - anim (object) #optional animation object 5106 ** 5107 = (object) original element 5108 \*/ 5109 elproto.pause = function (anim) { 5110 for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { 5111 if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { 5112 animationElements[i].paused = true; 5113 } 5114 } 5115 return this; 5116 }; 5117 /*\ 5118 * Element.resume 5119 [ method ] 5120 ** 5121 * Resumes animation if it was paused with @Element.pause method. 5122 ** 5123 > Parameters 5124 ** 5125 - anim (object) #optional animation object 5126 ** 5127 = (object) original element 5128 \*/ 5129 elproto.resume = function (anim) { 5130 for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { 5131 var e = animationElements[i]; 5132 if (eve("raphael.anim.resume." + this.id, this, e.anim) !== false) { 5133 delete e.paused; 5134 this.status(e.anim, e.status); 5135 } 5136 } 5137 return this; 5138 }; 5139 /*\ 5140 * Element.stop 5141 [ method ] 5142 ** 5143 * Stops animation of the element. 5144 ** 5145 > Parameters 5146 ** 5147 - anim (object) #optional animation object 5148 ** 5149 = (object) original element 5150 \*/ 5151 elproto.stop = function (anim) { 5152 for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { 5153 if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { 5154 animationElements.splice(i--, 1); 5155 } 5156 } 5157 return this; 5158 }; 5159 function stopAnimation(paper) { 5160 for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.paper == paper) { 5161 animationElements.splice(i--, 1); 5162 } 5163 } 5164 eve.on("raphael.remove", stopAnimation); 5165 eve.on("raphael.clear", stopAnimation); 5166 elproto.toString = function () { 5167 return "Rapha\xebl\u2019s object"; 5168 }; 5169 5170 // Set 5171 var Set = function (items) { 5172 this.items = []; 5173 this.length = 0; 5174 this.type = "set"; 5175 if (items) { 5176 for (var i = 0, ii = items.length; i < ii; i++) { 5177 if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) { 5178 this[this.items.length] = this.items[this.items.length] = items[i]; 5179 this.length++; 5180 } 5181 } 5182 } 5183 }, 5184 setproto = Set.prototype; 5185 /*\ 5186 * Set.push 5187 [ method ] 5188 ** 5189 * Adds each argument to the current set. 5190 = (object) original element 5191 \*/ 5192 setproto.push = function () { 5193 var item, 5194 len; 5195 for (var i = 0, ii = arguments.length; i < ii; i++) { 5196 item = arguments[i]; 5197 if (item && (item.constructor == elproto.constructor || item.constructor == Set)) { 5198 len = this.items.length; 5199 this[len] = this.items[len] = item; 5200 this.length++; 5201 } 5202 } 5203 return this; 5204 }; 5205 /*\ 5206 * Set.pop 5207 [ method ] 5208 ** 5209 * Removes last element and returns it. 5210 = (object) element 5211 \*/ 5212 setproto.pop = function () { 5213 this.length && delete this[this.length--]; 5214 return this.items.pop(); 5215 }; 5216 /*\ 5217 * Set.forEach 5218 [ method ] 5219 ** 5220 * Executes given function for each element in the set. 5221 * 5222 * If function returns `false` it will stop loop running. 5223 ** 5224 > Parameters 5225 ** 5226 - callback (function) function to run 5227 - thisArg (object) context object for the callback 5228 = (object) Set object 5229 \*/ 5230 setproto.forEach = function (callback, thisArg) { 5231 for (var i = 0, ii = this.items.length; i < ii; i++) { 5232 if (callback.call(thisArg, this.items[i], i) === false) { 5233 return this; 5234 } 5235 } 5236 return this; 5237 }; 5238 for (var method in elproto) if (elproto[has](method)) { 5239 setproto[method] = (function (methodname) { 5240 return function () { 5241 var arg = arguments; 5242 return this.forEach(function (el) { 5243 el[methodname][apply](el, arg); 5244 }); 5245 }; 5246 })(method); 5247 } 5248 setproto.attr = function (name, value) { 5249 if (name && R.is(name, array) && R.is(name[0], "object")) { 5250 for (var j = 0, jj = name.length; j < jj; j++) { 5251 this.items[j].attr(name[j]); 5252 } 5253 } else { 5254 for (var i = 0, ii = this.items.length; i < ii; i++) { 5255 this.items[i].attr(name, value); 5256 } 5257 } 5258 return this; 5259 }; 5260 /*\ 5261 * Set.clear 5262 [ method ] 5263 ** 5264 * Removeds all elements from the set 5265 \*/ 5266 setproto.clear = function () { 5267 while (this.length) { 5268 this.pop(); 5269 } 5270 }; 5271 /*\ 5272 * Set.splice 5273 [ method ] 5274 ** 5275 * Removes given element from the set 5276 ** 5277 > Parameters 5278 ** 5279 - index (number) position of the deletion 5280 - count (number) number of element to remove 5281 - insertion⦠(object) #optional elements to insert 5282 = (object) set elements that were deleted 5283 \*/ 5284 setproto.splice = function (index, count, insertion) { 5285 index = index < 0 ? mmax(this.length + index, 0) : index; 5286 count = mmax(0, mmin(this.length - index, count)); 5287 var tail = [], 5288 todel = [], 5289 args = [], 5290 i; 5291 for (i = 2; i < arguments.length; i++) { 5292 args.push(arguments[i]); 5293 } 5294 for (i = 0; i < count; i++) { 5295 todel.push(this[index + i]); 5296 } 5297 for (; i < this.length - index; i++) { 5298 tail.push(this[index + i]); 5299 } 5300 var arglen = args.length; 5301 for (i = 0; i < arglen + tail.length; i++) { 5302 this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen]; 5303 } 5304 i = this.items.length = this.length -= count - arglen; 5305 while (this[i]) { 5306 delete this[i++]; 5307 } 5308 return new Set(todel); 5309 }; 5310 /*\ 5311 * Set.exclude 5312 [ method ] 5313 ** 5314 * Removes given element from the set 5315 ** 5316 > Parameters 5317 ** 5318 - element (object) element to remove 5319 = (boolean) `true` if object was found & removed from the set 5320 \*/ 5321 setproto.exclude = function (el) { 5322 for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { 5323 this.splice(i, 1); 5324 return true; 5325 } 5326 }; 5327 setproto.animate = function (params, ms, easing, callback) { 5328 (R.is(easing, "function") || !easing) && (callback = easing || null); 5329 var len = this.items.length, 5330 i = len, 5331 item, 5332 set = this, 5333 collector; 5334 if (!len) { 5335 return this; 5336 } 5337 callback && (collector = function () { 5338 !--len && callback.call(set); 5339 }); 5340 easing = R.is(easing, string) ? easing : collector; 5341 var anim = R.animation(params, ms, easing, collector); 5342 item = this.items[--i].animate(anim); 5343 while (i--) { 5344 this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim, anim); 5345 (this.items[i] && !this.items[i].removed) || len--; 5346 } 5347 return this; 5348 }; 5349 setproto.insertAfter = function (el) { 5350 var i = this.items.length; 5351 while (i--) { 5352 this.items[i].insertAfter(el); 5353 } 5354 return this; 5355 }; 5356 setproto.getBBox = function () { 5357 var x = [], 5358 y = [], 5359 x2 = [], 5360 y2 = []; 5361 for (var i = this.items.length; i--;) if (!this.items[i].removed) { 5362 var box = this.items[i].getBBox(); 5363 x.push(box.x); 5364 y.push(box.y); 5365 x2.push(box.x + box.width); 5366 y2.push(box.y + box.height); 5367 } 5368 x = mmin[apply](0, x); 5369 y = mmin[apply](0, y); 5370 x2 = mmax[apply](0, x2); 5371 y2 = mmax[apply](0, y2); 5372 return { 5373 x: x, 5374 y: y, 5375 x2: x2, 5376 y2: y2, 5377 width: x2 - x, 5378 height: y2 - y 5379 }; 5380 }; 5381 setproto.clone = function (s) { 5382 s = this.paper.set(); 5383 for (var i = 0, ii = this.items.length; i < ii; i++) { 5384 s.push(this.items[i].clone()); 5385 } 5386 return s; 5387 }; 5388 setproto.toString = function () { 5389 return "Rapha\xebl\u2018s set"; 5390 }; 5391 5392 setproto.glow = function(glowConfig) { 5393 var ret = this.paper.set(); 5394 this.forEach(function(shape, index){ 5395 var g = shape.glow(glowConfig); 5396 if(g != null){ 5397 g.forEach(function(shape2, index2){
5398 ret.push(shape2); 5399 }); 5400 } 5401 }); 5402 return ret; 5403 }; 5404 5405 5406 /*\ 5407 * Set.isPointInside 5408 [ method ] 5409 ** 5410 * Determine if given point is inside this setâs elements 5411 ** 5412 > Parameters 5413 ** 5414 - x (number) x coordinate of the point 5415 - y (number) y coordinate of the point 5416 = (boolean) `true` if point is inside any of the set's elements 5417 \*/ 5418 setproto.isPointInside = function (x, y) { 5419 var isPointInside = false; 5420 this.forEach(function (el) { 5421 if (el.isPointInside(x, y)) { 5422 console.log('runned');
vendor: 10,571 bytes, lines 5422-5708
5422 5423 isPointInside = true; 5424 return false; // stop loop 5425 } 5426 }); 5427 return isPointInside; 5428 }; 5429 5430 /*\ 5431 * Raphael.registerFont 5432 [ method ] 5433 ** 5434 * Adds given font to the registered set of fonts for Raphaël. Should be used as an internal call from within Cufónâs font file. 5435 * Returns original parameter, so it could be used with chaining. 5436 # <a href="http://wiki.github.com/sorccu/cufon/about">More about Cufón and how to convert your font form TTF, OTF, etc to JavaScript file.</a> 5437 ** 5438 > Parameters 5439 ** 5440 - font (object) the font to register 5441 = (object) the font you passed in 5442 > Usage 5443 | Cufon.registerFont(Raphael.registerFont({â¦})); 5444 \*/ 5445 R.registerFont = function (font) { 5446 if (!font.face) { 5447 return font; 5448 } 5449 this.fonts = this.fonts || {}; 5450 var fontcopy = { 5451 w: font.w, 5452 face: {}, 5453 glyphs: {} 5454 }, 5455 family = font.face["font-family"]; 5456 for (var prop in font.face) if (font.face[has](prop)) { 5457 fontcopy.face[prop] = font.face[prop]; 5458 } 5459 if (this.fonts[family]) { 5460 this.fonts[family].push(fontcopy); 5461 } else { 5462 this.fonts[family] = [fontcopy]; 5463 } 5464 if (!font.svg) { 5465 fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10); 5466 for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) { 5467 var path = font.glyphs[glyph]; 5468 fontcopy.glyphs[glyph] = { 5469 w: path.w, 5470 k: {}, 5471 d: path.d && "M" + path.d.replace(/[mlcxtrv]/g, function (command) { 5472 return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M"; 5473 }) + "z" 5474 }; 5475 if (path.k) { 5476 for (var k in path.k) if (path[has](k)) { 5477 fontcopy.glyphs[glyph].k[k] = path.k[k]; 5478 } 5479 } 5480 } 5481 } 5482 return font; 5483 }; 5484 /*\ 5485 * Paper.getFont 5486 [ method ] 5487 ** 5488 * Finds font object in the registered fonts by given parameters. You could specify only one word from the font name, like âMyriadâ for âMyriad Proâ. 5489 ** 5490 > Parameters 5491 ** 5492 - family (string) font family name or any word from it 5493 - weight (string) #optional font weight 5494 - style (string) #optional font style 5495 - stretch (string) #optional font stretch 5496 = (object) the font object 5497 > Usage 5498 | paper.print(100, 100, "Test string", paper.getFont("Times", 800), 30); 5499 \*/ 5500 paperproto.getFont = function (family, weight, style, stretch) { 5501 stretch = stretch || "normal"; 5502 style = style || "normal"; 5503 weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400; 5504 if (!R.fonts) { 5505 return; 5506 } 5507 var font = R.fonts[family]; 5508 if (!font) { 5509 var name = new RegExp("(^|\\s)" + family.replace(/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i"); 5510 for (var fontName in R.fonts) if (R.fonts[has](fontName)) { 5511 if (name.test(fontName)) { 5512 font = R.fonts[fontName]; 5513 break; 5514 } 5515 } 5516 } 5517 var thefont; 5518 if (font) { 5519 for (var i = 0, ii = font.length; i < ii; i++) { 5520 thefont = font[i]; 5521 if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) { 5522 break; 5523 } 5524 } 5525 } 5526 return thefont; 5527 }; 5528 /*\ 5529 * Paper.print 5530 [ method ] 5531 ** 5532 * Creates path that represent given text written using given font at given position with given size. 5533 * Result of the method is path element that contains whole text as a separate path. 5534 ** 5535 > Parameters 5536 ** 5537 - x (number) x position of the text 5538 - y (number) y position of the text 5539 - string (string) text to print 5540 - font (object) font object, see @Paper.getFont 5541 - size (number) #optional size of the font, default is `16` 5542 - origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"` 5543 - letter_spacing (number) #optional number in range `-1..1`, default is `0` 5544 - line_spacing (number) #optional number in range `1..3`, default is `1` 5545 = (object) resulting path element, which consist of all letters 5546 > Usage 5547 | var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"}); 5548 \*/ 5549 paperproto.print = function (x, y, string, font, size, origin, letter_spacing, line_spacing) { 5550 origin = origin || "middle"; // baseline|middle 5551 letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); 5552 line_spacing = mmax(mmin(line_spacing || 1, 3), 1); 5553 var letters = Str(string)[split](E), 5554 shift = 0, 5555 notfirst = 0, 5556 path = E, 5557 scale; 5558 R.is(font, "string") && (font = this.getFont(font)); 5559 if (font) { 5560 scale = (size || 16) / font.face["units-per-em"]; 5561 var bb = font.face.bbox[split](separator), 5562 top = +bb[0], 5563 lineHeight = bb[3] - bb[1], 5564 shifty = 0, 5565 height = +bb[1] + (origin == "baseline" ? lineHeight + (+font.face.descent) : lineHeight / 2); 5566 for (var i = 0, ii = letters.length; i < ii; i++) { 5567 if (letters[i] == "\n") { 5568 shift = 0; 5569 curr = 0; 5570 notfirst = 0; 5571 shifty += lineHeight * line_spacing; 5572 } else { 5573 var prev = notfirst && font.glyphs[letters[i - 1]] || {}, 5574 curr = font.glyphs[letters[i]]; 5575 shift += notfirst ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0; 5576 notfirst = 1; 5577 } 5578 if (curr && curr.d) { 5579 path += R.transformPath(curr.d, ["t", shift * scale, shifty * scale, "s", scale, scale, top, height, "t", (x - top) / scale, (y - height) / scale]); 5580 } 5581 } 5582 } 5583 return this.path(path).attr({ 5584 fill: "#000", 5585 stroke: "none" 5586 }); 5587 }; 5588 5589 /*\ 5590 * Paper.add 5591 [ method ] 5592 ** 5593 * Imports elements in JSON array in format `{type: type, <attributes>}` 5594 ** 5595 > Parameters 5596 ** 5597 - json (array) 5598 = (object) resulting set of imported elements 5599 > Usage 5600 | paper.add([ 5601 | { 5602 | type: "circle", 5603 | cx: 10, 5604 | cy: 10, 5605 | r: 5 5606 | }, 5607 | { 5608 | type: "rect", 5609 | x: 10, 5610 | y: 10, 5611 | width: 10, 5612 | height: 10, 5613 | fill: "#fc0" 5614 | } 5615 | ]); 5616 \*/ 5617 paperproto.add = function (json) { 5618 if (R.is(json, "array")) { 5619 var res = this.set(), 5620 i = 0, 5621 ii = json.length, 5622 j; 5623 for (; i < ii; i++) { 5624 j = json[i] || {}; 5625 elements[has](j.type) && res.push(this[j.type]().attr(j)); 5626 } 5627 } 5628 return res; 5629 }; 5630 5631 /*\ 5632 * Raphael.format 5633 [ method ] 5634 ** 5635 * Simple format function. Replaces construction of type â`{<number>}`â to the corresponding argument. 5636 ** 5637 > Parameters 5638 ** 5639 - token (string) string to format 5640 - ⦠(string) rest of arguments will be treated as parameters for replacement 5641 = (string) formated string 5642 > Usage 5643 | var x = 10, 5644 | y = 20, 5645 | width = 40, 5646 | height = 50; 5647 | // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z" 5648 | paper.path(Raphael.format("M{0},{1}h{2}v{3}h{4}z", x, y, width, height, -width)); 5649 \*/ 5650 R.format = function (token, params) { 5651 var args = R.is(params, array) ? [0][concat](params) : arguments; 5652 token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { 5653 return args[++i] == null ? E : args[i]; 5654 })); 5655 return token || E; 5656 }; 5657 /*\ 5658 * Raphael.fullfill 5659 [ method ] 5660 ** 5661 * A little bit more advanced format function than @Raphael.format. Replaces construction of type â`{<name>}`â to the corresponding argument. 5662 ** 5663 > Parameters 5664 ** 5665 - token (string) string to format 5666 - json (object) object which properties will be used as a replacement 5667 = (string) formated string 5668 > Usage 5669 | // this will draw a rectangular shape equivalent to "M10,20h40v50h-40z" 5670 | paper.path(Raphael.fullfill("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", { 5671 | x: 10, 5672 | y: 20, 5673 | dim: { 5674 | width: 40, 5675 | height: 50, 5676 | "negative width": -40 5677 | } 5678 | })); 5679 \*/ 5680 R.fullfill = (function () { 5681 var tokenRegex = /\{([^\}]+)\}/g, 5682 objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties 5683 replacer = function (all, key, obj) { 5684 var res = obj; 5685 key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) { 5686 name = name || quotedName; 5687 if (res) { 5688 if (name in res) { 5689 res = res[name]; 5690 } 5691 typeof res == "function" && isFunc && (res = res()); 5692 } 5693 }); 5694 res = (res == null || res == obj ? all : res) + ""; 5695 return res; 5696 }; 5697 return function (str, obj) { 5698 return String(str).replace(tokenRegex, function (all, key) { 5699 return replacer(all, key, obj); 5700 }); 5701 }; 5702 })(); 5703 /*\ 5704 * Raphael.ninja 5705 [ method ] 5706 ** 5707 * If you want to leave no trace of Raphaël (Well, Raphaël creates only one global variable `Raphael`, but anyway.) You can use `ninja` method. 5708 * Beware, that in this case plugins could stop working, because they are depending on global variable exist
5708ance. 5709 ** 5710 = (object) Raphael object 5711 > Usage 5712 | (function (local_raphael) { 5713 | var paper = local_raphael(10, 10, 320, 200); 5714 | ⦠5715 | })(Raphael.ninja()); 5716 \*/ 5717 R.ninja = function () { 5718 oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; 5719 return R; 5720 }; 5721 /*\ 5722 * Raphael.st 5723 [ property (object) ] 5724 ** 5725 * You can add your own method to elements and sets. It is wise to add a set method for each element method 5726 * you added, so you will be able to call the same method on sets too. 5727 ** 5728 * See also @Raphael.el. 5729 > Usage 5730 | Raphael.el.red = function () { 5731 | this.attr({fill: "#f00"}); 5732 | }; 5733 | Raphael.st.red = function () { 5734 | this.forEach(function (el) { 5735 | el.red(); 5736 | }); 5737 | }; 5738 | // then use it 5739 | paper.set(paper.circle(100, 100, 20), paper.circle(110, 100, 20)).red(); 5740 \*/ 5741 R.st = setproto; 5742 // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html 5743 (function (doc, loaded, f) { 5744 if (doc.readyState == null && doc.addEventListener){ 5745 doc.addEventListener(loaded, f = function () { 5746 doc.removeEventListener(loaded, f, false); 5747 doc.readyState = "complete"; 5748 }, false); 5749 doc.readyState = "loading"; 5750 } 5751 function isLoaded() { 5752 (/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve("raphael.DOMload"); 5753 } 5754 isLoaded(); 5755 })(document, "DOMContentLoaded"); 5756 5757 eve.on("raphael.DOMload", function () { 5758 loaded = true; 5759 }); 5760 5761// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 5762// â Raphaël - JavaScript Vector Library â \\ 5763// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 5764// â SVG Module â \\ 5765// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 5766// â Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) â \\ 5767// â Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) â \\ 5768// â Licensed under the MIT (http://raphaeljs.com/license.html) license. â \\ 5769// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 5770 5771(function(){ 5772 if (!R.svg) { 5773 return; 5774 } 5775 var has = "hasOwnProperty", 5776 Str = String, 5777 toFloat = parseFloat, 5778 toInt = parseInt, 5779 math = Math, 5780 mmax = math.max, 5781 abs = math.abs, 5782 pow = math.pow, 5783 separator = /[, ]+/, 5784 eve = R.eve, 5785 E = "", 5786 S = " "; 5787 var xlink = "http://www.w3.org/1999/xlink", 5788 markers = { 5789 block: "M5,0 0,2.5 5,5z", 5790 classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z", 5791 diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z", 5792 open: "M6,1 1,3.5 6,6", 5793 oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z" 5794 }, 5795 markerCounter = {}; 5796 R.toString = function () { 5797 return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version; 5798 }; 5799 var $ = function (el, attr) { 5800 if (attr) { 5801 if (typeof el == "string") { 5802 el = $(el); 5803 } 5804 for (var key in attr) if (attr[has](key)) { 5805 if (key.substring(0, 6) == "xlink:") { 5806 el.setAttributeNS(xlink, key.substring(6), Str(attr[key])); 5807 } else { 5808 el.setAttribute(key, Str(attr[key])); 5809 } 5810 } 5811 } else { 5812 el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el); 5813 el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)"); 5814 } 5815 return el; 5816 }, 5817 addGradientFill = function (element, gradient) { 5818 var type = "linear",
vendor: 36,647 bytes, lines 5819-6724
5819 id = element.id + gradient, 5820 fx = .5, fy = .5, 5821 o = element.node, 5822 SVG = element.paper, 5823 s = o.style, 5824 el = R._g.doc.getElementById(id); 5825 if (!el) { 5826 gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) { 5827 type = "radial"; 5828 if (_fx && _fy) { 5829 fx = toFloat(_fx); 5830 fy = toFloat(_fy); 5831 var dir = ((fy > .5) * 2 - 1); 5832 pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && 5833 (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) && 5834 fy != .5 && 5835 (fy = fy.toFixed(5) - 1e-5 * dir); 5836 } 5837 return E; 5838 }); 5839 gradient = gradient.split(/\s*\-\s*/); 5840 if (type == "linear") { 5841 var angle = gradient.shift(); 5842 angle = -toFloat(angle); 5843 if (isNaN(angle)) { 5844 return null; 5845 } 5846 var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))], 5847 max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1); 5848 vector[2] *= max; 5849 vector[3] *= max; 5850 if (vector[2] < 0) { 5851 vector[0] = -vector[2]; 5852 vector[2] = 0; 5853 } 5854 if (vector[3] < 0) { 5855 vector[1] = -vector[3]; 5856 vector[3] = 0; 5857 } 5858 } 5859 var dots = R._parseDots(gradient); 5860 if (!dots) { 5861 return null; 5862 } 5863 id = id.replace(/[\(\)\s,\xb0#]/g, "_"); 5864 5865 if (element.gradient && id != element.gradient.id) { 5866 SVG.defs.removeChild(element.gradient); 5867 delete element.gradient; 5868 } 5869 5870 if (!element.gradient) { 5871 el = $(type + "Gradient", {id: id}); 5872 element.gradient = el; 5873 $(el, type == "radial" ? { 5874 fx: fx, 5875 fy: fy 5876 } : { 5877 x1: vector[0], 5878 y1: vector[1], 5879 x2: vector[2], 5880 y2: vector[3], 5881 gradientTransform: element.matrix.invert() 5882 }); 5883 SVG.defs.appendChild(el); 5884 for (var i = 0, ii = dots.length; i < ii; i++) { 5885 el.appendChild($("stop", { 5886 offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%", 5887 "stop-color": dots[i].color || "#fff" 5888 })); 5889 } 5890 } 5891 } 5892 $(o, { 5893 fill: "url(#" + id + ")", 5894 opacity: 1, 5895 "fill-opacity": 1 5896 }); 5897 s.fill = E; 5898 s.opacity = 1; 5899 s.fillOpacity = 1; 5900 return 1; 5901 }, 5902 updatePosition = function (o) { 5903 var bbox = o.getBBox(1); 5904 $(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"}); 5905 }, 5906 addArrow = function (o, value, isEnd) { 5907 if (o.type == "path") { 5908 var values = Str(value).toLowerCase().split("-"), 5909 p = o.paper, 5910 se = isEnd ? "end" : "start", 5911 node = o.node, 5912 attrs = o.attrs, 5913 stroke = attrs["stroke-width"], 5914 i = values.length, 5915 type = "classic", 5916 from, 5917 to, 5918 dx, 5919 refX, 5920 attr, 5921 w = 3, 5922 h = 3, 5923 t = 5; 5924 while (i--) { 5925 switch (values[i]) { 5926 case "block": 5927 case "classic": 5928 case "oval": 5929 case "diamond": 5930 case "open": 5931 case "none": 5932 type = values[i]; 5933 break; 5934 case "wide": h = 5; break; 5935 case "narrow": h = 2; break; 5936 case "long": w = 5; break; 5937 case "short": w = 2; break; 5938 } 5939 } 5940 if (type == "open") { 5941 w += 2; 5942 h += 2; 5943 t += 2; 5944 dx = 1; 5945 refX = isEnd ? 4 : 1; 5946 attr = { 5947 fill: "none", 5948 stroke: attrs.stroke 5949 }; 5950 } else { 5951 refX = dx = w / 2; 5952 attr = { 5953 fill: attrs.stroke, 5954 stroke: "none" 5955 }; 5956 } 5957 if (o._.arrows) { 5958 if (isEnd) { 5959 o._.arrows.endPath && markerCounter[o._.arrows.endPath]--; 5960 o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--; 5961 } else { 5962 o._.arrows.startPath && markerCounter[o._.arrows.startPath]--; 5963 o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--; 5964 } 5965 } else { 5966 o._.arrows = {}; 5967 } 5968 if (type != "none") { 5969 var pathId = "raphael-marker-" + type, 5970 markerId = "raphael-marker-" + se + type + w + h; 5971 if (!R._g.doc.getElementById(pathId)) { 5972 p.defs.appendChild($($("path"), { 5973 "stroke-linecap": "round", 5974 d: markers[type], 5975 id: pathId 5976 })); 5977 markerCounter[pathId] = 1; 5978 } else { 5979 markerCounter[pathId]++; 5980 } 5981 var marker = R._g.doc.getElementById(markerId), 5982 use; 5983 if (!marker) { 5984 marker = $($("marker"), { 5985 id: markerId, 5986 markerHeight: h, 5987 markerWidth: w, 5988 orient: "auto", 5989 refX: refX, 5990 refY: h / 2 5991 }); 5992 use = $($("use"), { 5993 "xlink:href": "#" + pathId, 5994 transform: (isEnd ? "rotate(180 " + w / 2 + " " + h / 2 + ") " : E) + "scale(" + w / t + "," + h / t + ")", 5995 "stroke-width": (1 / ((w / t + h / t) / 2)).toFixed(4) 5996 }); 5997 marker.appendChild(use); 5998 p.defs.appendChild(marker); 5999 markerCounter[markerId] = 1; 6000 } else { 6001 markerCounter[markerId]++; 6002 use = marker.getElementsByTagName("use")[0]; 6003 } 6004 $(use, attr); 6005 var delta = dx * (type != "diamond" && type != "oval"); 6006 if (isEnd) { 6007 from = o._.arrows.startdx * stroke || 0; 6008 to = R.getTotalLength(attrs.path) - delta * stroke; 6009 } else { 6010 from = delta * stroke; 6011 to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0); 6012 } 6013 attr = {}; 6014 attr["marker-" + se] = "url(#" + markerId + ")"; 6015 if (to || from) { 6016 attr.d = R.getSubpath(attrs.path, from, to); 6017 } 6018 $(node, attr); 6019 o._.arrows[se + "Path"] = pathId; 6020 o._.arrows[se + "Marker"] = markerId; 6021 o._.arrows[se + "dx"] = delta; 6022 o._.arrows[se + "Type"] = type; 6023 o._.arrows[se + "String"] = value; 6024 } else { 6025 if (isEnd) { 6026 from = o._.arrows.startdx * stroke || 0; 6027 to = R.getTotalLength(attrs.path) - from; 6028 } else { 6029 from = 0; 6030 to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0); 6031 } 6032 o._.arrows[se + "Path"] && $(node, {d: R.getSubpath(attrs.path, from, to)}); 6033 delete o._.arrows[se + "Path"]; 6034 delete o._.arrows[se + "Marker"]; 6035 delete o._.arrows[se + "dx"]; 6036 delete o._.arrows[se + "Type"]; 6037 delete o._.arrows[se + "String"]; 6038 } 6039 for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) { 6040 var item = R._g.doc.getElementById(attr); 6041 item && item.parentNode.removeChild(item); 6042 } 6043 } 6044 }, 6045 dasharray = { 6046 "": [0], 6047 "none": [0], 6048 "-": [3, 1], 6049 ".": [1, 1], 6050 "-.": [3, 1, 1, 1], 6051 "-..": [3, 1, 1, 1, 1, 1], 6052 ". ": [1, 3], 6053 "- ": [4, 3], 6054 "--": [8, 3], 6055 "- .": [4, 3, 1, 3], 6056 "--.": [8, 3, 1, 3], 6057 "--..": [8, 3, 1, 3, 1, 3] 6058 }, 6059 addDashes = function (o, value, params) { 6060 value = dasharray[Str(value).toLowerCase()]; 6061 if (value) { 6062 var width = o.attrs["stroke-width"] || "1", 6063 butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0, 6064 dashes = [], 6065 i = value.length; 6066 while (i--) { 6067 dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt; 6068 } 6069 $(o.node, {"stroke-dasharray": dashes.join(",")}); 6070 } 6071 }, 6072 setFillAndStroke = function (o, params) { 6073 var node = o.node, 6074 attrs = o.attrs, 6075 vis = node.style.visibility; 6076 node.style.visibility = "hidden"; 6077 for (var att in params) { 6078 if (params[has](att)) { 6079 if (!R._availableAttrs[has](att)) { 6080 continue; 6081 } 6082 var value = params[att]; 6083 attrs[att] = value; 6084 switch (att) { 6085 case "blur": 6086 o.blur(value); 6087 break; 6088 case "href": 6089 case "title": 6090 var hl = $("title"); 6091 var val = R._g.doc.createTextNode(value); 6092 hl.appendChild(val); 6093 node.appendChild(hl); 6094 break; 6095 case "target": 6096 var pn = node.parentNode; 6097 if (pn.tagName.toLowerCase() != "a") { 6098 var hl = $("a"); 6099 pn.insertBefore(hl, node); 6100 hl.appendChild(node); 6101 pn = hl; 6102 } 6103 if (att == "target") { 6104 pn.setAttributeNS(xlink, "show", value == "blank" ? "new" : value); 6105 } else { 6106 pn.setAttributeNS(xlink, att, value); 6107 } 6108 break; 6109 case "cursor": 6110 node.style.cursor = value; 6111 break; 6112 case "transform": 6113 o.transform(value); 6114 break; 6115 case "arrow-start": 6116 addArrow(o, value); 6117 break; 6118 case "arrow-end": 6119 addArrow(o, value, 1); 6120 break; 6121 case "clip-rect": 6122 var rect = Str(value).split(separator); 6123 if (rect.length == 4) { 6124 o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); 6125 var el = $("clipPath"), 6126 rc = $("rect"); 6127 el.id = R.createUUID(); 6128 $(rc, { 6129 x: rect[0], 6130 y: rect[1], 6131 width: rect[2], 6132 height: rect[3] 6133 }); 6134 el.appendChild(rc); 6135 o.paper.defs.appendChild(el); 6136 $(node, {"clip-path": "url(#" + el.id + ")"}); 6137 o.clip = rc; 6138 } 6139 if (!value) { 6140 var path = node.getAttribute("clip-path"); 6141 if (path) { 6142 var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E)); 6143 clip && clip.parentNode.removeChild(clip); 6144 $(node, {"clip-path": E}); 6145 delete o.clip; 6146 } 6147 } 6148 break; 6149 case "path": 6150 if (o.type == "path") { 6151 $(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"}); 6152 o._.dirty = 1; 6153 if (o._.arrows) { 6154 "startString" in o._.arrows && addArrow(o, o._.arrows.startString); 6155 "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); 6156 } 6157 } 6158 break; 6159 case "width": 6160 node.setAttribute(att, value); 6161 o._.dirty = 1; 6162 if (attrs.fx) { 6163 att = "x"; 6164 value = attrs.x; 6165 } else { 6166 break; 6167 } 6168 case "x": 6169 if (attrs.fx) { 6170 value = -attrs.x - (attrs.width || 0); 6171 } 6172 case "rx": 6173 if (att == "rx" && o.type == "rect") { 6174 break; 6175 } 6176 case "cx": 6177 node.setAttribute(att, value); 6178 o.pattern && updatePosition(o); 6179 o._.dirty = 1; 6180 break; 6181 case "height": 6182 node.setAttribute(att, value); 6183 o._.dirty = 1; 6184 if (attrs.fy) { 6185 att = "y"; 6186 value = attrs.y; 6187 } else { 6188 break; 6189 } 6190 case "y": 6191 if (attrs.fy) { 6192 value = -attrs.y - (attrs.height || 0); 6193 } 6194 case "ry": 6195 if (att == "ry" && o.type == "rect") { 6196 break; 6197 } 6198 case "cy": 6199 node.setAttribute(att, value); 6200 o.pattern && updatePosition(o); 6201 o._.dirty = 1; 6202 break; 6203 case "r": 6204 if (o.type == "rect") { 6205 $(node, {rx: value, ry: value}); 6206 } else { 6207 node.setAttribute(att, value); 6208 } 6209 o._.dirty = 1; 6210 break; 6211 case "src": 6212 if (o.type == "image") { 6213 node.setAttributeNS(xlink, "href", value); 6214 } 6215 break; 6216 case "stroke-width": 6217 if (o._.sx != 1 || o._.sy != 1) { 6218 value /= mmax(abs(o._.sx), abs(o._.sy)) || 1; 6219 } 6220 if (o.paper._vbSize) { 6221 value *= o.paper._vbSize; 6222 } 6223 node.setAttribute(att, value); 6224 if (attrs["stroke-dasharray"]) { 6225 addDashes(o, attrs["stroke-dasharray"], params); 6226 } 6227 if (o._.arrows) { 6228 "startString" in o._.arrows && addArrow(o, o._.arrows.startString); 6229 "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); 6230 } 6231 break; 6232 case "stroke-dasharray": 6233 addDashes(o, value, params); 6234 break; 6235 case "fill": 6236 var isURL = Str(value).match(R._ISURL); 6237 if (isURL) { 6238 el = $("pattern"); 6239 var ig = $("image"); 6240 el.id = R.createUUID(); 6241 $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1}); 6242 $(ig, {x: 0, y: 0, "xlink:href": isURL[1]}); 6243 el.appendChild(ig); 6244 6245 (function (el) { 6246 R._preload(isURL[1], function () { 6247 var w = this.offsetWidth, 6248 h = this.offsetHeight; 6249 $(el, {width: w, height: h}); 6250 $(ig, {width: w, height: h}); 6251 o.paper.safari(); 6252 }); 6253 })(el); 6254 o.paper.defs.appendChild(el); 6255 $(node, {fill: "url(#" + el.id + ")"}); 6256 o.pattern = el; 6257 o.pattern && updatePosition(o); 6258 break; 6259 } 6260 var clr = R.getRGB(value); 6261 if (!clr.error) { 6262 delete params.gradient; 6263 delete attrs.gradient; 6264 !R.is(attrs.opacity, "undefined") && 6265 R.is(params.opacity, "undefined") && 6266 $(node, {opacity: attrs.opacity}); 6267 !R.is(attrs["fill-opacity"], "undefined") && 6268 R.is(params["fill-opacity"], "undefined") && 6269 $(node, {"fill-opacity": attrs["fill-opacity"]}); 6270 } else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) { 6271 if ("opacity" in attrs || "fill-opacity" in attrs) { 6272 var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E)); 6273 if (gradient) { 6274 var stops = gradient.getElementsByTagName("stop"); 6275 $(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)}); 6276 } 6277 } 6278 attrs.gradient = value; 6279 attrs.fill = "none"; 6280 break; 6281 } 6282 clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity}); 6283 case "stroke": 6284 clr = R.getRGB(value); 6285 node.setAttribute(att, clr.hex); 6286 att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity}); 6287 if (att == "stroke" && o._.arrows) { 6288 "startString" in o._.arrows && addArrow(o, o._.arrows.startString); 6289 "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); 6290 } 6291 break; 6292 case "gradient": 6293 (o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value); 6294 break; 6295 case "opacity": 6296 if (attrs.gradient && !attrs[has]("stroke-opacity")) { 6297 $(node, {"stroke-opacity": value > 1 ? value / 100 : value}); 6298 } 6299 // fall 6300 case "fill-opacity": 6301 if (attrs.gradient) { 6302 gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E)); 6303 if (gradient) { 6304 stops = gradient.getElementsByTagName("stop"); 6305 $(stops[stops.length - 1], {"stop-opacity": value}); 6306 } 6307 break; 6308 } 6309 default: 6310 att == "font-size" && (value = toInt(value, 10) + "px"); 6311 var cssrule = att.replace(/(\-.)/g, function (w) { 6312 return w.substring(1).toUpperCase(); 6313 }); 6314 node.style[cssrule] = value; 6315 o._.dirty = 1; 6316 node.setAttribute(att, value); 6317 break; 6318 } 6319 } 6320 } 6321 6322 tuneText(o, params); 6323 node.style.visibility = vis; 6324 }, 6325 leading = 1.2, 6326 tuneText = function (el, params) { 6327 if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) { 6328 return; 6329 } 6330 var a = el.attrs, 6331 node = el.node, 6332 fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10; 6333 6334 if (params[has]("text")) { 6335 a.text = params.text; 6336 while (node.firstChild) { 6337 node.removeChild(node.firstChild); 6338 } 6339 var texts = Str(params.text).split("\n"), 6340 tspans = [], 6341 tspan; 6342 for (var i = 0, ii = texts.length; i < ii; i++) { 6343 tspan = $("tspan"); 6344 i && $(tspan, {dy: fontSize * leading, x: a.x}); 6345 tspan.appendChild(R._g.doc.createTextNode(texts[i])); 6346 node.appendChild(tspan); 6347 tspans[i] = tspan; 6348 } 6349 } else { 6350 tspans = node.getElementsByTagName("tspan"); 6351 for (i = 0, ii = tspans.length; i < ii; i++) if (i) { 6352 $(tspans[i], {dy: fontSize * leading, x: a.x}); 6353 } else { 6354 $(tspans[0], {dy: 0}); 6355 } 6356 } 6357 $(node, {x: a.x, y: a.y}); 6358 el._.dirty = 1; 6359 var bb = el._getBBox(), 6360 dif = a.y - (bb.y + bb.height / 2); 6361 dif && R.is(dif, "finite") && $(tspans[0], {dy: dif}); 6362 }, 6363 Element = function (node, svg) { 6364 var X = 0, 6365 Y = 0; 6366 /*\ 6367 * Element.node 6368 [ property (object) ] 6369 ** 6370 * Gives you a reference to the DOM object, so you can assign event handlers or just mess around. 6371 ** 6372 * Note: Donât mess with it. 6373 > Usage 6374 | // draw a circle at coordinate 10,10 with radius of 10 6375 | var c = paper.circle(10, 10, 10); 6376 | c.node.onclick = function () { 6377 | c.attr("fill", "red"); 6378 | }; 6379 \*/ 6380 this[0] = this.node = node; 6381 /*\ 6382 * Element.raphael 6383 [ property (object) ] 6384 ** 6385 * Internal reference to @Raphael object. In case it is not available. 6386 > Usage 6387 | Raphael.el.red = function () { 6388 | var hsb = this.paper.raphael.rgb2hsb(this.attr("fill")); 6389 | hsb.h = 1; 6390 | this.attr({fill: this.paper.raphael.hsb2rgb(hsb).hex}); 6391 | } 6392 \*/ 6393 node.raphael = true; 6394 /*\ 6395 * Element.id 6396 [ property (number) ] 6397 ** 6398 * Unique id of the element. Especially usesful when you want to listen to events of the element, 6399 * because all events are fired in format `<module>.<action>.<id>`. Also useful for @Paper.getById method. 6400 \*/ 6401 this.id = R._oid++; 6402 node.raphaelid = this.id; 6403 this.matrix = R.matrix(); 6404 this.realPath = null; 6405 /*\ 6406 * Element.paper 6407 [ property (object) ] 6408 ** 6409 * Internal reference to âpaperâ where object drawn. Mainly for use in plugins and element extensions. 6410 > Usage 6411 | Raphael.el.cross = function () { 6412 | this.attr({fill: "red"}); 6413 | this.paper.path("M10,10L50,50M50,10L10,50") 6414 | .attr({stroke: "red"}); 6415 | } 6416 \*/ 6417 this.paper = svg; 6418 this.attrs = this.attrs || {}; 6419 this._ = { 6420 transform: [], 6421 sx: 1, 6422 sy: 1, 6423 deg: 0, 6424 dx: 0, 6425 dy: 0, 6426 dirty: 1 6427 }; 6428 !svg.bottom && (svg.bottom = this); 6429 /*\ 6430 * Element.prev 6431 [ property (object) ] 6432 ** 6433 * Reference to the previous element in the hierarchy. 6434 \*/ 6435 this.prev = svg.top; 6436 svg.top && (svg.top.next = this); 6437 svg.top = this; 6438 /*\ 6439 * Element.next 6440 [ property (object) ] 6441 ** 6442 * Reference to the next element in the hierarchy. 6443 \*/ 6444 this.next = null; 6445 }, 6446 elproto = R.el; 6447 6448 Element.prototype = elproto; 6449 elproto.constructor = Element; 6450 6451 R._engine.path = function (pathString, SVG) { 6452 var el = $("path"); 6453 SVG.canvas && SVG.canvas.appendChild(el); 6454 var p = new Element(el, SVG); 6455 p.type = "path"; 6456 setFillAndStroke(p, { 6457 fill: "none", 6458 stroke: "#000", 6459 path: pathString 6460 }); 6461 return p; 6462 }; 6463 /*\ 6464 * Element.rotate 6465 [ method ] 6466 ** 6467 * Deprecated! Use @Element.transform instead. 6468 * Adds rotation by given angle around given point to the list of 6469 * transformations of the element. 6470 > Parameters 6471 - deg (number) angle in degrees 6472 - cx (number) #optional x coordinate of the centre of rotation 6473 - cy (number) #optional y coordinate of the centre of rotation 6474 * If cx & cy arenât specified centre of the shape is used as a point of rotation. 6475 = (object) @Element 6476 \*/ 6477 elproto.rotate = function (deg, cx, cy) { 6478 if (this.removed) { 6479 return this; 6480 } 6481 deg = Str(deg).split(separator); 6482 if (deg.length - 1) { 6483 cx = toFloat(deg[1]); 6484 cy = toFloat(deg[2]); 6485 } 6486 deg = toFloat(deg[0]); 6487 (cy == null) && (cx = cy); 6488 if (cx == null || cy == null) { 6489 var bbox = this.getBBox(1); 6490 cx = bbox.x + bbox.width / 2; 6491 cy = bbox.y + bbox.height / 2; 6492 } 6493 this.transform(this._.transform.concat([["r", deg, cx, cy]])); 6494 return this; 6495 }; 6496 /*\ 6497 * Element.scale 6498 [ method ] 6499 ** 6500 * Deprecated! Use @Element.transform instead. 6501 * Adds scale by given amount relative to given point to the list of 6502 * transformations of the element. 6503 > Parameters 6504 - sx (number) horisontal scale amount 6505 - sy (number) vertical scale amount 6506 - cx (number) #optional x coordinate of the centre of scale 6507 - cy (number) #optional y coordinate of the centre of scale 6508 * If cx & cy arenât specified centre of the shape is used instead. 6509 = (object) @Element 6510 \*/ 6511 elproto.scale = function (sx, sy, cx, cy) { 6512 if (this.removed) { 6513 return this; 6514 } 6515 sx = Str(sx).split(separator); 6516 if (sx.length - 1) { 6517 sy = toFloat(sx[1]); 6518 cx = toFloat(sx[2]); 6519 cy = toFloat(sx[3]); 6520 } 6521 sx = toFloat(sx[0]); 6522 (sy == null) && (sy = sx); 6523 (cy == null) && (cx = cy); 6524 if (cx == null || cy == null) { 6525 var bbox = this.getBBox(1); 6526 } 6527 cx = cx == null ? bbox.x + bbox.width / 2 : cx; 6528 cy = cy == null ? bbox.y + bbox.height / 2 : cy; 6529 this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); 6530 return this; 6531 }; 6532 /*\ 6533 * Element.translate 6534 [ method ] 6535 ** 6536 * Deprecated! Use @Element.transform instead. 6537 * Adds translation by given amount to the list of transformations of the element. 6538 > Parameters 6539 - dx (number) horisontal shift 6540 - dy (number) vertical shift 6541 = (object) @Element 6542 \*/ 6543 elproto.translate = function (dx, dy) { 6544 if (this.removed) { 6545 return this; 6546 } 6547 dx = Str(dx).split(separator); 6548 if (dx.length - 1) { 6549 dy = toFloat(dx[1]); 6550 } 6551 dx = toFloat(dx[0]) || 0; 6552 dy = +dy || 0; 6553 this.transform(this._.transform.concat([["t", dx, dy]])); 6554 return this; 6555 }; 6556 /*\ 6557 * Element.transform 6558 [ method ] 6559 ** 6560 * Adds transformation to the element which is separate to other attributes, 6561 * i.e. translation doesnât change `x` or `y` of the rectange. The format 6562 * of transformation string is similar to the path string syntax: 6563 | "t100,100r30,100,100s2,2,100,100r45s1.5" 6564 * Each letter is a command. There are four commands: `t` is for translate, `r` is for rotate, `s` is for 6565 * scale and `m` is for matrix. 6566 * 6567 * There are also alternative âabsoluteâ translation, rotation and scale: `T`, `R` and `S`. They will not take previous transformation into account. For example, `...T100,0` will always move element 100 px horisontally, while `...t100,0` could move it vertically if there is `r90` before. Just compare results of `r90t100,0` and `r90T100,0`. 6568 * 6569 * So, the example line above could be read like âtranslate by 100, 100; rotate 30° around 100, 100; scale twice around 100, 100; 6570 * rotate 45° around centre; scale 1.5 times relative to centreâ. As you can see rotate and scale commands have origin 6571 * coordinates as optional parameters, the default is the centre point of the element. 6572 * Matrix accepts six parameters. 6573 > Usage 6574 | var el = paper.rect(10, 20, 300, 200); 6575 | // translate 100, 100, rotate 45°, translate -100, 0 6576 | el.transform("t100,100r45t-100,0"); 6577 | // if you want you can append or prepend transformations 6578 | el.transform("...t50,50"); 6579 | el.transform("s2..."); 6580 | // or even wrap 6581 | el.transform("t50,50...t-50-50"); 6582 | // to reset transformation call method with empty string 6583 | el.transform(""); 6584 | // to get current value call it without parameters 6585 | console.log(el.transform()); 6586 > Parameters 6587 - tstr (string) #optional transformation string 6588 * If tstr isnât specified 6589 = (string) current transformation string 6590 * else 6591 = (object) @Element 6592 \*/ 6593 elproto.transform = function (tstr) { 6594 var _ = this._; 6595 if (tstr == null) { 6596 return _.transform; 6597 } 6598 R._extractTransform(this, tstr); 6599 6600 this.clip && $(this.clip, {transform: this.matrix.invert()}); 6601 this.pattern && updatePosition(this); 6602 this.node && $(this.node, {transform: this.matrix}); 6603 6604 if (_.sx != 1 || _.sy != 1) { 6605 var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; 6606 this.attr({"stroke-width": sw}); 6607 } 6608 6609 return this; 6610 }; 6611 /*\ 6612 * Element.hide 6613 [ method ] 6614 ** 6615 * Makes element invisible. See @Element.show. 6616 = (object) @Element 6617 \*/ 6618 elproto.hide = function () { 6619 !this.removed && this.paper.safari(this.node.style.display = "none"); 6620 return this; 6621 }; 6622 /*\ 6623 * Element.show 6624 [ method ] 6625 ** 6626 * Makes element visible. See @Element.hide. 6627 = (object) @Element 6628 \*/ 6629 elproto.show = function () { 6630 !this.removed && this.paper.safari(this.node.style.display = ""); 6631 return this; 6632 }; 6633 /*\ 6634 * Element.remove 6635 [ method ] 6636 ** 6637 * Removes element from the paper. 6638 \*/ 6639 elproto.remove = function () { 6640 if (this.removed || !this.node.parentNode) { 6641 return; 6642 } 6643 var paper = this.paper; 6644 paper.__set__ && paper.__set__.exclude(this); 6645 eve.unbind("raphael.*.*." + this.id); 6646 if (this.gradient) { 6647 paper.defs.removeChild(this.gradient); 6648 } 6649 R._tear(this, paper); 6650 if (this.node.parentNode.tagName.toLowerCase() == "a") { 6651 this.node.parentNode.parentNode.removeChild(this.node.parentNode); 6652 } else { 6653 this.node.parentNode.removeChild(this.node); 6654 } 6655 for (var i in this) { 6656 this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; 6657 } 6658 this.removed = true; 6659 }; 6660 elproto._getBBox = function () { 6661 if (this.node.style.display == "none") { 6662 this.show(); 6663 var hide = true; 6664 } 6665 var bbox = {}; 6666 try { 6667 bbox = this.node.getBBox(); 6668 } catch(e) { 6669 // Firefox 3.0.x plays badly here 6670 } finally { 6671 bbox = bbox || {}; 6672 } 6673 hide && this.hide(); 6674 return bbox; 6675 }; 6676 /*\ 6677 * Element.attr 6678 [ method ] 6679 ** 6680 * Sets the attributes of the element. 6681 > Parameters 6682 - attrName (string) attributeâs name 6683 - value (string) value 6684 * or 6685 - params (object) object of name/value pairs 6686 * or 6687 - attrName (string) attributeâs name 6688 * or 6689 - attrNames (array) in this case method returns array of current values for given attribute names 6690 = (object) @Element if attrsName & value or params are passed in. 6691 = (...) value of the attribute if only attrsName is passed in. 6692 = (array) array of values of the attribute if attrsNames is passed in. 6693 = (object) object of attributes if nothing is passed in. 6694 > Possible parameters 6695 # <p>Please refer to the <a href="http://www.w3.org/TR/SVG/" title="The W3C Recommendation for the SVG language describes these properties in detail.">SVG specification</a> for an explanation of these parameters.</p> 6696 o arrow-end (string) arrowhead on the end of the path. The format for string is `<type>[-<width>[-<length>]]`. Possible types: `classic`, `block`, `open`, `oval`, `diamond`, `none`, width: `wide`, `narrow`, `medium`, length: `long`, `short`, `midium`. 6697 o clip-rect (string) comma or space separated values: x, y, width and height 6698 o cursor (string) CSS type of the cursor 6699 o cx (number) the x-axis coordinate of the center of the circle, or ellipse 6700 o cy (number) the y-axis coordinate of the center of the circle, or ellipse 6701 o fill (string) colour, gradient or image 6702 o fill-opacity (number) 6703 o font (string) 6704 o font-family (string) 6705 o font-size (number) font size in pixels 6706 o font-weight (string) 6707 o height (number) 6708 o href (string) URL, if specified element behaves as hyperlink 6709 o opacity (number) 6710 o path (string) SVG path string format 6711 o r (number) radius of the circle, ellipse or rounded corner on the rect 6712 o rx (number) horisontal radius of the ellipse 6713 o ry (number) vertical radius of the ellipse 6714 o src (string) image URL, only works for @Element.image element 6715 o stroke (string) stroke colour 6716 o stroke-dasharray (string) [ââ, â`-`â, â`.`â, â`-.`â, â`-..`â, â`. `â, â`- `â, â`--`â, â`- .`â, â`--.`â, â`--..`â] 6717 o stroke-linecap (string) [â`butt`â, â`square`â, â`round`â] 6718 o stroke-linejoin (string) [â`bevel`â, â`round`â, â`miter`â] 6719 o stroke-miterlimit (number) 6720 o stroke-opacity (number) 6721 o stroke-width (number) stroke width in pixels, default is '1' 6722 o target (string) used with href 6723 o text (string) contents of the text element. Use `\n` for multiline text 6724 o text-anchor (string) [â`start`â, â`middle`â, â`end`â
6724], default is â`middle`â 6725 o title (string) will create tooltip with a given text 6726 o transform (string) see @Element.transform 6727 o width (number) 6728 o x (number) 6729 o y (number) 6730 > Gradients 6731 * Linear gradient format: â`â¹angleâº-â¹colourâº[-â¹colourâº[:â¹offsetâº]]*-â¹colourâº`â, example: â`90-#fff-#000`â â 90° 6732 * gradient from white to black or â`0-#fff-#f00:20-#000`â â 0° gradient from white via red (at 20%) to black. 6733 * 6734 * radial gradient: â`r[(â¹fxâº, â¹fyâº)]â¹colourâº[-â¹colourâº[:â¹offsetâº]]*-â¹colourâº`â, example: â`r#fff-#000`â â 6735 * gradient from white to black or â`r(0.25, 0.75)#fff-#000`â â gradient from white to black with focus point 6736 * at 0.25, 0.75. Focus point coordinates are in 0..1 range. Radial gradients can only be applied to circles and ellipses. 6737 > Path String 6738 # <p>Please refer to <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a pathâs data attributeâs format are described in the SVG specification.">SVG documentation regarding path string</a>. Raphaël fully supports it.</p> 6739 > Colour Parsing 6740 # <ul> 6741 # <li>Colour name (â<code>red</code>â, â<code>green</code>â, â<code>cornflowerblue</code>â, etc)</li> 6742 # <li>#â¢â¢â¢ â shortened HTML colour: (â<code>#000</code>â, â<code>#fc0</code>â, etc)</li> 6743 # <li>#â¢â¢â¢â¢â¢â¢ â full length HTML colour: (â<code>#000000</code>â, â<code>#bd2300</code>â)</li> 6744 # <li>rgb(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â red, green and blue channelsâ values: (â<code>rgb(200, 100, 0)</code>â)</li> 6745 # <li>rgb(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %: (â<code>rgb(100%, 175%, 0%)</code>â)</li> 6746 # <li>rgba(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â red, green and blue channelsâ values: (â<code>rgba(200, 100, 0, .5)</code>â)</li> 6747 # <li>rgba(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %: (â<code>rgba(100%, 175%, 0%, 50%)</code>â)</li> 6748 # <li>hsb(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â hue, saturation and brightness values: (â<code>hsb(0.5, 0.25, 1)</code>â)</li> 6749 # <li>hsb(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %</li> 6750 # <li>hsba(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â same as above, but with opacity</li> 6751 # <li>hsl(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â almost the same as hsb, see <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" title="HSL and HSV - Wikipedia, the free encyclopedia">Wikipedia page</a></li> 6752 # <li>hsl(â¢â¢â¢%, â¢â¢â¢%, â¢â¢â¢%) â same as above, but in %</li> 6753 # <li>hsla(â¢â¢â¢, â¢â¢â¢, â¢â¢â¢, â¢â¢â¢) â same as above, but with opacity</li> 6754 # <li>Optionally for hsb and hsl you could specify hue as a degree: â<code>hsl(240deg, 1, .5)</code>â or, if you want to go fancy, â<code>hsl(240°, 1, .5)</code>â</li> 6755 # </ul> 6756 \*/ 6757 elproto.attr = function (name, value) { 6758 if (this.removed) { 6759 return this; 6760 } 6761 if (name == null) { 6762 var res = {}; 6763 for (var a in this.attrs) if (this.attrs[has](a)) { 6764 res[a] = this.attrs[a]; 6765 } 6766 res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; 6767 res.transform = this._.transform; 6768 return res; 6769 } 6770 if (value == null && R.is(name, "string")) { 6771 if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { 6772 return this.attrs.gradient; 6773 } 6774 if (name == "transform") { 6775 return this._.transform; 6776 } 6777 var names = name.split(separator), 6778 out = {}; 6779 for (var i = 0, ii = names.length; i < ii; i++) { 6780 name = names[i]; 6781 if (name in this.attrs) { 6782 out[name] = this.attrs[name]; 6783 } else if (R.is(this.paper.customAttributes[name], "function")) { 6784 out[name] = this.paper.customAttributes[name].def; 6785 } else { 6786 out[name] = R._availableAttrs[name]; 6787 } 6788 } 6789 return ii - 1 ? out : out[names[0]]; 6790 } 6791 if (value == null && R.is(name, "array")) { 6792 out = {}; 6793 for (i = 0, ii = name.length; i < ii; i++) { 6794 out[name[i]] = this.attr(name[i]); 6795 } 6796 return out; 6797 } 6798 if (value != null) { 6799 var params = {}; 6800 params[name] = value; 6801 } else if (name != null && R.is(name, "object")) { 6802 params = name; 6803 } 6804 for (var key in params) { 6805 eve("raphael.attr." + key + "." + this.id, this, params[key]); 6806 } 6807 for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { 6808 var par = this.paper.customAttributes[key].apply(this, [].concat(params[key])); 6809 this.attrs[key] = params[key]; 6810 for (var subkey in par) if (par[has](subkey)) { 6811 params[subkey] = par[subkey]; 6812 } 6813 } 6814 setFillAndStroke(this, params); 6815 return this; 6816 }; 6817 /*\ 6818 * Element.toFront 6819 [ method ] 6820 ** 6821 * Moves the element so it is the closest to the viewerâs eyes, on top of other elements. 6822 = (object) @Element 6823 \*/ 6824 elproto.toFront = function () { 6825 if (this.removed) { 6826 return this; 6827 } 6828 if (this.node.parentNode.tagName.toLowerCase() == "a") { 6829 this.node.parentNode.parentNode.appendChild(this.node.parentNode); 6830 } else { 6831 this.node.parentNode.appendChild(this.node); 6832 } 6833 var svg = this.paper; 6834 svg.top != this && R._tofront(this, svg); 6835 return this; 6836 }; 6837 /*\ 6838 * Element.toBack 6839 [ method ] 6840 ** 6841 * Moves the element so it is the furthest from the viewerâs eyes, behind other elements. 6842 = (object) @Element 6843 \*/ 6844 elproto.toBack = function () { 6845 if (this.removed) { 6846 return this; 6847 } 6848 var parent = this.node.parentNode; 6849 if (parent.tagName.toLowerCase() == "a") { 6850 parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); 6851 } else if (parent.firstChild != this.node) { 6852 parent.insertBefore(this.node, this.node.parentNode.firstChild); 6853 } 6854 R._toback(this, this.paper); 6855 var svg = this.paper; 6856 return this; 6857 }; 6858 /*\ 6859 * Element.insertAfter 6860 [ method ] 6861 ** 6862 * Inserts current object after the given one. 6863 = (object) @Element 6864 \*/ 6865 elproto.insertAfter = function (element) { 6866 if (this.removed) { 6867 return this; 6868 } 6869 var node = element.node || element[element.length - 1].node; 6870 if (node.nextSibling) { 6871 node.parentNode.insertBefore(this.node, node.nextSibling); 6872 } else { 6873 node.parentNode.appendChild(this.node); 6874 } 6875 R._insertafter(this, element, this.paper); 6876 return this; 6877 }; 6878 /*\ 6879 * Element.insertBefore 6880 [ method ] 6881 ** 6882 * Inserts current object before the given one. 6883 = (object) @Element 6884 \*/ 6885 elproto.insertBefore = function (element) { 6886 if (this.removed) { 6887 return this; 6888 } 6889 var node = element.node || element[0].node; 6890 node.parentNode.insertBefore(this.node, node); 6891 R._insertbefore(this, element, this.paper); 6892 return this; 6893 }; 6894 elproto.blur = function (size) { 6895 // Experimental. No Safari support. Use it on your own risk. 6896 var t = this; 6897 if (+size !== 0) { 6898 var fltr = $("filter"), 6899 blur = $("feGaussianBlur"); 6900 t.attrs.blur = size; 6901 fltr.id = R.createUUID(); 6902 $(blur, {stdDeviation: +size || 1.5}); 6903 fltr.appendChild(blur); 6904 t.paper.defs.appendChild(fltr); 6905 t._blur = fltr; 6906 $(t.node, {filter: "url(#" + fltr.id + ")"}); 6907 } else { 6908 if (t._blur) { 6909 t._blur.parentNode.removeChild(t._blur); 6910 delete t._blur; 6911 delete t.attrs.blur; 6912 } 6913 t.node.removeAttribute("filter"); 6914 } 6915 return t; 6916 }; 6917 R._engine.circle = function (svg, x, y, r) { 6918 var el = $("circle"); 6919 svg.canvas && svg.canvas.appendChild(el); 6920 var res = new Element(el, svg); 6921 res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"}; 6922 res.type = "circle"; 6923 $(el, res.attrs); 6924 return res; 6925 }; 6926 R._engine.rect = function (svg, x, y, w, h, r) { 6927 var el = $("rect"); 6928 svg.canvas && svg.canvas.appendChild(el); 6929 var res = new Element(el, svg); 6930 res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"}; 6931 res.type = "rect"; 6932 $(el, res.attrs); 6933 return res; 6934 }; 6935 R._engine.ellipse = function (svg, x, y, rx, ry) { 6936 var el = $("ellipse"); 6937 svg.canvas && svg.canvas.appendChild(el); 6938 var res = new Element(el, svg); 6939 res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"}; 6940 res.type = "ellipse"; 6941 $(el, res.attrs); 6942 return res; 6943 }; 6944 R._engine.image = function (svg, src, x, y, w, h) { 6945 var el = $("image"); 6946 $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"}); 6947 el.setAttributeNS(xlink, "href", src); 6948 svg.canvas && svg.canvas.appendChild(el); 6949 var res = new Element(el, svg); 6950 res.attrs = {x: x, y: y, width: w, height: h, src: src}; 6951 res.type = "image"; 6952 return res; 6953 }; 6954 R._engine.text = function (svg, x, y, text) { 6955 var el = $("text"); 6956 svg.canvas && svg.canvas.appendChild(el); 6957 var res = new Element(el, svg); 6958 res.attrs = { 6959 x: x, 6960 y: y, 6961 "text-anchor": "middle", 6962 text: text, 6963 font: R._availableAttrs.font, 6964 stroke: "none", 6965 fill: "#000" 6966 }; 6967 res.type = "text"; 6968 setFillAndStroke(res, res.attrs); 6969 return res; 6970 }; 6971 R._engine.setSize = function (width, height) { 6972 this.width = width || this.width; 6973 this.height = height || this.height; 6974 this.canvas.setAttribute("width", this.width); 6975 this.canvas.setAttribute("height", this.height); 6976 if (this._viewBox) { 6977 this.setViewBox.apply(this, this._viewBox); 6978 } 6979 return this; 6980 }; 6981 R._engine.create = function () { 6982 var con = R._getContainer.apply(0, arguments), 6983 container = con && con.container, 6984 x = con.x, 6985 y = con.y, 6986 width = con.width, 6987 height = con.height; 6988 if (!container) { 6989 throw new Error("SVG container not found."); 6990 } 6991 var cnvs = $("svg"), 6992 css = "overflow:hidden;", 6993 isFloating; 6994 x = x || 0; 6995 y = y || 0; 6996 width = width || 512; 6997 height = height || 342;
6998 $(cnvs, { 6999 height: height, 7000 version: 1.1, 7001 width: width, 7002 xmlns: "http://www.w3.org/2000/svg" 7003 }); 7004 if (container == 1) { 7005 cnvs.style.cssText = css + "position:absolute;left:" + x + "px;top:" + y + "px"; 7006 R._g.doc.body.appendChild(cnvs); 7007 isFloating = 1; 7008 } else { 7009 cnvs.style.cssText = css + "position:relative"; 7010 if (container.firstChild) { 7011 container.insertBefore(cnvs, container.firstChild); 7012 } else { 7013 container.appendChild(cnvs); 7014 } 7015 } 7016 container = new R._Paper; 7017 container.width = width; 7018 container.height = height; 7019 container.canvas = cnvs; 7020 container.clear(); 7021 container._left = container._top = 0; 7022 isFloating && (container.renderfix = function () {}); 7023 container.renderfix(); 7024 return container; 7025 }; 7026 R._engine.setViewBox = function (x, y, w, h, fit) { 7027 eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]); 7028 var size = mmax(w / this.width, h / this.height), 7029 top = this.top, 7030 aspectRatio = fit ? "meet" : "xMinYMin", 7031 vb, 7032 sw; 7033 if (x == null) { 7034 if (this._vbSize) { 7035 size = 1; 7036 } 7037 delete this._vbSize; 7038 vb = "0 0 " + this.width + S + this.height; 7039 } else { 7040 this._vbSize = size; 7041 vb = x + S + y + S + w + S + h; 7042 } 7043 $(this.canvas, {
vendor: 38,549 bytes, lines 7044-8064
7044 viewBox: vb, 7045 preserveAspectRatio: aspectRatio 7046 }); 7047 while (size && top) { 7048 sw = "stroke-width" in top.attrs ? top.attrs["stroke-width"] : 1; 7049 top.attr({"stroke-width": sw}); 7050 top._.dirty = 1; 7051 top._.dirtyT = 1; 7052 top = top.prev; 7053 } 7054 this._viewBox = [x, y, w, h, !!fit]; 7055 return this; 7056 }; 7057 /*\ 7058 * Paper.renderfix 7059 [ method ] 7060 ** 7061 * Fixes the issue of Firefox and IE9 regarding subpixel rendering. If paper is dependant 7062 * on other elements after reflow it could shift half pixel which cause for lines to lost their crispness. 7063 * This method fixes the issue. 7064 ** 7065 Special thanks to Mariusz Nowak (http://www.medikoo.com/) for this method. 7066 \*/ 7067 R.prototype.renderfix = function () { 7068 var cnvs = this.canvas, 7069 s = cnvs.style, 7070 pos; 7071 try { 7072 pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix(); 7073 } catch (e) { 7074 pos = cnvs.createSVGMatrix(); 7075 } 7076 var left = -pos.e % 1, 7077 top = -pos.f % 1; 7078 if (left || top) { 7079 if (left) { 7080 this._left = (this._left + left) % 1; 7081 s.left = this._left + "px"; 7082 } 7083 if (top) { 7084 this._top = (this._top + top) % 1; 7085 s.top = this._top + "px"; 7086 } 7087 } 7088 }; 7089 /*\ 7090 * Paper.clear 7091 [ method ] 7092 ** 7093 * Clears the paper, i.e. removes all the elements. 7094 \*/ 7095 R.prototype.clear = function () { 7096 R.eve("raphael.clear", this); 7097 var c = this.canvas; 7098 while (c.firstChild) { 7099 c.removeChild(c.firstChild); 7100 } 7101 this.bottom = this.top = null; 7102 (this.desc = $("desc")).appendChild(R._g.doc.createTextNode("Created with Rapha\xebl " + R.version)); 7103 c.appendChild(this.desc); 7104 c.appendChild(this.defs = $("defs")); 7105 }; 7106 /*\ 7107 * Paper.remove 7108 [ method ] 7109 ** 7110 * Removes the paper from the DOM. 7111 \*/ 7112 R.prototype.remove = function () { 7113 eve("raphael.remove", this); 7114 this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); 7115 for (var i in this) { 7116 this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; 7117 } 7118 }; 7119 var setproto = R.st; 7120 for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { 7121 setproto[method] = (function (methodname) { 7122 return function () { 7123 var arg = arguments; 7124 return this.forEach(function (el) { 7125 el[methodname].apply(el, arg); 7126 }); 7127 }; 7128 })(method); 7129 } 7130})(); 7131 7132// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 7133// â Raphaël - JavaScript Vector Library â \\ 7134// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 7135// â VML Module â \\ 7136// ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ⤠\\ 7137// â Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) â \\ 7138// â Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) â \\ 7139// â Licensed under the MIT (http://raphaeljs.com/license.html) license. â \\ 7140// âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ \\ 7141 7142(function(){ 7143 if (!R.vml) { 7144 return; 7145 } 7146 var has = "hasOwnProperty", 7147 Str = String, 7148 toFloat = parseFloat, 7149 math = Math, 7150 round = math.round, 7151 mmax = math.max, 7152 mmin = math.min, 7153 abs = math.abs, 7154 fillString = "fill", 7155 separator = /[, ]+/, 7156 eve = R.eve, 7157 ms = " progid:DXImageTransform.Microsoft", 7158 S = " ", 7159 E = "", 7160 map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"}, 7161 bites = /([clmz]),?([^clmz]*)/gi, 7162 blurregexp = / progid:\S+Blur\([^\)]+\)/g, 7163 val = /-?[^,\s-]+/g, 7164 cssDot = "position:absolute;left:0;top:0;width:1px;height:1px", 7165 zoom = 21600, 7166 pathTypes = {path: 1, rect: 1, image: 1}, 7167 ovalTypes = {circle: 1, ellipse: 1}, 7168 path2vml = function (path) { 7169 var total = /[ahqstv]/ig, 7170 command = R._pathToAbsolute; 7171 Str(path).match(total) && (command = R._path2curve); 7172 total = /[clmz]/g; 7173 if (command == R._pathToAbsolute && !Str(path).match(total)) { 7174 var res = Str(path).replace(bites, function (all, command, args) { 7175 var vals = [], 7176 isMove = command.toLowerCase() == "m", 7177 res = map[command]; 7178 args.replace(val, function (value) { 7179 if (isMove && vals.length == 2) { 7180 res += vals + map[command == "m" ? "l" : "L"]; 7181 vals = []; 7182 } 7183 vals.push(round(value * zoom)); 7184 }); 7185 return res + vals; 7186 }); 7187 return res; 7188 } 7189 var pa = command(path), p, r; 7190 res = []; 7191 for (var i = 0, ii = pa.length; i < ii; i++) { 7192 p = pa[i]; 7193 r = pa[i][0].toLowerCase(); 7194 r == "z" && (r = "x"); 7195 for (var j = 1, jj = p.length; j < jj; j++) { 7196 r += round(p[j] * zoom) + (j != jj - 1 ? "," : E); 7197 } 7198 res.push(r); 7199 } 7200 return res.join(S); 7201 }, 7202 compensation = function (deg, dx, dy) { 7203 var m = R.matrix(); 7204 m.rotate(-deg, .5, .5); 7205 return { 7206 dx: m.x(dx, dy), 7207 dy: m.y(dx, dy) 7208 }; 7209 }, 7210 setCoords = function (p, sx, sy, dx, dy, deg) { 7211 var _ = p._, 7212 m = p.matrix, 7213 fillpos = _.fillpos, 7214 o = p.node, 7215 s = o.style, 7216 y = 1, 7217 flip = "", 7218 dxdy, 7219 kx = zoom / sx, 7220 ky = zoom / sy; 7221 s.visibility = "hidden"; 7222 if (!sx || !sy) { 7223 return; 7224 } 7225 o.coordsize = abs(kx) + S + abs(ky); 7226 s.rotation = deg * (sx * sy < 0 ? -1 : 1); 7227 if (deg) { 7228 var c = compensation(deg, dx, dy); 7229 dx = c.dx; 7230 dy = c.dy; 7231 } 7232 sx < 0 && (flip += "x"); 7233 sy < 0 && (flip += " y") && (y = -1); 7234 s.flip = flip; 7235 o.coordorigin = (dx * -kx) + S + (dy * -ky); 7236 if (fillpos || _.fillsize) { 7237 var fill = o.getElementsByTagName(fillString); 7238 fill = fill && fill[0]; 7239 o.removeChild(fill); 7240 if (fillpos) { 7241 c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1])); 7242 fill.position = c.dx * y + S + c.dy * y; 7243 } 7244 if (_.fillsize) { 7245 fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy); 7246 } 7247 o.appendChild(fill); 7248 } 7249 s.visibility = "visible"; 7250 }; 7251 R.toString = function () { 7252 return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; 7253 }; 7254 var addArrow = function (o, value, isEnd) { 7255 var values = Str(value).toLowerCase().split("-"), 7256 se = isEnd ? "end" : "start", 7257 i = values.length, 7258 type = "classic", 7259 w = "medium", 7260 h = "medium"; 7261 while (i--) { 7262 switch (values[i]) { 7263 case "block": 7264 case "classic": 7265 case "oval": 7266 case "diamond": 7267 case "open": 7268 case "none": 7269 type = values[i]; 7270 break; 7271 case "wide": 7272 case "narrow": h = values[i]; break; 7273 case "long": 7274 case "short": w = values[i]; break; 7275 } 7276 } 7277 var stroke = o.node.getElementsByTagName("stroke")[0]; 7278 stroke[se + "arrow"] = type; 7279 stroke[se + "arrowlength"] = w; 7280 stroke[se + "arrowwidth"] = h; 7281 }, 7282 setFillAndStroke = function (o, params) { 7283 // o.paper.canvas.style.display = "none"; 7284 o.attrs = o.attrs || {}; 7285 var node = o.node, 7286 a = o.attrs, 7287 s = node.style, 7288 xy, 7289 newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r), 7290 isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry), 7291 res = o; 7292 7293 7294 for (var par in params) if (params[has](par)) { 7295 a[par] = params[par]; 7296 } 7297 if (newpath) { 7298 a.path = R._getPath[o.type](o); 7299 o._.dirty = 1; 7300 } 7301 params.href && (node.href = params.href); 7302 params.title && (node.title = params.title); 7303 params.target && (node.target = params.target); 7304 params.cursor && (s.cursor = params.cursor); 7305 "blur" in params && o.blur(params.blur); 7306 if (params.path && o.type == "path" || newpath) { 7307 node.path = path2vml(~Str(a.path).toLowerCase().indexOf("r") ? R._pathToAbsolute(a.path) : a.path); 7308 if (o.type == "image") { 7309 o._.fillpos = [a.x, a.y]; 7310 o._.fillsize = [a.width, a.height]; 7311 setCoords(o, 1, 1, 0, 0, 0); 7312 } 7313 } 7314 "transform" in params && o.transform(params.transform); 7315 if (isOval) { 7316 var cx = +a.cx, 7317 cy = +a.cy, 7318 rx = +a.rx || +a.r || 0, 7319 ry = +a.ry || +a.r || 0; 7320 node.path = R.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom)); 7321 o._.dirty = 1; 7322 } 7323 if ("clip-rect" in params) { 7324 var rect = Str(params["clip-rect"]).split(separator); 7325 if (rect.length == 4) { 7326 rect[2] = +rect[2] + (+rect[0]); 7327 rect[3] = +rect[3] + (+rect[1]); 7328 var div = node.clipRect || R._g.doc.createElement("div"), 7329 dstyle = div.style; 7330 dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect); 7331 if (!node.clipRect) { 7332 dstyle.position = "absolute"; 7333 dstyle.top = 0; 7334 dstyle.left = 0; 7335 dstyle.width = o.paper.width + "px"; 7336 dstyle.height = o.paper.height + "px"; 7337 node.parentNode.insertBefore(div, node); 7338 div.appendChild(node); 7339 node.clipRect = div; 7340 } 7341 } 7342 if (!params["clip-rect"]) { 7343 node.clipRect && (node.clipRect.style.clip = "auto"); 7344 } 7345 } 7346 if (o.textpath) { 7347 var textpathStyle = o.textpath.style; 7348 params.font && (textpathStyle.font = params.font); 7349 params["font-family"] && (textpathStyle.fontFamily = '"' + params["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g, E) + '"'); 7350 params["font-size"] && (textpathStyle.fontSize = params["font-size"]); 7351 params["font-weight"] && (textpathStyle.fontWeight = params["font-weight"]); 7352 params["font-style"] && (textpathStyle.fontStyle = params["font-style"]); 7353 } 7354 if ("arrow-start" in params) { 7355 addArrow(res, params["arrow-start"]); 7356 } 7357 if ("arrow-end" in params) { 7358 addArrow(res, params["arrow-end"], 1); 7359 } 7360 if (params.opacity != null || 7361 params["stroke-width"] != null || 7362 params.fill != null || 7363 params.src != null || 7364 params.stroke != null || 7365 params["stroke-width"] != null || 7366 params["stroke-opacity"] != null || 7367 params["fill-opacity"] != null || 7368 params["stroke-dasharray"] != null || 7369 params["stroke-miterlimit"] != null || 7370 params["stroke-linejoin"] != null || 7371 params["stroke-linecap"] != null) { 7372 var fill = node.getElementsByTagName(fillString), 7373 newfill = false; 7374 fill = fill && fill[0]; 7375 !fill && (newfill = fill = createNode(fillString)); 7376 if (o.type == "image" && params.src) { 7377 fill.src = params.src; 7378 } 7379 params.fill && (fill.on = true); 7380 if (fill.on == null || params.fill == "none" || params.fill === null) { 7381 fill.on = false; 7382 } 7383 if (fill.on && params.fill) { 7384 var isURL = Str(params.fill).match(R._ISURL); 7385 if (isURL) { 7386 fill.parentNode == node && node.removeChild(fill); 7387 fill.rotate = true; 7388 fill.src = isURL[1]; 7389 fill.type = "tile"; 7390 var bbox = o.getBBox(1); 7391 fill.position = bbox.x + S + bbox.y; 7392 o._.fillpos = [bbox.x, bbox.y]; 7393 7394 R._preload(isURL[1], function () { 7395 o._.fillsize = [this.offsetWidth, this.offsetHeight]; 7396 }); 7397 } else { 7398 fill.color = R.getRGB(params.fill).hex; 7399 fill.src = E; 7400 fill.type = "solid"; 7401 if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill, fill)) { 7402 a.fill = "none"; 7403 a.gradient = params.fill; 7404 fill.rotate = false; 7405 } 7406 } 7407 } 7408 if ("fill-opacity" in params || "opacity" in params) { 7409 var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1); 7410 opacity = mmin(mmax(opacity, 0), 1); 7411 fill.opacity = opacity; 7412 if (fill.src) { 7413 fill.color = "none"; 7414 } 7415 } 7416 node.appendChild(fill); 7417 var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]), 7418 newstroke = false; 7419 !stroke && (newstroke = stroke = createNode("stroke")); 7420 if ((params.stroke && params.stroke != "none") || 7421 params["stroke-width"] || 7422 params["stroke-opacity"] != null || 7423 params["stroke-dasharray"] || 7424 params["stroke-miterlimit"] || 7425 params["stroke-linejoin"] || 7426 params["stroke-linecap"]) { 7427 stroke.on = true; 7428 } 7429 (params.stroke == "none" || params.stroke === null || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false); 7430 var strokeColor = R.getRGB(params.stroke); 7431 stroke.on && params.stroke && (stroke.color = strokeColor.hex); 7432 opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1); 7433 var width = (toFloat(params["stroke-width"]) || 1) * .75; 7434 opacity = mmin(mmax(opacity, 0), 1); 7435 params["stroke-width"] == null && (width = a["stroke-width"]); 7436 params["stroke-width"] && (stroke.weight = width); 7437 width && width < 1 && (opacity *= width) && (stroke.weight = 1); 7438 stroke.opacity = opacity; 7439 7440 params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); 7441 stroke.miterlimit = params["stroke-miterlimit"] || 8; 7442 params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); 7443 if (params["stroke-dasharray"]) { 7444 var dasharray = { 7445 "-": "shortdash", 7446 ".": "shortdot", 7447 "-.": "shortdashdot", 7448 "-..": "shortdashdotdot", 7449 ". ": "dot", 7450 "- ": "dash", 7451 "--": "longdash", 7452 "- .": "dashdot", 7453 "--.": "longdashdot", 7454 "--..": "longdashdotdot" 7455 }; 7456 stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E; 7457 } 7458 newstroke && node.appendChild(stroke); 7459 } 7460 if (res.type == "text") { 7461 res.paper.canvas.style.display = E; 7462 var span = res.paper.span, 7463 m = 100, 7464 fontSize = a.font && a.font.match(/\d+(?:\.\d*)?(?=px)/); 7465 s = span.style; 7466 a.font && (s.font = a.font); 7467 a["font-family"] && (s.fontFamily = a["font-family"]); 7468 a["font-weight"] && (s.fontWeight = a["font-weight"]); 7469 a["font-style"] && (s.fontStyle = a["font-style"]); 7470 fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10; 7471 s.fontSize = fontSize * m + "px"; 7472 res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, "<").replace(/&/g, "&").replace(/\n/g, "<br>")); 7473 var brect = span.getBoundingClientRect(); 7474 res.W = a.w = (brect.right - brect.left) / m; 7475 res.H = a.h = (brect.bottom - brect.top) / m; 7476 // res.paper.canvas.style.display = "none"; 7477 res.X = a.x; 7478 res.Y = a.y + res.H / 2; 7479 7480 ("x" in params || "y" in params) && (res.path.v = R.format("m{0},{1}l{2},{1}", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1)); 7481 var dirtyattrs = ["x", "y", "text", "font", "font-family", "font-weight", "font-style", "font-size"]; 7482 for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) { 7483 res._.dirty = 1; 7484 break; 7485 } 7486 7487 // text-anchor emulation 7488 switch (a["text-anchor"]) { 7489 case "start": 7490 res.textpath.style["v-text-align"] = "left"; 7491 res.bbx = res.W / 2; 7492 break; 7493 case "end": 7494 res.textpath.style["v-text-align"] = "right"; 7495 res.bbx = -res.W / 2; 7496 break; 7497 default: 7498 res.textpath.style["v-text-align"] = "center"; 7499 res.bbx = 0; 7500 break; 7501 } 7502 res.textpath.style["v-text-kern"] = true; 7503 } 7504 // res.paper.canvas.style.display = E; 7505 }, 7506 addGradientFill = function (o, gradient, fill) { 7507 o.attrs = o.attrs || {}; 7508 var attrs = o.attrs, 7509 pow = Math.pow, 7510 opacity, 7511 oindex, 7512 type = "linear", 7513 fxfy = ".5 .5"; 7514 o.attrs.gradient = gradient; 7515 gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) { 7516 type = "radial"; 7517 if (fx && fy) { 7518 fx = toFloat(fx); 7519 fy = toFloat(fy); 7520 pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5); 7521 fxfy = fx + S + fy; 7522 } 7523 return E; 7524 }); 7525 gradient = gradient.split(/\s*\-\s*/); 7526 if (type == "linear") { 7527 var angle = gradient.shift(); 7528 angle = -toFloat(angle); 7529 if (isNaN(angle)) { 7530 return null; 7531 } 7532 } 7533 var dots = R._parseDots(gradient); 7534 if (!dots) { 7535 return null; 7536 } 7537 o = o.shape || o.node; 7538 if (dots.length) { 7539 o.removeChild(fill); 7540 fill.on = true; 7541 fill.method = "none"; 7542 fill.color = dots[0].color; 7543 fill.color2 = dots[dots.length - 1].color; 7544 var clrs = []; 7545 for (var i = 0, ii = dots.length; i < ii; i++) { 7546 dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color); 7547 } 7548 fill.colors = clrs.length ? clrs.join() : "0% " + fill.color; 7549 if (type == "radial") { 7550 fill.type = "gradientTitle"; 7551 fill.focus = "100%"; 7552 fill.focussize = "0 0"; 7553 fill.focusposition = fxfy; 7554 fill.angle = 0; 7555 } else { 7556 // fill.rotate= true; 7557 fill.type = "gradient"; 7558 fill.angle = (270 - angle) % 360; 7559 } 7560 o.appendChild(fill); 7561 } 7562 return 1; 7563 }, 7564 Element = function (node, vml) { 7565 this[0] = this.node = node; 7566 node.raphael = true; 7567 this.id = R._oid++; 7568 node.raphaelid = this.id; 7569 this.X = 0; 7570 this.Y = 0; 7571 this.attrs = {}; 7572 this.paper = vml; 7573 this.matrix = R.matrix(); 7574 this._ = { 7575 transform: [], 7576 sx: 1, 7577 sy: 1, 7578 dx: 0, 7579 dy: 0, 7580 deg: 0, 7581 dirty: 1, 7582 dirtyT: 1 7583 }; 7584 !vml.bottom && (vml.bottom = this); 7585 this.prev = vml.top; 7586 vml.top && (vml.top.next = this); 7587 vml.top = this; 7588 this.next = null; 7589 }; 7590 var elproto = R.el; 7591 7592 Element.prototype = elproto; 7593 elproto.constructor = Element; 7594 elproto.transform = function (tstr) { 7595 if (tstr == null) { 7596 return this._.transform; 7597 } 7598 var vbs = this.paper._viewBoxShift, 7599 vbt = vbs ? "s" + [vbs.scale, vbs.scale] + "-1-1t" + [vbs.dx, vbs.dy] : E, 7600 oldt; 7601 if (vbs) { 7602 oldt = tstr = Str(tstr).replace(/\.{3}|\u2026/g, this._.transform || E); 7603 } 7604 R._extractTransform(this, vbt + tstr); 7605 var matrix = this.matrix.clone(), 7606 skew = this.skew, 7607 o = this.node, 7608 split, 7609 isGrad = ~Str(this.attrs.fill).indexOf("-"), 7610 isPatt = !Str(this.attrs.fill).indexOf("url("); 7611 matrix.translate(1, 1); 7612 if (isPatt || isGrad || this.type == "image") { 7613 skew.matrix = "1 0 0 1"; 7614 skew.offset = "0 0"; 7615 split = matrix.split(); 7616 if ((isGrad && split.noRotation) || !split.isSimple) { 7617 o.style.filter = matrix.toFilter(); 7618 var bb = this.getBBox(), 7619 bbt = this.getBBox(1), 7620 dx = bb.x - bbt.x, 7621 dy = bb.y - bbt.y; 7622 o.coordorigin = (dx * -zoom) + S + (dy * -zoom); 7623 setCoords(this, 1, 1, dx, dy, 0); 7624 } else { 7625 o.style.filter = E; 7626 setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate); 7627 } 7628 } else { 7629 o.style.filter = E; 7630 skew.matrix = Str(matrix); 7631 skew.offset = matrix.offset(); 7632 } 7633 oldt && (this._.transform = oldt); 7634 return this; 7635 }; 7636 elproto.rotate = function (deg, cx, cy) { 7637 if (this.removed) { 7638 return this; 7639 } 7640 if (deg == null) { 7641 return; 7642 } 7643 deg = Str(deg).split(separator); 7644 if (deg.length - 1) { 7645 cx = toFloat(deg[1]); 7646 cy = toFloat(deg[2]); 7647 } 7648 deg = toFloat(deg[0]); 7649 (cy == null) && (cx = cy); 7650 if (cx == null || cy == null) { 7651 var bbox = this.getBBox(1); 7652 cx = bbox.x + bbox.width / 2; 7653 cy = bbox.y + bbox.height / 2; 7654 } 7655 this._.dirtyT = 1; 7656 this.transform(this._.transform.concat([["r", deg, cx, cy]])); 7657 return this; 7658 }; 7659 elproto.translate = function (dx, dy) { 7660 if (this.removed) { 7661 return this; 7662 } 7663 dx = Str(dx).split(separator); 7664 if (dx.length - 1) { 7665 dy = toFloat(dx[1]); 7666 } 7667 dx = toFloat(dx[0]) || 0; 7668 dy = +dy || 0; 7669 if (this._.bbox) { 7670 this._.bbox.x += dx; 7671 this._.bbox.y += dy; 7672 } 7673 this.transform(this._.transform.concat([["t", dx, dy]])); 7674 return this; 7675 }; 7676 elproto.scale = function (sx, sy, cx, cy) { 7677 if (this.removed) { 7678 return this; 7679 } 7680 sx = Str(sx).split(separator); 7681 if (sx.length - 1) { 7682 sy = toFloat(sx[1]); 7683 cx = toFloat(sx[2]); 7684 cy = toFloat(sx[3]); 7685 isNaN(cx) && (cx = null); 7686 isNaN(cy) && (cy = null); 7687 } 7688 sx = toFloat(sx[0]); 7689 (sy == null) && (sy = sx); 7690 (cy == null) && (cx = cy); 7691 if (cx == null || cy == null) { 7692 var bbox = this.getBBox(1); 7693 } 7694 cx = cx == null ? bbox.x + bbox.width / 2 : cx; 7695 cy = cy == null ? bbox.y + bbox.height / 2 : cy; 7696 7697 this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); 7698 this._.dirtyT = 1; 7699 return this; 7700 }; 7701 elproto.hide = function () { 7702 !this.removed && (this.node.style.display = "none"); 7703 return this; 7704 }; 7705 elproto.show = function () { 7706 !this.removed && (this.node.style.display = E); 7707 return this; 7708 }; 7709 elproto._getBBox = function () { 7710 if (this.removed) { 7711 return {}; 7712 } 7713 return { 7714 x: this.X + (this.bbx || 0) - this.W / 2, 7715 y: this.Y - this.H, 7716 width: this.W, 7717 height: this.H 7718 }; 7719 }; 7720 elproto.remove = function () { 7721 if (this.removed || !this.node.parentNode) { 7722 return; 7723 } 7724 this.paper.__set__ && this.paper.__set__.exclude(this); 7725 R.eve.unbind("raphael.*.*." + this.id); 7726 R._tear(this, this.paper); 7727 this.node.parentNode.removeChild(this.node); 7728 this.shape && this.shape.parentNode.removeChild(this.shape); 7729 for (var i in this) { 7730 this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; 7731 } 7732 this.removed = true; 7733 }; 7734 elproto.attr = function (name, value) { 7735 if (this.removed) { 7736 return this; 7737 } 7738 if (name == null) { 7739 var res = {}; 7740 for (var a in this.attrs) if (this.attrs[has](a)) { 7741 res[a] = this.attrs[a]; 7742 } 7743 res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; 7744 res.transform = this._.transform; 7745 return res; 7746 } 7747 if (value == null && R.is(name, "string")) { 7748 if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) { 7749 return this.attrs.gradient; 7750 } 7751 var names = name.split(separator), 7752 out = {}; 7753 for (var i = 0, ii = names.length; i < ii; i++) { 7754 name = names[i]; 7755 if (name in this.attrs) { 7756 out[name] = this.attrs[name]; 7757 } else if (R.is(this.paper.customAttributes[name], "function")) { 7758 out[name] = this.paper.customAttributes[name].def; 7759 } else { 7760 out[name] = R._availableAttrs[name]; 7761 } 7762 } 7763 return ii - 1 ? out : out[names[0]]; 7764 } 7765 if (this.attrs && value == null && R.is(name, "array")) { 7766 out = {}; 7767 for (i = 0, ii = name.length; i < ii; i++) { 7768 out[name[i]] = this.attr(name[i]); 7769 } 7770 return out; 7771 } 7772 var params; 7773 if (value != null) { 7774 params = {}; 7775 params[name] = value; 7776 } 7777 value == null && R.is(name, "object") && (params = name); 7778 for (var key in params) { 7779 eve("raphael.attr." + key + "." + this.id, this, params[key]); 7780 } 7781 if (params) { 7782 for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { 7783 var par = this.paper.customAttributes[key].apply(this, [].concat(params[key])); 7784 this.attrs[key] = params[key]; 7785 for (var subkey in par) if (par[has](subkey)) { 7786 params[subkey] = par[subkey]; 7787 } 7788 } 7789 // this.paper.canvas.style.display = "none"; 7790 if (params.text && this.type == "text") { 7791 this.textpath.string = params.text; 7792 } 7793 setFillAndStroke(this, params); 7794 // this.paper.canvas.style.display = E; 7795 } 7796 return this; 7797 }; 7798 elproto.toFront = function () { 7799 !this.removed && this.node.parentNode.appendChild(this.node); 7800 this.paper && this.paper.top != this && R._tofront(this, this.paper); 7801 return this; 7802 }; 7803 elproto.toBack = function () { 7804 if (this.removed) { 7805 return this; 7806 } 7807 if (this.node.parentNode.firstChild != this.node) { 7808 this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); 7809 R._toback(this, this.paper); 7810 } 7811 return this; 7812 }; 7813 elproto.insertAfter = function (element) { 7814 if (this.removed) { 7815 return this; 7816 } 7817 if (element.constructor == R.st.constructor) { 7818 element = element[element.length - 1]; 7819 } 7820 if (element.node.nextSibling) { 7821 element.node.parentNode.insertBefore(this.node, element.node.nextSibling); 7822 } else { 7823 element.node.parentNode.appendChild(this.node); 7824 } 7825 R._insertafter(this, element, this.paper); 7826 return this; 7827 }; 7828 elproto.insertBefore = function (element) { 7829 if (this.removed) { 7830 return this; 7831 } 7832 if (element.constructor == R.st.constructor) { 7833 element = element[0]; 7834 } 7835 element.node.parentNode.insertBefore(this.node, element.node); 7836 R._insertbefore(this, element, this.paper); 7837 return this; 7838 }; 7839 elproto.blur = function (size) { 7840 var s = this.node.runtimeStyle, 7841 f = s.filter; 7842 f = f.replace(blurregexp, E); 7843 if (+size !== 0) { 7844 this.attrs.blur = size; 7845 s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")"; 7846 s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5)); 7847 } else { 7848 s.filter = f; 7849 s.margin = 0; 7850 delete this.attrs.blur; 7851 } 7852 return this; 7853 }; 7854 7855 R._engine.path = function (pathString, vml) { 7856 var el = createNode("shape"); 7857 el.style.cssText = cssDot; 7858 el.coordsize = zoom + S + zoom; 7859 el.coordorigin = vml.coordorigin; 7860 var p = new Element(el, vml), 7861 attr = {fill: "none", stroke: "#000"}; 7862 pathString && (attr.path = pathString); 7863 p.type = "path"; 7864 p.path = []; 7865 p.Path = E; 7866 setFillAndStroke(p, attr); 7867 vml.canvas.appendChild(el); 7868 var skew = createNode("skew"); 7869 skew.on = true; 7870 el.appendChild(skew); 7871 p.skew = skew; 7872 p.transform(E); 7873 return p; 7874 }; 7875 R._engine.rect = function (vml, x, y, w, h, r) { 7876 var path = R._rectPath(x, y, w, h, r), 7877 res = vml.path(path), 7878 a = res.attrs; 7879 res.X = a.x = x; 7880 res.Y = a.y = y; 7881 res.W = a.width = w; 7882 res.H = a.height = h; 7883 a.r = r; 7884 a.path = path; 7885 res.type = "rect"; 7886 return res; 7887 }; 7888 R._engine.ellipse = function (vml, x, y, rx, ry) { 7889 var res = vml.path(), 7890 a = res.attrs; 7891 res.X = x - rx; 7892 res.Y = y - ry; 7893 res.W = rx * 2; 7894 res.H = ry * 2; 7895 res.type = "ellipse"; 7896 setFillAndStroke(res, { 7897 cx: x, 7898 cy: y, 7899 rx: rx, 7900 ry: ry 7901 }); 7902 return res; 7903 }; 7904 R._engine.circle = function (vml, x, y, r) { 7905 var res = vml.path(), 7906 a = res.attrs; 7907 res.X = x - r; 7908 res.Y = y - r; 7909 res.W = res.H = r * 2; 7910 res.type = "circle"; 7911 setFillAndStroke(res, { 7912 cx: x, 7913 cy: y, 7914 r: r 7915 }); 7916 return res; 7917 }; 7918 R._engine.image = function (vml, src, x, y, w, h) { 7919 var path = R._rectPath(x, y, w, h), 7920 res = vml.path(path).attr({stroke: "none"}), 7921 a = res.attrs, 7922 node = res.node, 7923 fill = node.getElementsByTagName(fillString)[0]; 7924 a.src = src; 7925 res.X = a.x = x; 7926 res.Y = a.y = y; 7927 res.W = a.width = w; 7928 res.H = a.height = h; 7929 a.path = path; 7930 res.type = "image"; 7931 fill.parentNode == node && node.removeChild(fill); 7932 fill.rotate = true; 7933 fill.src = src; 7934 fill.type = "tile"; 7935 res._.fillpos = [x, y]; 7936 res._.fillsize = [w, h]; 7937 node.appendChild(fill); 7938 setCoords(res, 1, 1, 0, 0, 0); 7939 return res; 7940 }; 7941 R._engine.text = function (vml, x, y, text) { 7942 var el = createNode("shape"), 7943 path = createNode("path"), 7944 o = createNode("textpath"); 7945 x = x || 0; 7946 y = y || 0; 7947 text = text || ""; 7948 path.v = R.format("m{0},{1}l{2},{1}", round(x * zoom), round(y * zoom), round(x * zoom) + 1); 7949 path.textpathok = true; 7950 o.string = Str(text); 7951 o.on = true; 7952 el.style.cssText = cssDot; 7953 el.coordsize = zoom + S + zoom; 7954 el.coordorigin = "0 0"; 7955 var p = new Element(el, vml), 7956 attr = { 7957 fill: "#000", 7958 stroke: "none", 7959 font: R._availableAttrs.font, 7960 text: text 7961 }; 7962 p.shape = el; 7963 p.path = path; 7964 p.textpath = o; 7965 p.type = "text"; 7966 p.attrs.text = Str(text); 7967 p.attrs.x = x; 7968 p.attrs.y = y; 7969 p.attrs.w = 1; 7970 p.attrs.h = 1; 7971 setFillAndStroke(p, attr); 7972 el.appendChild(o); 7973 el.appendChild(path); 7974 vml.canvas.appendChild(el); 7975 var skew = createNode("skew"); 7976 skew.on = true; 7977 el.appendChild(skew); 7978 p.skew = skew; 7979 p.transform(E); 7980 return p; 7981 }; 7982 R._engine.setSize = function (width, height) { 7983 var cs = this.canvas.style; 7984 this.width = width; 7985 this.height = height; 7986 width == +width && (width += "px"); 7987 height == +height && (height += "px"); 7988 cs.width = width; 7989 cs.height = height; 7990 cs.clip = "rect(0 " + width + " " + height + " 0)"; 7991 if (this._viewBox) { 7992 R._engine.setViewBox.apply(this, this._viewBox); 7993 } 7994 return this; 7995 }; 7996 R._engine.setViewBox = function (x, y, w, h, fit) { 7997 R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]); 7998 var width = this.width, 7999 height = this.height, 8000 size = 1 / mmax(w / width, h / height), 8001 H, W; 8002 if (fit) { 8003 H = height / h; 8004 W = width / w; 8005 if (w * H < width) { 8006 x -= (width - w * H) / 2 / H; 8007 } 8008 if (h * W < height) { 8009 y -= (height - h * W) / 2 / W; 8010 } 8011 } 8012 this._viewBox = [x, y, w, h, !!fit]; 8013 this._viewBoxShift = { 8014 dx: -x, 8015 dy: -y, 8016 scale: size 8017 }; 8018 this.forEach(function (el) { 8019 el.transform("..."); 8020 }); 8021 return this; 8022 }; 8023 var createNode; 8024 R._engine.initWin = function (win) { 8025 var doc = win.document; 8026 doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); 8027 try { 8028 !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"); 8029 createNode = function (tagName) { 8030 return doc.createElement('<rvml:' + tagName + ' class="rvml">'); 8031 }; 8032 } catch (e) { 8033 createNode = function (tagName) { 8034 return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">'); 8035 }; 8036 } 8037 }; 8038 R._engine.initWin(R._g.win); 8039 R._engine.create = function () { 8040 var con = R._getContainer.apply(0, arguments), 8041 container = con.container, 8042 height = con.height, 8043 s, 8044 width = con.width, 8045 x = con.x, 8046 y = con.y; 8047 if (!container) { 8048 throw new Error("VML container not found."); 8049 } 8050 var res = new R._Paper, 8051 c = res.canvas = R._g.doc.createElement("div"), 8052 cs = c.style; 8053 x = x || 0; 8054 y = y || 0; 8055 width = width || 512; 8056 height = height || 342; 8057 res.width = width; 8058 res.height = height; 8059 width == +width && (width += "px"); 8060 height == +height && (height += "px"); 8061 res.coordsize = zoom * 1e3 + S + zoom * 1e3; 8062 res.coordorigin = "0 0"; 8063 res.span = R._g.doc.createElement("span"); 8064 res.span.style.cssText = "position:absolute;
8064left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;"; 8065 c.appendChild(res.span); 8066 cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height); 8067 if (container == 1) { 8068 R._g.doc.body.appendChild(c); 8069 cs.left = x + "px"; 8070 cs.top = y + "px"; 8071 cs.position = "absolute"; 8072 } else { 8073 if (container.firstChild) { 8074 container.insertBefore(c, container.firstChild); 8075 } else { 8076 container.appendChild(c); 8077 } 8078 } 8079 res.renderfix = function () {}; 8080 return res; 8081 }; 8082 R.prototype.clear = function () { 8083 R.eve("raphael.clear", this); 8084 this.canvas.innerHTML = E; 8085 this.span = R._g.doc.createElement("span"); 8086 this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; 8087 this.canvas.appendChild(this.span); 8088 this.bottom = this.top = null; 8089 }; 8090 R.prototype.remove = function () { 8091 R.eve("raphael.remove", this); 8092 this.canvas.parentNode.removeChild(this.canvas); 8093 for (var i in this) { 8094 this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; 8095 } 8096 return true; 8097 }; 8098 8099 var setproto = R.st; 8100 for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { 8101 setproto[method] = (function (methodname) { 8102 return function () { 8103 var arg = arguments; 8104 return this.forEach(function (el) { 8105 el[methodname].apply(el, arg); 8106 }); 8107 }; 8108 })(method); 8109 } 8110})(); 8111 8112 // EXPOSE 8113 // SVG and VML are appended just before the EXPOSE line 8114 // Even with AMD, Raphael should be defined globally 8115 oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); 8116 8117 return R; 8118})); 8119 8120(function() { 8121 8122 8123}).call(this); 8124 8125/** 8126* bootstrap.js v3.0.0 by @fat and @mdo 8127* Copyright 2013 Twitter Inc. 8128* http://www.apache.org/licenses/LICENSE-2.0 8129*/ 8130if (!jQuery) { throw new Error("Bootstrap requires jQuery") } 8131 8132/* ======================================================================== 8133 * Bootstrap: transition.js v3.0.0 8134 * http://twbs.github.com/bootstrap/javascript.html#transitions 8135 * ======================================================================== 8136 * Copyright 2013 Twitter, Inc. 8137 * 8138 * Licensed under the Apache License, Version 2.0 (the "License"); 8139 * you may not use this file except in compliance with the License. 8140 * You may obtain a copy of the License at 8141 * 8142 * http://www.apache.org/licenses/LICENSE-2.0 8143 * 8144 * Unless required by applicable law or agreed to in writing, software 8145 * distributed under the License is distributed on an "AS IS" BASIS, 8146 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8147 * See the License for the specific language governing permissions and 8148 * limitations under the License. 8149 * ======================================================================== */ 8150 8151 8152+function ($) { "use strict"; 8153 8154 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 8155 // ============================================================ 8156 8157 function transitionEnd() { 8158 var el = document.createElement('bootstrap') 8159 8160 var transEndEventNames = { 8161 'WebkitTransition' : 'webkitTransitionEnd' 8162 , 'MozTransition' : 'transitionend' 8163 , 'OTransition' : 'oTransitionEnd otransitionend' 8164 , 'transition' : 'transitionend' 8165 } 8166 8167 for (var name in transEndEventNames) { 8168 if (el.style[name] !== undefined) { 8169 return { end: transEndEventNames[name] } 8170 } 8171 } 8172 } 8173 8174 // http://blog.alexmaccaw.com/css-transitions 8175 $.fn.emulateTransitionEnd = function (duration) { 8176 var called = false, $el = this 8177 $(this).one($.support.transition.end, function () { called = true }) 8178 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 8179 setTimeout(callback, duration) 8180 return this 8181 } 8182 8183 $(function () { 8184 $.support.transition = transitionEnd() 8185 }) 8186 8187}(window.jQuery); 8188 8189/* ======================================================================== 8190 * Bootstrap: alert.js v3.0.0 8191 * http://twbs.github.com/bootstrap/javascript.html#alerts 8192 * ======================================================================== 8193 * Copyright 2013 Twitter, Inc. 8194 * 8195 * Licensed under the Apache License, Version 2.0 (the "License");
8196 * you may not use this file except in compliance with the License. 8197 * You may obtain a copy of the License at 8198 * 8199 * http://www.apache.org/licenses/LICENSE-2.0 8200 * 8201 * Unless required by applicable law or agreed to in writing, software 8202 * distributed under the License is distributed on an "AS IS" BASIS, 8203 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8204 * See the License for the specific language governing permissions and 8205 * limitations under the License. 8206 * ======================================================================== */ 8207 8208 8209+function ($) { "use strict"; 8210 8211 // ALERT CLASS DEFINITION 8212 // ====================== 8213 8214 var dismiss = '[data-dismiss="alert"]' 8215 var Alert = function (el) { 8216 $(el).on('click', dismiss, this.close) 8217 } 8218 8219 Alert.prototype.close = function (e) { 8220 var $this = $(this) 8221 var selector = $this.attr('data-target') 8222 8223 if (!selector) { 8224 selector = $this.attr('href') 8225 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 8226 } 8227 8228 var $parent = $(selector) 8229 8230 if (e) e.preventDefault() 8231 8232 if (!$parent.length) { 8233 $parent = $this.hasClass('alert') ? $this : $this.parent() 8234 } 8235 8236 $parent.trigger(e = $.Event('close.bs.alert')) 8237 8238 if (e.isDefaultPrevented()) return 8239 8240 $parent.removeClass('in') 8241 8242 function removeElement() { 8243 $parent.trigger('closed.bs.alert').remove() 8244 } 8245 8246 $.support.transition && $parent.hasClass('fade') ? 8247 $parent 8248 .one($.support.transition.end, removeElement) 8249 .emulateTransitionEnd(150) : 8250 removeElement() 8251 } 8252 8253 8254 // ALERT PLUGIN DEFINITION 8255 // ======================= 8256 8257 var old = $.fn.alert 8258 8259 $.fn.alert = function (option) { 8260 return this.each(function () { 8261 var $this = $(this) 8262 var data = $this.data('bs.alert') 8263 8264 if (!data) $this.data('bs.alert', (data = new Alert(this))) 8265 if (typeof option == 'string') data[option].call($this) 8266 }) 8267 } 8268 8269 $.fn.alert.Constructor = Alert 8270 8271 8272 // ALERT NO CONFLICT 8273 // ================= 8274 8275 $.fn.alert.noConflict = function () { 8276 $.fn.alert = old 8277 return this 8278 } 8279 8280 8281 // ALERT DATA-API 8282 // ============== 8283 8284 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 8285 8286}(window.jQuery); 8287 8288/* ======================================================================== 8289 * Bootstrap: button.js v3.0.0 8290 * http://twbs.github.com/bootstrap/javascript.html#buttons 8291 * ======================================================================== 8292 * Copyright 2013 Twitter, Inc. 8293 * 8294 * Licensed under the Apache License, Version 2.0 (the "License"); 8295 * you may not use this file except in compliance with the License. 8296 * You may obtain a copy of the License at 8297 * 8298 * http://www.apache.org/licenses/LICENSE-2.0 8299 * 8300 * Unless required by applicable law or agreed to in writing, software 8301 * distributed under the License is distributed on an "AS IS" BASIS, 8302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8303 * See the License for the specific language governing permissions and 8304 * limitations under the License. 8305 * ======================================================================== */ 8306 8307 8308+function ($) { "use strict"; 8309 8310 // BUTTON PUBLIC CLASS DEFINITION 8311 // ============================== 8312 8313 var Button = function (element, options) { 8314 this.$element = $(element) 8315 this.options = $.extend({}, Button.DEFAULTS, options) 8316 } 8317 8318 Button.DEFAULTS = { 8319 loadingText: 'loading...' 8320 } 8321 8322 Button.prototype.setState = function (state) { 8323 var d = 'disabled' 8324 var $el = this.$element 8325 var val = $el.is('input') ? 'val' : 'html' 8326 var data = $el.data() 8327 8328 state = state + 'Text' 8329 8330 if (!data.resetText) $el.data('resetText', $el[val]()) 8331 8332 $el[val](data[state] || this.options[state]) 8333 8334 // push to event loop to allow forms to submit 8335 setTimeout(function () { 8336 state == 'loadingText' ? 8337 $el.addClass(d).attr(d, d) : 8338 $el.removeClass(d).removeAttr(d); 8339 }, 0) 8340 } 8341 8342 Button.prototype.toggle = function () { 8343 var $parent = this.$element.closest('[data-toggle="buttons"]') 8344 8345 if ($parent.length) { 8346 var $input = this.$element.find('input') 8347 .prop('checked', !this.$element.hasClass('active')) 8348 .trigger('change') 8349 if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') 8350 } 8351 8352 this.$element.toggleClass('active') 8353 } 8354 8355
vendor: 12,988 bytes, lines 8356-8802
8356 // BUTTON PLUGIN DEFINITION 8357 // ======================== 8358 8359 var old = $.fn.button 8360 8361 $.fn.button = function (option) { 8362 return this.each(function () { 8363 var $this = $(this) 8364 var data = $this.data('bs.button') 8365 var options = typeof option == 'object' && option 8366 8367 if (!data) $this.data('bs.button', (data = new Button(this, options))) 8368 8369 if (option == 'toggle') data.toggle() 8370 else if (option) data.setState(option) 8371 }) 8372 } 8373 8374 $.fn.button.Constructor = Button 8375 8376 8377 // BUTTON NO CONFLICT 8378 // ================== 8379 8380 $.fn.button.noConflict = function () { 8381 $.fn.button = old 8382 return this 8383 } 8384 8385 8386 // BUTTON DATA-API 8387 // =============== 8388 8389 $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { 8390 var $btn = $(e.target) 8391 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') 8392 $btn.button('toggle') 8393 e.preventDefault() 8394 }) 8395 8396}(window.jQuery); 8397 8398/* ======================================================================== 8399 * Bootstrap: carousel.js v3.0.0 8400 * http://twbs.github.com/bootstrap/javascript.html#carousel 8401 * ======================================================================== 8402 * Copyright 2012 Twitter, Inc. 8403 * 8404 * Licensed under the Apache License, Version 2.0 (the "License"); 8405 * you may not use this file except in compliance with the License. 8406 * You may obtain a copy of the License at 8407 * 8408 * http://www.apache.org/licenses/LICENSE-2.0 8409 * 8410 * Unless required by applicable law or agreed to in writing, software 8411 * distributed under the License is distributed on an "AS IS" BASIS, 8412 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8413 * See the License for the specific language governing permissions and 8414 * limitations under the License. 8415 * ======================================================================== */ 8416 8417 8418+function ($) { "use strict"; 8419 8420 // CAROUSEL CLASS DEFINITION 8421 // ========================= 8422 8423 var Carousel = function (element, options) { 8424 this.$element = $(element) 8425 this.$indicators = this.$element.find('.carousel-indicators') 8426 this.options = options 8427 this.paused = 8428 this.sliding = 8429 this.interval = 8430 this.$active = 8431 this.$items = null 8432 8433 this.options.pause == 'hover' && this.$element 8434 .on('mouseenter', $.proxy(this.pause, this)) 8435 .on('mouseleave', $.proxy(this.cycle, this)) 8436 } 8437 8438 Carousel.DEFAULTS = { 8439 interval: 5000 8440 , pause: 'hover' 8441 , wrap: true 8442 } 8443 8444 Carousel.prototype.cycle = function (e) { 8445 e || (this.paused = false) 8446 8447 this.interval && clearInterval(this.interval) 8448 8449 this.options.interval 8450 && !this.paused 8451 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) 8452 8453 return this 8454 } 8455 8456 Carousel.prototype.getActiveIndex = function () { 8457 this.$active = this.$element.find('.item.active') 8458 this.$items = this.$active.parent().children() 8459 8460 return this.$items.index(this.$active) 8461 } 8462 8463 Carousel.prototype.to = function (pos) { 8464 var that = this 8465 var activeIndex = this.getActiveIndex() 8466 8467 if (pos > (this.$items.length - 1) || pos < 0) return 8468 8469 if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) 8470 if (activeIndex == pos) return this.pause().cycle() 8471 8472 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) 8473 } 8474 8475 Carousel.prototype.pause = function (e) { 8476 e || (this.paused = true) 8477 8478 if (this.$element.find('.next, .prev').length && $.support.transition.end) { 8479 this.$element.trigger($.support.transition.end) 8480 this.cycle(true) 8481 } 8482 8483 this.interval = clearInterval(this.interval) 8484 8485 return this 8486 } 8487 8488 Carousel.prototype.next = function () { 8489 if (this.sliding) return 8490 return this.slide('next') 8491 } 8492 8493 Carousel.prototype.prev = function () { 8494 if (this.sliding) return 8495 return this.slide('prev') 8496 } 8497 8498 Carousel.prototype.slide = function (type, next) { 8499 var $active = this.$element.find('.item.active') 8500 var $next = next || $active[type]() 8501 var isCycling = this.interval 8502 var direction = type == 'next' ? 'left' : 'right' 8503 var fallback = type == 'next' ? 'first' : 'last' 8504 var that = this 8505 8506 if (!$next.length) { 8507 if (!this.options.wrap) return 8508 $next = this.$element.find('.item')[fallback]() 8509 } 8510 8511 this.sliding = true 8512 8513 isCycling && this.pause() 8514 8515 var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) 8516 8517 if ($next.hasClass('active')) return 8518 8519 if (this.$indicators.length) { 8520 this.$indicators.find('.active').removeClass('active') 8521 this.$element.one('slid', function () { 8522 var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) 8523 $nextIndicator && $nextIndicator.addClass('active') 8524 }) 8525 } 8526 8527 if ($.support.transition && this.$element.hasClass('slide')) { 8528 this.$element.trigger(e) 8529 if (e.isDefaultPrevented()) return 8530 $next.addClass(type) 8531 $next[0].offsetWidth // force reflow 8532 $active.addClass(direction) 8533 $next.addClass(direction) 8534 $active 8535 .one($.support.transition.end, function () { 8536 $next.removeClass([type, direction].join(' ')).addClass('active') 8537 $active.removeClass(['active', direction].join(' ')) 8538 that.sliding = false 8539 setTimeout(function () { that.$element.trigger('slid') }, 0) 8540 }) 8541 .emulateTransitionEnd(600) 8542 } else { 8543 this.$element.trigger(e) 8544 if (e.isDefaultPrevented()) return 8545 $active.removeClass('active') 8546 $next.addClass('active') 8547 this.sliding = false 8548 this.$element.trigger('slid') 8549 } 8550 8551 isCycling && this.cycle() 8552 8553 return this 8554 } 8555 8556 8557 // CAROUSEL PLUGIN DEFINITION 8558 // ========================== 8559 8560 var old = $.fn.carousel 8561 8562 $.fn.carousel = function (option) { 8563 return this.each(function () { 8564 var $this = $(this) 8565 var data = $this.data('bs.carousel') 8566 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) 8567 var action = typeof option == 'string' ? option : options.slide 8568 8569 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) 8570 if (typeof option == 'number') data.to(option) 8571 else if (action) data[action]() 8572 else if (options.interval) data.pause().cycle() 8573 }) 8574 } 8575 8576 $.fn.carousel.Constructor = Carousel 8577 8578 8579 // CAROUSEL NO CONFLICT 8580 // ==================== 8581 8582 $.fn.carousel.noConflict = function () { 8583 $.fn.carousel = old 8584 return this 8585 } 8586 8587 8588 // CAROUSEL DATA-API 8589 // ================= 8590 8591 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { 8592 var $this = $(this), href 8593 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 8594 var options = $.extend({}, $target.data(), $this.data()) 8595 var slideIndex = $this.attr('data-slide-to') 8596 if (slideIndex) options.interval = false 8597 8598 $target.carousel(options) 8599 8600 if (slideIndex = $this.attr('data-slide-to')) { 8601 $target.data('bs.carousel').to(slideIndex) 8602 } 8603 8604 e.preventDefault() 8605 }) 8606 8607 $(window).on('load', function () { 8608 $('[data-ride="carousel"]').each(function () { 8609 var $carousel = $(this) 8610 $carousel.carousel($carousel.data()) 8611 }) 8612 }) 8613 8614}(window.jQuery); 8615 8616/* ======================================================================== 8617 * Bootstrap: collapse.js v3.0.0 8618 * http://twbs.github.com/bootstrap/javascript.html#collapse 8619 * ======================================================================== 8620 * Copyright 2012 Twitter, Inc. 8621 * 8622 * Licensed under the Apache License, Version 2.0 (the "License"); 8623 * you may not use this file except in compliance with the License. 8624 * You may obtain a copy of the License at 8625 * 8626 * http://www.apache.org/licenses/LICENSE-2.0 8627 * 8628 * Unless required by applicable law or agreed to in writing, software 8629 * distributed under the License is distributed on an "AS IS" BASIS, 8630 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8631 * See the License for the specific language governing permissions and 8632 * limitations under the License. 8633 * ======================================================================== */ 8634 8635 8636+function ($) { "use strict"; 8637 8638 // COLLAPSE PUBLIC CLASS DEFINITION 8639 // ================================ 8640 8641 var Collapse = function (element, options) { 8642 this.$element = $(element) 8643 this.options = $.extend({}, Collapse.DEFAULTS, options) 8644 this.transitioning = null 8645 8646 if (this.options.parent) this.$parent = $(this.options.parent) 8647 if (this.options.toggle) this.toggle() 8648 } 8649 8650 Collapse.DEFAULTS = { 8651 toggle: true 8652 } 8653 8654 Collapse.prototype.dimension = function () { 8655 var hasWidth = this.$element.hasClass('width') 8656 return hasWidth ? 'width' : 'height' 8657 } 8658 8659 Collapse.prototype.show = function () { 8660 if (this.transitioning || this.$element.hasClass('in')) return 8661 8662 var startEvent = $.Event('show.bs.collapse') 8663 this.$element.trigger(startEvent) 8664 if (startEvent.isDefaultPrevented()) return 8665 8666 var actives = this.$parent && this.$parent.find('> .panel > .in') 8667 8668 if (actives && actives.length) { 8669 var hasData = actives.data('bs.collapse') 8670 if (hasData && hasData.transitioning) return 8671 actives.collapse('hide') 8672 hasData || actives.data('bs.collapse', null) 8673 } 8674 8675 var dimension = this.dimension() 8676 8677 this.$element 8678 .removeClass('collapse') 8679 .addClass('collapsing') 8680 [dimension](0) 8681 8682 this.transitioning = 1 8683 8684 var complete = function () { 8685 this.$element 8686 .removeClass('collapsing') 8687 .addClass('in') 8688 [dimension]('auto') 8689 this.transitioning = 0 8690 this.$element.trigger('shown.bs.collapse') 8691 } 8692 8693 if (!$.support.transition) return complete.call(this) 8694 8695 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 8696 8697 this.$element 8698 .one($.support.transition.end, $.proxy(complete, this)) 8699 .emulateTransitionEnd(350) 8700 [dimension](this.$element[0][scrollSize]) 8701 } 8702 8703 Collapse.prototype.hide = function () { 8704 if (this.transitioning || !this.$element.hasClass('in')) return 8705 8706 var startEvent = $.Event('hide.bs.collapse') 8707 this.$element.trigger(startEvent) 8708 if (startEvent.isDefaultPrevented()) return 8709 8710 var dimension = this.dimension() 8711 8712 this.$element 8713 [dimension](this.$element[dimension]()) 8714 [0].offsetHeight 8715 8716 this.$element 8717 .addClass('collapsing') 8718 .removeClass('collapse') 8719 .removeClass('in') 8720 8721 this.transitioning = 1 8722 8723 var complete = function () { 8724 this.transitioning = 0 8725 this.$element 8726 .trigger('hidden.bs.collapse') 8727 .removeClass('collapsing') 8728 .addClass('collapse') 8729 } 8730 8731 if (!$.support.transition) return complete.call(this) 8732 8733 this.$element 8734 [dimension](0) 8735 .one($.support.transition.end, $.proxy(complete, this)) 8736 .emulateTransitionEnd(350) 8737 } 8738 8739 Collapse.prototype.toggle = function () { 8740 this[this.$element.hasClass('in') ? 'hide' : 'show']() 8741 } 8742 8743 8744 // COLLAPSE PLUGIN DEFINITION 8745 // ========================== 8746 8747 var old = $.fn.collapse 8748 8749 $.fn.collapse = function (option) { 8750 return this.each(function () { 8751 var $this = $(this) 8752 var data = $this.data('bs.collapse') 8753 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 8754 8755 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 8756 if (typeof option == 'string') data[option]() 8757 }) 8758 } 8759 8760 $.fn.collapse.Constructor = Collapse 8761 8762 8763 // COLLAPSE NO CONFLICT 8764 // ==================== 8765 8766 $.fn.collapse.noConflict = function () { 8767 $.fn.collapse = old 8768 return this 8769 } 8770 8771 8772 // COLLAPSE DATA-API 8773 // ================= 8774 8775 $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { 8776 var $this = $(this), href 8777 var target = $this.attr('data-target') 8778 || e.preventDefault() 8779 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 8780 var $target = $(target) 8781 var data = $target.data('bs.collapse') 8782 var option = data ? 'toggle' : $this.data() 8783 var parent = $this.attr('data-parent') 8784 var $parent = parent && $(parent) 8785 8786 if (!data || !data.transitioning) { 8787 if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') 8788 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') 8789 } 8790 8791 $target.collapse(option) 8792 }) 8793 8794}(window.jQuery); 8795 8796/* ======================================================================== 8797 * Bootstrap: dropdown.js v3.0.0 8798 * http://twbs.github.com/bootstrap/javascript.html#dropdowns 8799 * ======================================================================== 8800 * Copyright 2012 Twitter, Inc. 8801 * 8802 * Licensed under the Apache License, Version 2.0 (the "License");
8803 * you may not use this file except in compliance with the License. 8804 * You may obtain a copy of the License at 8805 * 8806 * http://www.apache.org/licenses/LICENSE-2.0 8807 * 8808 * Unless required by applicable law or agreed to in writing, software 8809 * distributed under the License is distributed on an "AS IS" BASIS, 8810 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8811 * See the License for the specific language governing permissions and 8812 * limitations under the License. 8813 * ======================================================================== */ 8814 8815 8816+function ($) { "use strict"; 8817 8818 // DROPDOWN CLASS DEFINITION 8819 // ========================= 8820 8821 var backdrop = '.dropdown-backdrop' 8822 var toggle = '[data-toggle=dropdown]' 8823 var Dropdown = function (element) { 8824 var $el = $(element).on('click.bs.dropdown', this.toggle) 8825 } 8826 8827 Dropdown.prototype.toggle = function (e) { 8828 var $this = $(this) 8829 8830 if ($this.is('.disabled, :disabled')) return 8831 8832 var $parent = getParent($this) 8833 var isActive = $parent.hasClass('open') 8834 8835 clearMenus() 8836 8837 if (!isActive) { 8838 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 8839 // if mobile we we use a backdrop because click events don't delegate 8840 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) 8841 } 8842 8843 $parent.trigger(e = $.Event('show.bs.dropdown')) 8844 8845 if (e.isDefaultPrevented()) return 8846 8847 $parent 8848 .toggleClass('open') 8849 .trigger('shown.bs.dropdown') 8850 8851 $this.focus() 8852 } 8853 8854 return false 8855 } 8856 8857 Dropdown.prototype.keydown = function (e) { 8858 if (!/(38|40|27)/.test(e.keyCode)) return 8859 8860 var $this = $(this) 8861 8862 e.preventDefault() 8863 e.stopPropagation() 8864 8865 if ($this.is('.disabled, :disabled')) return 8866 8867 var $parent = getParent($this) 8868 var isActive = $parent.hasClass('open') 8869 8870 if (!isActive || (isActive && e.keyCode == 27)) { 8871 if (e.which == 27) $parent.find(toggle).focus() 8872 return $this.click() 8873 } 8874 8875 var $items = $('[role=menu] li:not(.divider):visible a', $parent) 8876 8877 if (!$items.length) return 8878 8879 var index = $items.index($items.filter(':focus')) 8880 8881 if (e.keyCode == 38 && index > 0) index-- // up 8882 if (e.keyCode == 40 && index < $items.length - 1) index++ // down 8883 if (!~index) index=0 8884 8885 $items.eq(index).focus() 8886 } 8887 8888 function clearMenus() { 8889 $(backdrop).remove() 8890 $(toggle).each(function (e) { 8891 var $parent = getParent($(this)) 8892 if (!$parent.hasClass('open')) return 8893 $parent.trigger(e = $.Event('hide.bs.dropdown')) 8894 if (e.isDefaultPrevented()) return 8895 $parent.removeClass('open').trigger('hidden.bs.dropdown') 8896 }) 8897 } 8898 8899 function getParent($this) { 8900 var selector = $this.attr('data-target') 8901 8902 if (!selector) { 8903 selector = $this.attr('href') 8904 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 8905 } 8906 8907 var $parent = selector && $(selector) 8908 8909 return $parent && $parent.length ? $parent : $this.parent() 8910 } 8911 8912 8913 // DROPDOWN PLUGIN DEFINITION 8914 // ========================== 8915 8916 var old = $.fn.dropdown 8917 8918 $.fn.dropdown = function (option) { 8919 return this.each(function () { 8920 var $this = $(this) 8921 var data = $this.data('dropdown') 8922 8923 if (!data) $this.data('dropdown', (data = new Dropdown(this))) 8924 if (typeof option == 'string') data[option].call($this) 8925 }) 8926 } 8927 8928 $.fn.dropdown.Constructor = Dropdown 8929 8930 8931 // DROPDOWN NO CONFLICT 8932 // ==================== 8933 8934 $.fn.dropdown.noConflict = function () { 8935 $.fn.dropdown = old 8936 return this 8937 } 8938 8939 8940 // APPLY TO STANDARD DROPDOWN ELEMENTS 8941 // =================================== 8942 8943 $(document) 8944 .on('click.bs.dropdown.data-api', clearMenus) 8945 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 8946 .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle) 8947 .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) 8948 8949}(window.jQuery); 8950 8951/* ======================================================================== 8952 * Bootstrap: modal.js v3.0.0 8953 * http://twbs.github.com/bootstrap/javascript.html#modals 8954 * ======================================================================== 8955 * Copyright 2012 Twitter, Inc. 8956 * 8957 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 34,054 bytes, lines 8958-10123
8958 * you may not use this file except in compliance with the License. 8959 * You may obtain a copy of the License at 8960 * 8961 * http://www.apache.org/licenses/LICENSE-2.0 8962 * 8963 * Unless required by applicable law or agreed to in writing, software 8964 * distributed under the License is distributed on an "AS IS" BASIS, 8965 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 8966 * See the License for the specific language governing permissions and 8967 * limitations under the License. 8968 * ======================================================================== */ 8969 8970 8971+function ($) { "use strict"; 8972 8973 // MODAL CLASS DEFINITION 8974 // ====================== 8975 8976 var Modal = function (element, options) { 8977 this.options = options 8978 this.$element = $(element) 8979 this.$backdrop = 8980 this.isShown = null 8981 8982 if (this.options.remote) this.$element.load(this.options.remote) 8983 } 8984 8985 Modal.DEFAULTS = { 8986 backdrop: true 8987 , keyboard: true 8988 , show: true 8989 } 8990 8991 Modal.prototype.toggle = function (_relatedTarget) { 8992 return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) 8993 } 8994 8995 Modal.prototype.show = function (_relatedTarget) { 8996 var that = this 8997 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 8998 8999 this.$element.trigger(e) 9000 9001 if (this.isShown || e.isDefaultPrevented()) return 9002 9003 this.isShown = true 9004 9005 this.escape() 9006 9007 this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 9008 9009 this.backdrop(function () { 9010 var transition = $.support.transition && that.$element.hasClass('fade') 9011 9012 if (!that.$element.parent().length) { 9013 that.$element.appendTo(document.body) // don't move modals dom position 9014 } 9015 9016 that.$element.show() 9017 9018 if (transition) { 9019 that.$element[0].offsetWidth // force reflow 9020 } 9021 9022 that.$element 9023 .addClass('in') 9024 .attr('aria-hidden', false) 9025 9026 that.enforceFocus() 9027 9028 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 9029 9030 transition ? 9031 that.$element.find('.modal-dialog') // wait for modal to slide in 9032 .one($.support.transition.end, function () { 9033 that.$element.focus().trigger(e) 9034 }) 9035 .emulateTransitionEnd(300) : 9036 that.$element.focus().trigger(e) 9037 }) 9038 } 9039 9040 Modal.prototype.hide = function (e) { 9041 if (e) e.preventDefault() 9042 9043 e = $.Event('hide.bs.modal') 9044 9045 this.$element.trigger(e) 9046 9047 if (!this.isShown || e.isDefaultPrevented()) return 9048 9049 this.isShown = false 9050 9051 this.escape() 9052 9053 $(document).off('focusin.bs.modal') 9054 9055 this.$element 9056 .removeClass('in') 9057 .attr('aria-hidden', true) 9058 .off('click.dismiss.modal') 9059 9060 $.support.transition && this.$element.hasClass('fade') ? 9061 this.$element 9062 .one($.support.transition.end, $.proxy(this.hideModal, this)) 9063 .emulateTransitionEnd(300) : 9064 this.hideModal() 9065 } 9066 9067 Modal.prototype.enforceFocus = function () { 9068 $(document) 9069 .off('focusin.bs.modal') // guard against infinite focus loop 9070 .on('focusin.bs.modal', $.proxy(function (e) { 9071 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { 9072 this.$element.focus() 9073 } 9074 }, this)) 9075 } 9076 9077 Modal.prototype.escape = function () { 9078 if (this.isShown && this.options.keyboard) { 9079 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { 9080 e.which == 27 && this.hide() 9081 }, this)) 9082 } else if (!this.isShown) { 9083 this.$element.off('keyup.dismiss.bs.modal') 9084 } 9085 } 9086 9087 Modal.prototype.hideModal = function () { 9088 var that = this 9089 this.$element.hide() 9090 this.backdrop(function () { 9091 that.removeBackdrop() 9092 that.$element.trigger('hidden.bs.modal') 9093 }) 9094 } 9095 9096 Modal.prototype.removeBackdrop = function () { 9097 this.$backdrop && this.$backdrop.remove() 9098 this.$backdrop = null 9099 } 9100 9101 Modal.prototype.backdrop = function (callback) { 9102 var that = this 9103 var animate = this.$element.hasClass('fade') ? 'fade' : '' 9104 9105 if (this.isShown && this.options.backdrop) { 9106 var doAnimate = $.support.transition && animate 9107 9108 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') 9109 .appendTo(document.body) 9110 9111 this.$element.on('click.dismiss.modal', $.proxy(function (e) { 9112 if (e.target !== e.currentTarget) return 9113 this.options.backdrop == 'static' 9114 ? this.$element[0].focus.call(this.$element[0]) 9115 : this.hide.call(this) 9116 }, this)) 9117 9118 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 9119 9120 this.$backdrop.addClass('in') 9121 9122 if (!callback) return 9123 9124 doAnimate ? 9125 this.$backdrop 9126 .one($.support.transition.end, callback) 9127 .emulateTransitionEnd(150) : 9128 callback() 9129 9130 } else if (!this.isShown && this.$backdrop) { 9131 this.$backdrop.removeClass('in') 9132 9133 $.support.transition && this.$element.hasClass('fade')? 9134 this.$backdrop 9135 .one($.support.transition.end, callback) 9136 .emulateTransitionEnd(150) : 9137 callback() 9138 9139 } else if (callback) { 9140 callback() 9141 } 9142 } 9143 9144 9145 // MODAL PLUGIN DEFINITION 9146 // ======================= 9147 9148 var old = $.fn.modal 9149 9150 $.fn.modal = function (option, _relatedTarget) { 9151 return this.each(function () { 9152 var $this = $(this) 9153 var data = $this.data('bs.modal') 9154 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 9155 9156 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 9157 if (typeof option == 'string') data[option](_relatedTarget) 9158 else if (options.show) data.show(_relatedTarget) 9159 }) 9160 } 9161 9162 $.fn.modal.Constructor = Modal 9163 9164 9165 // MODAL NO CONFLICT 9166 // ================= 9167 9168 $.fn.modal.noConflict = function () { 9169 $.fn.modal = old 9170 return this 9171 } 9172 9173 9174 // MODAL DATA-API 9175 // ============== 9176 9177 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 9178 var $this = $(this) 9179 var href = $this.attr('href') 9180 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 9181 var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 9182 9183 e.preventDefault() 9184 9185 $target 9186 .modal(option, this) 9187 .one('hide', function () { 9188 $this.is(':visible') && $this.focus() 9189 }) 9190 }) 9191 9192 $(document) 9193 .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) 9194 .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') }) 9195 9196}(window.jQuery); 9197 9198/* ======================================================================== 9199 * Bootstrap: tooltip.js v3.0.0 9200 * http://twbs.github.com/bootstrap/javascript.html#tooltip 9201 * Inspired by the original jQuery.tipsy by Jason Frame 9202 * ======================================================================== 9203 * Copyright 2012 Twitter, Inc. 9204 * 9205 * Licensed under the Apache License, Version 2.0 (the "License"); 9206 * you may not use this file except in compliance with the License. 9207 * You may obtain a copy of the License at 9208 * 9209 * http://www.apache.org/licenses/LICENSE-2.0 9210 * 9211 * Unless required by applicable law or agreed to in writing, software 9212 * distributed under the License is distributed on an "AS IS" BASIS, 9213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9214 * See the License for the specific language governing permissions and 9215 * limitations under the License. 9216 * ======================================================================== */ 9217 9218 9219+function ($) { "use strict"; 9220 9221 // TOOLTIP PUBLIC CLASS DEFINITION 9222 // =============================== 9223 9224 var Tooltip = function (element, options) { 9225 this.type = 9226 this.options = 9227 this.enabled = 9228 this.timeout = 9229 this.hoverState = 9230 this.$element = null 9231 9232 this.init('tooltip', element, options) 9233 } 9234 9235 Tooltip.DEFAULTS = { 9236 animation: true 9237 , placement: 'top' 9238 , selector: false 9239 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' 9240 , trigger: 'hover focus' 9241 , title: '' 9242 , delay: 0 9243 , html: false 9244 , container: false 9245 } 9246 9247 Tooltip.prototype.init = function (type, element, options) { 9248 this.enabled = true 9249 this.type = type 9250 this.$element = $(element) 9251 this.options = this.getOptions(options) 9252 9253 var triggers = this.options.trigger.split(' ') 9254 9255 for (var i = triggers.length; i--;) { 9256 var trigger = triggers[i] 9257 9258 if (trigger == 'click') { 9259 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 9260 } else if (trigger != 'manual') { 9261 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' 9262 var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' 9263 9264 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 9265 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 9266 } 9267 } 9268 9269 this.options.selector ? 9270 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 9271 this.fixTitle() 9272 } 9273 9274 Tooltip.prototype.getDefaults = function () { 9275 return Tooltip.DEFAULTS 9276 } 9277 9278 Tooltip.prototype.getOptions = function (options) { 9279 options = $.extend({}, this.getDefaults(), this.$element.data(), options) 9280 9281 if (options.delay && typeof options.delay == 'number') { 9282 options.delay = { 9283 show: options.delay 9284 , hide: options.delay 9285 } 9286 } 9287 9288 return options 9289 } 9290 9291 Tooltip.prototype.getDelegateOptions = function () { 9292 var options = {} 9293 var defaults = this.getDefaults() 9294 9295 this._options && $.each(this._options, function (key, value) { 9296 if (defaults[key] != value) options[key] = value 9297 }) 9298 9299 return options 9300 } 9301 9302 Tooltip.prototype.enter = function (obj) { 9303 var self = obj instanceof this.constructor ? 9304 obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) 9305 9306 clearTimeout(self.timeout) 9307 9308 self.hoverState = 'in' 9309 9310 if (!self.options.delay || !self.options.delay.show) return self.show() 9311 9312 self.timeout = setTimeout(function () { 9313 if (self.hoverState == 'in') self.show() 9314 }, self.options.delay.show) 9315 } 9316 9317 Tooltip.prototype.leave = function (obj) { 9318 var self = obj instanceof this.constructor ? 9319 obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) 9320 9321 clearTimeout(self.timeout) 9322 9323 self.hoverState = 'out' 9324 9325 if (!self.options.delay || !self.options.delay.hide) return self.hide() 9326 9327 self.timeout = setTimeout(function () { 9328 if (self.hoverState == 'out') self.hide() 9329 }, self.options.delay.hide) 9330 } 9331 9332 Tooltip.prototype.show = function () { 9333 var e = $.Event('show.bs.'+ this.type) 9334 9335 if (this.hasContent() && this.enabled) { 9336 this.$element.trigger(e) 9337 9338 if (e.isDefaultPrevented()) return 9339 9340 var $tip = this.tip() 9341 9342 this.setContent() 9343 9344 if (this.options.animation) $tip.addClass('fade') 9345 9346 var placement = typeof this.options.placement == 'function' ? 9347 this.options.placement.call(this, $tip[0], this.$element[0]) : 9348 this.options.placement 9349 9350 var autoToken = /\s?auto?\s?/i 9351 var autoPlace = autoToken.test(placement) 9352 if (autoPlace) placement = placement.replace(autoToken, '') || 'top' 9353 9354 $tip 9355 .detach() 9356 .css({ top: 0, left: 0, display: 'block' }) 9357 .addClass(placement) 9358 9359 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) 9360 9361 var pos = this.getPosition() 9362 var actualWidth = $tip[0].offsetWidth 9363 var actualHeight = $tip[0].offsetHeight 9364 9365 if (autoPlace) { 9366 var $parent = this.$element.parent() 9367 9368 var orgPlacement = placement 9369 var docScroll = document.documentElement.scrollTop || document.body.scrollTop 9370 var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth() 9371 var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight() 9372 var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left 9373 9374 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' : 9375 placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' : 9376 placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' : 9377 placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' : 9378 placement 9379 9380 $tip 9381 .removeClass(orgPlacement) 9382 .addClass(placement) 9383 } 9384 9385 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) 9386 9387 this.applyPlacement(calculatedOffset, placement) 9388 this.$element.trigger('shown.bs.' + this.type) 9389 } 9390 } 9391 9392 Tooltip.prototype.applyPlacement = function(offset, placement) { 9393 var replace 9394 var $tip = this.tip() 9395 var width = $tip[0].offsetWidth 9396 var height = $tip[0].offsetHeight 9397 9398 // manually read margins because getBoundingClientRect includes difference 9399 var marginTop = parseInt($tip.css('margin-top'), 10) 9400 var marginLeft = parseInt($tip.css('margin-left'), 10) 9401 9402 // we must check for NaN for ie 8/9 9403 if (isNaN(marginTop)) marginTop = 0 9404 if (isNaN(marginLeft)) marginLeft = 0 9405 9406 offset.top = offset.top + marginTop 9407 offset.left = offset.left + marginLeft 9408 9409 $tip 9410 .offset(offset) 9411 .addClass('in') 9412 9413 // check to see if placing tip in new offset caused the tip to resize itself 9414 var actualWidth = $tip[0].offsetWidth 9415 var actualHeight = $tip[0].offsetHeight 9416 9417 if (placement == 'top' && actualHeight != height) { 9418 replace = true 9419 offset.top = offset.top + height - actualHeight 9420 } 9421 9422 if (/bottom|top/.test(placement)) { 9423 var delta = 0 9424 9425 if (offset.left < 0) { 9426 delta = offset.left * -2 9427 offset.left = 0 9428 9429 $tip.offset(offset) 9430 9431 actualWidth = $tip[0].offsetWidth 9432 actualHeight = $tip[0].offsetHeight 9433 } 9434 9435 this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') 9436 } else { 9437 this.replaceArrow(actualHeight - height, actualHeight, 'top') 9438 } 9439 9440 if (replace) $tip.offset(offset) 9441 } 9442 9443 Tooltip.prototype.replaceArrow = function(delta, dimension, position) { 9444 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') 9445 } 9446 9447 Tooltip.prototype.setContent = function () { 9448 var $tip = this.tip() 9449 var title = this.getTitle() 9450 9451 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) 9452 $tip.removeClass('fade in top bottom left right') 9453 } 9454 9455 Tooltip.prototype.hide = function () { 9456 var that = this 9457 var $tip = this.tip() 9458 var e = $.Event('hide.bs.' + this.type) 9459 9460 function complete() { 9461 if (that.hoverState != 'in') $tip.detach() 9462 } 9463 9464 this.$element.trigger(e) 9465 9466 if (e.isDefaultPrevented()) return 9467 9468 $tip.removeClass('in') 9469 9470 $.support.transition && this.$tip.hasClass('fade') ? 9471 $tip 9472 .one($.support.transition.end, complete) 9473 .emulateTransitionEnd(150) : 9474 complete() 9475 9476 this.$element.trigger('hidden.bs.' + this.type) 9477 9478 return this 9479 } 9480 9481 Tooltip.prototype.fixTitle = function () { 9482 var $e = this.$element 9483 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { 9484 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') 9485 } 9486 } 9487 9488 Tooltip.prototype.hasContent = function () { 9489 return this.getTitle() 9490 } 9491 9492 Tooltip.prototype.getPosition = function () { 9493 var el = this.$element[0] 9494 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { 9495 width: el.offsetWidth 9496 , height: el.offsetHeight 9497 }, this.$element.offset()) 9498 } 9499 9500 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { 9501 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : 9502 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : 9503 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : 9504 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } 9505 } 9506 9507 Tooltip.prototype.getTitle = function () { 9508 var title 9509 var $e = this.$element 9510 var o = this.options 9511 9512 title = $e.attr('data-original-title') 9513 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 9514 9515 return title 9516 } 9517 9518 Tooltip.prototype.tip = function () { 9519 return this.$tip = this.$tip || $(this.options.template) 9520 } 9521 9522 Tooltip.prototype.arrow = function () { 9523 return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow') 9524 } 9525 9526 Tooltip.prototype.validate = function () { 9527 if (!this.$element[0].parentNode) { 9528 this.hide() 9529 this.$element = null 9530 this.options = null 9531 } 9532 } 9533 9534 Tooltip.prototype.enable = function () { 9535 this.enabled = true 9536 } 9537 9538 Tooltip.prototype.disable = function () { 9539 this.enabled = false 9540 } 9541 9542 Tooltip.prototype.toggleEnabled = function () { 9543 this.enabled = !this.enabled 9544 } 9545 9546 Tooltip.prototype.toggle = function (e) { 9547 var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this 9548 self.tip().hasClass('in') ? self.leave(self) : self.enter(self) 9549 } 9550 9551 Tooltip.prototype.destroy = function () { 9552 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) 9553 } 9554 9555 9556 // TOOLTIP PLUGIN DEFINITION 9557 // ========================= 9558 9559 var old = $.fn.tooltip 9560 9561 $.fn.tooltip = function (option) { 9562 return this.each(function () { 9563 var $this = $(this) 9564 var data = $this.data('bs.tooltip') 9565 var options = typeof option == 'object' && option 9566 9567 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) 9568 if (typeof option == 'string') data[option]() 9569 }) 9570 } 9571 9572 $.fn.tooltip.Constructor = Tooltip 9573 9574 9575 // TOOLTIP NO CONFLICT 9576 // =================== 9577 9578 $.fn.tooltip.noConflict = function () { 9579 $.fn.tooltip = old 9580 return this 9581 } 9582 9583}(window.jQuery); 9584 9585/* ======================================================================== 9586 * Bootstrap: popover.js v3.0.0 9587 * http://twbs.github.com/bootstrap/javascript.html#popovers 9588 * ======================================================================== 9589 * Copyright 2012 Twitter, Inc. 9590 * 9591 * Licensed under the Apache License, Version 2.0 (the "License"); 9592 * you may not use this file except in compliance with the License. 9593 * You may obtain a copy of the License at 9594 * 9595 * http://www.apache.org/licenses/LICENSE-2.0 9596 * 9597 * Unless required by applicable law or agreed to in writing, software 9598 * distributed under the License is distributed on an "AS IS" BASIS, 9599 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9600 * See the License for the specific language governing permissions and 9601 * limitations under the License. 9602 * ======================================================================== */ 9603 9604 9605+function ($) { "use strict"; 9606 9607 // POPOVER PUBLIC CLASS DEFINITION 9608 // =============================== 9609 9610 var Popover = function (element, options) { 9611 this.init('popover', element, options) 9612 } 9613 9614 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') 9615 9616 Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, { 9617 placement: 'right' 9618 , trigger: 'click' 9619 , content: '' 9620 , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 9621 }) 9622 9623 9624 // NOTE: POPOVER EXTENDS tooltip.js 9625 // ================================ 9626 9627 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype) 9628 9629 Popover.prototype.constructor = Popover 9630 9631 Popover.prototype.getDefaults = function () { 9632 return Popover.DEFAULTS 9633 } 9634 9635 Popover.prototype.setContent = function () { 9636 var $tip = this.tip() 9637 var title = this.getTitle() 9638 var content = this.getContent() 9639 9640 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) 9641 $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) 9642 9643 $tip.removeClass('fade top bottom left right in') 9644 9645 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do 9646 // this manually by checking the contents. 9647 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide() 9648 } 9649 9650 Popover.prototype.hasContent = function () { 9651 return this.getTitle() || this.getContent() 9652 } 9653 9654 Popover.prototype.getContent = function () { 9655 var $e = this.$element 9656 var o = this.options 9657 9658 return $e.attr('data-content') 9659 || (typeof o.content == 'function' ? 9660 o.content.call($e[0]) : 9661 o.content) 9662 } 9663 9664 Popover.prototype.arrow = function () { 9665 return this.$arrow = this.$arrow || this.tip().find('.arrow') 9666 } 9667 9668 Popover.prototype.tip = function () { 9669 if (!this.$tip) this.$tip = $(this.options.template) 9670 return this.$tip 9671 } 9672 9673 9674 // POPOVER PLUGIN DEFINITION 9675 // ========================= 9676 9677 var old = $.fn.popover 9678 9679 $.fn.popover = function (option) { 9680 return this.each(function () { 9681 var $this = $(this) 9682 var data = $this.data('bs.popover') 9683 var options = typeof option == 'object' && option 9684 9685 if (!data) $this.data('bs.popover', (data = new Popover(this, options))) 9686 if (typeof option == 'string') data[option]() 9687 }) 9688 } 9689 9690 $.fn.popover.Constructor = Popover 9691 9692 9693 // POPOVER NO CONFLICT 9694 // =================== 9695 9696 $.fn.popover.noConflict = function () { 9697 $.fn.popover = old 9698 return this 9699 } 9700 9701}(window.jQuery); 9702 9703/* ======================================================================== 9704 * Bootstrap: scrollspy.js v3.0.0 9705 * http://twbs.github.com/bootstrap/javascript.html#scrollspy 9706 * ======================================================================== 9707 * Copyright 2012 Twitter, Inc. 9708 * 9709 * Licensed under the Apache License, Version 2.0 (the "License"); 9710 * you may not use this file except in compliance with the License. 9711 * You may obtain a copy of the License at 9712 * 9713 * http://www.apache.org/licenses/LICENSE-2.0 9714 * 9715 * Unless required by applicable law or agreed to in writing, software 9716 * distributed under the License is distributed on an "AS IS" BASIS, 9717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9718 * See the License for the specific language governing permissions and 9719 * limitations under the License. 9720 * ======================================================================== */ 9721 9722 9723+function ($) { "use strict"; 9724 9725 // SCROLLSPY CLASS DEFINITION 9726 // ========================== 9727 9728 function ScrollSpy(element, options) { 9729 var href 9730 var process = $.proxy(this.process, this) 9731 9732 this.$element = $(element).is('body') ? $(window) : $(element) 9733 this.$body = $('body') 9734 this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process) 9735 this.options = $.extend({}, ScrollSpy.DEFAULTS, options) 9736 this.selector = (this.options.target 9737 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 9738 || '') + ' .nav li > a' 9739 this.offsets = $([]) 9740 this.targets = $([]) 9741 this.activeTarget = null 9742 9743 this.refresh() 9744 this.process() 9745 } 9746 9747 ScrollSpy.DEFAULTS = { 9748 offset: 10 9749 } 9750 9751 ScrollSpy.prototype.refresh = function () { 9752 var offsetMethod = this.$element[0] == window ? 'offset' : 'position' 9753 9754 this.offsets = $([]) 9755 this.targets = $([]) 9756 9757 var self = this 9758 var $targets = this.$body 9759 .find(this.selector) 9760 .map(function () { 9761 var $el = $(this) 9762 var href = $el.data('target') || $el.attr('href') 9763 var $href = /^#\w/.test(href) && $(href) 9764 9765 return ($href 9766 && $href.length 9767 && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null 9768 }) 9769 .sort(function (a, b) { return a[0] - b[0] }) 9770 .each(function () { 9771 self.offsets.push(this[0]) 9772 self.targets.push(this[1]) 9773 }) 9774 } 9775 9776 ScrollSpy.prototype.process = function () { 9777 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset 9778 var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight 9779 var maxScroll = scrollHeight - this.$scrollElement.height() 9780 var offsets = this.offsets 9781 var targets = this.targets 9782 var activeTarget = this.activeTarget 9783 var i 9784 9785 if (scrollTop >= maxScroll) { 9786 return activeTarget != (i = targets.last()[0]) && this.activate(i) 9787 } 9788 9789 for (i = offsets.length; i--;) { 9790 activeTarget != targets[i] 9791 && scrollTop >= offsets[i] 9792 && (!offsets[i + 1] || scrollTop <= offsets[i + 1]) 9793 && this.activate( targets[i] ) 9794 } 9795 } 9796 9797 ScrollSpy.prototype.activate = function (target) { 9798 this.activeTarget = target 9799 9800 $(this.selector) 9801 .parents('.active') 9802 .removeClass('active') 9803 9804 var selector = this.selector 9805 + '[data-target="' + target + '"],' 9806 + this.selector + '[href="' + target + '"]' 9807 9808 var active = $(selector) 9809 .parents('li') 9810 .addClass('active') 9811 9812 if (active.parent('.dropdown-menu').length) { 9813 active = active 9814 .closest('li.dropdown') 9815 .addClass('active') 9816 } 9817 9818 active.trigger('activate') 9819 } 9820 9821 9822 // SCROLLSPY PLUGIN DEFINITION 9823 // =========================== 9824 9825 var old = $.fn.scrollspy 9826 9827 $.fn.scrollspy = function (option) { 9828 return this.each(function () { 9829 var $this = $(this) 9830 var data = $this.data('bs.scrollspy') 9831 var options = typeof option == 'object' && option 9832 9833 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) 9834 if (typeof option == 'string') data[option]() 9835 }) 9836 } 9837 9838 $.fn.scrollspy.Constructor = ScrollSpy 9839 9840 9841 // SCROLLSPY NO CONFLICT 9842 // ===================== 9843 9844 $.fn.scrollspy.noConflict = function () { 9845 $.fn.scrollspy = old 9846 return this 9847 } 9848 9849 9850 // SCROLLSPY DATA-API 9851 // ================== 9852 9853 $(window).on('load', function () { 9854 $('[data-spy="scroll"]').each(function () { 9855 var $spy = $(this) 9856 $spy.scrollspy($spy.data()) 9857 }) 9858 }) 9859 9860}(window.jQuery); 9861 9862/* ======================================================================== 9863 * Bootstrap: tab.js v3.0.0 9864 * http://twbs.github.com/bootstrap/javascript.html#tabs 9865 * ======================================================================== 9866 * Copyright 2012 Twitter, Inc. 9867 * 9868 * Licensed under the Apache License, Version 2.0 (the "License"); 9869 * you may not use this file except in compliance with the License. 9870 * You may obtain a copy of the License at 9871 * 9872 * http://www.apache.org/licenses/LICENSE-2.0 9873 * 9874 * Unless required by applicable law or agreed to in writing, software 9875 * distributed under the License is distributed on an "AS IS" BASIS, 9876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9877 * See the License for the specific language governing permissions and 9878 * limitations under the License. 9879 * ======================================================================== */ 9880 9881 9882+function ($) { "use strict"; 9883 9884 // TAB CLASS DEFINITION 9885 // ==================== 9886 9887 var Tab = function (element) { 9888 this.element = $(element) 9889 } 9890 9891 Tab.prototype.show = function () { 9892 var $this = this.element 9893 var $ul = $this.closest('ul:not(.dropdown-menu)') 9894 var selector = $this.attr('data-target') 9895 9896 if (!selector) { 9897 selector = $this.attr('href') 9898 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 9899 } 9900 9901 if ($this.parent('li').hasClass('active')) return 9902 9903 var previous = $ul.find('.active:last a')[0] 9904 var e = $.Event('show.bs.tab', { 9905 relatedTarget: previous 9906 }) 9907 9908 $this.trigger(e) 9909 9910 if (e.isDefaultPrevented()) return 9911 9912 var $target = $(selector) 9913 9914 this.activate($this.parent('li'), $ul) 9915 this.activate($target, $target.parent(), function () { 9916 $this.trigger({ 9917 type: 'shown.bs.tab' 9918 , relatedTarget: previous 9919 }) 9920 }) 9921 } 9922 9923 Tab.prototype.activate = function (element, container, callback) { 9924 var $active = container.find('> .active') 9925 var transition = callback 9926 && $.support.transition 9927 && $active.hasClass('fade') 9928 9929 function next() { 9930 $active 9931 .removeClass('active') 9932 .find('> .dropdown-menu > .active') 9933 .removeClass('active') 9934 9935 element.addClass('active') 9936 9937 if (transition) { 9938 element[0].offsetWidth // reflow for transition 9939 element.addClass('in') 9940 } else { 9941 element.removeClass('fade') 9942 } 9943 9944 if (element.parent('.dropdown-menu')) { 9945 element.closest('li.dropdown').addClass('active') 9946 } 9947 9948 callback && callback() 9949 } 9950 9951 transition ? 9952 $active 9953 .one($.support.transition.end, next) 9954 .emulateTransitionEnd(150) : 9955 next() 9956 9957 $active.removeClass('in') 9958 } 9959 9960 9961 // TAB PLUGIN DEFINITION 9962 // ===================== 9963 9964 var old = $.fn.tab 9965 9966 $.fn.tab = function ( option ) { 9967 return this.each(function () { 9968 var $this = $(this) 9969 var data = $this.data('bs.tab') 9970 9971 if (!data) $this.data('bs.tab', (data = new Tab(this))) 9972 if (typeof option == 'string') data[option]() 9973 }) 9974 } 9975 9976 $.fn.tab.Constructor = Tab 9977 9978 9979 // TAB NO CONFLICT 9980 // =============== 9981 9982 $.fn.tab.noConflict = function () { 9983 $.fn.tab = old 9984 return this 9985 } 9986 9987 9988 // TAB DATA-API 9989 // ============ 9990 9991 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { 9992 e.preventDefault() 9993 $(this).tab('show') 9994 }) 9995 9996}(window.jQuery); 9997 9998/* ======================================================================== 9999 * Bootstrap: affix.js v3.0.0 10000 * http://twbs.github.com/bootstrap/javascript.html#affix 10001 * ======================================================================== 10002 * Copyright 2012 Twitter, Inc. 10003 * 10004 * Licensed under the Apache License, Version 2.0 (the "License"); 10005 * you may not use this file except in compliance with the License. 10006 * You may obtain a copy of the License at 10007 * 10008 * http://www.apache.org/licenses/LICENSE-2.0 10009 * 10010 * Unless required by applicable law or agreed to in writing, software 10011 * distributed under the License is distributed on an "AS IS" BASIS, 10012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10013 * See the License for the specific language governing permissions and 10014 * limitations under the License. 10015 * ======================================================================== */ 10016 10017 10018+function ($) { "use strict"; 10019 10020 // AFFIX CLASS DEFINITION 10021 // ====================== 10022 10023 var Affix = function (element, options) { 10024 this.options = $.extend({}, Affix.DEFAULTS, options) 10025 this.$window = $(window) 10026 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) 10027 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) 10028 10029 this.$element = $(element) 10030 this.affixed = 10031 this.unpin = null 10032 10033 this.checkPosition() 10034 } 10035 10036 Affix.RESET = 'affix affix-top affix-bottom' 10037 10038 Affix.DEFAULTS = { 10039 offset: 0 10040 } 10041 10042 Affix.prototype.checkPositionWithEventLoop = function () { 10043 setTimeout($.proxy(this.checkPosition, this), 1) 10044 } 10045 10046 Affix.prototype.checkPosition = function () { 10047 if (!this.$element.is(':visible')) return 10048 10049 var scrollHeight = $(document).height() 10050 var scrollTop = this.$window.scrollTop() 10051 var position = this.$element.offset() 10052 var offset = this.options.offset 10053 var offsetTop = offset.top 10054 var offsetBottom = offset.bottom 10055 10056 if (typeof offset != 'object') offsetBottom = offsetTop = offset 10057 if (typeof offsetTop == 'function') offsetTop = offset.top() 10058 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() 10059 10060 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : 10061 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : 10062 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false 10063 10064 if (this.affixed === affix) return 10065 if (this.unpin) this.$element.css('top', '') 10066 10067 this.affixed = affix 10068 this.unpin = affix == 'bottom' ? position.top - scrollTop : null 10069 10070 this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : '')) 10071 10072 if (affix == 'bottom') { 10073 this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() }) 10074 } 10075 } 10076 10077 10078 // AFFIX PLUGIN DEFINITION 10079 // ======================= 10080 10081 var old = $.fn.affix 10082 10083 $.fn.affix = function (option) { 10084 return this.each(function () { 10085 var $this = $(this) 10086 var data = $this.data('bs.affix') 10087 var options = typeof option == 'object' && option 10088 10089 if (!data) $this.data('bs.affix', (data = new Affix(this, options))) 10090 if (typeof option == 'string') data[option]() 10091 }) 10092 } 10093 10094 $.fn.affix.Constructor = Affix 10095 10096 10097 // AFFIX NO CONFLICT 10098 // ================= 10099 10100 $.fn.affix.noConflict = function () { 10101 $.fn.affix = old 10102 return this 10103 } 10104 10105 10106 // AFFIX DATA-API 10107 // ============== 10108 10109 $(window).on('load', function () { 10110 $('[data-spy="affix"]').each(function () { 10111 var $spy = $(this) 10112 var data = $spy.data() 10113 10114 data.offset = data.offset || {} 10115 10116 if (data.offsetBottom) data.offset.bottom = data.offsetBottom 10117 if (data.offsetTop) data.offset.top = data.offsetTop 10118 10119 $spy.affix(data) 10120 }) 10121 }) 10122 10123}(window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.