1/*! 2 * jQuery++ - 2.0.0 3 * http://jquerypp.com 4 * Copyright (c) 2015 Bitovi 5 * Mon, 25 May 2015 13:13:41 GMT 6 * Licensed MIT 7 8 * Includes: jquerypp/dom/animate/animate,jquerypp/dom/compare/compare,jquerypp/dom/cookie/cookie,jquerypp/dom/form_params/form_params,jquerypp/dom/range/range,jquerypp/dom/selection/selection,jquerypp/dom/within/within,jquerypp/event/removed/removed,jquerypp/event/drag/drag,jquerypp/event/drop/drop,jquerypp/event/hover/hover,jquerypp/event/key/key,jquerypp/event/pause/pause,jquerypp/event/resize/resize,jquerypp/event/swipe/swipe 9 * Download from: http://bitbuilder.herokuapp.com/jquerypp.custom.js?plugins=jquerypp%2Fdom%2Fanimate%2Fanimate&plugins=jquerypp%2Fdom%2Fcompare%2Fcompare&plugins=jquerypp%2Fdom%2Fcookie%2Fcookie&plugins=jquerypp%2Fdom%2Fform_params%2Fform_params&plugins=jquerypp%2Fdom%2Frange%2Frange&plugins=jquerypp%2Fdom%2Fselection%2Fselection&plugins=jquerypp%2Fdom%2Fwithin%2Fwithin&plugins=jquerypp%2Fevent%2Fremoved%2Fremoved&plugins=jquerypp%2Fevent%2Fdrag%2Fdrag&plugins=jquerypp%2Fevent%2Fdrop%2Fdrop&plugins=jquerypp%2Fevent%2Fhover%2Fhover&plugins=jquerypp%2Fevent%2Fkey%2Fkey&plugins=jquerypp%2Fevent%2Fpause%2Fpause&plugins=jquerypp%2Fevent%2Fresize%2Fresize&plugins=jquerypp%2Fevent%2Fswipe%2Fswipe 10 */ 11/*[global-shim-start]*/ 12(function (exports, global){ 13 var origDefine = global.define; 14 15 var get = function(name){ 16 var parts = name.split("."), 17 cur = global, 18 i; 19 for(i = 0 ; i < parts.length; i++){ 20 if(!cur) { 21 break; 22 } 23 cur = cur[parts[i]]; 24 } 25 return cur; 26 }; 27 var modules = (global.define && global.define.modules) || 28 (global._define && global._define.modules) || {}; 29 var ourDefine = global.define = function(moduleName, deps, callback){ 30 var module; 31 if(typeof deps === "function") { 32 callback = deps; 33 deps = []; 34 } 35 var args = [], 36 i; 37 for(i =0; i < deps.length; i++) { 38 args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); 39 } 40 // CJS has no dependencies but 3 callback arguments 41 if(!deps.length && callback.length) { 42 module = { exports: {} }; 43 var require = function(name) { 44 return exports[name] ? get(exports[name]) : modules[name]; 45 }; 46 args.push(require, module.exports, module); 47 } 48 // Babel uses only the exports objet 49 else if(!args[0] && deps[0] === "exports") { 50 module = { exports: {} }; 51 args[0] = module.exports; 52 } 53 54 global.define = origDefine; 55 var result = callback ? callback.apply(null, args) : undefined; 56 global.define = ourDefine; 57 58 // Favor CJS module.exports over the return value 59 modules[moduleName] = module && module.exports ? module.exports : result; 60 }; 61 global.define.orig = origDefine; 62 global.define.modules = modules; 63 global.define.amd = true; 64 global.System = { 65 define: function(__name, __code){ 66 global.define = origDefine; 67 eval("(function() { " + __code + " \n }).call(global);"); 68 global.define = ourDefine; 69 }, 70 orig: global.System 71 }; 72})({"jquery":"jQuery","zepto":"Zepto"},window) 73/*[email protected]#dom/animate/animate*/ 74define('jquerypp/dom/animate/animate', ['jquery'], function ($) { 75 var animationNum = 0, styleSheet = null, cache = [], browser = null, oldanimate = $.fn.animate, getStyleSheet = function () { 76 if (!styleSheet) { 77 var style = document.createElement('style'); 78 style.setAttribute('type', 'text/css'); 79 style.setAttribute('media', 'screen'); 80 document.getElementsByTagName('head')[0].appendChild(style); 81 if (!window.createPopup) { 82 style.appendChild(document.createTextNode('')); 83 } 84 styleSheet = style.sheet; 85 } 86 return styleSheet; 87 }, removeAnimation = function (sheet, name) { 88 for (var j = sheet.cssRules.length - 1; j >= 0; j--) { 89 var rule = sheet.cssRules[j]; 90 if (rule.type === 7 && rule.name == name) { 91 sheet.deleteRule(j); 92 return; 93 } 94 } 95 }, passThrough = function (props, ops, easing, callback) { 96 var nonElement = !(this[0] && this[0].nodeType), isInline = !nonElement && $(this).css('display') === '
96inline' && $(this).css('float') === 'none', browser = getBrowser(); 97 for (var name in props) { 98 if (props[name] == 'show' || props[name] == 'hide' || props[name] == 'toggle' || $.isArray(props[name]) || props[name] < 0 || name == 'zIndex' || name == 'z-index' || name == 'scrollTop' || name == 'scrollLeft') { 99 return true; 100 } 101 } 102 return props.jquery === true || browser === null || browser.prefix === '-o-' || $.isEmptyObject(props) || (easing || easing && typeof easing == 'string') || $.isPlainObject(ops) || isInline || nonElement; 103 }, cssValue = function (origName, value) { 104 if (typeof value === 'number' && !$.cssNumber[origName]) { 105 return value += 'px'; 106 } 107 return value; 108 }, getBrowser = function () { 109 if (!browser) { 110 var t, el = document.createElement('fakeelement'), transitions = { 111 'transition': { 112 transitionEnd: 'transitionEnd', 113 prefix: '' 114 }, 115 'MozTransition': { 116 transitionEnd: 'animationend', 117 prefix: '-moz-' 118 }, 119 'WebkitTransition': { 120 transitionEnd: 'webkitAnimationEnd', 121 prefix: '-webkit-' 122 }, 123 'OTransition': { 124 transitionEnd: 'oTransitionEnd', 125 prefix: '-o-' 126 } 127 }; 128 for (t in transitions) { 129 if (t in el.style) { 130 browser = transitions[t]; 131 } 132 } 133 } 134 return browser; 135 }, ffProps = { 136 top: function (el) { 137 return el.position().top; 138 }, 139 left: function (el) { 140 return el.position().left; 141 }, 142 width: function (el) { 143 return el.width(); 144 }, 145 height: function (el) { 146 return el.height(); 147 }, 148 fontSize: function (el) { 149 return '1em'; 150 } 151 }, addPrefix = function (properties) { 152 var result = {}; 153 $.each(properties, function (name, value) { 154 result[getBrowser().prefix + name] = value; 155 }); 156 return result; 157 }, getAnimation = function (style) { 158 var sheet, name, last; 159 $.each(cache, function (i, animation) { 160 if (style === animation.style) { 161 name = animation.name; 162 animation.age = 0; 163 } else { 164 animation.age += 1; 165 } 166 }); 167 if (!name) { 168 sheet = getStyleSheet(); 169 name = 'jquerypp_animation_' + animationNum++; 170 sheet.insertRule('@' + getBrowser().prefix + 'keyframes ' + name + ' ' + style, sheet.cssRules && sheet.cssRules.length || 0); 171 cache.push({ 172 name: name, 173 style: style, 174 age: 0 175 }); 176 cache.sort(function (first, second) { 177 return first.age - second.age; 178 }); 179 if (cache.length > 20) { 180 last = cache.pop(); 181 removeAnimation(sheet, last.name); 182 } 183 } 184 return name; 185 }; 186 $.fn.animate = function (props, speed, easing, callback) { 187 if (passThrough.apply(this, arguments)) { 188 return oldanimate.apply(this, arguments); 189 } 190 var optall = $.speed(speed, easing, callback), overflow = []; 191 if ('height' in props || 'width' in props) { 192 overflow = [ 193 this[0].style.overflow, 194 this[0].style.overflowX, 195 this[0].style.overflowY 196 ]; 197 this.css('overflow', 'hidden'); 198 } 199 this.queue(optall.queue, function (done) { 200 var current, properties = [], to = '', prop, self = $(this), duration = optall.duration, animationName, dataKey, style = '{ from {', animationEnd = function (currentCSS, exec) { 201 if (!exec) { 202 self[0].style.overflow = overflow[0]; 203 self[0].style.overflowX = overflow[1]; 204 self[0].style.overflowY = overflow[2]; 205 } else { 206 self.css('overflow', ''); 207 } 208 self.css(currentCSS); 209 self.css(addPrefix({ 210 'animation-duration': '', 211 'animation-name': '', 212 'animation-fill-mode': '', 213 'animation-play-state': '' 214 })); 215 if ($.isFunction(optall.old) && exec) { 216 optall.old.call(self[0], true); 217 } 218 $.removeData(self, dataKey, true); 219 }, finishAnimation = function () { 220 animationEnd(props, true); 221 done(); 222 }; 223 for (prop in props) { 224 properties.push(prop); 225 } 226 if (getBrowser().prefix === '-moz-') {
227 $.each(properties, function (i, prop) { 228 var converter = ffProps[$.camelCase(prop)]; 229 if (converter && self.css(prop) == 'auto') { 230 self.css(prop, converter(self)); 231 } 232 }); 233 } 234 current = self.css.apply(self, properties); 235 $.each(properties, function (i, cur) { 236 var name = cur.replace(/([A-Z]|^ms)/g, '-$1').toLowerCase(); 237 style += name + ' : ' + cssValue(cur, current[cur]) + '; '; 238 to += name + ' : ' + cssValue(cur, props[cur]) + '; '; 239 }); 240 style += '} to {' + to + ' }}'; 241 animationName = getAnimation(style); 242 dataKey = animationName + '.run'; 243 $._data(this, dataKey, { 244 stop: function (gotoEnd) { 245 self.css(addPrefix({ 'animation-play-state': 'paused' })); 246 self.off(getBrowser().transitionEnd, finishAnimation); 247 if (!gotoEnd) { 248 animationEnd(self.styles.apply(self, properties), false); 249 } else { 250 animationEnd(props, true); 251 } 252 } 253 }); 254 self.css(addPrefix({ 255 'animation-duration': duration + 'ms', 256 'animation-name': animationName, 257 'animation-fill-mode': 'forwards' 258 })); 259 self.one(getBrowser().transitionEnd, finishAnimation); 260 }); 261 return this; 262 }; 263 return $; 264}); 265/*[email protected]#dom/compare/compare*/ 266define('jquerypp/dom/compare/compare', ['jquery'], function ($) { 267 $.fn.compare = function (element) { 268 try { 269 element = element.jquery ? element[0] : element; 270 } catch (e) { 271 return null; 272 } 273 if (window.HTMLElement) { 274 var s = HTMLElement.prototype.toString.call(element); 275 if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]' || s === '[object Window]') { 276 return null; 277 } 278 } 279 if (this[0].compareDocumentPosition) { 280 return this[0].compareDocumentPosition(element); 281 } 282 if (this[0] == document && element != document) 283 return 8; 284 var number = (this[0] !== element && this[0].contains(element) && 16) + (this[0] != element && element.contains(this[0]) && 8), docEl = document.documentElement; 285 if (this[0].sourceIndex) { 286 number += this[0].sourceIndex < element.sourceIndex && 4; 287 number += this[0].sourceIndex > element.sourceIndex && 2; 288 number += (this[0].ownerDocument !== element.ownerDocument || this[0] != docEl && this[0].sourceIndex <= 0 || element != docEl && element.sourceIndex <= 0) && 1; 289 } 290 return number; 291 }; 292 return $; 293}); 294/*[email protected]#dom/cookie/cookie*/ 295define('jquerypp/dom/cookie/cookie', ['jquery'], function ($) { 296 $.cookie = function (name, value, options) { 297 if (typeof value != 'undefined') { 298 options = options || {}; 299 if (value === null) { 300 value = ''; 301 options.expires = -1; 302 } 303 if (typeof value == 'object' && JSON.stringify) { 304 value = JSON.stringify(value); 305 } 306 var expires = ''; 307 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 308 var date; 309 if (typeof options.expires == 'number') { 310 date = new Date(); 311 date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000); 312 } else { 313 date = options.expires; 314 } 315 expires = '; expires=' + date.toUTCString(); 316 } 317 var path = options.path ? '; path=' + options.path : ''; 318 var domain = options.domain ? '; domain=' + options.domain : ''; 319 var secure = options.secure ? '; secure' : ''; 320 document.cookie = [ 321 name, 322 '=', 323 encodeURIComponent(value), 324 expires, 325 path, 326 domain, 327 secure 328 ].join(''); 329 } else { 330 var cookieValue = null; 331 if (document.cookie && document.cookie != '') { 332 var cookies = document.cookie.split(';'); 333 for (var i = 0; i < cookies.length; i++) { 334 var cookie = $.trim(cookies[i]); 335 if (cookie.substring(0, name.length + 1) == name + '=') { 336 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 337 break; 338 } 339 } 340 } 341 if (cookieValue && cookieValue.match(/^\s*\{/)) { 342 try { 343 cookieValue = JSON.parse(cookieValue); 344 } catch (e) { 345 } 346 } 347 return cookieValue; 348 } 349 }; 350 return $; 351}); 352/*[email protected]#dom/form_params/form_params*/ 353define('jquerypp/dom/form_params/form_params', ['jquery'], function ($) { 354 var keyBreaker = /[^\[\]]+/g, convertValue = function (value) { 355 if ($.isNumeric(value)) { 356 return parseFloat(value); 357 } else if (value === 'true') { 358 return true; 359 } else if (value === 'false') { 360 return false;
361 } else if (value === '' || value === null) { 362 return undefined; 363 } 364 return value; 365 }, nestData = function (elem, type, data, parts, value, seen, fullName) { 366 var name = parts.shift(); 367 fullName = fullName ? fullName + '.' + name : name; 368 if (parts.length) { 369 if (!data[name]) { 370 data[name] = {}; 371 } 372 nestData(elem, type, data[name], parts, value, seen, fullName); 373 } else { 374 if (fullName in seen && type != 'radio' && !$.isArray(data[name])) { 375 if (name in data) { 376 data[name] = [data[name]]; 377 } else { 378 data[name] = []; 379 } 380 } else { 381 seen[fullName] = true; 382 } 383 if ((type == 'radio' || type == 'checkbox') && !elem.is(':checked')) { 384 return; 385 } 386 if (!data[name]) { 387 data[name] = value; 388 } else { 389 data[name].push(value); 390 } 391 } 392 }; 393 $.fn.extend({ 394 formParams: function (params) { 395 var convert; 396 if (!!params === params) { 397 convert = params; 398 params = null; 399 } 400 if (params) { 401 return this.setParams(params); 402 } else { 403 return this.getParams(convert); 404 } 405 }, 406 setParams: function (params) { 407 this.find('[name]').each(function () { 408 var $this = $(this), value = params[$this.attr('name')]; 409 if (value !== undefined) { 410 if ($this.is(':radio')) { 411 if ($this.val() == value) { 412 $this.attr('checked', true); 413 } 414 } else if ($this.is(':checkbox')) { 415 value = $.isArray(value) ? value : [value]; 416 if ($.inArray($this.val(), value) > -1) { 417 $this.attr('checked', true); 418 } 419 } else { 420 $this.val(value); 421 } 422 } 423 }); 424 }, 425 getParams: function (convert) { 426 var data = {}, seen = {}, current; 427 this.find('[name]:not(:disabled)').each(function () { 428 var $this = $(this), type = $this.attr('type'), name = $this.attr('name'), value = $this.val(), parts; 429 if (type == 'submit' || !name) { 430 return; 431 } 432 parts = name.match(keyBreaker); 433 if (!parts.length) { 434 parts = [name]; 435 } 436 if (convert) { 437 value = convertValue(value); 438 } 439 nestData($this, type, data, parts, value, seen); 440 }); 441 return data; 442 } 443 }); 444 return $; 445}); 446/*[email protected]#dom/range/range*/ 447define('jquerypp/dom/range/range', [ 448 'jquery', 449 'jquerypp/dom/compare/compare' 450], function ($) { 451 $.fn.range = function () { 452 return $.Range(this[0]); 453 }; 454 var convertType = function (type) { 455 return type.replace(/([a-z])([a-z]+)/gi, function (all, first, next) { 456 return first + next.toLowerCase(); 457 }).replace(/_/g, ''); 458 }, reverse = function (type) { 459 return type.replace(/^([a-z]+)_TO_([a-z]+)/i, function (all, first, last) { 460 return last + '_TO_' + first; 461 }); 462 }, getWindow = function (element) { 463 return element ? element.ownerDocument.defaultView || element.ownerDocument.parentWindow : window; 464 }, bisect = function (el, start, end) { 465 if (end - start == 1) { 466 return; 467 } 468 }, support = {}; 469 $.Range = function (range) { 470 if (this.constructor !== $.Range) { 471 return new $.Range(range); 472 } 473 if (range && range.jquery) { 474 range = range[0]; 475 } 476 if (!range || range.nodeType) { 477 this.win = getWindow(range); 478 if (this.win.document.createRange) { 479 this.range = this.win.document.createRange(); 480 } else if (this.win && this.win.document.body && this.win.document.body.createTextRange) { 481 this.range = this.win.document.body.createTextRange(); 482 } 483 if (range) { 484 this.select(range); 485 } 486 } else if (range.clientX != null || range.pageX != null || range.left != null) { 487 this.moveToPoint(range); 488 } else if (range.originalEvent && range.originalEvent.touches && range.originalEvent.touches.length) { 489 this.moveToPoint(range.originalEvent.touches[0]); 490 } else if (range.originalEvent && range.originalEvent.changedTouches && range.originalEvent.changedTouches.length) { 491 this.moveToPoint(range.originalEvent.changedTouches[0]); 492 } else { 493 this.range = range; 494 } 495 }; 496 $.Range.current = function (el) { 497 var win = getWindow(el), selection;
498 if (win.getSelection) { 499 selection = win.getSelection(); 500 return new $.Range(selection.rangeCount ? selection.getRangeAt(0) : win.document.createRange()); 501 } else { 502 return new $.Range(win.document.selection.createRange()); 503 } 504 }; 505 $.extend($.Range.prototype, { 506 moveToPoint: function (point) { 507 var clientX = point.clientX, clientY = point.clientY; 508 if (!clientX) { 509 var off = scrollOffset(); 510 clientX = (point.pageX || point.left || 0) - off.left; 511 clientY = (point.pageY || point.top || 0) - off.top; 512 } 513 if (support.moveToPoint) { 514 this.range = $.Range().range; 515 this.range.moveToPoint(clientX, clientY); 516 return this; 517 } 518 var parent = document.elementFromPoint(clientX, clientY); 519 for (var n = 0; n < parent.childNodes.length; n++) { 520 var node = parent.childNodes[n]; 521 if (node.nodeType === 3 || node.nodeType === 4) { 522 var range = $.Range(node), length = range.toString().length; 523 for (var i = 1; i < length + 1; i++) { 524 var rect = range.end(i).rect(); 525 if (rect.left <= clientX && rect.left + rect.width >= clientX && rect.top <= clientY && rect.top + rect.height >= clientY) { 526 range.start(i - 1); 527 this.range = range.range; 528 return this; 529 } 530 } 531 } 532 } 533 var previous; 534 iterate(parent.childNodes, function (textNode) { 535 var range = $.Range(textNode); 536 if (range.rect().top > point.clientY) { 537 return false; 538 } else { 539 previous = range; 540 } 541 }); 542 if (previous) { 543 previous.start(previous.toString().length); 544 this.range = previous.range; 545 } else { 546 this.range = $.Range(parent).range; 547 } 548 }, 549 window: function () { 550 return this.win || window; 551 }, 552 overlaps: function (elRange) { 553 if (elRange.nodeType) { 554 elRange = $.Range(elRange).select(elRange); 555 } 556 var startToStart = this.compare('START_TO_START', elRange), endToEnd = this.compare('END_TO_END', elRange); 557 if (startToStart <= 0 && endToEnd >= 0) { 558 return true; 559 } 560 if (startToStart >= 0 && this.compare('START_TO_END', elRange) <= 0) { 561 return true; 562 } 563 if (this.compare('END_TO_START', elRange) >= 0 && endToEnd <= 0) { 564 return true; 565 } 566 return false; 567 }, 568 collapse: function (toStart) { 569 this.range.collapse(toStart === undefined ? true : toStart); 570 return this; 571 }, 572 toString: function () { 573 return typeof this.range.text == 'string' ? this.range.text : this.range.toString(); 574 }, 575 start: function (set) { 576 if (set === undefined) { 577 if (this.range.startContainer) { 578 return { 579 container: this.range.startContainer, 580 offset: this.range.startOffset 581 }; 582 } else { 583 var start = this.clone().collapse().parent(); 584 var startRange = $.Range(start).select(start).collapse(); 585 startRange.move('END_TO_START', this); 586 return { 587 container: start, 588 offset: startRange.toString().length 589 }; 590 } 591 } else { 592 if (this.range.setStart) { 593 if (typeof set == 'number') { 594 this.range.setStart(this.range.startContainer, set); 595 } else if (typeof set == 'string') { 596 var res = callMove(this.range.startContainer, this.range.startOffset, parseInt(set, 10)); 597 this.range.setStart(res.node, res.offset); 598 } else { 599 this.range.setStart(set.container, set.offset); 600 } 601 } else { 602 if (typeof set == 'string') { 603 this.range.moveStart('character', parseInt(set, 10)); 604 } else { 605 var container = this.start().container, offset; 606 if (typeof set == 'number') { 607 offset = set; 608 } else { 609 container = set.container; 610 offset = set.offset; 611 } 612 var newPoint = $.Range(container).collapse(); 613 newPoint.range.move(offset); 614 this.move('START_TO_START', newPoint); 615 } 616 } 617 return this; 618 } 619 }, 620 end: function (set) { 621 if (set === undefined) { 622 if (this.range.startContainer) { 623 return { 624 container: this.range.endContainer, 625 offset: this.range.endOffset 626 }; 627 } else { 628 var end = this.clone().collapse(false).parent(), endRange = $.Range(end).select(end).collapse(); 629 endRange.move('END_TO_END', this); 630 return { 631 container: end, 632 offset: endRange.toString().length 633 }; 634 } 635 } else { 636 if (this.range.setEnd) { 637 if (typeof set == 'number') { 638 this.range.setEnd(this.range.endContainer, set); 639 } else if (typeof set == 'string') { 640 var res = callMove(this.range.endContainer, this.range.endOffset, parseInt(set, 10)); 641 this.range.setEnd(res.node, res.offset); 642 } else { 643 this.range.setEnd(set.container, set.offset); 644 } 645 } else { 646 if (typeof set == 'string') { 647 this.range.moveEnd('character', parseInt(set, 10)); 648 } else { 649 var container = this.end().container, offset; 650 if (typeof set == 'number') { 651 offset = set; 652 } else { 653 container = set.container; 654 offset = set.offset; 655 } 656 var newPoint = $.Range(container).collapse(); 657 newPoint.range.move(offset); 658 this.move('END_TO_START', newPoint); 659 } 660 } 661 return this; 662 } 663 }, 664 parent: function () { 665 if (this.range.commonAncestorContainer) { 666 return this.range.commonAncestorContainer; 667 } else { 668 var parentElement = this.range.parentElement(), range = this.range; 669 iterate(parentElement.childNodes, function (txtNode) { 670 if ($.Range(txtNode).range.inRange(range)) { 671 parentElement = txtNode; 672 return false;
673 } 674 }); 675 return parentElement; 676 } 677 }, 678 rect: function (from) { 679 var rect = this.range.getBoundingClientRect(); 680 if (!rect.height && !rect.width) { 681 rect = this.range.getClientRects()[0]; 682 } 683 if (from === 'page') { 684 var off = scrollOffset(); 685 rect = $.extend({}, rect); 686 rect.top += off.top; 687 rect.left += off.left; 688 } 689 return rect; 690 }, 691 rects: function (from) { 692 var rects = $.map($.makeArray(this.range.getClientRects()).sort(function (rect1, rect2) { 693 return rect2.width * rect2.height - rect1.width * rect1.height; 694 }), function (rect) { 695 return $.extend({}, rect); 696 }), i = 0, j, len = rects.length; 697 while (i < rects.length) { 698 var cur = rects[i], found = false; 699 j = i + 1; 700 while (j < rects.length) { 701 if (withinRect(cur, rects[j])) { 702 if (!rects[j].width) { 703 rects.splice(j, 1); 704 } else { 705 found = rects[j]; 706 break; 707 } 708 } else { 709 j++; 710 } 711 } 712 if (found) { 713 rects.splice(i, 1); 714 } else { 715 i++; 716 } 717 } 718 if (from == 'page') { 719 var off = scrollOffset(); 720 return $.each(rects, function (ith, item) { 721 item.top += off.top; 722 item.left += off.left; 723 }); 724 } 725 return rects; 726 } 727 }); 728 (function () { 729 var fn = $.Range.prototype, range = $.Range().range; 730 fn.compare = range.compareBoundaryPoints ? function (type, range) { 731 return this.range.compareBoundaryPoints(this.window().Range[reverse(type)], range.range); 732 } : function (type, range) { 733 return this.range.compareEndPoints(convertType(type), range.range); 734 }; 735 fn.move = range.setStart ? function (type, range) { 736 var rangesRange = range.range; 737 switch (type) { 738 case 'START_TO_END': 739 this.range.setStart(rangesRange.endContainer, rangesRange.endOffset); 740 break; 741 case 'START_TO_START': 742 this.range.setStart(rangesRange.startContainer, rangesRange.startOffset); 743 break; 744 case 'END_TO_END': 745 this.range.setEnd(rangesRange.endContainer, rangesRange.endOffset); 746 break; 747 case 'END_TO_START': 748 this.range.setEnd(rangesRange.startContainer, rangesRange.startOffset); 749 break; 750 } 751 return this; 752 } : function (type, range) { 753 this.range.setEndPoint(convertType(type), range.range); 754 return this; 755 }; 756 var cloneFunc = range.cloneRange ? 'cloneRange' : 'duplicate', selectFunc = range.selectNodeContents ? 'selectNodeContents' : 'moveToElementText'; 757 fn.clone = function () { 758 return $.Range(this.range[cloneFunc]()); 759 }; 760 fn.select = range.selectNodeContents ? function (el) { 761 if (!el) { 762 var selection = this.window().getSelection(); 763 selection.removeAllRanges(); 764 selection.addRange(this.range); 765 } else { 766 this.range.selectNodeContents(el); 767 } 768 return this; 769 } : function (el) { 770 if (!el) { 771 this.range.select(); 772 } else if (el.nodeType === 3) { 773 var parent = el.parentNode, start = 0, end; 774 iterate(parent.childNodes, function (txtNode) { 775 if (txtNode === el) { 776 end = start + txtNode.nodeValue.length; 777 return false;
778 } else { 779 start = start + txtNode.nodeValue.length; 780 } 781 }); 782 this.range.moveToElementText(parent); 783 this.range.moveEnd('character', end - this.range.text.length); 784 this.range.moveStart('character', start); 785 } else { 786 this.range.moveToElementText(el); 787 } 788 return this; 789 }; 790 }()); 791 var iterate = function (elems, cb) { 792 var elem, start; 793 for (var i = 0; elems[i]; i++) { 794 elem = elems[i]; 795 if (elem.nodeType === 3 || elem.nodeType === 4) { 796 if (cb(elem) === false) { 797 return false; 798 } 799 } else if (elem.nodeType !== 8) { 800 if (iterate(elem.childNodes, cb) === false) { 801 return false; 802 } 803 } 804 } 805 }, isText = function (node) { 806 return node.nodeType === 3 || node.nodeType === 4; 807 }, iteratorMaker = function (toChildren, toNext) { 808 return function (node, mustMoveRight) { 809 if (node[toChildren] && !mustMoveRight) { 810 return isText(node[toChildren]) ? node[toChildren] : arguments.callee(node[toChildren]); 811 } else if (node[toNext]) { 812 return isText(node[toNext]) ? node[toNext] : arguments.callee(node[toNext]); 813 } else if (node.parentNode) { 814 return arguments.callee(node.parentNode, true); 815 } 816 }; 817 }, getNextTextNode = iteratorMaker('firstChild', 'nextSibling'), getPrevTextNode = iteratorMaker('lastChild', 'previousSibling'), callMove = function (container, offset, howMany) { 818 var mover = howMany < 0 ? getPrevTextNode : getNextTextNode; 819 if (!isText(container)) {
820 container = container.childNodes[offset] ? container.childNodes[offset] : container.lastChild; 821 if (!isText(container)) { 822 container = mover(container); 823 } 824 return move(container, howMany); 825 } else { 826 if (offset + howMany < 0) { 827 return move(mover(container), offset + howMany); 828 } else { 829 return move(container, offset + howMany); 830 } 831 } 832 }, move = function (from, howMany) { 833 var mover = howMany < 0 ? getPrevTextNode : getNextTextNode; 834 howMany = Math.abs(howMany); 835 while (from && howMany >= from.nodeValue.length) { 836 howMany = howMany - from.nodeValue.length; 837 from = mover(from); 838 } 839 return { 840 node: from, 841 offset: mover === getNextTextNode ? howMany : from.nodeValue.length - howMany 842 }; 843 }, supportWhitespace, isWhitespace = function (el) { 844 if (supportWhitespace == null) { 845 supportWhitespace = 'isElementContentWhitespace' in el; 846 } 847 return supportWhitespace ? el.isElementContentWhitespace : el.nodeType === 3 && '' == el.data.trim(); 848 }, within = function (rect, point) { 849 return rect.left <= point.clientX && rect.left + rect.width >= point.clientX && rect.top <= point.clientY && rect.top + rect.height >= point.clientY; 850 }, withinRect = function (outer, inner) { 851 return within(outer, { 852 clientX: inner.left, 853 clientY: inner.top 854 }) && within(outer, { 855 clientX: inner.left + inner.width, 856 clientY: inner.top 857 }) && within(outer, { 858 clientX: inner.left, 859 clientY: inner.top + inner.height 860 }) && within(outer, { 861 clientX: inner.left + inner.width, 862 clientY: inner.top + inner.height 863 }); 864 }, scrollOffset = function (win) { 865 var win = win || window; 866 doc = win.document.documentElement, body = win.document.body; 867 return { 868 left: (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0), 869 top: (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientTop || 0) 870 }; 871 }; 872 support.moveToPoint = !!$.Range().range.moveToPoint; 873 return $; 874}); 875/*[email protected]#dom/selection/selection*/ 876define('jquerypp/dom/selection/selection', [ 877 'jquery', 878 'jquerypp/dom/range/range' 879], function ($) { 880 var getWindow = function (element) { 881 return element ? element.ownerDocument.defaultView || element.ownerDocument.parentWindow : window; 882 }, getElementsSelection = function (el, win) { 883 var current = $.Range.current(el).clone(), entireElement = $.Range(el).select(el); 884 if (!current.overlaps(entireElement)) { 885 return null; 886 } 887 if (current.compare('START_TO_START', entireElement) < 1) { 888 startPos = 0; 889 current.move('START_TO_START', entireElement); 890 } else { 891 fromElementToCurrent = entireElement.clone(); 892 fromElementToCurrent.move('END_TO_START', current); 893 startPos = fromElementToCurrent.toString().length; 894 } 895 if (current.compare('END_TO_END', entireElement) >= 0) { 896 endPos = entireElement.toString().length; 897 } else { 898 endPos = startPos + current.toString().length; 899 } 900 return { 901 start: startPos, 902 end: endPos, 903 width: endPos - startPos 904 }; 905 }, getSelection = function (el) { 906 var win = getWindow(el); 907 if (el.selectionStart !== undefined) { 908 if (document.activeElement && document.activeElement != el && el.selectionStart == el.selectionEnd && el.selectionStart == 0) { 909 return { 910 start: el.value.length, 911 end: el.value.length, 912 width: 0 913 }; 914 } 915 return { 916 start: el.selectionStart, 917 end: el.selectionEnd, 918 width: el.selectionEnd - el.selectionStart 919 }; 920 }
920 else if (win.getSelection) { 921 return getElementsSelection(el, win); 922 } else { 923 try { 924 if (el.nodeName.toLowerCase() == 'input') { 925 var real = getWindow(el).document.selection.createRange(), r = el.createTextRange(); 926 r.setEndPoint('EndToStart', real); 927 var start = r.text.length; 928 return { 929 start: start, 930 end: start + real.text.length, 931 width: real.text.length 932 }; 933 } else { 934 var res = getElementsSelection(el, win); 935 if (!res) { 936 return res; 937 } 938 var current = $.Range.current().clone(), r2 = current.clone().collapse().range, r3 = current.clone().collapse(false).range; 939 r2.moveStart('character', -1); 940 r3.moveStart('character', -1); 941 if (res.startPos != 0 && r2.text == '') { 942 res.startPos += 2; 943 } 944 if (res.endPos != 0 && r3.text == '') { 945 res.endPos += 2; 946 } 947 return res; 948 } 949 } catch (e) { 950 return { 951 start: el.value.length, 952 end: el.value.length, 953 width: 0 954 }; 955 } 956 } 957 }, select = function (el, start, end) { 958 var win = getWindow(el); 959 if (el.setSelectionRange) { 960 if (end === undefined) { 961 el.focus(); 962 el.setSelectionRange(start, start); 963 } else { 964 el.select(); 965 el.selectionStart = start; 966 el.selectionEnd = end; 967 } 968 } else if (el.createTextRange) { 969 var r = el.createTextRange(); 970 r.moveStart('character', start); 971 end = end || start; 972 r.moveEnd('character', end - el.value.length); 973 r.select(); 974 } else if (win.getSelection) { 975 var doc = win.document, sel = win.getSelection(), range = doc.createRange(), ranges = [ 976 start, 977 end !== undefined ? end : start 978 ]; 979 getCharElement([el], ranges); 980 range.setStart(ranges[0].el, ranges[0].count); 981 range.setEnd(ranges[1].el, ranges[1].count); 982 sel.removeAllRanges(); 983 sel.addRange(range); 984 } else if (win.document.body.createTextRange) { 985 var range = document.body.createTextRange(); 986 range.moveToElementText(el); 987 range.collapse(); 988 range.moveStart('character', start); 989 range.moveEnd('character', end !== undefined ? end : start); 990 range.select(); 991 } 992 }, replaceWithLess = function (start, len, range, el) { 993 if (typeof range[0] === 'number' && range[0] < len) { 994 range[0] = { 995 el: el, 996 count: range[0] - start 997 }; 998 } 999 if (typeof range[1] === 'number' && range[1] <= len) { 1000 range[1] = { 1001 el: el, 1002 count: range[1] - start 1003 }; 1004 ; 1005 } 1006 }, getCharElement = function (elems, range, len) { 1007 var elem, start; 1008 len = len || 0; 1009 for (var i = 0; elems[i]; i++) { 1010 elem = elems[i]; 1011 if (elem.nodeType === 3 || elem.nodeType === 4) { 1012 start = len; 1013 len += elem.nodeValue.length; 1014 replaceWithLess(start, len, range, elem); 1015 } else if (elem.nodeType !== 8) { 1016 len = getCharElement(elem.childNodes, range, len); 1017 } 1018 } 1019 return len; 1020 }; 1021 $.fn.selection = function (start, end) { 1022 if (start !== undefined) { 1023 return this.each(function () { 1024 select(this, start, end); 1025 }); 1026 } else { 1027 return getSelection(this[0]); 1028 } 1029 }; 1030 $.fn.selection.getCharElement = getCharElement; 1031 return $; 1032}); 1033/*[email protected]#dom/within/within*/ 1034define('jquerypp/dom/within/within', ['jquery'], function ($) { 1035 var withinBox = function (x, y, left, top, width, height) { 1036 return y >= top && y < top + height && x >= left && x < left + width; 1037 };
1038 $.fn.within = function (left, top, useOffsetCache) { 1039 var ret = []; 1040 this.each(function () { 1041 var q = jQuery(this); 1042 if (this == document.documentElement) { 1043 return ret.push(this); 1044 } 1045 var offset = useOffsetCache ? $.data(this, 'offsetCache') || $.data(this, 'offsetCache', q.offset()) : q.offset(); 1046 var res = withinBox(left, top, offset.left, offset.top, this.offsetWidth, this.offsetHeight); 1047 if (res) { 1048 ret.push(this); 1049 } 1050 }); 1051 return this.pushStack($.unique(ret), 'within', left + ',' + top); 1052 }; 1053 $.fn.withinBox = function (left, top, width, height, useOffsetCache) { 1054 var ret = []; 1055 this.each(function () { 1056 var q = jQuery(this); 1057 if (this == document.documentElement) 1058 return ret.push(this); 1059 var offset = useOffsetCache ? $.data(this, 'offset') || $.data(this, 'offset', q.offset()) : q.offset(); 1060 var ew = q.width(), eh = q.height(), res = !(offset.top > top + height || offset.top + eh < top || offset.left > left + width || offset.left + ew < left); 1061 if (res) 1062 ret.push(this); 1063 }); 1064 return this.pushStack($.unique(ret), 'withinBox', $.makeArray(arguments).join(',')); 1065 }; 1066 return $; 1067}); 1068/*[email protected]#event/removed/removed*/ 1069define('jquerypp/event/removed/removed', ['jquery'], function ($) { 1070 var oldClean = $.cleanData; 1071 $.cleanData = function (elems) { 1072 for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { 1073 $(elem).triggerHandler('removed'); 1074 } 1075 oldClean(elems); 1076 }; 1077 return $; 1078}); 1079/*[email protected]#lang/vector/vector*/ 1080define('jquerypp/lang/vector/vector', ['jquery'], function ($) { 1081 var getSetZero = function (v) { 1082 return v !== undefined ? this.array[0] = v : this.array[0]; 1083 }, getSetOne = function (v) { 1084 return v !== undefined ? this.array[1] = v : this.array[1]; 1085 }; 1086 $.Vector = function (arr) { 1087 var array = $.isArray(arr) ? arr : $.makeArray(arguments); 1088 this.update(array); 1089 }; 1090 $.Vector.prototype = { 1091 app: function (f) { 1092 var i, newArr = []; 1093 for (i = 0; i < this.array.length; i++) { 1094 newArr.push(f(this.array[i], i)); 1095 } 1096 return new $.Vector(newArr); 1097 }, 1098 plus: function () { 1099 var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments), arr = this.array.slice(0), vec = new $.Vector(); 1100 for (i = 0; i < args.length; i++) { 1101 arr[i] = (arr[i] ? arr[i] : 0) + args[i]; 1102 } 1103 return vec.update(arr); 1104 }, 1105 minus: function () { 1106 var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments), arr = this.array.slice(0), vec = new $.Vector(); 1107 for (i = 0; i < args.length; i++) { 1108 arr[i] = (arr[i] ? arr[i] : 0) - args[i]; 1109 } 1110 return vec.update(arr); 1111 }, 1112 equals: function () { 1113 var i, args = arguments[0] instanceof $.Vector ? arguments[0].array : $.makeArray(arguments), arr = this.array.slice(0), vec = new $.Vector(); 1114 for (i = 0; i < args.length; i++) { 1115 if (arr[i] != args[i]) { 1116 return null; 1117 } 1118 } 1119 return vec.update(arr); 1120 }, 1121 x: getSetZero, 1122 left: getSetZero, 1123 width: getSetZero, 1124 y: getSetOne, 1125 top: getSetOne, 1126 height: getSetOne, 1127 toString: function () { 1128 return '(' + this.array.join(', ') + ')'; 1129 }, 1130 update: function (array) { 1131 var i; 1132 if (this.array) { 1133 for (i = 0; i < this.array.length; i++) { 1134 delete this.array[i]; 1135 } 1136 } 1137 this.array = array; 1138 for (i = 0; i < array.length; i++) { 1139 this[i] = this.array[i]; 1140 } 1141 return this; 1142 } 1143 }; 1144 $.Event.prototype.vector = function () { 1145 var touches = 'ontouchend' in document && this.originalEvent.changedTouches && this.originalEvent.changedTouches.length ? this.originalEvent.changedTouches[0] : this; 1146 if (this.originalEvent.synthetic) { 1147 var doc = document.documentElement, body = document.body; 1148 return new $.Vector(touches.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0), touches.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0)); 1149 } else { 1150 return new $.Vector(touches.pageX, touches.pageY); 1151 } 1152 }; 1153 $.fn.offsetv = function () { 1154 if (this[0] == window) { 1155 return new $.Vector(window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft, window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop); 1156 } else { 1157 var offset = this.offset() || {}; 1158 return new $.Vector(offset.left, offset.top); 1159 } 1160 }; 1161 $.fn.dimensionsv = function (which) { 1162 if (this[0] == window || !which) { 1163 return new $.Vector(this.width(), this.height()); 1164 } else { 1165 return new $.Vector(this[which + 'Width'](), this[which + 'Height']()); 1166 } 1167 }; 1168 return $; 1169}); 1170/*[email protected]#event/livehack/livehack*/ 1171define('jquerypp/event/livehack/livehack', ['jquery'], function ($) { 1172 var event = $.event, findHelper = function (events, types, callback, selector) { 1173 var t, type, typeHandlers, all, h, handle, namespaces, namespace, match; 1174 for (t = 0; t < types.length; t++) { 1175 type = types[t]; 1176 all = type.indexOf('.') < 0; 1177 if (!all) { 1178 namespaces = type.split('.'); 1179 type = namespaces.shift(); 1180 namespace = new RegExp('(^|\\.)' + namespaces.slice(0).sort().join('\\.(?:.*\\.)?') + '(\\.|$)'); 1181 } 1182 typeHandlers = (events[type] || []).slice(0); 1183 for (h = 0; h < typeHandlers.length; h++) { 1184 handle = typeHandlers[h]; 1185 match = all || namespace.test(handle.namespace); 1186 if (match) { 1187 if (selector) { 1188 if (handle.selector === selector) { 1189 callback(type, handle.origHandler || handle.handler); 1190 } 1191 } else if (selector === null) { 1192 callback(type, handle.origHandler || handle.handler, handle.selector); 1193 } else if (!handle.selector) { 1194 callback(type, handle.origHandler || handle.handler); 1195 } 1196 } 1197 } 1198 } 1199 }; 1200 event.find = function (el, types, selector) { 1201 var events = ($._data(el) || {}).events, handlers = [], t, liver, live; 1202 if (!events) { 1203 return handlers; 1204 } 1205 findHelper(events, types, function (type, handler) { 1206 handlers.push(handler); 1207 }, selector); 1208 return handlers; 1209 }; 1210 event.findBySelector = function (el, types) { 1211 var events = $._data(el).events, selectors = {}, add = function (selector, event, handler) { 1212 var select = selectors[selector] || (selectors[selector] = {}), events = select[event] || (select[event] = []); 1213 events.push(handler); 1214 }; 1215 if (!events) { 1216 return selectors; 1217 } 1218 findHelper(events, types, function (type, handler, selector) { 1219 add(selector || '', type, handler); 1220 }, null); 1221 return selectors; 1222 }; 1223 event.supportTouch = 'ontouchend' in document; 1224 $.fn.respondsTo = function (events) { 1225 if (!this.length) { 1226 return false;
1227 } else { 1228 return event.find(this[0], $.isArray(events) ? events : [events]).length > 0; 1229 } 1230 }; 1231 $.fn.triggerHandled = function (event, data) { 1232 event = typeof event == 'string' ? $.Event(event) : event; 1233 this.trigger(event, data); 1234 return event.handled; 1235 }; 1236 event.setupHelper = function (types, startingEvent, onFirst) { 1237 if (!onFirst) { 1238 onFirst = startingEvent; 1239 startingEvent = null; 1240 } 1241 var add = function (handleObj) { 1242 var bySelector, selector = handleObj.selector || '', namespace = handleObj.namespace ? '.' + handleObj.namespace : ''; 1243 if (selector) { 1244 bySelector = event.find(this, types, selector); 1245 if (!bySelector.length) { 1246 $(this).delegate(selector, startingEvent + namespace, onFirst); 1247 } 1248 } else { 1249 if (!event.find(this, types, selector).length) { 1250 event.add(this, startingEvent + namespace, onFirst, { 1251 selector: selector, 1252 delegate: this 1253 }); 1254 } 1255 } 1256 }, remove = function (handleObj) { 1257 var bySelector, selector = handleObj.selector || ''; 1258 if (selector) { 1259 bySelector = event.find(this, types, selector); 1260 if (!bySelector.length) { 1261 $(this).undelegate(selector, startingEvent, onFirst); 1262 } 1263 } else { 1264 if (!event.find(this, types, selector).length) { 1265 event.remove(this, startingEvent, onFirst, { 1266 selector: selector, 1267 delegate: this 1268 }); 1269 } 1270 } 1271 }; 1272 $.each(types, function () { 1273 event.special[this] = { 1274 add: add, 1275 remove: remove, 1276 setup: function () { 1277 }, 1278 teardown: function () { 1279 } 1280 }; 1281 }); 1282 }; 1283 return $; 1284}); 1285/*[email protected]#event/reverse/reverse*/ 1286define('jquerypp/event/reverse/reverse', ['jquery'], function ($) { 1287 $.event.reverse = function (name, attributes) { 1288 var bound = $(), count = 0, dispatch = $.event.handle || $.event.dispatch; 1289 $.event.special[name] = { 1290 setup: function () { 1291 if (this !== window) { 1292 bound.push(this); 1293 $.unique(bound); 1294 } 1295 return this !== window; 1296 }, 1297 teardown: function () { 1298 bound = bound.not(this); 1299 return this !== window; 1300 }, 1301 add: function (handleObj) { 1302 var origHandler = handleObj.handler; 1303 handleObj.origHandler = origHandler; 1304 handleObj.handler = function (ev, data) { 1305 var isWindow = this === window; 1306 if (attributes && attributes.handler) { 1307 var result = attributes.handler.apply(this, arguments); 1308 if (result === true) { 1309 return; 1310 } 1311 } 1312 if (count === 0) { 1313 count++; 1314 var where = data === false ? ev.target : this; 1315 dispatch.call(where, ev, data); 1316 if (ev.isPropagationStopped()) { 1317 count--; 1318 return; 1319 } 1320 var index = bound.index(this), length = bound.length, child, sub; 1321 while (++index < length && (child = bound[index]) && (isWindow || $.contains(where, child))) { 1322 dispatch.call(child, ev, data); 1323 if (ev.isPropagationStopped()) { 1324 while (++index < length && (sub = bound[index])) { 1325 if (!$.contains(child, sub)) { 1326 index--; 1327 break; 1328 } 1329 } 1330 } 1331 } 1332 ev.stopImmediatePropagation(); 1333 count--; 1334 } else { 1335 handleObj.origHandler.call(this, ev, data); 1336 } 1337 }; 1338 } 1339 }; 1340 $([ 1341 document, 1342 window 1343 ]).bind(name, function () { 1344 }); 1345 return $.event.special[name]; 1346 }; 1347 return $; 1348}); 1349/*[email protected]#event/drag/core/core*/ 1350define('jquerypp/event/drag/core/core', [ 1351 'jquery', 1352 'jquerypp/lang/vector/vector', 1353 'jquerypp/event/livehack/livehack', 1354 'jquerypp/event/reverse/reverse' 1355], function ($) { 1356 if (!$.event.special.move) { 1357 $.event.reverse('move'); 1358 } 1359 var bind = function (object, method) { 1360 var args = Array.prototype.slice.call(arguments, 2); 1361 return function () { 1362 var args2 = [this].concat(args, $.makeArray(arguments)); 1363 return method.apply(object, args2); 1364 }; 1365 }, event = $.event, clearSelection = window.getSelection ? function () { 1366 window.getSelection().removeAllRanges(); 1367 } : function () { 1368 }, supportTouch = !window._phantom && 'ontouchend' in document, startEvent = supportTouch ? 'touchstart' : 'mousedown', stopEvent = supportTouch ? 'touchend' : 'mouseup', moveEvent = supportTouch ? 'touchmove' : 'mousemove', preventTouchScroll = function (ev) { 1369 ev.preventDefault(); 1370 }; 1371 $.Drag = function () { 1372 }; 1373 $.extend($.Drag, { 1374 lowerName: 'drag', 1375 current: null, 1376 distance: 0, 1377 mousedown: function (ev, element) { 1378 var isLeftButton = ev.button === 0 || ev.button == 1, doEvent = isLeftButton || supportTouch; 1379 if (!doEvent || this.current) { 1380 return; 1381 } 1382 var drag = new $.Drag(), delegate = ev.delegateTarget || element, selector = ev.handleObj.selector, self = this; 1383 this.current = drag; 1384 drag.setup({ 1385 element: element, 1386 delegate: ev.delegateTarget || element, 1387 selector: ev.handleObj.selector, 1388 moved: false, 1389 _distance: this.distance, 1390 callbacks: { 1391 dragdown: event.find(delegate, ['dragdown'], selector), 1392 draginit: event.find(delegate, ['draginit'], selector), 1393 dragover: event.find(delegate, ['dragover'], selector), 1394 dragmove: event.find(delegate, ['dragmove'], selector), 1395 dragout: event.find(delegate, ['dragout'], selector), 1396 dragend: event.find(delegate, ['dragend'], selector), 1397 dragcleanup: event.find(delegate, ['dragcleanup'], selector) 1398 }, 1399 destroyed: function () { 1400 self.current = null; 1401 } 1402 }, ev); 1403 } 1404 }); 1405 $.extend($.Drag.prototype, { 1406 setup: function (options, ev) { 1407 $.extend(this, options); 1408 this.element = $(this.element); 1409 this.event = ev; 1410 this.moved = false;
1411 this.allowOtherDrags = false; 1412 var mousemove = bind(this, this.mousemove), mouseup = bind(this, this.mouseup); 1413 this._mousemove = mousemove; 1414 this._mouseup = mouseup; 1415 this._distance = options.distance ? options.distance : 0; 1416 this.mouseStartPosition = ev.vector(); 1417 $(document).bind(moveEvent, mousemove); 1418 $(document).bind(stopEvent, mouseup); 1419 if (supportTouch) { 1420 $(document).bind(moveEvent, preventTouchScroll); 1421 } 1422 if (!this.callEvents('down', this.element, ev)) { 1423 this.noSelection(this.delegate); 1424 clearSelection(); 1425 } 1426 }, 1427 destroy: function () { 1428 $(document).unbind(moveEvent, this._mousemove); 1429 $(document).unbind(stopEvent, this._mouseup); 1430 if (supportTouch) { 1431 $(document).unbind(moveEvent, preventTouchScroll); 1432 } 1433 if (!this.moved) { 1434 this.event = this.element = null; 1435 } 1436 if (!supportTouch) { 1437 this.selection(this.delegate); 1438 } 1439 this.destroyed(); 1440 }, 1441 mousemove: function (docEl, ev) { 1442 if (!this.moved) { 1443 var dist = Math.sqrt(Math.pow(ev.pageX - this.event.pageX, 2) + Math.pow(ev.pageY - this.event.pageY, 2)); 1444 if (dist < this._distance) { 1445 return false; 1446 } 1447 this.init(this.element, ev); 1448 this.moved = true; 1449 } 1450 this.element.trigger('move', this); 1451 var pointer = ev.vector(); 1452 if (this._start_position && this._start_position.equal(pointer)) { 1453 return; 1454 } 1455 this.draw(pointer, ev); 1456 }, 1457 mouseup: function (docEl, event) { 1458 if (this.moved) { 1459 this.end(event); 1460 } 1461 this.destroy(); 1462 }, 1463 noSelection: function (elm) { 1464 elm = elm || this.delegate; 1465 document.documentElement.onselectstart = function () { 1466 return false; 1467 }; 1468 document.documentElement.unselectable = 'on'; 1469 this.selectionDisabled = this.selectionDisabled ? this.selectionDisabled.add(elm) : $(elm); 1470 this.selectionDisabled.css('-moz-user-select', '-moz-none'); 1471 }, 1472 selection: function () { 1473 if (this.selectionDisabled) { 1474 document.documentElement.onselectstart = function () { 1475 }; 1476 document.documentElement.unselectable = 'off'; 1477 this.selectionDisabled.css('-moz-user-select', ''); 1478 } 1479 }, 1480 init: function (element, event) { 1481 element = $(element); 1482 var startElement = this.movingElement = this.element = $(element); 1483 this._cancelled = false; 1484 this.event = event; 1485 this.mouseElementPosition = this.mouseStartPosition.minus(this.element.offsetv()); 1486 this.callEvents('init', element, event); 1487 if (this._cancelled === true) { 1488 return; 1489 } 1490 this.startPosition = startElement != this.movingElement ? this.movingElement.offsetv() : this.currentDelta(); 1491 this.makePositioned(this.movingElement); 1492 this.oldZIndex = this.movingElement.css('zIndex'); 1493 this.movingElement.css('zIndex', 1000); 1494 if (!this._only && this.constructor.responder) { 1495 this.constructor.responder.compile(event, this); 1496 } 1497 }, 1498 makePositioned: function (that) { 1499 var style, pos = that.css('position'); 1500 if (!pos || pos == 'static') { 1501 style = { position: 'relative' }; 1502 if (window.opera) { 1503 style.top = '0px'; 1504 style.left = '0px'; 1505 } 1506 that.css(style); 1507 } 1508 }, 1509 callEvents: function (type, element, event, drop) { 1510 var i, cbs = this.callbacks[this.constructor.lowerName + type]; 1511 for (i = 0; i < cbs.length; i++) { 1512 cbs[i].call(element, event, this, drop); 1513 } 1514 return cbs.length; 1515 }, 1516 currentDelta: function () { 1517 return new $.Vector(parseInt(this.movingElement.css('left'), 10) || 0, parseInt(this.movingElement.css('top'), 10) || 0); 1518 }, 1519 draw: function (pointer, event) { 1520 if (this._cancelled) { 1521 return; 1522 } 1523 clearSelection(); 1524 this.location = pointer.minus(this.mouseElementPosition); 1525 this.move(event); 1526 if (this._cancelled) { 1527 return; 1528 } 1529 if (!event.isDefaultPrevented()) { 1530 this.position(this.location); 1531 } 1532 if (!this._only && this.constructor.responder) { 1533 this.constructor.responder.show(pointer, this, event); 1534 } 1535 }, 1536 position: function (newOffsetv) { 1537 var style, dragged_element_css_offset = this.currentDelta(), dragged_element_position_vector = this.movingElement.offsetv().minus(dragged_element_css_offset); 1538 this.required_css_position = newOffsetv.minus(dragged_element_position_vector); 1539 this.offsetv = newOffsetv; 1540 style = this.movingElement[0].style; 1541 if (!this._cancelled && !this._horizontal) { 1542 style.top = this.required_css_position.top() + 'px'; 1543 } 1544 if (!this._cancelled && !this._vertical) { 1545 style.left = this.required_css_position.left() + 'px'; 1546 } 1547 }, 1548 move: function (event) { 1549 this.callEvents('move', this.element, event); 1550 }, 1551 over: function (event, drop) { 1552 this.callEvents('over', this.element, event, drop); 1553 }, 1554 out: function (event, drop) { 1555 this.callEvents('out', this.element, event, drop); 1556 }, 1557 end: function (event) { 1558 if (this._cancelled) { 1559 return; 1560 } 1561 if (!this._only && this.constructor.responder) { 1562 this.constructor.responder.end(event, this); 1563 } 1564 this.callEvents('end', this.element, event); 1565 if (this._revert) { 1566 var self = this; 1567 this.movingElement.animate({ 1568 top: this.startPosition.top() + 'px', 1569 left: this.startPosition.left() + 'px' 1570 }, function () { 1571 self.cleanup.apply(self, arguments); 1572 }); 1573 } else { 1574 this.cleanup(event); 1575 } 1576 this.event = null; 1577 }, 1578 cleanup: function (event) { 1579 this.movingElement.css({ zIndex: this.oldZIndex }); 1580 if (this.movingElement[0] !== this.element[0] && !this.movingElement.has(this.element[0]).length && !this.element.has(this.movingElement[0]).length) { 1581 this.movingElement.css({ display: 'none' }); 1582 } 1583 if (this._removeMovingElement) { 1584 this.movingElement.remove(); 1585 } 1586 if (event) { 1587 this.callEvents('cleanup', this.element, event); 1588 } 1589 this.movingElement = this.element = this.event = null; 1590 }, 1591 cancel: function () { 1592 this._cancelled = true; 1593 if (!this._only && this.constructor.responder) { 1594 this.constructor.responder.clear(this.event.vector(), this, this.event); 1595 } 1596 this.destroy(); 1597 }, 1598 ghost: function (parent) { 1599 var ghost = this.movingElement.clone().css('position', 'absolute'); 1600 if (parent) { 1601 $(parent).append(ghost); 1602 } else { 1603 $(this.movingElement).after(ghost); 1604 } 1605 ghost.width(this.movingElement.width()).height(this.movingElement.height()); 1606 ghost.offset(this.movingElement.offset()); 1607 this.movingElement = ghost; 1608 this.noSelection(ghost); 1609 this._removeMovingElement = true; 1610 return ghost; 1611 }, 1612 representative: function (element, offsetX, offsetY) { 1613 this._offsetX = offsetX || 0; 1614 this._offsetY = offsetY || 0; 1615 var p = this.mouseStartPosition; 1616 this.movingElement = $(element); 1617 this.movingElement.css({ 1618 top: p.y() - this._offsetY + 'px', 1619 left: p.x() - this._offsetX + 'px', 1620 display: 'block', 1621 position: 'absolute' 1622 }).show(); 1623 this.noSelection(this.movingElement); 1624 this.mouseElementPosition = new $.Vector(this._offsetX, this._offsetY); 1625 return this; 1626 }, 1627 revert: function (val) { 1628 this._revert = val === undefined ? true : val; 1629 return this; 1630 }, 1631 vertical: function () { 1632 this._vertical = true; 1633 return this; 1634 }, 1635 horizontal: function () { 1636 this._horizontal = true; 1637 return this; 1638 }, 1639 only: function (only) { 1640 return this._only = only === undefined ? true : only; 1641 }, 1642 distance: function (val) { 1643 if (val !== undefined) { 1644 this._distance = val; 1645 return this; 1646 } else { 1647 return this._distance; 1648 } 1649 } 1650 }); 1651 event.setupHelper([ 1652 'dragdown', 1653 'draginit', 1654 'dragover', 1655 'dragmove', 1656 'dragout', 1657 'dragend', 1658 'dragcleanup' 1659 ], startEvent, function (e) { 1660 $.Drag.mousedown.call($.Drag, e, this); 1661 }); 1662 return $; 1663}); 1664/*[email protected]#event/drag/step/step*/ 1665define('jquerypp/event/drag/step/step', [ 1666 'jquery', 1667 'jquerypp/event/drag/core/core' 1668], function ($) { 1669 var round = function (x, m) { 1670 return Math.round(x / m) * m; 1671 }; 1672 $.Drag.prototype.step = function (amount, container, center) { 1673 if (typeof amount == 'number') { 1674 amount = { 1675 x: amount, 1676 y: amount
1677 }; 1678 } 1679 container = container || $(document.body); 1680 this._step = amount; 1681 var styles = container.css([ 1682 'borderTopWidth', 1683 'paddingTop', 1684 'borderLeftWidth', 1685 'paddingLeft' 1686 ]); 1687 var top = parseInt(styles.borderTopWidth) + parseInt(styles.paddingTop), left = parseInt(styles.borderLeftWidth) + parseInt(styles.paddingLeft); 1688 this._step.offset = container.offsetv().plus(left, top); 1689 this._step.center = center; 1690 return this; 1691 }; 1692 (function () { 1693 var oldPosition = $.Drag.prototype.position; 1694 $.Drag.prototype.position = function (offsetPositionv) { 1695 if (this._step) { 1696 var step = this._step, center = step.center && step.center.toLowerCase(), movingSize = this.movingElement.dimensionsv('outer'), lot = step.offset.top() - (center && center != 'x' ? movingSize.height() / 2 : 0), lof = step.offset.left() - (center && center != 'y' ? movingSize.width() / 2 : 0); 1697 if (this._step.x) { 1698 offsetPositionv.left(Math.round(lof + round(offsetPositionv.left() - lof, this._step.x))); 1699 } 1700 if (this._step.y) { 1701 offsetPositionv.top(Math.round(lot + round(offsetPositionv.top() - lot, this._step.y))); 1702 } 1703 } 1704 oldPosition.call(this, offsetPositionv); 1705 }; 1706 }()); 1707 return $; 1708}); 1709/*[email protected]#event/drag/limit/limit*/ 1710define('jquerypp/event/drag/limit/limit', [ 1711 'jquery', 1712 'jquerypp/event/drag/core/core' 1713], function ($) { 1714 $.Drag.prototype.limit = function (container, center) { 1715 var styles = container.css([ 1716 'borderTopWidth', 1717 'paddingTop', 1718 'borderLeftWidth', 1719 'paddingLeft' 1720 ]), paddingBorder = new $.Vector(parseInt(styles.borderLeftWidth, 10) + parseInt(styles.paddingLeft, 10) || 0, parseInt(styles.borderTopWidth, 10) + parseInt(styles.paddingTop, 10) || 0); 1721 this._limit = { 1722 offset: container.offsetv().plus(paddingBorder), 1723 size: container.dimensionsv(), 1724 center: center === true ? 'both' : center 1725 }; 1726 return this; 1727 }; 1728 var oldPosition = $.Drag.prototype.position; 1729 $.Drag.prototype.position = function (offsetPositionv) { 1730 if (this._limit) { 1731 var limit = this._limit, center = limit.center && limit.center.toLowerCase(), movingSize = this.movingElement.dimensionsv('outer'), halfHeight = center && center != 'x' ? movingSize.height() / 2 : 0, halfWidth = center && center != 'y' ? movingSize.width() / 2 : 0, lot = limit.offset.top(), lof = limit.offset.left(), height = limit.size.height(), width = limit.size.width(); 1732 if (offsetPositionv.top() + halfHeight < lot) { 1733 offsetPositionv.top(lot - halfHeight); 1734 } 1735 if (offsetPositionv.top() + movingSize.height() - halfHeight > lot + height) { 1736 offsetPositionv.top(lot + height - movingSize.height() + halfHeight); 1737 } 1738 if (offsetPositionv.left() + halfWidth < lof) { 1739 offsetPositionv.left(lof - halfWidth); 1740 } 1741 if (offsetPositionv.left() + movingSize.width() - halfWidth > lof + width) { 1742 offsetPositionv.left(lof + width - movingSize.left() + halfWidth); 1743 } 1744 } 1745 oldPosition.call(this, offsetPositionv); 1746 }; 1747 return $; 1748}); 1749/*[email protected]#event/drop/drop*/ 1750define('jquerypp/event/drop/drop', [ 1751 'jquery', 1752 'jquerypp/event/drag/core/core', 1753 'jquerypp/dom/within/within', 1754 'jquerypp/dom/compare/compare' 1755], function ($) { 1756 var event = $.event; 1757 var eventNames = [ 1758 'dropover', 1759 'dropon', 1760 'dropout', 1761 'dropinit', 1762 'dropmove', 1763 'dropend' 1764 ]; 1765 $.Drop = function (callbacks, element) { 1766 $.extend(this, callbacks); 1767 this.element = $(element); 1768 }; 1769 $.each(eventNames, function () { 1770 event.special[this] = { 1771 add: function (handleObj) { 1772 var el = $(this), current = el.data('dropEventCount') || 0; 1773 el.data('dropEventCount', current + 1); 1774 if (current == 0) { 1775 $.Drop.addElement(this); 1776 } 1777 }, 1778 remove: function () { 1779 var el = $(this), current = el.data('dropEventCount') || 0; 1780 el.data('dropEventCount', current - 1); 1781 if (current <= 1) { 1782 $.Drop.removeElement(this); 1783 } 1784 } 1785 }; 1786 }); 1787 $.extend($.Drop, { 1788 lowerName: 'drop', 1789 _rootElements: [], 1790 _elements: $(), 1791 last_active: [], 1792 endName: 'dropon', 1793 addElement: function (el) { 1794 for (var i = 0; i < this._rootElements.length; i++) { 1795 if (el == this._rootElements[i]) 1796 return; 1797 } 1798 this._rootElements.push(el); 1799 }, 1800 removeElement: function (el) { 1801 for (var i = 0; i < this._rootElements.length; i++) { 1802 if (el == this._rootElements[i]) { 1803 this._rootElements.splice(i, 1); 1804 return; 1805 } 1806 } 1807 }, 1808 sortByDeepestChild: function (a, b) { 1809 var compare = a.element.compare(b.element); 1810 if (compare & 16 || compare & 4) 1811 return 1; 1812 if (compare & 8 || compare & 2) 1813 return -1; 1814 return 0; 1815 }, 1816 isAffected: function (point, moveable, responder) { 1817 return responder.element != moveable.element && responder.element.within(point[0], point[1], responder._cache).length == 1; 1818 }, 1819 deactivate: function (responder, mover, event) { 1820 mover.out(event, responder); 1821 responder.callHandlers(this.lowerName + 'out', responder.element[0], event, mover); 1822 }, 1823 activate: function (responder, mover, event) { 1824 mover.over(event, responder); 1825 responder.callHandlers(this.lowerName + 'over', responder.element[0], event, mover); 1826 }, 1827 move: function (responder, mover, event) { 1828 responder.callHandlers(this.lowerName + 'move', responder.element[0], event, mover); 1829 }, 1830 compile: function (event, drag) { 1831 if (!this.dragging && !drag) { 1832 return; 1833 } else if (!this.dragging) { 1834 this.dragging = drag; 1835 this.last_active = []; 1836 } 1837 var el, drops, selector, dropResponders, newEls = [], dragging = this.dragging; 1838 for (var i = 0; i < this._rootElements.length; i++) { 1839 el = this._rootElements[i]; 1840 var drops = $.event.findBySelector(el, eventNames); 1841 for (selector in drops) { 1842 dropResponders = selector ? jQuery(selector, el) : [el]; 1843 for (var e = 0; e < dropResponders.length; e++) { 1844 if (this.addCallbacks(dropResponders[e], drops[selector], dragging)) { 1845 newEls.push(dropResponders[e]); 1846 } 1847 ; 1848 } 1849 } 1850 } 1851 this.add(newEls, event, dragging); 1852 }, 1853 addCallbacks: function (el, callbacks, onlyNew) { 1854 var origData = $.data(el, '_dropData'); 1855 if (!origData) { 1856 $.data(el, '_dropData', new $.Drop(callbacks, el)); 1857 return true; 1858 } else if (!onlyNew) { 1859 var origCbs = origData; 1860 for (var eventName in callbacks) { 1861 origCbs[eventName] = origCbs[eventName] ? origCbs[eventName].concat(callbacks[eventName]) : callbacks[eventName]; 1862 } 1863 return false;
1864 } 1865 }, 1866 add: function (newEls, event, drag, dragging) { 1867 var i = 0, drop; 1868 while (i < newEls.length) { 1869 drop = $.data(newEls[i], '_dropData'); 1870 drop.callHandlers(this.lowerName + 'init', newEls[i], event, drag); 1871 if (drop._canceled) { 1872 newEls.splice(i, 1); 1873 } else { 1874 i++; 1875 } 1876 } 1877 this._elements.push.apply(this._elements, newEls); 1878 }, 1879 show: function (point, moveable, event) { 1880 var element = moveable.element; 1881 if (!this._elements.length) 1882 return; 1883 var respondable, affected = [], propagate = true, i = 0, j, la, toBeActivated, aff, oldLastActive = this.last_active, responders = [], self = this, drag; 1884 while (i < this._elements.length) { 1885 drag = $.data(this._elements[i], '_dropData'); 1886 if (!drag) { 1887 this._elements.splice(i, 1); 1888 } else { 1889 i++; 1890 if (self.isAffected(point, moveable, drag)) { 1891 affected.push(drag); 1892 } 1893 } 1894 } 1895 affected.sort(this.sortByDeepestChild); 1896 event.stopRespondPropagate = function () { 1897 propagate = false; 1898 }; 1899 toBeActivated = affected.slice(); 1900 this.last_active = affected; 1901 for (j = 0; j < oldLastActive.length; j++) { 1902 la = oldLastActive[j]; 1903 i = 0; 1904 while (aff = toBeActivated[i]) { 1905 if (la == aff) { 1906 toBeActivated.splice(i, 1); 1907 break; 1908 } else { 1909 i++; 1910 } 1911 } 1912 if (!aff) { 1913 this.deactivate(la, moveable, event); 1914 } 1915 if (!propagate) 1916 return; 1917 } 1918 for (var i = 0; i < toBeActivated.length; i++) { 1919 this.activate(toBeActivated[i], moveable, event); 1920 if (!propagate) 1921 return; 1922 } 1923 for (i = 0; i < affected.length; i++) { 1924 this.move(affected[i], moveable, event); 1925 if (!propagate) 1926 return; 1927 } 1928 }, 1929 end: function (event, moveable) { 1930 var la, endName = this.lowerName + 'end', onEvent = $.Event(this.endName, event), dropData; 1931 for (var i = 0; i < this.last_active.length; i++) { 1932 la = this.last_active[i]; 1933 if (this.isAffected(event.vector(), moveable, la) && la[this.endName]) { 1934 la.callHandlers(this.endName, null, onEvent, moveable); 1935 } 1936 if (onEvent.isPropagationStopped()) { 1937 break; 1938 } 1939 } 1940 for (var r = 0; r < this._elements.length; r++) { 1941 dropData = $.data(this._elements[r], '_dropData'); 1942 dropData && dropData.callHandlers(endName, null, event, moveable); 1943 } 1944 this.clear(); 1945 }, 1946 clear: function () { 1947 this._elements.each(function () { 1948 $.removeData(this, '_dropData'); 1949 }); 1950 this._elements = $(); 1951 delete this.dragging; 1952 } 1953 }); 1954 $.Drag.responder = $.Drop; 1955 $.extend($.Drop.prototype, { 1956 callHandlers: function (method, el, ev, drag) { 1957 var length = this[method] ? this[method].length : 0; 1958 for (var i = 0; i < length; i++) { 1959 this[method][i].call(el || this.element[0], ev, this, drag); 1960 } 1961 }, 1962 cache: function (value) { 1963 this._cache = value != null ? value : true; 1964 }, 1965 cancel: function () { 1966 this._canceled = true; 1967 } 1968 }); 1969 return $; 1970}); 1971/*[email protected]#event/drag/scroll/scroll*/ 1972define('jquerypp/event/drag/scroll/scroll', [ 1973 'jquery', 1974 'jquerypp/event/drop/drop' 1975], function ($) { 1976 $.Drag.prototype.scrolls = function (elements, options) { 1977 var elements = $(elements); 1978 for (var i = 0; i < elements.length; i++) { 1979 this.constructor.responder._elements.push(elements.eq(i).data('_dropData', new $.Scrollable(elements[i], options))[0]); 1980 } 1981 }, $.Scrollable = function (element, options) { 1982 this.element = jQuery(element); 1983 this.options = $.extend({ 1984 distance: 30, 1985 delta: function (diff, distance) { 1986 return (distance - diff) / 2; 1987 }, 1988 direction: 'xy', 1989 delay: 15 1990 }, options); 1991 this.x = this.options.direction.indexOf('x') != -1; 1992 this.y = this.options.direction.indexOf('y') != -1; 1993 }; 1994 $.extend($.Scrollable.prototype, { 1995 init: function (element) { 1996 this.element = jQuery(element); 1997 }, 1998 callHandlers: function (method, el, ev, drag) { 1999 this[method](el || this.element[0], ev, this, drag); 2000 }, 2001 dropover: function () { 2002 }, 2003 dropon: function () { 2004 this.clear_timeout(); 2005 }, 2006 dropout: function () { 2007 this.clear_timeout(); 2008 }, 2009 dropinit: function () { 2010 }, 2011 dropend: function () { 2012 }, 2013 clear_timeout: function () { 2014 if (this.interval) { 2015 clearTimeout(this.interval); 2016 this.interval = null; 2017 } 2018 }, 2019 distance: function (diff) { 2020 return (30 - diff) / 2; 2021 }, 2022 dropmove: function (el, ev, drop, drag) { 2023 this.clear_timeout(); 2024 var mouse = ev.vector(), location_object = $(el == document.documentElement ? window : el), dimensions = location_object.dimensionsv('outer'), position = location_object.offsetv(), bottom = position.y() + dimensions.y() - mouse.y(), top = mouse.y() - position.y(), right = position.x() + dimensions.x() - mouse.x(), left = mouse.x() - position.x(), dx = 0, dy = 0, distance = this.options.distance; 2025 if (bottom < distance && this.y) { 2026 dy = this.options.delta(bottom, distance); 2027 } else if (top < distance && this.y) { 2028 dy = -this.options.delta(top, distance); 2029 } 2030 if (right < distance && this.options && this.x) { 2031 dx = this.options.delta(right, distance); 2032 } else if (left < distance && this.x) { 2033 dx = -this.options.delta(left, distance); 2034 } 2035 if (dx || dy) { 2036 var self = this; 2037 this.interval = setTimeout(function () { 2038 self.move($(el), drag.movingElement, dx, dy, ev, ev.clientX, ev.clientY, ev.screenX, ev.screenY); 2039 }, this.options.delay); 2040 } 2041 }, 2042 move: function (scroll_element, drag_element, dx, dy, ev) { 2043 scroll_element.scrollTop(scroll_element.scrollTop() + dy); 2044 scroll_element.scrollLeft(scroll_element.scrollLeft() + dx); 2045 drag_element.trigger($.event.fix({ 2046 type: 'mousemove', 2047 clientX: ev.clientX, 2048 clientY: ev.clientY, 2049 screenX: ev.screenX, 2050 screenY: ev.screenY, 2051 pageX: ev.pageX, 2052 pageY: ev.pageY 2053 })); 2054 } 2055 }); 2056 return $; 2057}); 2058/*[email protected]#event/drag/drag*/ 2059define('jquerypp/event/drag/drag', [ 2060 'jquery', 2061 'jquerypp/event/drag/core/core', 2062 'jquerypp/event/drag/step/step', 2063 'jquerypp/event/drag/limit/limit', 2064 'jquerypp/event/drag/scroll/scroll' 2065], function ($) { 2066 return $; 2067}); 2068/*[email protected]#event/hover/hover*/ 2069define('jquerypp/event/hover/hover', [ 2070 'jquery', 2071 'jquerypp/event/livehack/livehack' 2072], function ($) { 2073 $.Hover = function () {
2074 this._delay = $.Hover.delay; 2075 this._distance = $.Hover.distance; 2076 this._leave = $.Hover.leave; 2077 }; 2078 $.extend($.Hover, { 2079 delay: 100, 2080 distance: 10, 2081 leave: 0 2082 }); 2083 $.extend($.Hover.prototype, { 2084 delay: function (delay) { 2085 this._delay = delay; 2086 return this; 2087 }, 2088 distance: function (distance) { 2089 this._distance = distance; 2090 return this; 2091 }, 2092 leave: function (leave) { 2093 this._leave = leave; 2094 return this; 2095 } 2096 }); 2097 var event = $.event, handle = event.handle, onmouseenter = function (ev) { 2098 var delegate = ev.delegateTarget || ev.currentTarget; 2099 var selector = ev.handleObj.selector; 2100 var pending = $.data(delegate, '_hover' + selector); 2101 if (pending) { 2102 if (!pending.forcing) { 2103 pending.forcing = true; 2104 clearTimeout(pending.leaveTimer); 2105 var leaveTime = pending.leaving ? Math.max(0, pending.hover.leave - (new Date() - pending.leaving)) : pending.hover.leave; 2106 var self = this; 2107 setTimeout(function () { 2108 pending.callHoverLeave(); 2109 onmouseenter.call(self, ev); 2110 }, leaveTime); 2111 } 2112 return; 2113 } 2114 var loc = { 2115 pageX: ev.pageX, 2116 pageY: ev.pageY 2117 }, dist = 0, timer, enteredEl = this, hovered = false, lastEv = ev, hover = new $.Hover(), leaveTimer, callHoverLeave = function () { 2118 $.each(event.find(delegate, ['hoverleave'], selector), function () { 2119 this.call(enteredEl, ev, hover); 2120 }); 2121 cleanUp(); 2122 }, mousemove = function (ev) { 2123 clearTimeout(leaveTimer); 2124 dist += Math.pow(ev.pageX - loc.pageX, 2) + Math.pow(ev.pageY - loc.pageY, 2); 2125 loc = { 2126 pageX: ev.pageX, 2127 pageY: ev.pageY 2128 }; 2129 lastEv = ev; 2130 }, mouseleave = function (ev) { 2131 clearTimeout(timer); 2132 if (hovered) { 2133 if (hover._leave === 0) { 2134 callHoverLeave(); 2135 } else { 2136 clearTimeout(leaveTimer); 2137 pending.leaving = new Date(); 2138 leaveTimer = pending.leaveTimer = setTimeout(function () { 2139 callHoverLeave(); 2140 }, hover._leave); 2141 } 2142 } else { 2143 cleanUp(); 2144 } 2145 }, cleanUp = function () { 2146 $(enteredEl).unbind('mouseleave', mouseleave); 2147 $(enteredEl).unbind('mousemove', mousemove); 2148 $.removeData(delegate, '_hover' + selector); 2149 }, hoverenter = function () { 2150 $.each(event.find(delegate, ['hoverenter'], selector), function () { 2151 this.call(enteredEl, lastEv, hover); 2152 }); 2153 hovered = true; 2154 }; 2155 pending = { 2156 callHoverLeave: callHoverLeave, 2157 hover: hover 2158 }; 2159 $.data(delegate, '_hover' + selector, pending); 2160 $(enteredEl).bind('mousemove', mousemove).bind('mouseleave', mouseleave); 2161 $.each(event.find(delegate, ['hoverinit'], selector), function () { 2162 this.call(enteredEl, ev, hover); 2163 }); 2164 if (hover._delay === 0) { 2165 hoverenter(); 2166 } else { 2167 timer = setTimeout(function () { 2168 if (dist < hover._distance && $(enteredEl).queue().length == 0) { 2169 hoverenter(); 2170 return; 2171 } else { 2172 dist = 0; 2173 timer = setTimeout(arguments.callee, hover._delay); 2174 } 2175 }, hover._delay); 2176 } 2177 }; 2178 event.setupHelper([ 2179 'hoverinit', 2180 'hoverenter', 2181 'hoverleave', 2182 'hovermove' 2183 ], 'mouseenter', onmouseenter); 2184 return $; 2185}); 2186/*[email protected]#event/key/key*/ 2187define('jquerypp/event/key/key', ['jquery'], function ($) { 2188 var uaMatch = function (ua) { 2189 ua = ua.toLowerCase(); 2190 var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || []; 2191 return { 2192 browser: match[1] || '', 2193 version: match[2] || '0' 2194 }; 2195 }; 2196 var keymap = {}, reverseKeyMap = {}, currentBrowser = uaMatch(navigator.userAgent).browser; 2197 $.event.key = function (browser, map) { 2198 if (browser === undefined) { 2199 return keymap; 2200 } 2201 if (map === undefined) { 2202 map = browser; 2203 browser = currentBrowser; 2204 } 2205 if (!keymap[browser]) { 2206 keymap[browser] = {}; 2207 } 2208 $.extend(keymap[browser], map); 2209 if (!reverseKeyMap[browser]) { 2210 reverseKeyMap[browser] = {}; 2211 } 2212 for (var name in map) { 2213 reverseKeyMap[browser][map[name]] = name; 2214 } 2215 }; 2216 $.event.key({ 2217 '\b': '8', 2218 '\t': '9', 2219 '\r': '13', 2220 'shift': '16', 2221 'ctrl': '17', 2222 'alt': '18', 2223 'pause-break': '19', 2224 'caps': '20', 2225 'escape': '27', 2226 'num-lock': '144', 2227 'scroll-lock': '145', 2228 'print': '44', 2229 'page-up': '33', 2230 'page-down': '34', 2231 'end': '35', 2232 'home': '36', 2233 'left': '37', 2234 'up': '38', 2235 'right': '39', 2236 'down': '40', 2237 'insert': '45', 2238 'delete': '46', 2239 ' ': '32', 2240 '0': '48', 2241 '1': '49', 2242 '2': '50', 2243 '3': '51', 2244 '4': '52', 2245 '5': '53', 2246 '6': '54', 2247 '7': '55', 2248 '8': '56', 2249 '9': '57', 2250 'a': '65', 2251 'b': '66', 2252 'c': '67', 2253 'd': '68', 2254 'e': '69', 2255 'f': '70', 2256 'g': '71', 2257 'h': '72', 2258 'i': '73', 2259 'j': '74', 2260 'k': '75', 2261 'l': '76', 2262 'm': '77', 2263 'n': '78', 2264 'o': '79', 2265 'p': '80', 2266 'q': '81', 2267 'r': '82', 2268 's': '83', 2269 't': '84', 2270 'u': '85', 2271 'v': '86', 2272 'w': '87', 2273 'x': '88', 2274 'y': '89', 2275 'z': '90', 2276 'num0': '96', 2277 'num1': '97', 2278 'num2': '98', 2279 'num3': '99', 2280 'num4': '100', 2281 'num5': '101', 2282 'num6': '102', 2283 'num7': '103', 2284 'num8': '104', 2285 'num9': '105', 2286 '*': '106', 2287 '+': '107',
2288 '-': '109', 2289 '.': '110', 2290 '/': '111', 2291 ';': '186', 2292 '=': '187', 2293 ',': '188', 2294 '-': '189', 2295 '.': '190', 2296 '/': '191', 2297 '`': '192', 2298 '[': '219', 2299 '\\': '220', 2300 ']': '221', 2301 '\'': '222', 2302 'left window key': '91', 2303 'right window key': '92', 2304 'select key': '93', 2305 'f1': '112', 2306 'f2': '113', 2307 'f3': '114', 2308 'f4': '115', 2309 'f5': '116', 2310 'f6': '117', 2311 'f7': '118', 2312 'f8': '119', 2313 'f9': '120', 2314 'f10': '121', 2315 'f11': '122', 2316 'f12': '123' 2317 }); 2318 $.Event.prototype.keyName = function () { 2319 var event = this, test = /\w/, key_Key = reverseKeyMap[currentBrowser][(event.keyCode || event.which) + ''], char_Key = String.fromCharCode(event.keyCode || event.which), key_Char = event.charCode && reverseKeyMap[currentBrowser][event.charCode + ''], char_Char = event.charCode && String.fromCharCode(event.charCode); 2320 if (char_Char && test.test(char_Char)) { 2321 return char_Char.toLowerCase(); 2322 } 2323 if (key_Char && test.test(key_Char)) { 2324 return char_Char.toLowerCase(); 2325 } 2326 if (char_Key && test.test(char_Key)) { 2327 return char_Key.toLowerCase(); 2328 } 2329 if (key_Key && test.test(key_Key)) { 2330 return key_Key.toLowerCase(); 2331 } 2332 if (event.type == 'keypress') { 2333 return event.keyCode ? String.fromCharCode(event.keyCode) : String.fromCharCode(event.which); 2334 } 2335 if (!event.keyCode && event.which) { 2336 return String.fromCharCode(event.which); 2337 } 2338 return reverseKeyMap[currentBrowser][event.keyCode + '']; 2339 }; 2340 return $; 2341}); 2342/*[email protected]#event/default/default*/ 2343define('jquerypp/event/default/default', ['jquery'], function ($) { 2344 $.fn.triggerAsync = function (type, data, success, prevented) { 2345 if (typeof data == 'function') { 2346 prevented = success; 2347 success = data; 2348 data = undefined; 2349 } 2350 if (this.length) { 2351 var el = this; 2352 setTimeout(function () { 2353 el.trigger({ 2354 type: type, 2355 _success: success, 2356 _prevented: prevented 2357 }, data); 2358 }, 0); 2359 } else { 2360 if (success) 2361 success.call(this); 2362 } 2363 return this; 2364 }; 2365 var types = {}, rnamespaces = /\.(.*)$/, $event = $.event; 2366 $event.special['default'] = { 2367 add: function (handleObj) { 2368 types[handleObj.namespace.replace(rnamespaces, '')] = true; 2369 }, 2370 setup: function () { 2371 return true; 2372 } 2373 }; 2374 var oldTrigger = $event.trigger; 2375 $event.trigger = function defaultTriggerer(event, data, elem, onlyHandlers) { 2376 var type = event.type || event, event = typeof event === 'object' ? event[$.expando] ? event : new $.Event(type, event) : new $.Event(type), res = oldTrigger.call($.event, event, data, elem, onlyHandlers), paused = event.isPaused && event.isPaused(); 2377 if (!onlyHandlers && !event.isDefaultPrevented() && event.type.indexOf('default') !== 0) { 2378 oldTrigger('default.' + event.type, data, elem); 2379 if (event._success) { 2380 event._success(event); 2381 } 2382 } 2383 if (!onlyHandlers && event.isDefaultPrevented() && event.type.indexOf('default') !== 0 && !paused) { 2384 if (event._prevented) { 2385 event._prevented(event); 2386 } 2387 } 2388 if (paused) { 2389 event.isDefaultPrevented = event.pausedState.isDefaultPrevented; 2390 event.isPropagationStopped = event.pausedState.isPropagationStopped; 2391 } 2392 return res; 2393 }; 2394 return $; 2395}); 2396/*[email protected]#event/pause/pause*/ 2397define('jquerypp/event/pause/pause', [ 2398 'jquery', 2399 'jquerypp/event/default/default' 2400], function ($) { 2401 var current, rnamespaces = /\.(.*)$/, returnFalse = function () { 2402 return false; 2403 }, returnTrue = function () { 2404 return true; 2405 }; 2406 $.Event.prototype.isPaused = returnFalse; 2407 $.Event.prototype.pause = function () { 2408 this.pausedState = { 2409 isDefaultPrevented: this.isDefaultPrevented() ? returnTrue : returnFalse, 2410 isPropagationStopped: this.isPropagationStopped() ? returnTrue : returnFalse 2411 }; 2412 this.stopImmediatePropagation(); 2413 this.preventDefault(); 2414 this.isPaused = returnTrue; 2415 }; 2416 $.Event.prototype.resume = function () { 2417 var handleObj = this.handleObj, currentTarget = this.currentTarget; 2418 var origType = $.event.special[handleObj.origType], origHandle = origType && origType.handle; 2419 if (!origType) { 2420 $.event.special[handleObj.origType] = {}; 2421 } 2422 $.event.special[handleObj.origType].handle = function (ev) { 2423 if (ev.handleObj === handleObj && ev.currentTarget === currentTarget) { 2424 if (!origType) { 2425 delete $.event.special[handleObj.origType]; 2426 } else { 2427 $.event.special[handleObj.origType].handle = origHandle; 2428 } 2429 } 2430 }; 2431 delete this.pausedState; 2432 this.isPaused = this.isImmediatePropagationStopped = returnFalse; 2433 if (!this.isPropagationStopped()) { 2434 $.event.trigger(this, [], this.target); 2435 } 2436 }; 2437 return $; 2438}); 2439/*[email protected]#event/resize/resize*/ 2440define('jquerypp/event/resize/resize', ['jquerypp/event/reverse/reverse'], function ($) { 2441 var win = $(window), windowWidth = 0, windowHeight = 0, timer; 2442 $(function () { 2443 windowWidth = win.width(); 2444 windowHeight = win.height(); 2445 }); 2446 $.event.reverse('resize', { 2447 handler: function (ev, data) { 2448 var isWindow = this === window; 2449 if (isWindow && ev.originalEvent) { 2450 var width = win.width(), height = win.height(); 2451 if (width != windowWidth || height != windowHeight) { 2452 windowWidth = width; 2453 windowHeight = height; 2454 clearTimeout(timer); 2455 timer = setTimeout(function () { 2456 win.trigger('resize'); 2457 }, 1); 2458 } 2459 return true; 2460 } 2461 } 2462 }); 2463 return $; 2464}); 2465/*[email protected]#event/swipe/swipe*/ 2466define('jquerypp/event/swipe/swipe', [ 2467 'jquery', 2468 'jquerypp/event/livehack/livehack' 2469], function ($) { 2470 var isPhantom = /Phantom/.test(navigator.userAgent), supportTouch = !isPhantom && 'ontouchend' in document, scrollEvent = 'touchmove scroll', touchStartEvent = supportTouch ? 'touchstart' : 'mousedown', touchStopEvent = supportTouch ? 'touchend' : 'mouseup', touchMoveEvent = supportTouch ? 'touchmove' : 'mousemove', data = function (event) { 2471 var d = event.originalEvent.touches ? event.originalEvent.touches[0] : event; 2472 return { 2473 time: new Date().getTime(), 2474 coords: [ 2475 d.clientX, 2476 d.clientY 2477 ], 2478 origin: $(event.target) 2479 }; 2480 }; 2481 var swipe = $.event.swipe = { 2482 delay: 500, 2483 max: 320, 2484 min: 30 2485 }; 2486 $.event.setupHelper([ 2487 'swipe', 2488 'swipeleft', 2489 'swiperight', 2490 'swipeup', 2491 'swipedown' 2492 ], touchStartEvent, function (ev) { 2493 var start = data(ev), stop, delegate = ev.delegateTarget || ev.currentTarget, selector = ev.handleObj.selector, entered = this; 2494 function moveHandler(event) { 2495 if (!start) { 2496 return; 2497 } 2498 stop = data(event); 2499 if (Math.abs(start.coords[0] - stop.coords[0]) > 10) { 2500 event.preventDefault(); 2501 } 2502 } 2503 ; 2504 $(document.documentElement).bind(touchMoveEvent, moveHandler).one(touchStopEvent, function (event) { 2505 $(this).unbind(touchMoveEvent, moveHandler); 2506 if (start && stop) { 2507 var deltaX = Math.abs(start.coords[0] - stop.coords[0]), deltaY = Math.abs(start.coords[1] - stop.coords[1]), distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); 2508 if (stop.time - start.time < swipe.delay && distance >= swipe.min && distance <= swipe.max) { 2509 var events = ['swipe']; 2510 if (deltaX >= swipe.min && deltaY < swipe.min) { 2511 events.push(start.coords[0] > stop.coords[0] ? 'swipeleft' : 'swiperight'); 2512 } else if (deltaY >= swipe.min && deltaX < swipe.min) { 2513 events.push(start.coords[1] < stop.coords[1] ? 'swipedown' : 'swipeup'); 2514 } 2515 $.each($.event.find(delegate, events, selector), function () { 2516 this.call(entered, ev, { 2517 start: start, 2518 end: stop 2519 }); 2520 }); 2521 } 2522 } 2523 start = stop = undefined; 2524 }); 2525 }); 2526 return $; 2527});
2528/*[global-shim-end]*/ 2529(function (){ 2530 window._define = window.define; 2531 window.define = window.define.orig; 2532 window.System = window.System.orig; 2533})();
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.