1/*----------------------------------------------------------------------*/ 2/* jQuery UI Touch Punch 0.1.0 3/* Copyright 2010, Dave Furfero 4/* https://github.com/furf/jquery-ui-touch-punch 5/* Extend the jQuery UI for iPad an iPhone 6/* depends jquery.ui.widget.js, jquery.ui.mouse.js 7/*----------------------------------------------------------------------*/ 8 9 10(function ($) { 11 $.support.touch = typeof Touch === 'object'; 12 13 if (!$.support.touch) { 14 return; 15 } 16 17 var mouseProto = $.ui.mouse.prototype, 18 _mouseInit = mouseProto._mouseInit, 19 _mouseDown = mouseProto._mouseDown, 20 _mouseUp = mouseProto._mouseUp, 21 22 mouseEvents = { 23 touchstart: 'mousedown', 24 touchmove: 'mousemove', 25 touchend: 'mouseup' 26 }; 27 28 function makeMouseEvent(event) { 29 event.stopPropagation(); 30 var touch = event.originalEvent.changedTouches[0]; 31 return $.extend(event, { 32 type: mouseEvents[event.type], 33 which: 1, 34 pageX: touch.pageX, 35 pageY: touch.pageY, 36 screenX: touch.screenX, 37 screenY: touch.screenY, 38 clientX: touch.clientX, 39 clientY: touch.clientY 40 }); 41 } 42 43 mouseProto._mouseInit = function () { 44 45 var self = this; 46 47 self.element.bind('touchstart.' + self.widgetName, function (event) {
48 return self._mouseDown(makeMouseEvent(event)); 49 }); 50 51 _mouseInit.call(self); 52 }; 53 54 mouseProto._mouseDown = function (event) { 55 56 57 var self = this, 58 ret = _mouseDown.call(self, event); 59 60 if (self.options.handle && !$(event.target).is(self.options.handle)) { 61 mouseProto._mouseUp(event); 62 return; 63 } 64 65 self._touchMoveDelegate = function (event) { 66 return self._mouseMove(makeMouseEvent(event)); 67 }; 68 69 self._touchEndDelegate = function (event) { 70 return self._mouseUp(makeMouseEvent(event)); 71 }; 72 73 $(document).bind('touchmove.' + self.widgetName, self._touchMoveDelegate).bind('touchend.' + self.widgetName, self._touchEndDelegate); 74 75 return ret; 76 }; 77 78 mouseProto._mouseUp = function (event) { 79 80 var self = this; 81 $(document).unbind('touchmove.' + self.widgetName, self._touchMoveDelegate).unbind('touchend.' + self.widgetName, self._touchEndDelegate); 82 83 return _mouseUp.call(self, event); 84 }; 85})(jQuery); 86 87 88/*----------------------------------------------------------------------*/ 89/* jQuery MouseWheel Plugin by Brandon Aaron 90/* http://brandonaaron.net/code/mousewheel/docs 91/*----------------------------------------------------------------------*/ 92 93 94(function ($) { 95 96 $.event.special.mousewheel = { 97 setup: function () { 98 var handler = $.event.special.mousewheel.handler; 99 100 // Fix pageX, pageY, clientX and clientY for mozilla 101 if ($.browser.mozilla) $(this).bind('mousemove.mousewheel', function (event) { 102 $.data(this, 'mwcursorposdata', { 103 pageX: event.pageX, 104 pageY: event.pageY, 105 clientX: event.clientX, 106 clientY: event.clientY 107 }); 108 }); 109 110 if (this.addEventListener) this.addEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 111 else this.onmousewheel = handler; 112 }, 113 114 teardown: function () { 115 var handler = $.event.special.mousewheel.handler; 116 117 $(this).unbind('mousemove.mousewheel'); 118 119 if (this.removeEventListener) this.removeEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 120 else this.onmousewheel = function () {}; 121 122 $.removeData(this, 'mwcursorposdata'); 123 }, 124 125 handler: function (event) { 126 var args = Array.prototype.slice.call(arguments, 1); 127 128 event = $.event.fix(event || window.event); 129 // Get correct pageX, pageY, clientX and clientY for mozilla 130 $.extend(event, $.data(this, 'mwcursorposdata') || {}); 131 var delta = 0, 132 returnValue = true; 133 134 if (event.wheelDelta) { 135 delta = (event.wheelDelta / 120); 136 } 137 if (event.detail) { 138 delta = (-event.detail / 3); 139 } 140 //if ( $.browser.opera ) delta=(event.wheelDelta/120); 141 event.data = event.data || {}; 142 event.type = "mousewheel"; 143 144 // Add delta to the front of the arguments 145 args.unshift(delta); 146 // Add event to the front of the arguments 147 args.unshift(event); 148 149 return $.event.handle.apply(this, args); 150 } 151 }; 152 153 $.fn.extend({ 154 mousewheel: function (fn) { 155 return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); 156 }, 157 158 unmousewheel: function (fn) { 159 return this.unbind("mousewheel", fn); 160 } 161 }); 162 163})(jQuery); 164 165 166/*----------------------------------------------------------------------*/ 167/* jQuery Tipsy Plugin by Jason Frame https://twitter.com/jaz303 v 1.0.0a 168/* http://onehackoranother.com/projects/jquery/tipsy/ 169/* (c) 2008-2010 jason frame [[email protected]] 170/* releated under the MIT license 171/* 172/* !!! I did some modifications on that plugin! !!! 173/*----------------------------------------------------------------------*/ 174 175 176 177(function ($) { 178 function fixTitle($ele) { 179 if ($ele.attr('title') || typeof ($ele.attr('original-title')) != 'string') { 180 $ele.attr('original-title', $ele.attr('title') || '').removeAttr('title'); 181 } 182 } 183 184 function Tipsy(element, options) { 185 this.$element = $(element); 186 this.options = options; 187 this.enabled = true; 188 fixTitle(this.$element); 189 } 190 191 Tipsy.prototype = { 192 show: function () { 193 var title = this.getTitle(); 194 if (title && this.enabled) { 195 var $tip = this.tip(); 196 197 $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title); 198 $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity 199 $tip.remove().css({ 200 top: 0, 201 left: 0, 202 visibility: 'hidden', 203 display: 'block' 204 }).appendTo(document.body); 205 var pos = $.extend({}, this.$element.offset(), { 206 width: this.$element[0].offsetWidth, 207 height: this.$element[0].offsetHeight 208 }); 209 210 var actualWidth = $tip[0].offsetWidth, 211 actualHeight = $tip[0].offsetHeight; 212 var gravity = (typeof this.options.gravity == 'function') ? this.options.gravity.call(this.$element[0]) : this.options.gravity; 213 214 var tp; 215 var mp; 216 switch (gravity.charAt(0)) { 217 case 'n': 218 tp = { 219 top: pos.top + pos.height + this.options.offset, 220 left: pos.left + pos.width / 2 - actualWidth / 2 221 };
222 mp = {top:15,left:-actualWidth/2}; 223 break; 224 case 's': 225 tp = { 226 top: pos.top - actualHeight - this.options.offset, 227 left: pos.left + pos.width / 2 - actualWidth / 2 228 }; 229 mp = {top:-actualHeight-15,left:-actualWidth/2}; 230 break; 231 case 'e': 232 tp = { 233 top: pos.top + pos.height / 2 - actualHeight / 2, 234 left: pos.left - actualWidth - this.options.offset 235 }; 236 mp = {top:-actualHeight/2,left:-12-actualWidth}; 237 break; 238 case 'w': 239 tp = { 240 top: pos.top + pos.height / 2 - actualHeight / 2, 241 left: pos.left + pos.width + this.options.offset 242 }; 243 mp = {top:-actualHeight/2,left:12}; 244 break; 245 } 246 if (gravity.length == 2) { 247 if (gravity.charAt(1) == 'w') { 248 //tp.left = pos.left + pos.width / 2 - 15; 249 tp.left = pos.left - 5; 250 mp.left += actualWidth/2-15; 251 } else { 252 //tp.left = pos.left + pos.width / 2 - actualWidth + 15; 253 mp.left -= actualWidth/2-15; 254 tp.left = pos.left + pos.width - actualWidth + 5; 255 } 256 } 257 258 if(this.options.followMouse){ 259 $(document).bind('mousemove.tipsy',function(e){ 260 var x = e.pageX+mp.left, y = e.pageY+mp.top; 261 $tip.css({ 262 left: x, 263 top: y 264 }); 265 }); 266 } 267 268 $tip.css(tp).addClass('tipsy-' + gravity); 269 if (this.options.fade) { 270 $tip.stop().css({ 271 opacity: 0, 272 display: 'block', 273 visibility: 'visible' 274 }).animate({ 275 opacity: this.options.opacity 276 }); 277 } else { 278 $tip.css({ 279 visibility: 'visible', 280 opacity: this.options.opacity 281 }); 282 } 283 } 284 }, 285 286 hide: function () { 287 if(this.options.followMouse){ 288 $(document).unbind('mousemove.tipsy'); 289 } 290 if (this.options.fade) { 291 this.tip().stop().fadeOut(function () { 292 $(this).remove(); 293 }); 294 } else { 295 this.tip().remove(); 296 } 297 }, 298 299 getTitle: function () { 300 var title, $e = this.$element, 301 o = this.options; 302 fixTitle($e); 303 var title, o = this.options; 304 if (typeof o.title == 'string') { 305 title = $e.attr(o.title == 'title' ? 'original-title' : o.title); 306 } else if (typeof o.title == 'function') { 307 title = o.title.call($e[0]); 308 } 309 title = ('' + title).replace(/(^\s*|\s*$)/, ""); 310 return title || o.fallback; 311 }, 312 313 setTitel: function(title) { 314 this.options.fallback = title; 315 }, 316 317 tip: function () { 318 if (!this.$tip) { 319 this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-outer"><div class="tipsy-inner"/></div></div>'); 320 } 321 return this.$tip; 322 }, 323 324 validate: function () { 325 if (!this.$element[0].parentNode) { 326 this.hide(); 327 this.$element = null; 328 this.options = null; 329 } 330 }, 331 332 enable: function () { 333 this.enabled = true; 334 }, 335 disable: function () { 336 this.enabled = false; 337 }, 338 toggleEnabled: function () { 339 this.enabled = !this.enabled; 340 } 341 }; 342 343 $.fn.tipsy = function (options) { 344 345 if (options === true) { 346 return this.data('tipsy'); 347 } else if (typeof options == 'string') { 348 return this.data('tipsy')[options](arguments[1], arguments[2]); 349 } 350 351 options = $.extend({}, $.fn.tipsy.defaults, options); 352 353 function get(ele) { 354 var tipsy = $.data(ele, 'tipsy'); 355 if (!tipsy) { 356 tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); 357 $.data(ele, 'tipsy', tipsy); 358 } 359 return tipsy; 360 } 361 362 function enter() { 363 var tipsy = get(this); 364 tipsy.hoverState = 'in'; 365 if (options.delayIn == 0) { 366 tipsy.show(); 367 } else { 368 setTimeout(function () { 369 if (tipsy.hoverState == 'in') tipsy.show(); 370 }, options.delayIn); 371 } 372 }; 373 374 function leave() { 375 var tipsy = get(this); 376 tipsy.hoverState = 'out'; 377 if (options.delayOut == 0) { 378 tipsy.hide(); 379 } else { 380 setTimeout(function () { 381 if (tipsy.hoverState == 'out') tipsy.hide(); 382 }, options.delayOut); 383 } 384 }; 385 386 if (!options.live) this.each(function () { 387 get(this); 388 }); 389 390 if (options.trigger != 'manual') { 391 var binder = options.live ? 'live' : 'bind', 392 eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', 393 eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; 394 this[binder](eventIn, enter)[binder](eventOut, leave); 395 } 396 397 return this; 398 399 }; 400 401 $.fn.tipsy.defaults = { 402 delayIn: 0, 403 delayOut: 0, 404 fade: false, 405 fallback: '', 406 gravity: 'n', 407 html: false, 408 live: false, 409 offset: 0, 410 opacity: 0.8, 411 //CUSTOM followMouse 412 followMouse: false, 413 title: 'title', 414 trigger: 'hover' 415 }; 416 417 // Overwrite this method to provide options on a per-element basis. 418 // For example, you could store the gravity in a 'tipsy-gravity' attribute: 419 // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); 420 // (remember - do not modify 'options' in place!) 421 $.fn.tipsy.elementOptions = function (ele, options) { 422 return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; 423 }; 424 425 $.fn.tipsy.autoNS = function () { 426 return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; 427 }; 428 429 $.fn.tipsy.autoWE = function () { 430 return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; 431 }; 432 433})(jQuery); 434 435 436/*----------------------------------------------------------------------*/ 437/* jQuery Uniform v1.7.5
438/* Copyright © 2009 Josh Pyles / Pixelmatrix Design LLC 439/* http://pixelmatrixdesign.com 440/* License: MIT License - http://www.opensource.org/licenses/mit-license.php 441/*----------------------------------------------------------------------*/ 442 443 444(function ($) { 445 $.uniform = { 446 options: { 447 selectClass: 'selector', 448 radioClass: 'radio', 449 checkboxClass: 'checker', 450 fileClass: 'uploader', 451 filenameClass: 'filename', 452 fileBtnClass: 'action', 453 fileDefaultText: 'No file selected', 454 fileBtnText: 'Choose File', 455 checkedClass: 'checked', 456 focusClass: 'focus', 457 disabledClass: 'disabled', 458 buttonClass: 'button', 459 activeClass: 'active', 460 hoverClass: 'hover', 461 useID: true, 462 idPrefix: 'uniform', 463 resetSelector: false, 464 autoHide: true 465 }, 466 elements: [] 467 }; 468 469 if ($.browser.msie && $.browser.version < 7) { 470 $.support.selectOpacity = false; 471 } else { 472 $.support.selectOpacity = true; 473 } 474 475 $.fn.uniform = function (options) { 476 477 options = $.extend($.uniform.options, options); 478 479 var el = this; 480 //code for specifying a reset button 481 if (options.resetSelector != false) { 482 $(options.resetSelector).mouseup(function () { 483 function resetThis() { 484 $.uniform.update(el); 485 } 486 setTimeout(resetThis, 10); 487 }); 488 } 489 490 function doInput(elem) { 491 $el = $(elem); 492 $el.addClass($el.attr("type")); 493 storeElement(elem); 494 } 495 496 function doTextarea(elem) { 497 $(elem).addClass("uniform"); 498 storeElement(elem); 499 } 500 501 function doButton(elem) { 502 var $el = $(elem); 503 504 var divTag = $("<div>"), 505 spanTag = $("<span>"); 506 507 divTag.addClass(options.buttonClass); 508 509 if (options.useID && $el.attr("id") != "") divTag.attr("id", options.idPrefix + "-" + $el.attr("id")); 510 511 var btnText; 512 513 if ($el.is("a") || $el.is("button")) { 514 btnText = $el.text(); 515 } else if ($el.is(":submit") || $el.is(":reset") || $el.is("input[type=button]")) { 516 btnText = $el.attr("value"); 517 } 518 519 btnText = btnText == "" ? $el.is(":reset") ? "Reset" : "Submit" : btnText; 520 521 spanTag.html(btnText); 522 523 $el.css("opacity", 0); 524 $el.wrap(divTag); 525 $el.wrap(spanTag); 526 527 //redefine variables 528 divTag = $el.closest("div"); 529 spanTag = $el.closest("span"); 530 531 if ($el.is(":disabled")) divTag.addClass(options.disabledClass); 532 533 divTag.bind({ 534 "mouseenter.uniform": function () { 535 divTag.addClass(options.hoverClass); 536 }, 537 "mouseleave.uniform": function () { 538 divTag.removeClass(options.hoverClass); 539 divTag.removeClass(options.activeClass); 540 }, 541 "mousedown.uniform touchbegin.uniform": function () { 542 divTag.addClass(options.activeClass); 543 }, 544 "mouseup.uniform touchend.uniform": function () { 545 divTag.removeClass(options.activeClass); 546 }, 547 "click.uniform touchend.uniform": function (e) { 548 if ($(e.target).is("span") || $(e.target).is("div")) { 549 if (elem[0].dispatchEvent) { 550 var ev = document.createEvent('MouseEvents'); 551 ev.initEvent('click', true, true); 552 elem[0].dispatchEvent(ev); 553 } else { 554 elem[0].click(); 555 } 556 } 557 } 558 }); 559 560 elem.bind({ 561 "focus.uniform": function () { 562 divTag.addClass(options.focusClass); 563 }, 564 "blur.uniform": function () { 565 divTag.removeClass(options.focusClass); 566 } 567 }); 568 569 $.uniform.noSelect(divTag); 570 storeElement(elem); 571 572 } 573 574 function doSelect(elem) { 575 var $el = $(elem); 576 577 var divTag = $('<div />'), 578 spanTag = $('<span />'); 579 580 if (!$el.css("display") == "none" && options.autoHide) { 581 divTag.hide(); 582 } 583 584 divTag.addClass(options.selectClass); 585 586 if (options.useID && elem.attr("id") != "") { 587 divTag.attr("id", options.idPrefix + "-" + elem.attr("id")); 588 } 589 590 var selected = elem.find(":selected:first"); 591 if (selected.length == 0) { 592 selected = elem.find("option:first"); 593 } 594 spanTag.html(selected.html()); 595 596 elem.css('opacity', 0); 597 elem.wrap(divTag); 598 elem.before(spanTag); 599 600 //redefine variables 601 divTag = elem.parent("div"); 602 spanTag = elem.siblings("span"); 603 604 elem.bind({ 605 "change.uniform": function () { 606 spanTag.text(elem.find(":selected").html()); 607 divTag.removeClass(options.activeClass); 608 }, 609 "focus.uniform": function () { 610 divTag.addClass(options.focusClass); 611 }, 612 "blur.uniform": function () { 613 divTag.removeClass(options.focusClass); 614 divTag.removeClass(options.activeClass); 615 }, 616 "mousedown.uniform touchbegin.uniform": function () { 617 divTag.addClass(options.activeClass); 618 }, 619 "mouseup.uniform touchend.uniform": function () { 620 divTag.removeClass(options.activeClass); 621 }, 622 "click.uniform touchend.uniform": function () { 623 divTag.removeClass(options.activeClass); 624 }, 625 "mouseenter.uniform": function () { 626 divTag.addClass(options.hoverClass); 627 }, 628 "mouseleave.uniform": function () { 629 divTag.removeClass(options.hoverClass); 630 divTag.removeClass(options.activeClass); 631 }, 632 "keyup.uniform": function () { 633 spanTag.text(elem.find(":selected").html()); 634 } 635 }); 636 637 //handle disabled state 638 if ($(elem).attr("disabled")) { 639 //box is checked by default, check our box 640 divTag.addClass(options.disabledClass); 641 } 642 $.uniform.noSelect(spanTag); 643 644 storeElement(elem); 645 646 } 647 648 function doCheckbox(elem) { 649 var $el = $(elem); 650 651 var divTag = $('<div />'), 652 spanTag = $('<span />'); 653 654 if (!$el.css("display") == "none" && options.autoHide) { 655 divTag.hide(); 656 } 657 658 divTag.addClass(options.checkboxClass); 659 660 //assign the id of the element 661 if (options.useID && elem.attr("id") != "") { 662 divTag.attr("id", options.idPrefix + "-" + elem.attr("id")); 663 } 664 665 //wrap with the proper elements 666 $(elem).wrap(divTag); 667 $(elem).wrap(spanTag); 668 669 //redefine variables 670 spanTag = elem.parent(); 671 divTag = spanTag.parent(); 672
673 //hide normal input and add focus classes 674 $(elem).css("opacity", 0).bind({ 675 "focus.uniform": function () { 676 divTag.addClass(options.focusClass); 677 }, 678 "blur.uniform": function () { 679 divTag.removeClass(options.focusClass); 680 }, 681 "click.uniform touchend.uniform": function () { 682 if (!$(elem).prop("checked")) { 683 //box was just unchecked, uncheck span 684 spanTag.removeClass(options.checkedClass); 685 } else { 686 //box was just checked, check span. 687 spanTag.addClass(options.checkedClass); 688 } 689 }, 690 "mousedown.uniform touchbegin.uniform": function () { 691 divTag.addClass(options.activeClass); 692 }, 693 "mouseup.uniform touchend.uniform": function () { 694 divTag.removeClass(options.activeClass); 695 }, 696 "mouseenter.uniform": function () { 697 divTag.addClass(options.hoverClass); 698 }, 699 "mouseleave.uniform": function () { 700 divTag.removeClass(options.hoverClass); 701 divTag.removeClass(options.activeClass); 702 } 703 }); 704 705 //handle defaults 706 if ($(elem).prop("checked")) { 707 //box is checked by default, check our box 708 spanTag.addClass(options.checkedClass); 709 } 710 711 //handle disabled state 712 if ($(elem).prop("disabled")) { 713 //box is checked by default, check our box 714 divTag.addClass(options.disabledClass); 715 } 716 717 storeElement(elem); 718 } 719 720 function doRadio(elem) { 721 var $el = $(elem); 722 723 var divTag = $('<div />'), 724 spanTag = $('<span />'); 725 726 if (!$el.css("display") == "none" && options.autoHide) { 727 divTag.hide(); 728 } 729 730 divTag.addClass(options.radioClass); 731 732 if (options.useID && elem.attr("id") != "") { 733 divTag.attr("id", options.idPrefix + "-" + elem.attr("id")); 734 } 735 736 //wrap with the proper elements 737 $(elem).wrap(divTag); 738 $(elem).wrap(spanTag); 739 740 //redefine variables 741 spanTag = elem.parent(); 742 divTag = spanTag.parent(); 743 744 //hide normal input and add focus classes 745 $(elem).css("opacity", 0).bind({ 746 "focus.uniform": function () { 747 divTag.addClass(options.focusClass); 748 }, 749 "blur.uniform": function () { 750 divTag.removeClass(options.focusClass); 751 }, 752 "click.uniform touchend.uniform": function () { 753 if (!$(elem).prop("checked")) { 754 //box was just unchecked, uncheck span 755 spanTag.removeClass(options.checkedClass); 756 } else { 757 //box was just checked, check span 758 var classes = options.radioClass.split(" ")[0]; 759 $("." + classes + " span." + options.checkedClass + ":has([name='" + $(elem).attr('name') + "'])").removeClass(options.checkedClass); 760 spanTag.addClass(options.checkedClass); 761 } 762 }, 763 "mousedown.uniform touchend.uniform": function () { 764 if (!$(elem).is(":disabled")) { 765 divTag.addClass(options.activeClass); 766 } 767 }, 768 "mouseup.uniform touchbegin.uniform": function () { 769 divTag.removeClass(options.activeClass); 770 }, 771 "mouseenter.uniform touchend.uniform": function () { 772 divTag.addClass(options.hoverClass); 773 }, 774 "mouseleave.uniform": function () { 775 divTag.removeClass(options.hoverClass); 776 divTag.removeClass(options.activeClass); 777 } 778 }); 779 780 //handle defaults 781 if ($(elem).prop("checked")) { 782 //box is checked by default, check span 783 spanTag.addClass(options.checkedClass); 784 } 785 //handle disabled state 786 if ($(elem).prop("disabled")) { 787 //box is checked by default, check our box 788 divTag.addClass(options.disabledClass); 789 } 790 791 storeElement(elem); 792 793 } 794 795 function doFile(elem) { 796 //sanitize input 797 var $el = $(elem); 798 799 var divTag = $('<div />'), 800 filenameTag = $('<span>' + options.fileDefaultText + '</span>'), 801 btnTag = $('<span>' + options.fileBtnText + '</span>'); 802 803 if (!$el.css("display") == "none" && options.autoHide) { 804 divTag.hide(); 805 } 806 807 divTag.addClass(options.fileClass); 808 filenameTag.addClass(options.filenameClass); 809 btnTag.addClass(options.fileBtnClass); 810 811 if (options.useID && $el.attr("id") != "") { 812 divTag.attr("id", options.idPrefix + "-" + $el.attr("id")); 813 } 814 815 //wrap with the proper elements 816 $el.wrap(divTag); 817 $el.after(btnTag); 818 $el.after(filenameTag); 819 820 //redefine variables 821 divTag = $el.closest("div"); 822 filenameTag = $el.siblings("." + options.filenameClass); 823 btnTag = $el.siblings("." + options.fileBtnClass); 824 825 //set the size 826 if (!$el.attr("size")) { 827 var divWidth = divTag.width(); 828 //$el.css("width", divWidth); 829 $el.attr("size", divWidth / 10); 830 } 831 832 //actions 833 var setFilename = function () { 834 835 var filename = $el.val(); 836 if (filename === '') { 837 filename = options.fileDefaultText; 838 } else { 839 filename = filename.split(/[\/\\]+/); 840 filename = filename[(filename.length - 1)]; 841 } 842 filenameTag.text(filename); 843 }; 844 845 // Account for input saved across refreshes 846 setFilename(); 847 848 $el.css("opacity", 0).bind({ 849 "focus.uniform": function () { 850 divTag.addClass(options.focusClass); 851 }, 852 "blur.uniform": function () { 853 divTag.removeClass(options.focusClass); 854 }, 855 "mousedown.uniform": function () { 856 if (!$(elem).is(":disabled")) { 857 divTag.addClass(options.activeClass); 858 } 859 }, 860 "mouseup.uniform": function () { 861 divTag.removeClass(options.activeClass); 862 }, 863 "mouseenter.uniform": function () { 864 divTag.addClass(options.hoverClass); 865 }, 866 "mouseleave.uniform": function () { 867 divTag.removeClass(options.hoverClass); 868 divTag.removeClass(options.activeClass); 869 } 870 }); 871 872 // IE7 doesn't fire onChange until blur or second fire. 873 if ($.browser.msie) { 874 // IE considers browser chrome blocking I/O, so it 875 // suspends tiemouts until after the file has been selected. 876 $el.bind('click.uniform.ie7', function () { 877 setTimeout(setFilename, 0); 878 }); 879 } else { 880 // All other browsers behave properly 881 $el.bind('change.uniform', setFilename); 882 } 883 884 //handle defaults 885 if ($el.attr("disabled")) { 886 //box is checked by default, check our box 887 divTag.addClass(options.disabledClass); 888 } 889 890 $.uniform.noSelect(filenameTag); 891 $.uniform.noSelect(btnTag); 892 893 storeElement(elem); 894 895 } 896 897 $.uniform.restore = function (elem) { 898 if (elem == undefined) { 899 elem = $($.uniform.elements); 900 } 901 902 $(elem).each(function () { 903 if ($(this).is(":checkbox")) { 904 //unwrap from span and div 905 $(this).unwrap().unwrap(); 906 } else if ($(this).is("select")) { 907 //remove sibling span 908 $(this).siblings("span").remove(); 909 //unwrap parent div 910 $(this).unwrap(); 911 } else if ($(this).is(":radio")) { 912 //unwrap from span and div 913 $(this).unwrap().unwrap(); 914 } else if ($(this).is(":file")) { 915 //remove sibling spans 916 $(this).siblings("span").remove(); 917 //unwrap parent div 918 $(this).unwrap(); 919 } else if ($(this).is("button, :submit, :reset, a, input[type='button']")) { 920 //unwrap from span and div 921 $(this).unwrap().unwrap(); 922 } 923 924 //unbind events 925 $(this).unbind(".uniform"); 926 927 //reset inline style 928 $(this).css("opacity", "1"); 929 930 //remove item from list of uniformed elements 931 var index = $.inArray($(elem), $.uniform.elements); 932 $.uniform.elements.splice(index, 1); 933 }); 934 }; 935 936 function storeElement(elem) { 937 //store this element in our global array 938 elem = $(elem).get(); 939 if (elem.length > 1) { 940 $.each(elem, function (i, val) { 941 $.uniform.elements.push(val); 942 }); 943 } else { 944 $.uniform.elements.push(elem); 945 } 946 } 947 948 //noSelect v1.0 949 $.uniform.noSelect = function (elem) { 950 function f() { 951 return false;
952 }; 953 $(elem).each(function () { 954 this.onselectstart = this.ondragstart = f; // Webkit & IE 955 $(this).mousedown(f) // Webkit & Opera 956 .css({ 957 MozUserSelect: 'none' 958 }); // Firefox 959 }); 960 }; 961 962 $.uniform.update = function (elem) { 963 if (elem == undefined) { 964 elem = $($.uniform.elements); 965 } 966 //sanitize input 967 elem = $(elem); 968 969 elem.each(function () { 970 //do to each item in the selector 971 //function to reset all classes 972 var $e = $(this); 973 974 if ($e.is("select")) { 975 //element is a select 976 var spanTag = $e.siblings("span"); 977 var divTag = $e.parent("div"); 978 979 divTag.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass); 980 981 //reset current selected text 982 spanTag.html($e.find(":selected").html()); 983 984 if ($e.is(":disabled")) { 985 divTag.addClass(options.disabledClass); 986 } else { 987 divTag.removeClass(options.disabledClass); 988 } 989 990 } else if ($e.is(":checkbox")) { 991 //element is a checkbox 992 var spanTag = $e.closest("span"); 993 var divTag = $e.closest("div"); 994 995 divTag.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass); 996 spanTag.removeClass(options.checkedClass); 997 998 if ($e.is(":checked")) { 999 spanTag.addClass(options.checkedClass); 1000 } 1001 if ($e.is(":disabled")) { 1002 divTag.addClass(options.disabledClass); 1003 } else { 1004 divTag.removeClass(options.disabledClass); 1005 } 1006 1007 } else if ($e.is(":radio")) { 1008 //element is a radio 1009 var spanTag = $e.closest("span"); 1010 var divTag = $e.closest("div"); 1011 1012 divTag.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass); 1013 spanTag.removeClass(options.checkedClass); 1014 1015 if ($e.is(":checked")) { 1016 spanTag.addClass(options.checkedClass); 1017 } 1018 1019 if ($e.is(":disabled")) { 1020 divTag.addClass(options.disabledClass); 1021 } else { 1022 divTag.removeClass(options.disabledClass); 1023 } 1024 } else if ($e.is(":file")) { 1025 var divTag = $e.parent("div"); 1026 var filenameTag = $e.siblings(options.filenameClass); 1027 btnTag = $e.siblings(options.fileBtnClass); 1028 1029 divTag.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass); 1030 1031 filenameTag.text($e.val()); 1032 1033 if ($e.is(":disabled")) { 1034 divTag.addClass(options.disabledClass); 1035 } else { 1036 divTag.removeClass(options.disabledClass); 1037 } 1038 } else if ($e.is(":submit") || $e.is(":reset") || $e.is("button") || $e.is("a") || elem.is("input[type=button]")) { 1039 var divTag = $e.closest("div"); 1040 divTag.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass); 1041 1042 if ($e.is(":disabled")) { 1043 divTag.addClass(options.disabledClass); 1044 } else { 1045 divTag.removeClass(options.disabledClass); 1046 } 1047 1048 } 1049 1050 }); 1051 }; 1052 1053 return this.each(function () { 1054 if ($.support.selectOpacity) { 1055 var elem = $(this); 1056 1057 if (elem.is("select")) { 1058 //element is a select 1059 if (elem.attr("multiple") != true) { 1060 //element is not a multi-select 1061 if (elem.attr("size") == undefined || elem.attr("size") <= 1) { 1062 doSelect(elem); 1063 } 1064 } 1065 } else if (elem.is(":checkbox")) { 1066 //element is a checkbox 1067 doCheckbox(elem); 1068 } else if (elem.is(":radio")) { 1069 //element is a radio 1070 doRadio(elem); 1071 } else if (elem.is(":file")) { 1072 //element is a file upload 1073 doFile(elem); 1074 } else if (elem.is(":text, :password, input[type='email']")) { 1075 doInput(elem); 1076 } else if (elem.is("textarea")) { 1077 doTextarea(elem); 1078 } else if (elem.is("a") || elem.is(":submit") || elem.is(":reset") || elem.is("button") || elem.is("input[type=button]")) { 1079 doButton(elem); 1080 } 1081 1082 } 1083 }); 1084 }; 1085})(jQuery); 1086 1087 1088/*----------------------------------------------------------------------*/ 1089/* Elastic jQuery plugin v1.6.5 1090/* Copyright 2011, Jan Jarfalk 1091/* http://www.unwrongest.com 1092/* MIT License - http://www.opensource.org/licenses/mit-license.php 1093/*----------------------------------------------------------------------*/ 1094 1095 1096(function(jQuery){ 1097 jQuery.fn.extend({ 1098 elastic: function() { 1099 1100 // We will create a div clone of the textarea 1101 // by copying these attributes from the textarea to the div. 1102 var mimics = [ 1103 'paddingTop', 1104 'paddingRight', 1105 'paddingBottom', 1106 'paddingLeft', 1107 'fontSize', 1108 'lineHeight', 1109 'fontFamily', 1110 'width', 1111 'fontWeight']; 1112 1113 return this.each( function() { 1114 1115 // Elastic only works on textareas 1116 if ( this.type != 'textarea' ) { 1117 return false;
1118 } 1119 1120 var $textarea = jQuery(this), 1121 $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}), 1122 lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), 1123 minheight = parseInt($textarea.css('height'),10) || lineHeight*3, 1124 maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, 1125 goalheight = 0, 1126 i = 0; 1127 1128 // Opera returns max-height of -1 if not set 1129 if (maxheight < 0) { maxheight = Number.MAX_VALUE; } 1130 1131 // Append the twin to the DOM 1132 // We are going to meassure the height of this, not the textarea. 1133 $twin.appendTo($textarea.parent()); 1134 1135 // Copy the essential styles (mimics) from the textarea to the twin 1136 var i = mimics.length; 1137 while(i--){ 1138 $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString())); 1139 } 1140 1141 1142 // Sets a given height and overflow state on the textarea 1143 function setHeightAndOverflow(height, overflow){ 1144 curratedHeight = Math.floor(parseInt(height,10)); 1145 if($textarea.height() != curratedHeight){ 1146 $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); 1147 1148 } 1149 } 1150 1151 1152 // This function will update the height of the textarea if necessary 1153 function update() { 1154 1155 // Get curated content from the textarea. 1156 var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ /g, ' ').replace(/<|>/g, '>').replace(/\n/g, '<br />'); 1157 1158 // Compare curated content with curated twin. 1159 var twinContent = $twin.html().replace(/<br>/ig,'<br />'); 1160 1161 if(textareaContent+' ' != twinContent){ 1162 1163 // Add an extra white space so new rows are added when you are at the end of a row. 1164 $twin.html(textareaContent+' '); 1165 1166 // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height 1167 if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){ 1168 1169 var goalheight = $twin.height()+lineHeight; 1170 if(goalheight >= maxheight) { 1171 setHeightAndOverflow(maxheight,'auto'); 1172 } else if(goalheight <= minheight) { 1173 setHeightAndOverflow(minheight,'hidden'); 1174 } else { 1175 setHeightAndOverflow(goalheight,'hidden'); 1176 } 1177 1178 } 1179 1180 } 1181 1182 } 1183 1184 // Hide scrollbars 1185 $textarea.css({'overflow':'hidden'}); 1186 1187 // Update textarea size on keyup, change, cut and paste 1188 $textarea.bind('keyup change cut paste', function(){ 1189 update(); 1190 }); 1191 1192 // Compact textarea on blur 1193 // Lets animate this.... 1194 $textarea.bind('blur',function(){ 1195 if($twin.height() < maxheight){ 1196 if($twin.height() > minheight) { 1197 $textarea.height($twin.height()); 1198 } else { 1199 $textarea.height(minheight); 1200 } 1201 } 1202 }); 1203 1204 // And this line is to catch the browser paste event 1205 $textarea.live('input paste',function(e){ setTimeout( update, 250); }); 1206 1207 // Run update once when elastic is initialized 1208 update(); 1209 1210 }); 1211 1212 } 1213 }); 1214})(jQuery); 1215 1216/*----------------------------------------------------------------------*/ 1217/* jQuery miniColors: A small color selector 1218/* Copyright 2011 Cory LaViska for A Beautiful Site, LLC. 1219/* http://abeautifulsite.net/blog/2011/02/jquery-minicolors-a-color-selector-for-input-controls/ 1220/* Dual licensed under the MIT or GPL Version 2 licenses 1221/*----------------------------------------------------------------------*/ 1222 1223 1224 1225(function ($) { 1226 $.fn.miniColors = function (o, data) { 1227 1228 1229 var create = function (input, o, data) { 1230 1231 // 1232 // Creates a new instance of the miniColors selector 1233 // 1234 // Determine initial color (defaults to white) 1235 var color = cleanHex(input.val()); 1236 if (!color) color = 'FFFFFF'; 1237 var hsb = hex2hsb(color); 1238 1239 // Create trigger 1240 var trigger = $('<a class="miniColors-trigger" style="background-color: #' + color + '" href="#"></a>'); 1241 trigger.insertAfter(input); 1242 1243 // Add necessary attributes 1244 input.addClass('miniColors').attr('maxlength', 7).attr('autocomplete', 'off'); 1245 1246 // Set input data 1247 input.data('trigger', trigger); 1248 input.data('hsb', hsb); 1249 if (o.change) input.data('change', o.change); 1250 1251 // Handle options 1252 if (o.readonly) input.attr('readonly', true); 1253 if (o.disabled) disable(input); 1254 1255 // Show selector when trigger is clicked 1256 trigger.bind('click.miniColors', function (event) { 1257 event.preventDefault(); 1258 input.trigger('focus'); 1259 }); 1260 1261 // Show selector when input receives focus 1262 input.bind('focus.miniColors', function (event) { 1263 show(input); 1264 }); 1265 1266 // Hide on blur 1267 input.bind('blur.miniColors', function (event) { 1268 var hex = cleanHex(input.val()); 1269 input.val(hex ? '#' + hex : ''); 1270 }); 1271 1272 // Hide when tabbing out of the input 1273 input.bind('keydown.miniColors', function (event) { 1274 if (event.keyCode === 9) hide(input); 1275 }); 1276 1277 // Update when color is typed in 1278 input.bind('keyup.miniColors', function (event) { 1279 // Remove non-hex characters 1280 var filteredHex = input.val().replace(/[^A-F0-9#]/ig, ''); 1281 input.val(filteredHex); 1282 if (!setColorFromInput(input)) {
1283 // Reset trigger color when color is invalid 1284 input.data('trigger').css('backgroundColor', '#FFF'); 1285 } 1286 }); 1287 1288 // Handle pasting 1289 input.bind('paste.miniColors', function (event) { 1290 // Short pause to wait for paste to complete 1291 setTimeout(function () { 1292 input.trigger('keyup'); 1293 }, 5); 1294 }); 1295 1296 }; 1297 1298 1299 var destroy = function (input) { 1300 1301 // 1302 // Destroys an active instance of the miniColors selector 1303 // 1304 hide(); 1305 1306 input = $(input); 1307 input.data('trigger').remove(); 1308 input.removeAttr('autocomplete'); 1309 input.removeData('trigger'); 1310 input.removeData('selector'); 1311 input.removeData('hsb'); 1312 input.removeData('huePicker'); 1313 input.removeData('colorPicker'); 1314 input.removeData('mousebutton'); 1315 input.removeData('moving'); 1316 input.unbind('click.miniColors'); 1317 input.unbind('focus.miniColors'); 1318 input.unbind('blur.miniColors'); 1319 input.unbind('keyup.miniColors'); 1320 input.unbind('keydown.miniColors'); 1321 input.unbind('paste.miniColors'); 1322 $(document).unbind('mousedown.miniColors'); 1323 $(document).unbind('mousemove.miniColors'); 1324 1325 }; 1326 1327 1328 var enable = function (input) { 1329 1330 // 1331 // Disables the input control and the selector 1332 // 1333 input.attr('disabled', false); 1334 input.data('trigger').css('opacity', 1); 1335 1336 }; 1337 1338 1339 var disable = function (input) { 1340 1341 // 1342 // Disables the input control and the selector 1343 // 1344 hide(input); 1345 input.attr('disabled', true); 1346 input.data('trigger').css('opacity', .5); 1347 1348 }; 1349 1350 1351 var show = function (input) { 1352 1353 // 1354 // Shows the miniColors selector 1355 // 1356 if (input.attr('disabled')) return false; 1357 1358 // Hide all other instances 1359 hide(); 1360 1361 // Generate the selector 1362 var selector = $('<div class="miniColors-selector"></div>'); 1363 selector.append('<div class="miniColors-colors" style="background-color: #FFF;"><div class="miniColors-colorPicker"></div></div>'); 1364 selector.append('<div class="miniColors-hues"><div class="miniColors-huePicker"></div></div>'); 1365 selector.css({ 1366 top: input.is(':visible') ? input.offset().top + input.outerHeight() : input.data('trigger').offset().top + input.data('trigger').outerHeight(), 1367 left: input.is(':visible') ? input.offset().left : input.data('trigger').offset().left, 1368 display: 'none' 1369 }).addClass(input.attr('class')); 1370 1371 // Set background for colors 1372 var hsb = input.data('hsb'); 1373 selector.find('.miniColors-colors').css('backgroundColor', '#' + hsb2hex({ 1374 h: hsb.h, 1375 s: 100, 1376 b: 100 1377 })); 1378 1379 // Set colorPicker position 1380 var colorPosition = input.data('colorPosition'); 1381 if (!colorPosition) colorPosition = getColorPositionFromHSB(hsb); 1382 selector.find('.miniColors-colorPicker').css('top', colorPosition.y + 'px').css('left', colorPosition.x + 'px'); 1383 1384 // Set huePicker position 1385 var huePosition = input.data('huePosition'); 1386 if (!huePosition) huePosition = getHuePositionFromHSB(hsb); 1387 selector.find('.miniColors-huePicker').css('top', huePosition.y + 'px'); 1388 1389 1390 // Set input data 1391 input.data('selector', selector); 1392 input.data('huePicker', selector.find('.miniColors-huePicker')); 1393 input.data('colorPicker', selector.find('.miniColors-colorPicker')); 1394 input.data('mousebutton', 0); 1395 1396 $('BODY').append(selector); 1397 selector.fadeIn(100); 1398 1399 // Prevent text selection in IE 1400 selector.bind('selectstart', function () { 1401 return false; 1402 }); 1403 1404 $(document).bind('mousedown.miniColors', function (event) { 1405 input.data('mousebutton', 1); 1406 1407 if ($(event.target).parents().andSelf().hasClass('miniColors-colors')) { 1408 event.preventDefault(); 1409 input.data('moving', 'colors'); 1410 moveColor(input, event); 1411 } 1412 1413 if ($(event.target).parents().andSelf().hasClass('miniColors-hues')) { 1414 event.preventDefault(); 1415 input.data('moving', 'hues'); 1416 moveHue(input, event); 1417 } 1418 1419 if ($(event.target).parents().andSelf().hasClass('miniColors-selector')) { 1420 event.preventDefault(); 1421 return; 1422 } 1423 1424 if ($(event.target).parents().andSelf().hasClass('miniColors')) return; 1425 1426 hide(input); 1427 }); 1428 1429 $(document).bind('mouseup.miniColors', function (event) { 1430 input.data('mousebutton', 0); 1431 input.removeData('moving'); 1432 }); 1433 1434 $(document).bind('mousemove.miniColors', function (event) { 1435 if (input.data('mousebutton') === 1) { 1436 if (input.data('moving') === 'colors') moveColor(input, event); 1437 if (input.data('moving') === 'hues') moveHue(input, event); 1438 } 1439 }); 1440 1441 }; 1442 1443 1444 var hide = function (input) { 1445 1446 // 1447 // Hides one or more miniColors selectors 1448 // 1449 // Hide all other instances if input isn't specified 1450 if (!input) input = '.miniColors'; 1451 1452 $(input).each(function () { 1453 var selector = $(this).data('selector'); 1454 $(this).removeData('selector'); 1455 $(selector).fadeOut(100, function () { 1456 $(this).remove(); 1457 }); 1458 }); 1459 1460 $(document).unbind('mousedown.miniColors'); 1461 $(document).unbind('mousemove.miniColors'); 1462 1463 }; 1464 1465 1466 var moveColor = function (input, event) { 1467 1468 var colorPicker = input.data('colorPicker'); 1469 1470 colorPicker.hide(); 1471 1472 var position = { 1473 x: event.clientX - input.data('selector').find('.miniColors-colors').offset().left + $(document).scrollLeft() - 5, 1474 y: event.clientY - input.data('selector').find('.miniColors-colors').offset().top + $(document).scrollTop() - 5 1475 }; 1476 1477 if (position.x <= -5) position.x = -5; 1478 if (position.x >= 144) position.x = 144; 1479 if (position.y <= -5) position.y = -5; 1480 if (position.y >= 144) position.y = 144; 1481 input.data('colorPosition', position); 1482 colorPicker.css('left', position.x).css('top', position.y).show(); 1483 1484 // Calculate saturation 1485 var s = Math.round((position.x + 5) * .67); 1486 if (s < 0) s = 0; 1487 if (s > 100) s = 100; 1488 1489 // Calculate brightness 1490 var b = 100 - Math.round((position.y + 5) * .67); 1491 if (b < 0) b = 0; 1492 if (b > 100) b = 100; 1493 1494 // Update HSB values 1495 var hsb = input.data('hsb'); 1496 hsb.s = s; 1497 hsb.b = b; 1498 1499 // Set color 1500 setColor(input, hsb, true); 1501 1502 }; 1503 1504 1505 var moveHue = function (input, event) { 1506 1507 var huePicker = input.data('huePicker'); 1508 1509 huePicker.hide(); 1510 1511 var position = { 1512 y: event.clientY - input.data('selector').find('.miniColors-colors').offset().top + $(document).scrollTop() - 1 1513 }; 1514 1515 if (position.y <= -1) position.y = -1; 1516 if (position.y >= 149) position.y = 149; 1517 input.data('huePosition', position); 1518 huePicker.css('top', position.y).show(); 1519 1520 // Calculate hue 1521 var h = Math.round((150 - position.y - 1) * 2.4); 1522 if (h < 0) h = 0; 1523 if (h > 360) h = 360; 1524 1525 // Update HSB values 1526 var hsb = input.data('hsb'); 1527 hsb.h = h; 1528 1529 // Set color 1530 setColor(input, hsb, true); 1531 1532 }; 1533 1534 1535 var setColor = function (input, hsb, updateInputValue) { 1536 1537 input.data('hsb', hsb); 1538 var hex = hsb2hex(hsb); 1539 if (updateInputValue) input.val('#' + hex); 1540 input.data('trigger').css('backgroundColor', '#' + hex); 1541 if (input.data('selector')) input.data('selector').find('.miniColors-colors').css('backgroundColor', '#' + hsb2hex({ 1542 h: hsb.h, 1543 s: 100, 1544 b: 100 1545 })); 1546 1547 if (input.data('change')) { 1548 input.data('change').call(input, '#' + hex, hsb2rgb(hsb)); 1549 } 1550 1551 }; 1552 1553 1554 var setColorFromInput = function (input) { 1555
1556 // Don't update if the hex color is invalid 1557 var hex = cleanHex(input.val()); 1558 if (!hex) return false; 1559 1560 // Get HSB equivalent 1561 var hsb = hex2hsb(hex); 1562 1563 // If color is the same, no change required 1564 var currentHSB = input.data('hsb'); 1565 if (hsb.h === currentHSB.h && hsb.s === currentHSB.s && hsb.b === currentHSB.b) return true; 1566 1567 // Set colorPicker position 1568 var colorPosition = getColorPositionFromHSB(hsb); 1569 var colorPicker = $(input.data('colorPicker')); 1570 colorPicker.css('top', colorPosition.y + 'px').css('left', colorPosition.x + 'px'); 1571 1572 // Set huePosition position 1573 var huePosition = getHuePositionFromHSB(hsb); 1574 var huePicker = $(input.data('huePicker')); 1575 huePicker.css('top', huePosition.y + 'px'); 1576 1577 setColor(input, hsb, false); 1578 1579 return true; 1580 1581 }; 1582 1583 1584 var getColorPositionFromHSB = function (hsb) { 1585 1586 var x = Math.ceil(hsb.s / .67); 1587 if (x < 0) x = 0; 1588 if (x > 150) x = 150; 1589 1590 var y = 150 - Math.ceil(hsb.b / .67); 1591 if (y < 0) y = 0; 1592 if (y > 150) y = 150; 1593 1594 return { 1595 x: x - 5, 1596 y: y - 5 1597 }; 1598 1599 }; 1600 1601 1602 var getHuePositionFromHSB = function (hsb) { 1603 1604 var y = 150 - (hsb.h / 2.4); 1605 if (y < 0) h = 0; 1606 if (y > 150) h = 150; 1607 1608 return { 1609 y: y - 1 1610 }; 1611 1612 }; 1613 1614 1615 var cleanHex = function (hex) { 1616 1617 // 1618 // Turns a dirty hex string into clean, 6-character hex color 1619 // 1620 hex = hex.replace(/[^A-Fa-f0-9]/, ''); 1621 1622 if (hex.length == 3) { 1623 hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; 1624 } 1625 1626 return hex.length === 6 ? hex : null; 1627 1628 }; 1629 1630 1631 var hsb2rgb = function (hsb) { 1632 var rgb = {}; 1633 var h = Math.round(hsb.h); 1634 var s = Math.round(hsb.s * 255 / 100); 1635 var v = Math.round(hsb.b * 255 / 100); 1636 if (s == 0) { 1637 rgb.r = rgb.g = rgb.b = v; 1638 } else { 1639 var t1 = v; 1640 var t2 = (255 - s) * v / 255; 1641 var t3 = (t1 - t2) * (h % 60) / 60; 1642 if (h == 360) h = 0; 1643 if (h < 60) { 1644 rgb.r = t1; 1645 rgb.b = t2; 1646 rgb.g = t2 + t3; 1647 } else if (h < 120) { 1648 rgb.g = t1; 1649 rgb.b = t2; 1650 rgb.r = t1 - t3; 1651 } else if (h < 180) { 1652 rgb.g = t1; 1653 rgb.r = t2; 1654 rgb.b = t2 + t3; 1655 } else if (h < 240) { 1656 rgb.b = t1; 1657 rgb.r = t2; 1658 rgb.g = t1 - t3; 1659 } else if (h < 300) { 1660 rgb.b = t1; 1661 rgb.g = t2; 1662 rgb.r = t2 + t3; 1663 } else if (h < 360) { 1664 rgb.r = t1; 1665 rgb.g = t2; 1666 rgb.b = t1 - t3; 1667 } else { 1668 rgb.r = 0; 1669 rgb.g = 0; 1670 rgb.b = 0; 1671 } 1672 } 1673 return { 1674 r: Math.round(rgb.r), 1675 g: Math.round(rgb.g), 1676 b: Math.round(rgb.b) 1677 }; 1678 }; 1679 1680 1681 var rgb2hex = function (rgb) { 1682 1683 var hex = [ 1684 rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; 1685 $.each(hex, function (nr, val) { 1686 if (val.length == 1) hex[nr] = '0' + val; 1687 }); 1688 1689 return hex.join(''); 1690 }; 1691 1692 1693 var hex2rgb = function (hex) { 1694 var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16); 1695 1696 return { 1697 r: hex >> 16, 1698 g: (hex & 0x00FF00) >> 8, 1699 b: (hex & 0x0000FF) 1700 }; 1701 }; 1702 1703 1704 var rgb2hsb = function (rgb) { 1705 var hsb = { 1706 h: 0, 1707 s: 0, 1708 b: 0 1709 }; 1710 var min = Math.min(rgb.r, rgb.g, rgb.b); 1711 var max = Math.max(rgb.r, rgb.g, rgb.b); 1712 var delta = max - min; 1713 hsb.b = max; 1714 hsb.s = max != 0 ? 255 * delta / max : 0; 1715 if (hsb.s != 0) { 1716 if (rgb.r == max) { 1717 hsb.h = (rgb.g - rgb.b) / delta; 1718 } else if (rgb.g == max) { 1719 hsb.h = 2 + (rgb.b - rgb.r) / delta; 1720 } else { 1721 hsb.h = 4 + (rgb.r - rgb.g) / delta; 1722 } 1723 } else { 1724 hsb.h = -1; 1725 } 1726 hsb.h *= 60; 1727 if (hsb.h < 0) { 1728 hsb.h += 360; 1729 } 1730 hsb.s *= 100 / 255; 1731 hsb.b *= 100 / 255; 1732 return hsb; 1733 }; 1734 1735 1736 var hex2hsb = function (hex) { 1737 var hsb = rgb2hsb(hex2rgb(hex)); 1738 // Zero out hue marker for black, white, and grays (saturation === 0) 1739 if (hsb.s === 0) hsb.h = 360; 1740 return hsb; 1741 }; 1742 1743 1744 var hsb2hex = function (hsb) { 1745 return rgb2hex(hsb2rgb(hsb)); 1746 }; 1747 1748 1749 // 1750 // Handle calls to $([selector]).miniColors() 1751 // 1752 switch (o) { 1753 1754 case 'readonly': 1755 1756 $(this).each(function () { 1757 $(this).attr('readonly', data); 1758 }); 1759 1760 return $(this); 1761 1762 break; 1763 1764 case 'disabled': 1765 1766 $(this).each(function () { 1767 if (data) { 1768 disable($(this)); 1769 } else { 1770 enable($(this)); 1771 } 1772 }); 1773 1774 return $(this); 1775 1776 case 'value': 1777 1778 $(this).each(function () { 1779 if(typeof data !== 'string'){ 1780 data = hsb2hex(data); 1781 } 1782 $(this).val(data).trigger('keyup'); 1783 }); 1784 1785 return $(this); 1786 1787 break; 1788 1789 case 'destroy': 1790 1791 $(this).each(function () { 1792 destroy($(this)); 1793 }); 1794 1795 return $(this); 1796 1797 default: 1798 1799 if (!o) o = {}; 1800 1801 $(this).each(function () { 1802 1803 // Must be called on an input element 1804 if ($(this)[0].tagName.toLowerCase() !== 'input') return; 1805 1806 // If a trigger is present, the control was already created 1807 if ($(this).data('trigger')) return; 1808 1809 // Create the control 1810 create($(this), o, data); 1811 1812 }); 1813 1814 return $(this); 1815 1816 } 1817 1818 1819 }; 1820 1821})(jQuery); 1822 1823 1824 1825/*----------------------------------------------------------------------*/ 1826/* 1827/*----------------------------------------------------------------------*/ 1828 1829 1830 1831/* 1832 * jQuery Iframe Transport Plugin 1.2.1 1833 * https://github.com/blueimp/jQuery-File-Upload 1834 * 1835 * Copyright 2011, Sebastian Tschan 1836 * https://blueimp.net 1837 * 1838 * Licensed under the MIT license: 1839 * http://creativecommons.org/licenses/MIT/ 1840 */ 1841 1842/*jslint unparam: true */ 1843/*global jQuery */ 1844 1845(function ($) { 1846 'use strict'; 1847 1848 // Helper variable to create unique names for the transport iframes: 1849 var counter = 0; 1850 1851 // The iframe transport accepts three additional options: 1852 // options.fileInput: a jQuery collection of file input fields 1853 // options.paramName: the parameter name for the file form data, 1854 // overrides the name property of the file input field(s) 1855 // options.formData: an array of objects with name and value properties, 1856 // equivalent to the return data of .serializeArray(), e.g.: 1857 // [{name: a, value: 1}, {name: b, value: 2}] 1858 $.ajaxTransport('iframe', function (options, originalOptions, jqXHR) { 1859 if (options.type === 'POST' || options.type === 'GET') { 1860 var form, 1861 iframe; 1862 return { 1863 send: function (headers, completeCallback) { 1864 form = $('<form style="display:none;"></form>'); 1865 // javascript:false as initial iframe src 1866 // prevents warning popups on HTTPS in IE6. 1867 // IE versions below IE8 cannot set the name property of 1868 // elements that have already been added to the DOM,
1869 // so we set the name along with the iframe HTML markup: 1870 iframe = $( 1871 '<iframe src="javascript:false;" name="iframe-transport-' + 1872 (counter += 1) + '"></iframe>' 1873 ).bind('load', function () { 1874 var fileInputClones; 1875 iframe 1876 .unbind('load') 1877 .bind('load', function () { 1878 var response; 1879 // Wrap in a try/catch block to catch exceptions thrown 1880 // when trying to access cross-domain iframe contents: 1881 try { 1882 response = iframe.contents(); 1883 } catch (e) { 1884 response = $(); 1885 } 1886 // The complete callback returns the 1887 // iframe content document as response object: 1888 completeCallback( 1889 200, 1890 'success', 1891 {'iframe': response} 1892 ); 1893 // Fix for IE endless progress bar activity bug 1894 // (happens on form submits to iframe targets): 1895 $('<iframe src="javascript:false;"></iframe>') 1896 .appendTo(form); 1897 form.remove(); 1898 }); 1899 form 1900 .prop('target', iframe.prop('name')) 1901 .prop('action', options.url) 1902 .prop('method', options.type); 1903 if (options.formData) { 1904 $.each(options.formData, function (index, field) { 1905 $('<input type="hidden"/>') 1906 .prop('name', field.name) 1907 .val(field.value) 1908 .appendTo(form); 1909 }); 1910 } 1911 if (options.fileInput && options.fileInput.length && 1912 options.type === 'POST') { 1913 fileInputClones = options.fileInput.clone(); 1914 // Insert a clone for each file input field: 1915 options.fileInput.after(function (index) { 1916 return fileInputClones[index]; 1917 }); 1918 if (options.paramName) { 1919 options.fileInput.each(function () { 1920 $(this).prop('name', options.paramName); 1921 }); 1922 } 1923 // Appending the file input fields to the hidden form 1924 // removes them from their original location: 1925 form 1926 .append(options.fileInput) 1927 .prop('enctype', 'multipart/form-data') 1928 // enctype must be set as encoding for IE: 1929 .prop('encoding', 'multipart/form-data'); 1930 } 1931 form.submit(); 1932 // Insert the file input fields at their original location 1933 // by replacing the clones with the originals: 1934 if (fileInputClones && fileInputClones.length) { 1935 options.fileInput.each(function (index, input) { 1936 var clone = $(fileInputClones[index]); 1937 $(input).prop('name', clone.prop('name')); 1938 clone.replaceWith(input); 1939 }); 1940 } 1941 }); 1942 form.append(iframe).appendTo('body'); 1943 }, 1944 abort: function () { 1945 if (iframe) { 1946 // javascript:false as iframe src aborts the request 1947 // and prevents warning popups on HTTPS in IE6. 1948 // concat is used to avoid the "Script URL" JSLint error: 1949 iframe 1950 .unbind('load') 1951 .prop('src', 'javascript'.concat(':false;')); 1952 } 1953 if (form) { 1954 form.remove(); 1955 } 1956 } 1957 }; 1958 } 1959 }); 1960 1961 // The iframe transport returns the iframe content document as response. 1962 // The following adds converters from iframe to text, json, html, and script: 1963 $.ajaxSetup({ 1964 converters: { 1965 'iframe text': function (iframe) { 1966 return iframe.text(); 1967 }, 1968 'iframe json': function (iframe) { 1969 return $.parseJSON(iframe.text()); 1970 }, 1971 'iframe html': function (iframe) { 1972 return iframe.find('body').html(); 1973 }, 1974 'iframe script': function (iframe) { 1975 return $.globalEval(iframe.text()); 1976 } 1977 } 1978 }); 1979 1980}(jQuery)); 1981 1982 1983/* 1984 * jQuery File Upload Plugin 5.0.2 1985 * https://github.com/blueimp/jQuery-File-Upload 1986 * 1987 * Copyright 2010, Sebastian Tschan 1988 * https://blueimp.net 1989 * 1990 * Licensed under the MIT license: 1991 * http://creativecommons.org/licenses/MIT/ 1992 */ 1993 1994/*jslint nomen: true, unparam: true, regexp: true */ 1995/*global document, XMLHttpRequestUpload, Blob, File, FormData, location, jQuery */ 1996 1997(function ($) { 1998 'use strict'; 1999 2000 // The fileupload widget listens for change events on file input fields 2001 // defined via fileInput setting and drop events of the given dropZone. 2002 // In addition to the default jQuery Widget methods, the fileupload widget 2003 // exposes the "add" and "send" methods, to add or directly send files 2004 // using the fileupload API. 2005 // By default, files added via file input selection, drag & drop or 2006 // "add" method are uploaded immediately, but it is possible to override 2007 // the "add" callback option to queue file uploads. 2008 $.widget('blueimp.fileupload', { 2009 2010 options: { 2011 // The namespace used for event handler binding on the dropZone and 2012 // fileInput collections. 2013 // If not set, the name of the widget ("fileupload") is used. 2014 namespace: undefined, 2015 // The drop target collection, by the default the complete document. 2016 // Set to null or an empty collection to disable drag & drop support: 2017 dropZone: $(document), 2018 // The file input field collection, that is listened for change events. 2019 // If undefined, it is set to the file input fields inside 2020 // of the widget element on plugin initialization. 2021 // Set to null or an empty collection to disable the change listener. 2022 fileInput: undefined, 2023 // By default, the file input field is replaced with a clone after 2024 // each input field change event. This is required for iframe transport 2025 // queues and allows change events to be fired for the same file 2026 // selection, but can be disabled by setting the following option to fal
2026se: 2027 replaceFileInput: true, 2028 // The parameter name for the file form data (the request argument name). 2029 // If undefined or empty, the name property of the file input field is 2030 // used, or "files[]" if the file input name property is also empty: 2031 paramName: undefined, 2032 // By default, each file of a selection is uploaded using an individual 2033 // request for XHR type uploads. Set to false to upload file 2034 // selections in one request each: 2035 singleFileUploads: true, 2036 // Set the following option to true to issue all file upload requests 2037 // in a sequential order: 2038 sequentialUploads: false, 2039 // Set the following option to true to force iframe transport uploads: 2040 forceIframeTransport: false, 2041 // By default, XHR file uploads are sent as multipart/form-data. 2042 // The iframe transport is always using multipart/form-data. 2043 // Set to false to enable non-multipart XHR uploads: 2044 multipart: true, 2045 // To upload large files in smaller chunks, set the following option 2046 // to a preferred maximum chunk size. If set to 0, null or undefined, 2047 // or the browser does not support the required Blob API, files will 2048 // be uploaded as a whole. 2049 maxChunkSize: undefined, 2050 // When a non-multipart upload or a chunked multipart upload has been 2051 // aborted, this option can be used to resume the upload by setting 2052 // it to the size of the already uploaded bytes. This option is most 2053 // useful when modifying the options object inside of the "add" or 2054 // "send" callbacks, as the options are cloned for each file upload. 2055 uploadedBytes: undefined, 2056 // By default, failed (abort or error) file uploads are removed from the 2057 // global progress calculation. Set the following option to false to 2058 // prevent recalculating the global progress data: 2059 recalculateProgress: true, 2060 2061 // Additional form data to be sent along with the file uploads can be set 2062 // using this option, which accepts an array of objects with name and 2063 // value properties, a function returning such an array, a FormData 2064 // object (for XHR file uploads), or a simple object. 2065 // The form of the first fileInput is given as parameter to the function: 2066 formData: function (form) { 2067 return form.serializeArray(); 2068 }, 2069 2070 // The add callback is invoked as soon as files are added to the fileupload 2071 // widget (via file input selection, drag & drop or add API call). 2072 // If the singleFileUploads option is enabled, this callback will be 2073 // called once for each file in the selection for XHR file uplaods, else 2074 // once for each file selection. 2075 // The upload starts when the submit method is invoked on the data parameter. 2076 // The data object contains a files property holding the added files 2077 // and allows to override plugin options as well as define ajax settings. 2078 // Listeners for this callback can also be bound the following way: 2079 // .bind('fileuploadadd', func); 2080 // data.submit() returns a Promise object and allows to attach additional 2081 // handlers using jQuery's Deferred callbacks: 2082 // data.submit().done(func).fail(func).always(func); 2083 add: function (e, data) { 2084 data.submit(); 2085 }, 2086 2087 // Other callbacks: 2088 // Callback for the start of each file upload request: 2089 // send: function (e, data) {}, // .bind('fileuploadsend', func); 2090 // Callback for successful uploads: 2091 // done: function (e, data) {}, // .bind('fileuploaddone', func); 2092 // Callback for failed (abort or error) uploads: 2093 // fail: function (e, data) {}, // .bind('fileuploadfail', func); 2094 // Callback for completed (success, abort or error) requests: 2095 // always: function (e, data) {}, // .bind('fileuploadalways', func); 2096 // Callback for upload progress events: 2097 // progress: function (e, data) {}, // .bind('fileuploadprogress', func); 2098 // Callback for global upload progress events: 2099 // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func); 2100 // Callback for uploads start, equivalent to the global ajaxStart event: 2101 // start: function (e) {}, // .bind('fileuploadstart', func); 2102 // Callback for uploads stop, equivalent to the global ajaxStop event: 2103 // stop: function (e) {}, // .bind('fileuploadstop', func); 2104 // Callback for change events of the fileInput collection: 2105 // change: function (e, data) {}, // .bind('fileuploadchange', func); 2106 // Callback for drop events of the dropZone collection: 2107 // drop: function (e, data) {}, // .bind('fileuploaddrop', func); 2108 // Callback for dragover events of the dropZone collection: 2109 // dragover: function (e) {}, // .bind('fileuploaddragover', func); 2110 2111 // The plugin options are used as settings object for the ajax calls. 2112 // The following are jQuery ajax settings required for the file uploads: 2113 processData: false, 2114 contentType: false, 2115 cache: false 2116 }, 2117 2118 // A list of options that require a refresh after assigning a new value: 2119 _refreshOptionsList: ['namespace', 'dropZone', 'fileInput'], 2120 2121 _isXHRUpload: function (options) { 2122 var undef = 'undefined'; 2123 return !options.forceIframeTransport && 2124 typeof XMLHttpRequestUpload !== undef && typeof File !== undef && 2125 (!options.multipart || typeof FormData !== undef); 2126 }, 2127 2128 _getFormData: function (options) { 2129 var formData; 2130 if (typeof options.formData === 'function') { 2131 return options.formData(options.form); 2132 } else if ($.isArray(options.formData)) { 2133 return options.formData; 2134 } else if (options.formData) { 2135 formData = []; 2136 $.each(options.formData, function (name, value) { 2137 formData.push({name: name, value: value}); 2138 }); 2139 return formData; 2140 } 2141 return []; 2142 }, 2143 2144 _getTotal: function (files) { 2145 var total = 0; 2146 $.each(files, function (index, file) { 2147 total += file.size || 1; 2148 }); 2149 return total; 2150 }, 2151 2152 _onProgress: function (e, data) { 2153 if (e.lengthComputable) { 2154 var total = data.total || this._getTotal(data.files), 2155 loaded = parseInt( 2156 e.loaded / e.total * (data.chunkSize || total), 2157 10 2158 ) + (data.uploadedBytes || 0); 2159 this._loaded += loaded - (data.loaded || data.uploadedBytes || 0); 2160 data.lengthComputable = true; 2161 data.loaded = loaded; 2162 data.total = total; 2163 // Trigger a custom progress event with a total data property set 2164 // to the file size(s) of the current upload and a loaded data 2165 // property calculated accordingly: 2166 this._trigger('progress', e, data); 2167 // Trigger a global progress event for all current file uploads, 2168 // including ajax calls queued for sequential file uploads: 2169 this._trigger('progressall', e, { 2170 lengthComputable: true, 2171 loaded: this._loaded, 2172 total: this._total 2173 }); 2174 } 2175 }, 2176 2177 _initProgressListener: function (options) { 2178 var that = this, 2179 xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); 2180 // Accesss to the native XHR object is required to add event listeners 2181 // for the upload progress event: 2182 if (xhr.upload && xhr.upload.addEventListener) { 2183 xhr.upload.addEventListener('progress', function (e) { 2184 that._onProgress(e, options); 2185 }, false); 2186 options.xhr = function () { 2187 return xhr; 2188 }; 2189 } 2190 }, 2191 2192 _initXHRData: function (options) { 2193 var formData, 2194 file = options.files[0]; 2195 if (!options.multipart || options.blob) { 2196 // For non-multipart uploads and chunked uploads, 2197 // file meta data is not part of the request body, 2198 // so we transmit this data as part of the HTTP headers. 2199 // For cross domain requests, these headers must be allowed 2200 // via Access-Control-Allow-Headers or removed using 2201 // the beforeSend callback: 2202 options.headers = $.extend(options.headers, { 2203 'X-File-Name': file.name, 2204 'X-File-Type': file.type, 2205 'X-File-Size': file.size 2206 }); 2207 if (!options.blob) { 2208 // Non-chunked non-multipart upload: 2209 options.contentType = file.type; 2210 options.data = file; 2211 } else if (!options.multipart) { 2212 // Chunked non-multipart upload: 2213 options.contentType = 'application/octet-stream'; 2214 options.data = options.blob; 2215 } 2216 } 2217 if (options.multipart && typeof FormData !== 'undefined') { 2218 if (options.formData instanceof FormData) { 2219 formData = options.formData; 2220 } else { 2221 formData = new FormData(); 2222 $.each(this._getFormData(options), function (index, field) { 2223 formData.append(field.name, field.value); 2224 }); 2225 } 2226 if (options.blob) { 2227 formData.append(options.paramName, options.blob); 2228 } else { 2229 $.each(options.files, function (index, file) { 2230 // File objects are also Blob instances. 2231 // This check allows the tests to run with 2232 // dummy objects: 2233 if (file instanceof Blob) { 2234 formData.append(options.paramName, file); 2235 } 2236 }); 2237 } 2238 options.data = formData; 2239 } 2240 // Blob reference is not needed anymore, free memory: 2241 options.blob = null; 2242 }, 2243 2244 _initIframeSettings: function (options) { 2245 // Setting the dataType to iframe enables the iframe transport: 2246 options.dataType = 'iframe ' + (options.dataType || ''); 2247 // The iframe transport accepts a serialized array as form data: 2248 options.formData = this._getFormData(options); 2249 }, 2250 2251 _initDataSettings: function (options) { 2252 if (this._isXHRUpload(options)) { 2253 if (!this._chunkedUpload(options, true)) { 2254 if (!options.data) { 2255 this._initXHRData(options); 2256 } 2257 this._initProgressListener(options); 2258 } 2259 } else { 2260 this._initIframeSettings(options); 2261 } 2262 }, 2263 2264 _initFormSettings: function (options) { 2265 // Retrieve missing options from the input field and the 2266 // associated form, if available: 2267 if (!options.form || !options.form.length) { 2268 options.form = $(options.fileInput.prop('form')); 2269 } 2270 if (!options.paramName) { 2271 options.paramName = options.fileInput.prop('name') || 2272 'files[]'; 2273 } 2274 if (!options.url) { 2275 options.url = options.form.prop('action') || location.href; 2276 } 2277 // The HTTP request method must be "POST" or "PUT": 2278 options.type = (options.type || options.form.prop('method') || '') 2279 .toUpperCase(); 2280 if (options.type !== 'POST' && options.type !== 'PUT') { 2281 options.type = 'POST'; 2282 } 2283 }, 2284 2285 _getAJAXSettings: function (data) { 2286 var options = $.extend({}, this.options, data); 2287 this._initFormSettings(options); 2288 this._initDataSettings(options); 2289 return options; 2290 }, 2291 2292 // Maps jqXHR callbacks to the equivalent 2293 // methods of the given Promise object: 2294 _enhancePromise: function (promise) { 2295 promise.success = promise.done; 2296 promise.error = promise.fail; 2297 promise.complete = promise.always; 2298 return promise; 2299 }, 2300 2301 // Creates and returns a Promise object enhanced with 2302 // the jqXHR methods abort, success, error and complete: 2303 _getXHRPromise: function (resolveOrReject, context, args
2303) { 2304 var dfd = $.Deferred(), 2305 promise = dfd.promise(); 2306 context = context || this.options.context || promise; 2307 if (resolveOrReject === true) { 2308 dfd.resolveWith(context, args); 2309 } else if (resolveOrReject === false) { 2310 dfd.rejectWith(context, args); 2311 } 2312 promise.abort = dfd.promise; 2313 return this._enhancePromise(promise); 2314 }, 2315 2316 // Uploads a file in multiple, sequential requests 2317 // by splitting the file up in multiple blob chunks. 2318 // If the second parameter is true, only tests if the file 2319 // should be uploaded in chunks, but does not invoke any 2320 // upload requests: 2321 _chunkedUpload: function (options, testOnly) { 2322 var that = this, 2323 file = options.files[0], 2324 fs = file.size, 2325 ub = options.uploadedBytes = options.uploadedBytes || 0, 2326 mcs = options.maxChunkSize || fs, 2327 // Use the Blob methods with the slice implementation 2328 // according to the W3C Blob API specification: 2329 slice = file.webkitSlice || file.mozSlice || file.slice, 2330 upload, 2331 n, 2332 jqXHR, 2333 pipe; 2334 if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || 2335 options.data) { 2336 return false; 2337 } 2338 if (testOnly) { 2339 return true; 2340 } 2341 if (ub >= fs) { 2342 file.error = 'uploadedBytes'; 2343 return this._getXHRPromise(false); 2344 } 2345 // n is the number of blobs to upload, 2346 // calculated via filesize, uploaded bytes and max chunk size: 2347 n = Math.ceil((fs - ub) / mcs); 2348 // The chunk upload method accepting the chunk number as parameter: 2349 upload = function (i) { 2350 if (!i) { 2351 return that._getXHRPromise(true); 2352 } 2353 // Upload the blobs in sequential order: 2354 return upload(i -= 1).pipe(function () { 2355 // Clone the options object for each chunk upload: 2356 var o = $.extend({}, options); 2357 o.blob = slice.call( 2358 file, 2359 ub + i * mcs, 2360 ub + (i + 1) * mcs 2361 ); 2362 // Store the current chunk size, as the blob itself 2363 // will be dereferenced after data processing: 2364 o.chunkSize = o.blob.size; 2365 // Process the upload data (the blob and potential form data): 2366 that._initXHRData(o); 2367 // Add progress listeners for this chunk upload: 2368 that._initProgressListener(o); 2369 jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context)) 2370 .done(function () { 2371 // Create a progress event if upload is done and 2372 // no progress event has been invoked for this chunk: 2373 if (!o.loaded) { 2374 that._onProgress($.Event('progress', { 2375 lengthComputable: true, 2376 loaded: o.chunkSize, 2377 total: o.chunkSize 2378 }), o); 2379 } 2380 options.uploadedBytes = o.uploadedBytes 2381 += o.chunkSize; 2382 }); 2383 return jqXHR; 2384 }); 2385 }; 2386 // Return the piped Promise object, enhanced with an abort method, 2387 // which is delegated to the jqXHR object of the current upload, 2388 // and jqXHR callbacks mapped to the equivalent Promise methods: 2389 pipe = upload(n); 2390 pipe.abort = function () { 2391 return jqXHR.abort(); 2392 }; 2393 return this._enhancePromise(pipe); 2394 }, 2395 2396 _beforeSend: function (e, data) { 2397 if (this._active === 0) { 2398 // the start callback is triggered when an upload starts 2399 // and no other uploads are currently running, 2400 // equivalent to the global ajaxStart event: 2401 this._trigger('start'); 2402 } 2403 this._active += 1; 2404 // Initialize the global progress values: 2405 this._loaded += data.uploadedBytes || 0; 2406 this._total += this._getTotal(data.files); 2407 }, 2408 2409 _onDone: function (result, textStatus, jqXHR, options) { 2410 if (!this._isXHRUpload(options)) { 2411 // Create a progress event for each iframe load: 2412 this._onProgress($.Event('progress', { 2413 lengthComputable: true, 2414 loaded: 1, 2415 total: 1 2416 }), options); 2417 } 2418 options.result = result; 2419 options.textStatus = textStatus; 2420 options.jqXHR = jqXHR; 2421 this._trigger('done', null, options); 2422 }, 2423 2424 _onFail: function (jqXHR, textStatus, errorThrown, options) { 2425 options.jqXHR = jqXHR; 2426 options.textStatus = textStatus; 2427 options.errorThrown = errorThrown; 2428 this._trigger('fail', null, options); 2429 if (options.recalculateProgress) { 2430 // Remove the failed (error or abort) file upload from 2431 // the global progress calculation: 2432 this._loaded -= options.loaded || options.uploadedBytes || 0;
2433 this._total -= options.total || this._getTotal(options.files); 2434 } 2435 }, 2436 2437 _onAlways: function (result, textStatus, jqXHR, errorThrown, options) { 2438 this._active -= 1; 2439 options.result = result; 2440 options.textStatus = textStatus; 2441 options.jqXHR = jqXHR; 2442 options.errorThrown = errorThrown; 2443 this._trigger('always', null, options); 2444 if (this._active === 0) { 2445 // The stop callback is triggered when all uploads have 2446 // been completed, equivalent to the global ajaxStop event: 2447 this._trigger('stop'); 2448 // Reset the global progress values: 2449 this._loaded = this._total = 0; 2450 } 2451 }, 2452 2453 _onSend: function (e, data) { 2454 var that = this, 2455 jqXHR, 2456 pipe, 2457 options = that._getAJAXSettings(data), 2458 send = function (resolve, args) { 2459 jqXHR = jqXHR || ( 2460 (resolve !== false && 2461 that._trigger('send', e, options) !== false && 2462 (that._chunkedUpload(options) || $.ajax(options))) || 2463 that._getXHRPromise(false, options.context, args) 2464 ).done(function (result, textStatus, jqXHR) { 2465 that._onDone(result, textStatus, jqXHR, options); 2466 }).fail(function (jqXHR, textStatus, errorThrown) { 2467 that._onFail(jqXHR, textStatus, errorThrown, options); 2468 }).always(function (a1, a2, a3) { 2469 if (!a3 || typeof a3 === 'string') { 2470 that._onAlways(undefined, a2, a1, a3, options); 2471 } else { 2472 that._onAlways(a1, a2, a3, undefined, options); 2473 } 2474 }); 2475 return jqXHR; 2476 }; 2477 this._beforeSend(e, options); 2478 if (this.options.sequentialUploads) { 2479 // Return the piped Promise object, enhanced with an abort method, 2480 // which is delegated to the jqXHR object of the current upload, 2481 // and jqXHR callbacks mapped to the equivalent Promise methods: 2482 pipe = (this._sequence = this._sequence.pipe(send, send)); 2483 pipe.abort = function () { 2484 if (!jqXHR) { 2485 return send(false, [undefined, 'abort', 'abort']); 2486 } 2487 return jqXHR.abort(); 2488 }; 2489 return this._enhancePromise(pipe); 2490 } 2491 return send(); 2492 }, 2493 2494 _onAdd: function (e, data) { 2495 var that = this, 2496 result = true, 2497 options = $.extend({}, this.options, data); 2498 if (options.singleFileUploads && this._isXHRUpload(options)) { 2499 $.each(data.files, function (index, file) { 2500 var newData = $.extend({}, data, {files: [file]}); 2501 newData.submit = function () { 2502 return that._onSend(e, newData); 2503 }; 2504 return (result = that._trigger('add', e, newData)); 2505 }); 2506 return result; 2507 } else if (data.files.length) { 2508 data = $.extend({}, data); 2509 data.submit = function () { 2510 return that._onSend(e, data); 2511 }; 2512 return this._trigger('add', e, data); 2513 } 2514 }, 2515 2516 // File Normalization for Gecko 1.9.1 (Firefox 3.5) support: 2517 _normalizeFile: function (index, file) { 2518 if (file.name === undefined && file.size === undefined) { 2519 file.name = file.fileName; 2520 file.size = file.fileSize; 2521 } 2522 }, 2523 2524 _replaceFileInput: function (input) { 2525 var inputClone = input.clone(true); 2526 $('<form></form>').append(inputClone)[0].reset(); 2527 // Detaching allows to insert the fileInput on another form 2528 // without loosing the file input value: 2529 input.after(inputClone).detach(); 2530 // Replace the original file input element in the fileInput 2531 // collection with the clone, which has been copied including 2532 // event handlers: 2533 this.options.fileInput = this.options.fileInput.map(function (i, el) { 2534 if (el === input[0]) { 2535 return inputClone[0]; 2536 } 2537 return el; 2538 }); 2539 }, 2540 2541 _onChange: function (e) { 2542 var that = e.data.fileupload, 2543 data = { 2544 files: $.each($.makeArray(e.target.files), that._normalizeFile), 2545 fileInput: $(e.target), 2546 form: $(e.target.form) 2547 }; 2548 if (!data.files.length) { 2549 // If the files property is not available, the browser does not 2550 // support the File API and we add a pseudo File object with 2551 // the input value as name with path information removed: 2552 data.files = [{name: e.target.value.replace(/^.*\\/, '')}]; 2553 } 2554 // Store the form reference as jQuery data for other event handlers, 2555 // as the form property is not available after replacing the file input
2555: 2556 if (data.form.length) { 2557 data.fileInput.data('blueimp.fileupload.form', data.form); 2558 } else { 2559 data.form = data.fileInput.data('blueimp.fileupload.form'); 2560 } 2561 if (that.options.replaceFileInput) { 2562 that._replaceFileInput(data.fileInput); 2563 } 2564 if (that._trigger('change', e, data) === false || 2565 that._onAdd(e, data) === false) { 2566 return false; 2567 } 2568 }, 2569 2570 _onDrop: function (e) { 2571 var that = e.data.fileupload, 2572 dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer, 2573 data = { 2574 files: $.each( 2575 $.makeArray(dataTransfer && dataTransfer.files), 2576 that._normalizeFile 2577 ) 2578 }; 2579 if (that._trigger('drop', e, data) === false || 2580 that._onAdd(e, data) === false) { 2581 return false; 2582 } 2583 e.preventDefault(); 2584 }, 2585 2586 _onDragOver: function (e) { 2587 var that = e.data.fileupload, 2588 dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer; 2589 if (that._trigger('dragover', e) === false) { 2590 return false; 2591 } 2592 if (dataTransfer) { 2593 dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy'; 2594 } 2595 e.preventDefault(); 2596 }, 2597 2598 _initEventHandlers: function () { 2599 var ns = this.options.namespace || this.name; 2600 this.options.dropZone 2601 .bind('dragover.' + ns, {fileupload: this}, this._onDragOver) 2602 .bind('drop.' + ns, {fileupload: this}, this._onDrop); 2603 this.options.fileInput 2604 .bind('change.' + ns, {fileupload: this}, this._onChange); 2605 }, 2606 2607 _destroyEventHandlers: function () { 2608 var ns = this.options.namespace || this.name; 2609 this.options.dropZone 2610 .unbind('dragover.' + ns, this._onDragOver) 2611 .unbind('drop.' + ns, this._onDrop); 2612 this.options.fileInput 2613 .unbind('change.' + ns, this._onChange); 2614 }, 2615 2616 _beforeSetOption: function (key, value) { 2617 //this._destroyEventHandlers(); 2618 }, 2619 2620 _afterSetOption: function (key, value) { 2621 var options = this.options; 2622 if (!options.fileInput) { 2623 options.fileInput = $(); 2624 } 2625 if (!options.dropZone) { 2626 options.dropZone = $(); 2627 } 2628 this._initEventHandlers(); 2629 }, 2630 2631 _setOption: function (key, value) { 2632 var refresh = $.inArray(key, this._refreshOptionsList) !== -1; 2633 if (refresh) { 2634 this._beforeSetOption(key, value); 2635 } 2636 $.Widget.prototype._setOption.call(this, key, value); 2637 if (refresh) { 2638 this._afterSetOption(key, value); 2639 } 2640 }, 2641 2642 _create: function () { 2643 var options = this.options; 2644 if (options.fileInput === undefined) { 2645 options.fileInput = this.element.is('input:file') ? 2646 this.element : this.element.find('input:file'); 2647 } else if (!options.fileInput) { 2648 options.fileInput = $(); 2649 } 2650 if (!options.dropZone) { 2651 options.dropZone = $(); 2652 } 2653 this._sequence = this._getXHRPromise(true); 2654 this._active = this._loaded = this._total = 0; 2655 this._initEventHandlers(); 2656 }, 2657 2658 destroy: function () { 2659 // this._destroyEventHandlers(); 2660 //$.Widget.prototype.destroy.call(this); 2661 }, 2662 2663 enable: function () { 2664 $.Widget.prototype.enable.call(this); 2665 this._initEventHandlers(); 2666 }, 2667 2668 disable: function () { 2669 this._destroyEventHandlers(); 2670 $.Widget.prototype.disable.call(this); 2671 }, 2672 2673 // This method is exposed to the widget API and allows adding files 2674 // using the fileupload API. The data parameter accepts an object which 2675 // must have a files property and can contain additional options: 2676 // .fileupload('add', {files: filesList}); 2677 add: function (data) { 2678 if (!data || this.options.disabled) { 2679 return; 2680 } 2681 data.files = $.each($.makeArray(data.files), this._normalizeFile); 2682 this._onAdd(null, data); 2683 }, 2684 2685 // This method is exposed to the widget API and allows sending files 2686 // using the fileupload API. The data parameter accepts an object which 2687 // must have a files property and can contain additional options: 2688 // .fileupload('send', {files: filesList}); 2689 // The method returns a Promise object for the file upload call. 2690 send: function (data) { 2691 if (data && !this.options.disabled) { 2692 data.files = $.each($.makeArray(data.files), this._normalizeFile); 2693 if (data.files.length) { 2694 return this._onSend(null, data); 2695 } 2696 } 2697 return this._getXHRPromise(false, data && data.context); 2698 } 2699 2700 }); 2701 2702}(jQuery)); 2703 2704 2705/* 2706* FancyBox - jQuery Plugin 2707* Simple and fancy lightbox alternative 2708* 2709* Examples and documentation at: http://fancybox.net 2710* 2711* Copyright (c) 2008 - 2010 Janis Skarnelis 2712* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. 2713* 2714* Version: 1.3.4 (11/11/2010) 2715* Requires: jQuery v1.3+ 2716* 2717* Dual licensed under the MIT and GPL licenses: 2718* http://www.opensource.org/licenses/mit-license.php 2719* http://www.gnu.org/licenses/gpl.html 2720*/ 2721 2722;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>'); 2723F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)|| 2724c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick= 2725false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel", 2726function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+ 2727'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';
2727P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win== 2728"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+ 2729";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor, 2730opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length? 2731d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding}); 2732y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height== 2733i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents()); 2734f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode== 273537||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});
2735if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto"); 2736s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j); 2737f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c); 2738j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type== 2739"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"), 274010)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)}; 2741b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k= 27420,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+ 27431)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h= 2744true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");
2744b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1; 2745b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5- 2746d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f); 2747D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()}); 2748b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}}; 2749b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing", 2750easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(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.