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/// <reference path="jquery-1.7.min.js" /> 10 11 12(function ($) { 13 $.support.touch = typeof Touch === 'object'; 14 15 if (!$.support.touch) { 16 return; 17 } 18 19 var mouseProto = $.ui.mouse.prototype, 20 _mouseInit = mouseProto._mouseInit, 21 _mouseDown = mouseProto._mouseDown, 22 _mouseUp = mouseProto._mouseUp, 23 24 mouseEvents = { 25 touchstart: 'mousedown', 26 touchmove: 'mousemove', 27 touchend: 'mouseup' 28 }; 29 30 function makeMouseEvent(event) { 31 event.stopPropagation(); 32 var touch = event.originalEvent.changedTouches[0]; 33 return $.extend(event, { 34 type: mouseEvents[event.type], 35 which: 1, 36 pageX: touch.pageX, 37 pageY: touch.pageY, 38 screenX: touch.screenX, 39 screenY: touch.screenY, 40 clientX: touch.clientX, 41 clientY: touch.clientY 42 }); 43 } 44 45 mouseProto._mouseInit = function () { 46 47 var self = this; 48 49 self.element.bind('touchstart.' + self.widgetName, function (event) {
50 return self._mouseDown(makeMouseEvent(event)); 51 }); 52 53 _mouseInit.call(self); 54 }; 55 56 mouseProto._mouseDown = function (event) { 57 58 59 var self = this, 60 ret = _mouseDown.call(self, event); 61 62 if (self.options.handle && !$(event.target).is(self.options.handle)) { 63 mouseProto._mouseUp(event); 64 return; 65 } 66 67 self._touchMoveDelegate = function (event) { 68 return self._mouseMove(makeMouseEvent(event)); 69 }; 70 71 self._touchEndDelegate = function (event) { 72 return self._mouseUp(makeMouseEvent(event)); 73 }; 74 75 $(document).bind('touchmove.' + self.widgetName, self._touchMoveDelegate).bind('touchend.' + self.widgetName, self._touchEndDelegate); 76 77 return ret; 78 }; 79 80 mouseProto._mouseUp = function (event) { 81 82 var self = this; 83 $(document).unbind('touchmove.' + self.widgetName, self._touchMoveDelegate).unbind('touchend.' + self.widgetName, self._touchEndDelegate); 84 85 return _mouseUp.call(self, event); 86 }; 87})(jQuery); 88 89 90/*----------------------------------------------------------------------*/ 91/* jQuery MouseWheel Plugin by Brandon Aaron 92/* http://brandonaaron.net/code/mousewheel/docs 93/*----------------------------------------------------------------------*/ 94 95 96(function ($) { 97 98 $.event.special.mousewheel = { 99 setup: function () { 100 var handler = $.event.special.mousewheel.handler; 101 102 // Fix pageX, pageY, clientX and clientY for mozilla 103 if ($.browser.mozilla) $(this).bind('mousemove.mousewheel', function (event) { 104 $.data(this, 'mwcursorposdata', { 105 pageX: event.pageX, 106 pageY: event.pageY, 107 clientX: event.clientX, 108 clientY: event.clientY 109 }); 110 }); 111 112 if (this.addEventListener) this.addEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 113 else this.onmousewheel = handler; 114 }, 115 116 teardown: function () { 117 var handler = $.event.special.mousewheel.handler; 118 119 $(this).unbind('mousemove.mousewheel'); 120 121 if (this.removeEventListener) this.removeEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false); 122 else this.onmousewheel = function () {}; 123 124 $.removeData(this, 'mwcursorposdata'); 125 }, 126 127 handler: function (event) { 128 var args = Array.prototype.slice.call(arguments, 1); 129 130 event = $.event.fix(event || window.event); 131 // Get correct pageX, pageY, clientX and clientY for mozilla 132 $.extend(event, $.data(this, 'mwcursorposdata') || {}); 133 var delta = 0, 134 returnValue = true; 135 136 if (event.wheelDelta) { 137 delta = (event.wheelDelta / 120); 138 } 139 if (event.detail) { 140 delta = (-event.detail / 3); 141 } 142 //if ( $.browser.opera ) delta=(event.wheelDelta/120); 143 event.data = event.data || {}; 144 event.type = "mousewheel"; 145 146 // Add delta to the front of the arguments 147 args.unshift(delta); 148 // Add event to the front of the arguments 149 args.unshift(event); 150 151 return $.event.handle.apply(this, args); 152 } 153 }; 154 155 $.fn.extend({ 156 mousewheel: function (fn) { 157 return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); 158 }, 159 160 unmousewheel: function (fn) { 161 return this.unbind("mousewheel", fn); 162 } 163 }); 164 165})(jQuery); 166 167 168/*----------------------------------------------------------------------*/ 169/* jQuery Tipsy Plugin by Jason Frame https://twitter.com/jaz303 v 1.0.0a 170/* http://onehackoranother.com/projects/jquery/tipsy/ 171/* (c) 2008-2010 jason frame [[email protected]] 172/* releated under the MIT license 173/* 174/* !!! I did some modifications on that plugin! !!! 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(this.options.appendTo); 205 var pos = $.extend({}, this.$element.offset(), { 206 width: this.$element[0].offsetWidth, 207 height: this.$element[0].offsetHeight 208 }); 209 if(this.options.appendTo != 'body')pos.top = pos.left = 0; 210 211 var actualWidth = $tip[0].offsetWidth, 212 actualHeight = $tip[0].offsetHeight; 213 var gravity = (typeof this.options.gravity == 'function') ? this.options.gravity.call(this.$element[0]) : this.options.gravity;
214 215 var tp; 216 var mp; 217 switch (gravity.charAt(0)) { 218 case 'n': 219 tp = { 220 top: pos.top + pos.height + this.options.offset, 221 left: pos.left + pos.width / 2 - actualWidth / 2 222 }; 223 mp = {top:15,left:-actualWidth/2}; 224 break; 225 case 's': 226 tp = { 227 top: pos.top - actualHeight - this.options.offset, 228 left: pos.left + pos.width / 2 - actualWidth / 2 229 }; 230 mp = {top:-actualHeight-15,left:-actualWidth/2}; 231 break; 232 case 'e': 233 tp = { 234 top: pos.top + pos.height / 2 - actualHeight / 2, 235 left: pos.left - actualWidth - this.options.offset 236 }; 237 mp = {top:-actualHeight/2,left:-12-actualWidth}; 238 break; 239 case 'w': 240 tp = { 241 top: pos.top + pos.height / 2 - actualHeight / 2, 242 left: pos.left + pos.width + this.options.offset 243 }; 244 mp = {top:-actualHeight/2,left:12}; 245 break; 246 } 247 if (gravity.length == 2) { 248 if (gravity.charAt(1) == 'w') { 249 //tp.left = pos.left + pos.width / 2 - 15; 250 tp.left = pos.left - 5; 251 mp.left += actualWidth/2-15; 252 } else { 253 //tp.left = pos.left + pos.width / 2 - actualWidth + 15; 254 mp.left -= actualWidth/2-15; 255 tp.left = pos.left + pos.width - actualWidth + 5; 256 } 257 } 258 259 if(this.options.followMouse){ 260 $(document).bind('mousemove.tipsy',function(e){ 261 var x = e.pageX+mp.left, y = e.pageY+mp.top; 262 $tip.css({ 263 left: x, 264 top: y 265 }); 266 }); 267 } 268 269 $tip.css(tp).addClass('tipsy-' + gravity); 270 if (this.options.fade) { 271 $tip.stop().css({ 272 opacity: 0, 273 display: 'block', 274 visibility: 'visible' 275 }).animate({ 276 opacity: this.options.opacity 277 }); 278 } else { 279 $tip.css({ 280 visibility: 'visible', 281 opacity: this.options.opacity 282 }); 283 } 284 } 285 }, 286 287 hide: function () { 288 if(this.options.followMouse){ 289 $(document).unbind('mousemove.tipsy'); 290 } 291 if (this.options.fade) { 292 this.tip().stop().fadeOut(function () { 293 $(this).remove(); 294 }); 295 } else { 296 this.tip().remove(); 297 } 298 }, 299 300 getTitle: function () { 301 var title, $e = this.$element, 302 o = this.options; 303 fixTitle($e); 304 var title, o = this.options; 305 if (typeof o.title == 'string') { 306 title = $e.attr(o.title == 'title' ? 'original-title' : o.title); 307 } else if (typeof o.title == 'function') { 308 title = o.title.call($e[0]); 309 } 310 if(!title) title = o.fallback; 311 title = ('' + title).replace(/(^\s*|\s*$)/, ""); 312 return title || o.fallback; 313 }, 314 315 setTitel: function(title) { 316 this.options.fallback = title; 317 }, 318 319 tip: function () { 320 if (!this.$tip) { 321 this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-outer"><div class="tipsy-inner"/></div></div>'); 322 } 323 return this.$tip; 324 }, 325 326 validate: function () { 327 if (!this.$element[0].parentNode) { 328 this.hide(); 329 this.$element = null; 330 this.options = null; 331 } 332 }, 333 334 enable: function () { 335 this.enabled = true; 336 }, 337 disable: function () { 338 this.enabled = false; 339 }, 340 update: function () { 341 var $tip = this.tip(); 342 $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](this.options.fallback); 343 }, 344 toggleEnabled: function () { 345 this.enabled = !this.enabled; 346 } 347 }; 348 349 $.fn.tipsy = function (options) { 350 351 if (options === true) { 352 return this.data('tipsy'); 353 } else if (typeof options == 'string') { 354 if(this.data('tipsy') == undefined) 355 return; 356 return this.data('tipsy')[options](arguments[1], arguments[2]); 357 } 358 359 options = $.extend({}, $.fn.tipsy.defaults, options); 360 361 function get(ele) { 362 var tipsy = $.data(ele, 'tipsy'); 363 if (!tipsy) { 364 tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); 365 $.data(ele, 'tipsy', tipsy); 366 } 367 return tipsy; 368 } 369 370 function enter() { 371 var tipsy = get(this); 372 tipsy.hoverState = 'in'; 373 if (options.delayIn == 0) { 374 tipsy.show(); 375 } else { 376 setTimeout(function () { 377 if (tipsy.hoverState == 'in') tipsy.show(); 378 }, options.delayIn); 379 } 380 }; 381 382 function leave() { 383 var tipsy = get(this); 384 tipsy.hoverState = 'out'; 385 if (options.delayOut == 0) { 386 tipsy.hide(); 387 } else { 388 setTimeout(function () { 389 if (tipsy.hoverState == 'out') tipsy.hide(); 390 }, options.delayOut); 391 } 392 }; 393 394 if (!options.live) this.each(function () { 395 get(this); 396 }); 397 if (options.trigger != 'manual') { 398 var binder = options.live ? 'live' : 'bind', 399 eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', 400 eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; 401 this[binder](eventIn+'.tipsy', enter)[binder](eventOut+'.tipsy', leave); 402 } 403 404 return this; 405 406 }; 407 408 $.fn.tipsy.defaults = { 409 delayIn: 0, 410 delayOut: 0, 411 fade: false, 412 fallback: '', 413 gravity: 'n', 414 html: false, 415 live: false, 416 offset: 0, 417 opacity: 0.8, 418 //CUSTOM followMouse 419 followMouse: false, 420 appendTo: 'body', 421 title: 'title',
422 trigger: 'hover' 423 }; 424 425 // Overwrite this method to provide options on a per-element basis. 426 // For example, you could store the gravity in a 'tipsy-gravity' attribute: 427 // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); 428 // (remember - do not modify 'options' in place!) 429 $.fn.tipsy.elementOptions = function (ele, options) { 430 return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; 431 }; 432 433 $.fn.tipsy.autoNS = function () { 434 return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; 435 }; 436 437 $.fn.tipsy.autoWE = function () { 438 return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; 439 }; 440 441})(jQuery); 442 443 444/*----------------------------------------------------------------------*/ 445/* jQuery Uniform v1.7.5 446/* Copyright © 2009 Josh Pyles / Pixelmatrix Design LLC 447/* http://pixelmatrixdesign.com 448/* License: MIT License - http://www.opensource.org/licenses/mit-license.php 449/*----------------------------------------------------------------------*/ 450 451 452(function($) { 453 $.uniform = { 454 options: { 455 selectClass: 'selector', 456 radioClass: 'radio', 457 checkboxClass: 'checker', 458 fileClass: 'uploader', 459 filenameClass: 'filename', 460 fileBtnClass: 'action', 461 fileDefaultText: 'Optional', 462 fileBtnText: 'Choose File', 463 checkedClass: 'checked', 464 focusClass: 'focus', 465 disabledClass: 'disabled', 466 buttonClass: 'button', 467 activeClass: 'active', 468 hoverClass: 'hover', 469 useID: true, 470 idPrefix: 'uniform', 471 resetSelector: false, 472 autoHide: true 473 }, 474 elements: [] 475 }; 476 477 if($.browser.msie && $.browser.version < 7){ 478 $.support.selectOpacity = false; 479 }else{ 480 $.support.selectOpacity = true; 481 } 482 483 $.fn.uniform = function(options) { 484 485 options = $.extend($.uniform.options, options); 486 487 var el = this; 488 //code for specifying a reset button 489 if(options.resetSelector != false){ 490 $(options.resetSelector).mouseup(function(){ 491 function resetThis(){ 492 $.uniform.update(el); 493 } 494 setTimeout(resetThis, 10); 495 }); 496 } 497 498 function doInput(elem){ 499 $el = $(elem); 500 $el.addClass($el.attr("type")); 501 storeElement(elem); 502 } 503 504 function doTextarea(elem){ 505 $(elem).addClass("uniform"); 506 storeElement(elem); 507 } 508 509 function doButton(elem){ 510 var $el = $(elem); 511 512 var divTag = $("<div>"), 513 spanTag = $("<span>"); 514 515 divTag.addClass(options.buttonClass); 516 517 if(options.useID && $el.attr("id") != "") divTag.attr("id", options.idPrefix+"-"+$el.attr("id")); 518 519 var btnText; 520 521 if($el.is("a") || $el.is("button")){ 522 btnText = $el.text(); 523 }else if($el.is(":submit") || $el.is(":reset") || $el.is("input[type=button]")){ 524 btnText = $el.attr("value"); 525 } 526 527 btnText = btnText == "" ? $el.is(":reset") ? "Reset" : "Submit" : btnText; 528 529 spanTag.html(btnText); 530 531 $el.css("opacity", 0); 532 $el.wrap(divTag); 533 $el.wrap(spanTag); 534 535 //redefine variables 536 divTag = $el.closest("div"); 537 spanTag = $el.closest("span"); 538 539 if($el.is(":disabled")) divTag.addClass(options.disabledClass); 540 541 divTag.bind({ 542 "mouseenter.uniform": function(){ 543 divTag.addClass(options.hoverClass); 544 }, 545 "mouseleave.uniform": function(){ 546 divTag.removeClass(options.hoverClass); 547 divTag.removeClass(options.activeClass); 548 }, 549 "mousedown.uniform touchbegin.uniform": function(){ 550 divTag.addClass(options.activeClass); 551 }, 552 "mouseup.uniform touchend.uniform": function(){ 553 divTag.removeClass(options.activeClass); 554 }, 555 "click.uniform touchend.uniform": function(e){ 556 if($(e.target).is("span") || $(e.target).is("div")){ 557 if(elem[0].dispatchEvent){ 558 var ev = document.createEvent('MouseEvents'); 559 ev.initEvent( 'click', true, true ); 560 elem[0].dispatchEvent(ev); 561 }else{ 562 elem[0].click(); 563 } 564 } 565 } 566 }); 567 568 elem.bind({ 569 "focus.uniform": function(){ 570 divTag.addClass(options.focusClass); 571 }, 572 "blur.uniform": function(){ 573 divTag.removeClass(options.focusClass); 574 } 575 }); 576 577 $.uniform.noSelect(divTag); 578 storeElement(elem); 579 580 } 581 582 function doSelect(elem){ 583 var $el = $(elem); 584 585 var divTag = $('<div />'), 586 spanTag = $('<span />'); 587 588 if(!$el.css("display") == "none" && options.autoHide){ 589 divTag.hide(); 590 } 591 592 divTag.addClass(options.selectClass); 593 594 if(options.useID && elem.attr("id") != ""){ 595 divTag.attr("id", options.idPrefix+"-"+elem.attr("id")); 596 } 597 598 var selected = elem.find(":selected:first"); 599 if(selected.length == 0){ 600 selected = elem.find("option:first"); 601 } 602 spanTag.html(selected.html().replace('&','&').substr(0,98)); 603 604 elem.css('opacity', 0); 605 elem.wrap(divTag); 606 elem.before(spanTag); 607 608 //redefine variables 609 divTag = elem.parent("div"); 610 spanTag = elem.siblings("span"); 611 612 elem.bind({ 613 "change.uniform": function() { 614 spanTag.html(elem.find(":selected").html().replace('&','&').substr(0,98)); 615 616 divTag.removeClass(options.activeClass); 617 }, 618 "focus.uniform": function() { 619 divTag.addClass(options.focusClass); 620 }, 621 "blur.uniform": function() { 622 divTag.removeClass(options.focusClass); 623 divTag.removeClass(options.activeClass); 624 }, 625 "mousedown.uniform touchbegin.uniform": function() { 626 divTag.addClass(options.activeClass); 627 }, 628 "mouseup.uniform touchend.uniform": function() { 629 divTag.removeClass(options.activeClass); 630 }, 631 "click.uniform touchend.uniform": function(){ 632 divTag.removeClass(options.activeClass); 633 }, 634 "mouseenter.uniform": function() { 635 divTag.addClass(options.hoverClass); 636 }, 637 "mouseleave.uniform": function() { 638 divTag.removeClass(options.hoverClass); 639 divTag.removeClass(options.activeClass); 640 }, 641 "keyup.uniform": function(){ 642 spanTag.text(elem.find(":selected").html().replace('&','&').substr(0,98)); 643 } 644 }); 645 646 //handle disabled state 647 if($(elem).attr("disabled")){ 648 //box is checked by default, check our box 649 divTag.addClass(options.disabledClass); 650 } 651 $.uniform.noSelect(spanTag); 652 653 storeElement(elem); 654 655 } 656 657 function doCheckbox(elem){ 658 var $el = $(elem); 659 var divTag = $('<div />'), 660 spanTag = $('<span />'); 661 662 if(!$el.css("display") == "none" && options.autoHide){ 663 divTag.hide(); 664 } 665 666 divTag.addClass(options.checkboxClass); 667 668 //assign the id of the element 669 if(options.useID && elem.attr("id") != ""){ 670 divTag.attr("id", options.idPrefix+"-"+elem.attr("id")); 671 } 672 673 //wrap with the proper elements 674 $(elem).wrap(divTag); 675 $(elem).wrap(spanTag); 676 677 //redefine variables 678 spanTag = elem.parent(); 679 divTag = spanTag.parent(); 680
681 //hide normal input and add focus classes 682 $(elem) 683 .css("opacity", 0) 684 .bind({ 685 "focus.uniform": function(){ 686 divTag.addClass(options.focusClass); 687 }, 688 "blur.uniform": function(){ 689 divTag.removeClass(options.focusClass); 690 }, 691 "click.uniform touchend.uniform": function(){ 692 if(!$(elem).attr("checked")){ 693 //box was just unchecked, uncheck span 694 spanTag.removeClass(options.checkedClass); 695 696 }else{ 697 //box was just checked, check span. 698 spanTag.addClass(options.checkedClass); 699 700 } 701 }, 702 "mousedown.uniform touchbegin.uniform": function() { 703 divTag.addClass(options.activeClass); 704 }, 705 "mouseup.uniform touchend.uniform": function() { 706 divTag.removeClass(options.activeClass); 707 }, 708 "mouseenter.uniform": function() { 709 divTag.addClass(options.hoverClass); 710 }, 711 "mouseleave.uniform": function() { 712 divTag.removeClass(options.hoverClass); 713 divTag.removeClass(options.activeClass); 714 } 715 }); 716 717 //handle defaults 718 if($(elem).attr("checked")){ 719 //box is checked by default, check our box 720 721 spanTag.addClass(options.checkedClass); 722 } 723 724 //handle disabled state 725 if($(elem).attr("disabled")){ 726 //box is checked by default, check our box 727 divTag.addClass(options.disabledClass); 728 } 729 730 storeElement(elem); 731 } 732 733 function doRadio(elem){ 734 var $el = $(elem); 735 736 var divTag = $('<div />'), 737 spanTag = $('<span />'); 738 739 if(!$el.css("display") == "none" && options.autoHide){ 740 divTag.hide(); 741 } 742 743 divTag.addClass(options.radioClass); 744 745 if(options.useID && elem.attr("id") != ""){ 746 divTag.attr("id", options.idPrefix+"-"+elem.attr("id")); 747 } 748 749 //wrap with the proper elements 750 $(elem).wrap(divTag); 751 $(elem).wrap(spanTag); 752 753 //redefine variables 754 spanTag = elem.parent(); 755 divTag = spanTag.parent(); 756 757 //hide normal input and add focus classes 758 $(elem) 759 .css("opacity", 0) 760 .bind({ 761 "focus.uniform": function(){ 762 divTag.addClass(options.focusClass); 763 }, 764 "blur.uniform": function(){ 765 divTag.removeClass(options.focusClass); 766 }, 767 "click.uniform touchend.uniform": function(){ 768 if(!$(elem).attr("checked")){ 769 //box was just unchecked, uncheck span 770 spanTag.removeClass(options.checkedClass); 771 }else{ 772 //box was just checked, check span 773 var classes = options.radioClass.split(" ")[0]; 774 $("." + classes + " span." + options.checkedClass + ":has([name='" + $(elem).attr('name') + "'])").removeClass(options.checkedClass); 775 spanTag.addClass(options.checkedClass); 776 } 777 }, 778 "mousedown.uniform touchend.uniform": function() { 779 if(!$(elem).is(":disabled")){ 780 divTag.addClass(options.activeClass); 781 } 782 }, 783 "mouseup.uniform touchbegin.uniform": function() { 784 divTag.removeClass(options.activeClass); 785 }, 786 "mouseenter.uniform touchend.uniform": function() { 787 divTag.addClass(options.hoverClass); 788 }, 789 "mouseleave.uniform": function() { 790 divTag.removeClass(options.hoverClass); 791 divTag.removeClass(options.activeClass); 792 } 793 }); 794 795 //handle defaults 796 if($(elem).attr("checked")){ 797 //box is checked by default, check span 798 spanTag.addClass(options.checkedClass); 799 } 800 //handle disabled state 801 if($(elem).attr("disabled")){ 802 //box is checked by default, check our box 803 divTag.addClass(options.disabledClass); 804 } 805 806 storeElement(elem); 807 808 } 809 810 function IdentifyFileName(id) 811 { 812 var file = $(id).val(); 813 814 var flag = true; 815 var extension = file.substr((file.lastIndexOf('.') + 1)); 816 817 switch (extension) { 818 case 'jpg': 819 case 'jpeg': 820 case 'png': 821 case 'WPD': 822 case 'JPG': 823 case 'RAR': 824 case 'ZIP': 825 case 'JPEG': 826 case 'PNG': 827 case 'TXT': 828 case 'txt': 829 case 'wpd': 830 case 'doc': 831 case 'rtf': 832 case 'RTF': 833 case 'docx': 834 case 'pdf': 835 836 case 'rar': 837 case 'zip': 838 flag = true; 839 840 break; 841 default: 842 flag = false; 843 844 } 845 846 if (!flag) { 847 848 849 850 851 852 $.alert(" Please upload one of the following file types:<br> " + 853"PDF<br> " + 854"Word<br> " + 855"Word Perfect<br> " + 856"Text<br> " + 857"Image file (such as JPEG, TIFF or bitmap)"); 858 $(".ui-dialog-title").html("Invalid File Type"); 859 860 } 861 else { 862 try{ 863 var fileInput = $(id)[0]; 864 var imgbytes = fileInput.files[0].size; // Size returned in bytes. 865 866 var imgkbytes = Math.round(parseInt(imgbytes) / 1024); 867 868 if (parseInt(imgkbytes) > 10240) { 869 870 flag=false; 871 $.alert("<p style='margin:6% 0 0 0;padding:0;'>The maximum file upload size is 10 MB.</p>"); 872 $(".ui-dialog-title").html("File Size Too Large "); 873 } 874 } 875 catch(e){} 876 } 877 if(document.getElementById("fileFlag").value!=undefined) 878 document.getElementById("fileFlag").value = flag; 879 880 return flag; 881 } 882 883 884 function doFile(elem){ 885 //sanitize input 886 var $el = $(elem); 887 888 //var divTag = $('<div />'), 889 // filenameTag = $('<span>'+options.fileDefaultText+'</span>'), 890 // btnTag = $('<span>'+options.fileBtnText+'</span>');<b class="cap-uploader"></b> 891 var divTag = $('<div />'), 892 filenameTag = $('<input type="text" tabindex="-1" value="'+options.fileDefaultText+'" style="height:93%;;background-color:#EBEBEB;font-family:arial;font-style:italic;"></input>'), 893 btnTag = $('<button id="btnOpenFile" class="'+options.fileBtnClass+'" style="vertical-align: top; padding: 6px 12px;margin-left:8px;" type="button">Upload Notice</button>'); 894 895 if(!$el.css("display") == "none" && options.autoHide){ 896 divTag.hide(); 897 } 898 899 divTag.addClass(options.fileClass); 900 filenameTag.addClass(options.filenameClass); 901 //btnTag.addClass(options.fileBtnClass); 902 903 if(options.useID && $el.attr("id") != ""){ 904 divTag.attr("id", options.idPrefix+"-"+$el.attr("id")); 905 } 906 907 //wrap with the proper elements 908 $el.wrap(divTag); 909 $el.after(btnTag); 910 911 $el.after(filenameTag); 912 913 //redefine variables 914 divTag = $el.closest("div"); 915 filenameTag = $el.siblings("."+options.filenameClass); 916 btnTag = $el.siblings("."+options.fileBtnClass); 917 918 //set the size 919 if(!$el.attr("size")){ 920 var divWidth = divTag.width(); 921 //divTag.width() 922 // $el.css("width", "0px"); 923 $el.attr("size", divWidth/10); 924 925 } 926 $el.css("margin-right","10px"); 927 //actions 928 var setFilename = function() 929 { 930 var filename = $el.val(); 931 if (filename === '') 932 { 933 filename = options.fileDefaultText; 934 } 935 else 936 { 937 filename = filename.split(/[\/\\]+/); 938 filename = filename[(filename.length-1)]; 939 } 940 var val= true; 941 942 if(filename!="Optional"){ 943 val= IdentifyFileName($el); 944 } 945 if(val){ 946 filenameTag.val(filename); 947 } 948 else 949 { 950 filenameTag.val(""); 951 952 } 953 954 955 }; 956 957 // Account for input saved across refreshes 958 setFilename(); 959 960 $el 961 .css("opacity", 0) 962 .bind({ 963 "focus.uniform": function(){ 964 divTag.addClass(options.focusClass); 965 }, 966 "blur.uniform": function(){ 967 divTag.removeClass(options.focusClass); 968 }, 969 "mousedown.uniform": function() { 970 if(!$(elem).is(":disabled")){ 971 divTag.addClass(options.activeClass); 972 } 973 }, 974 "mouseup.uniform": function() { 975 divTag.removeClass(options.activeClass); 976 }, 977 "mouseenter.uniform": function() { 978 divTag.addClass(options.hoverClass); 979 }, 980 "mouseleave.uniform": function() { 981 divTag.removeClass(options.hoverClass); 982 divTag.removeClass(options.activeClass); 983 } 984 }); 985 986 // IE7 doesn't fire onChange until blur or second fire. 987 if ($.browser.msie){ 988 // IE considers browser chrome blocking I/O, so it 989 // suspends tiemouts until after the file has been selected. 990 $el.bind('click.uniform.ie7', function() { 991 setTimeout(setFilename, 0); 992 }); 993 }else{ 994 // All other browsers behave properly 995 $el.bind('change.uniform', setFilename); 996 } 997 998 //handle defaults 999 if($el.attr("disabled")){ 1000 //box is checked by default, check our box 1001 divTag.addClass(options.disabledClass); 1002 } 1003 1004 $.uniform.noSelect(filenameTag); 1005 $.uniform.noSelect(btnTag); 1006 1007 storeElement(elem); 1008 1009 } 1010 1011 $.uniform.restore = function(elem){ 1012 if(elem == undefined){ 1013 elem = $($.uniform.elements); 1014 } 1015 1016 $(elem).each(function(){ 1017 if($(this).is(":checkbox")){ 1018 //unwrap from span and div 1019 $(this).unwrap().unwrap(); 1020 }else if($(this).is("select")){ 1021 //remove sibling span 1022 $(this).siblings("span").remove(); 1023 //unwrap parent div 1024 $(this).unwrap(); 1025 }else if($(this).is(":radio")){ 1026 //unwrap from span and div 1027 $(this).unwrap().unwrap(); 1028 }else if($(this).is(":file")){ 1029 //remove sibling spans 1030 $(this).siblings("span").remove(); 1031 //unwrap parent div 1032 $(this).unwrap(); 1033 }else if($(this).is("button, :submit, :reset, a, input[type='button']")){ 1034 //unwrap from span and div 1035 $(this).unwrap().unwrap(); 1036 } 1037 1038 //unbind events 1039 $(this).unbind(".uniform"); 1040 1041 //reset inline style 1042 $(this).css("opacity", "1"); 1043 1044 //remove item from list of uniformed elements 1045 var index = $.inArray($(elem), $.uniform.elements); 1046 $.uniform.elements.splice(index, 1); 1047 }); 1048 }; 1049 1050 function storeElement(elem){ 1051 //store this element in our global array 1052 elem = $(elem).get(); 1053 if(elem.length > 1){ 1054 $.each(elem, function(i, val){ 1055 $.uniform.elements.push(val); 1056 }); 1057 }else{ 1058 $.uniform.elements.push(elem); 1059 } 1060 } 1061 1062 //noSelect v1.0 1063 $.uniform.noSelect = function(elem) { 1064 function f() { 1065 return false; 1066 }; 1067 $(elem).each(function() { 1068 this.onselectstart = this.ondragstart = f; // Webkit & IE 1069 $(this) 1070 .mousedown(f) // Webkit & Opera 1071 .css({ MozUserSelect: 'none' }); // Firefox 1072 }); 1073 }; 1074 1075 $.uniform.update = function(elem){ 1076 if(elem == undefined){ 1077 elem = $($.uniform.elements); 1078 } 1079 //sanitize input 1080 elem = $(elem); 1081 1082 elem.each(function(){ 1083 //do to each item in the selector 1084 //function to reset all classes 1085 var $e = $(this); 1086 1087 if($e.is("select")){ 1088 //element is a select 1089 var spanTag = $e.siblings("span"); 1090 var divTag = $e.parent("div"); 1091 1092 divTag.removeClass(options.hoverClass+" "+options.focusClass+" "+options.activeClass); 1093 1094 //reset current selected text 1095 spanTag.html($e.find(":selected").html()); 1096 1097 if($e.is(":disabled")){ 1098 divTag.addClass(options.disabledClass); 1099 }else{ 1100 divTag.removeClass(options.disabledClass); 1101 } 1102 1103 }else if($e.is(":checkbox")){ 1104 //element is a checkbox 1105 var spanTag = $e.closest("span"); 1106 var divTag = $e.closest("div"); 1107 1108 divTag.removeClass(options.hoverClass+" "+options.focusClass+" "+options.activeClass); 1109 spanTag.removeClass(options.checkedClass); 1110 1111 if($e.is(":checked")){ 1112 spanTag.addClass(options.checkedClass); 1113 } 1114 if($e.is(":disabled")){ 1115 divTag.addClass(options.disabledClass); 1116 }else{ 1117 divTag.removeClass(options.disabledClass); 1118 } 1119 1120 }else if($e.is(":radio")){ 1121 //element is a radio 1122 var spanTag = $e.closest("span"); 1123 var divTag = $e.closest("div"); 1124 1125 divTag.removeClass(options.hoverClass+" "+options.focusClass+" "+options.activeClass); 1126 spanTag.removeClass(options.checkedClass); 1127 1128 if($e.is(":checked")){ 1129 spanTag.addClass(options.checkedClass); 1130 } 1131 1132 if($e.is(":disabled")){ 1133 divTag.addClass(options.disabledClass); 1134 }else{ 1135 divTag.removeClass(options.disabledClass); 1136 } 1137 }else if($e.is(":file")) { 1138 var divTag = $e.parent("div"); 1139 var filenameTag = $e.siblings(options.filenameClass); 1140 btnTag = $e.siblings(options.fileBtnClass); 1141 1142 divTag.removeClass(options.hoverClass+" "+options.focusClass+" "+options.activeClass); 1143 1144 filenameTag.text($e.val()); 1145 1146 1147 if($e.is(":disabled")){ 1148 divTag.addClass(options.disabledClass); 1149 }else{ 1150 divTag.removeClass(options.disabledClass); 1151 } 1152 }else if($e.is(":submit") || $e.is(":reset") || $e.is("button") || $e.is("a") || elem.is("input[type=button]")){ 1153 var divTag = $e.closest("div"); 1154 divTag.removeClass(options.hoverClass+" "+options.focusClass+" "+options.activeClass); 1155 1156 if($e.is(":disabled")){ 1157 divTag.addClass(options.disabledClass); 1158 }else{ 1159 divTag.removeClass(options.disabledClass); 1160 } 1161 1162 } 1163 1164 }); 1165 }; 1166 1167 return this.each(function() {
1168 if($.support.selectOpacity){ 1169 var elem = $(this); 1170 1171 if(elem.is("select")){ 1172 //element is a select 1173 if(elem.attr("multiple") != true){ 1174 //element is not a multi-select 1175 if(elem.attr("size") == undefined || elem.attr("size") <= 1){ 1176 doSelect(elem); 1177 } 1178 } 1179 }else if(elem.is(":checkbox")){ 1180 //element is a checkbox 1181 doCheckbox(elem); 1182 }else if(elem.is(":radio")){ 1183 //element is a radio 1184 doRadio(elem); 1185 } else if (elem.is(":file") && !elem.hasClass('noUniform')) { 1186 //element is a file upload 1187 doFile(elem); 1188 }else if(elem.is(":text, :password, input[type='email']")){ 1189 doInput(elem); 1190 }else if(elem.is("textarea")){ 1191 doTextarea(elem); 1192 }else if(elem.is("a") || elem.is(":submit") || elem.is(":reset") || elem.is("button") || elem.is("input[type=button]")){ 1193 doButton(elem); 1194 } 1195 1196 } 1197 }); 1198 }; 1199})(jQuery); 1200 1201 1202/*----------------------------------------------------------------------*/ 1203/* Elastic jQuery plugin v1.6.5 1204/* Copyright 2011, Jan Jarfalk 1205/* http://www.unwrongest.com 1206/* MIT License - http://www.opensource.org/licenses/mit-license.php 1207/*----------------------------------------------------------------------*/ 1208 1209 1210(function(jQuery){ 1211 jQuery.fn.extend({ 1212 elastic: function() { 1213 1214 // We will create a div clone of the textarea 1215 // by copying these attributes from the textarea to the div. 1216 var mimics = [ 1217 'paddingTop', 1218 'paddingRight', 1219 'paddingBottom', 1220 'paddingLeft', 1221 'fontSize', 1222 'lineHeight', 1223 'fontFamily', 1224 'width', 1225 'fontWeight']; 1226 1227 return this.each( function() { 1228 1229 // Elastic only works on textareas 1230 if ( this.type != 'textarea' ) { 1231 return false; 1232 } 1233 1234 var $textarea = jQuery(this), 1235 $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}), 1236 lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'), 1237 minheight = parseInt($textarea.css('height'),10) || lineHeight*3, 1238 maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE, 1239 goalheight = 0, 1240 i = 0; 1241 1242 // Opera returns max-height of -1 if not set 1243 if (maxheight < 0) { maxheight = Number.MAX_VALUE; } 1244 1245 // Append the twin to the DOM 1246 // We are going to meassure the height of this, not the textarea. 1247 $twin.appendTo($textarea.parent()); 1248 1249 // Copy the essential styles (mimics) from the textarea to the twin 1250 var i = mimics.length; 1251 while(i--){ 1252 $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString())); 1253 } 1254 1255 1256 // Sets a given height and overflow state on the textarea 1257 function setHeightAndOverflow(height, overflow){ 1258 curratedHeight = Math.floor(parseInt(height,10)); 1259 if($textarea.height() != curratedHeight){ 1260 $textarea.css({'height': curratedHeight + 'px','overflow':overflow}); 1261 1262 } 1263 } 1264 1265 1266 // This function will update the height of the textarea if necessary 1267 function update() { 1268 1269 // Get curated content from the textarea. 1270 var textareaContent = $textarea.val().replace(/&/g,'&').replace(/ /g, ' ').replace(/<|>/g, '>').replace(/\n/g, '<br />'); 1271 1272 // Compare curated content with curated twin. 1273 var twinContent = $twin.html().replace(/<br>/ig,'<br />'); 1274 1275 if(textareaContent+' ' != twinContent){ 1276 1277 // Add an extra white space so new rows are added when you are at the end of a row. 1278 $twin.html(textareaContent+' '); 1279 1280 // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height 1281 if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){ 1282 1283 var goalheight = $twin.height()+lineHeight; 1284 if(goalheight >= maxheight) { 1285 setHeightAndOverflow(maxheight,'auto'); 1286 }
1286 else if(goalheight <= minheight) { 1287 setHeightAndOverflow(minheight,'hidden'); 1288 } else { 1289 setHeightAndOverflow(goalheight,'hidden'); 1290 } 1291 1292 } 1293 1294 } 1295 1296 } 1297 1298 // Hide scrollbars 1299 $textarea.css({'overflow':'hidden'}); 1300 1301 // Update textarea size on keyup, change, cut and paste 1302 $textarea.bind('keyup change cut paste', function(){ 1303 update(); 1304 }); 1305 1306 // Compact textarea on blur 1307 // Lets animate this.... 1308 $textarea.bind('blur',function(){ 1309 if($twin.height() < maxheight){ 1310 if($twin.height() > minheight) { 1311 $textarea.height($twin.height()); 1312 } else { 1313 $textarea.height(minheight); 1314 } 1315 } 1316 }); 1317 1318 // And this line is to catch the browser paste event 1319 $textarea.live('input paste',function(e){ setTimeout( update, 250); }); 1320 1321 // Run update once when elastic is initialized 1322 update(); 1323 1324 }); 1325 1326 } 1327 }); 1328})(jQuery); 1329 1330/*----------------------------------------------------------------------*/ 1331/* jQuery miniColors: A small color selector 1332/* Copyright 2011 Cory LaViska for A Beautiful Site, LLC. 1333/* http://abeautifulsite.net/blog/2011/02/jquery-minicolors-a-color-selector-for-input-controls/ 1334/* Dual licensed under the MIT or GPL Version 2 licenses 1335/*----------------------------------------------------------------------*/ 1336 1337 1338 1339(function ($) { 1340 $.fn.miniColors = function (o, data) { 1341 1342 1343 var create = function (input, o, data) { 1344 1345 // 1346 // Creates a new instance of the miniColors selector 1347 // 1348 // Determine initial color (defaults to white) 1349 var color = cleanHex(input.val()); 1350 if (!color) color = 'FFFFFF'; 1351 var hsb = hex2hsb(color); 1352 1353 // Create trigger 1354 var trigger = $('<a class="miniColors-trigger" style="background-color: #' + color + '" href="#"></a>'); 1355 trigger.insertAfter(input); 1356 1357 // Add necessary attributes 1358 input.addClass('miniColors').attr('maxlength', 7).attr('autocomplete', 'off'); 1359 1360 // Set input data 1361 input.data('trigger', trigger); 1362 input.data('hsb', hsb); 1363 if (o.change) input.data('change', o.change); 1364 1365 // Handle options 1366 if (o.readonly) input.attr('readonly', true); 1367 if (o.disabled) disable(input); 1368 1369 // Show selector when trigger is clicked 1370 trigger.bind('click.miniColors', function (event) { 1371 event.preventDefault(); 1372 input.trigger('focus'); 1373 }); 1374 1375 // Show selector when input receives focus 1376 input.bind('focus.miniColors', function (event) { 1377 show(input); 1378 }); 1379 1380 // Hide on blur 1381 input.bind('blur.miniColors', function (event) { 1382 var hex = cleanHex(input.val()); 1383 input.val(hex ? '#' + hex : ''); 1384 }); 1385 1386 // Hide when tabbing out of the input 1387 input.bind('keydown.miniColors', function (event) { 1388 if (event.keyCode === 9) hide(input); 1389 }); 1390 1391 // Update when color is typed in 1392 input.bind('keyup.miniColors', function (event) { 1393 // Remove non-hex characters 1394 var filteredHex = input.val().replace(/[^A-F0-9#]/ig, ''); 1395 input.val(filteredHex); 1396 if (!setColorFromInput(input)) { 1397 // Reset trigger color when color is invalid 1398 input.data('trigger').css('backgroundColor', '#FFF'); 1399 } 1400 }); 1401 1402 // Handle pasting 1403 input.bind('paste.miniColors', function (event) { 1404 // Short pause to wait for paste to complete 1405 setTimeout(function () { 1406 input.trigger('keyup'); 1407 }, 5); 1408 }); 1409 1410 }; 1411 1412 1413 var destroy = function (input) { 1414 1415 // 1416 // Destroys an active instance of the miniColors selector 1417 // 1418 hide(); 1419 1420 input = $(input); 1421 input.data('trigger').remove(); 1422 input.removeAttr('autocomplete'); 1423 input.removeData('trigger'); 1424 input.removeData('selector'); 1425 input.removeData('hsb'); 1426 input.removeData('huePicker'); 1427 input.removeData('colorPicker'); 1428 input.removeData('mousebutton'); 1429 input.removeData('moving'); 1430 input.unbind('click.miniColors'); 1431 input.unbind('focus.miniColors'); 1432 input.unbind('blur.miniColors'); 1433 input.unbind('keyup.miniColors'); 1434 input.unbind('keydown.miniColors'); 1435 input.unbind('paste.miniColors'); 1436 $(document).unbind('mousedown.miniColors'); 1437 $(document).unbind('mousemove.miniColors'); 1438 1439 }; 1440 1441 1442 var enable = function (input) { 1443 1444 // 1445 // Disables the input control and the selector 1446 // 1447 input.attr('disabled', false); 1448 input.data('trigger').css('opacity', 1); 1449 1450 }; 1451 1452 1453 var disable = function (input) { 1454 1455 // 1456 // Disables the input control and the selector 1457 // 1458 hide(input); 1459 input.attr('disabled', true); 1460 input.data('trigger').css('opacity', .5); 1461 1462 }; 1463 1464 1465 var show = function (input) { 1466 1467 // 1468 // Shows the miniColors selector 1469 // 1470 if (input.attr('disabled')) return false; 1471 1472 // Hide all other instances 1473 hide(); 1474 1475 // Generate the selector 1476 var selector = $('<div class="miniColors-selector"></div>'); 1477 selector.append('<div class="miniColors-colors" style="background-color: #FFF;"><div class="miniColors-colorPicker"></div></div>'); 1478 selector.append('<div class="miniColors-hues"><div class="miniColors-huePicker"></div></div>'); 1479 selector.css({ 1480 top: input.is(':visible') ? input.offset().top + input.outerHeight() : input.data('trigger').offset().top + input.data('trigger').outerHeight(), 1481 left: input.is(':visible') ? input.offset().left : input.data('trigger').offset().left, 1482 display: 'none' 1483 }).addClass(input.attr('class')); 1484 1485 // Set background for colors 1486 var hsb = input.data('hsb'); 1487 selector.find('.miniColors-colors').css('backgroundColor', '#' + hsb2hex({ 1488 h: hsb.h, 1489 s: 100, 1490 b: 100 1491 })); 1492 1493 // Set colorPicker position 1494 var colorPosition = input.data('colorPosition'); 1495 if (!colorPosition) colorPosition = getColorPositionFromHSB(hsb); 1496 selector.find('.miniColors-colorPicker').css('top', colorPosition.y + 'px').css('left', colorPosition.x + 'px'); 1497 1498 // Set huePicker position 1499 var huePosition = input.data('huePosition'); 1500 if (!huePosition) huePosition = getHuePositionFromHSB(hsb); 1501 selector.find('.miniColors-huePicker').css('top', huePosition.y + 'px'); 1502 1503 1504 // Set input data 1505 input.data('selector', selector); 1506 input.data('huePicker', selector.find('.miniColors-huePicker')); 1507 input.data('colorPicker', selector.find('.miniColors-colorPicker')); 1508 input.data('mousebutton', 0); 1509 1510 $('BODY').append(selector); 1511 selector.fadeIn(100); 1512 1513 // Prevent text selection in IE 1514 selector.bind('selectstart', function () { 1515 return false; 1516 }); 1517 1518 $(document).bind('mousedown.miniColors', function (event) { 1519 input.data('mousebutton', 1); 1520 1521 if ($(event.target).parents().andSelf().hasClass('miniColors-colors')) { 1522 event.preventDefault(); 1523 input.data('moving', 'colors');
1524 moveColor(input, event); 1525 } 1526 1527 if ($(event.target).parents().andSelf().hasClass('miniColors-hues')) { 1528 event.preventDefault(); 1529 input.data('moving', 'hues'); 1530 moveHue(input, event); 1531 } 1532 1533 if ($(event.target).parents().andSelf().hasClass('miniColors-selector')) { 1534 event.preventDefault(); 1535 return; 1536 } 1537 1538 if ($(event.target).parents().andSelf().hasClass('miniColors')) return; 1539 1540 hide(input); 1541 }); 1542 1543 $(document).bind('mouseup.miniColors', function (event) { 1544 input.data('mousebutton', 0); 1545 input.removeData('moving'); 1546 }); 1547 1548 $(document).bind('mousemove.miniColors', function (event) { 1549 if (input.data('mousebutton') === 1) { 1550 if (input.data('moving') === 'colors') moveColor(input, event); 1551 if (input.data('moving') === 'hues') moveHue(input, event); 1552 } 1553 }); 1554 1555 }; 1556 1557 1558 var hide = function (input) { 1559 1560 // 1561 // Hides one or more miniColors selectors 1562 // 1563 // Hide all other instances if input isn't specified 1564 if (!input) input = '.miniColors'; 1565 1566 $(input).each(function () { 1567 var selector = $(this).data('selector'); 1568 $(this).removeData('selector'); 1569 $(selector).fadeOut(100, function () { 1570 $(this).remove(); 1571 }); 1572 }); 1573 1574 $(document).unbind('mousedown.miniColors'); 1575 $(document).unbind('mousemove.miniColors'); 1576 1577 }; 1578 1579 1580 var moveColor = function (input, event) { 1581 1582 var colorPicker = input.data('colorPicker'); 1583 1584 colorPicker.hide(); 1585 1586 var position = { 1587 x: event.clientX - input.data('selector').find('.miniColors-colors').offset().left + $(document).scrollLeft() - 5, 1588 y: event.clientY - input.data('selector').find('.miniColors-colors').offset().top + $(document).scrollTop() - 5 1589 }; 1590 1591 if (position.x <= -5) position.x = -5; 1592 if (position.x >= 144) position.x = 144; 1593 if (position.y <= -5) position.y = -5; 1594 if (position.y >= 144) position.y = 144; 1595 input.data('colorPosition', position); 1596 colorPicker.css('left', position.x).css('top', position.y).show(); 1597 1598 // Calculate saturation 1599 var s = Math.round((position.x + 5) * .67); 1600 if (s < 0) s = 0; 1601 if (s > 100) s = 100; 1602 1603 // Calculate brightness 1604 var b = 100 - Math.round((position.y + 5) * .67); 1605 if (b < 0) b = 0; 1606 if (b > 100) b = 100; 1607 1608 // Update HSB values 1609 var hsb = input.data('hsb'); 1610 hsb.s = s; 1611 hsb.b = b; 1612 1613 // Set color 1614 setColor(input, hsb, true); 1615 1616 }; 1617 1618 1619 var moveHue = function (input, event) { 1620 1621 var huePicker = input.data('huePicker'); 1622 1623 huePicker.hide(); 1624 1625 var position = { 1626 y: event.clientY - input.data('selector').find('.miniColors-colors').offset().top + $(document).scrollTop() - 1 1627 }; 1628 1629 if (position.y <= -1) position.y = -1; 1630 if (position.y >= 149) position.y = 149; 1631 input.data('huePosition', position); 1632 huePicker.css('top', position.y).show(); 1633 1634 // Calculate hue 1635 var h = Math.round((150 - position.y - 1) * 2.4); 1636 if (h < 0) h = 0; 1637 if (h > 360) h = 360; 1638 1639 // Update HSB values 1640 var hsb = input.data('hsb'); 1641 hsb.h = h; 1642 1643 // Set color 1644 setColor(input, hsb, true); 1645 1646 }; 1647 1648 1649 var setColor = function (input, hsb, updateInputValue) { 1650 1651 input.data('hsb', hsb); 1652 var hex = hsb2hex(hsb); 1653 if (updateInputValue) input.val('#' + hex); 1654 input.data('trigger').css('backgroundColor', '#' + hex); 1655 if (input.data('selector')) input.data('selector').find('.miniColors-colors').css('backgroundColor', '#' + hsb2hex({ 1656 h: hsb.h, 1657 s: 100, 1658 b: 100 1659 })); 1660 1661 if (input.data('change')) { 1662 input.data('change').call(input, '#' + hex, hsb2rgb(hsb)); 1663 } 1664 1665 }; 1666 1667 1668 var setColorFromInput = function (input) { 1669 1670 // Don't update if the hex color is invalid 1671 var hex = cleanHex(input.val()); 1672 if (!hex) return false; 1673 1674 // Get HSB equivalent 1675 var hsb = hex2hsb(hex); 1676 1677 // If color is the same, no change required 1678 var currentHSB = input.data('hsb'); 1679 if (hsb.h === currentHSB.h && hsb.s === currentHSB.s && hsb.b === currentHSB.b) return true; 1680 1681 // Set colorPicker position 1682 var colorPosition = getColorPositionFromHSB(hsb); 1683 var colorPicker = $(input.data('colorPicker')); 1684 colorPicker.css('top', colorPosition.y + 'px').css('left', colorPosition.x + 'px'); 1685 1686 // Set huePosition position 1687 var huePosition = getHuePositionFromHSB(hsb); 1688 var huePicker = $(input.data('huePicker')); 1689 huePicker.css('top', huePosition.y + 'px'); 1690 1691 setColor(input, hsb, false); 1692 1693 return true; 1694 1695 }; 1696 1697 1698 var getColorPositionFromHSB = function (hsb) { 1699 1700 var x = Math.ceil(hsb.s / .67);
1701 if (x < 0) x = 0; 1702 if (x > 150) x = 150; 1703 1704 var y = 150 - Math.ceil(hsb.b / .67); 1705 if (y < 0) y = 0; 1706 if (y > 150) y = 150; 1707 1708 return { 1709 x: x - 5, 1710 y: y - 5 1711 }; 1712 1713 }; 1714 1715 1716 var getHuePositionFromHSB = function (hsb) { 1717 1718 var y = 150 - (hsb.h / 2.4); 1719 if (y < 0) h = 0; 1720 if (y > 150) h = 150; 1721 1722 return { 1723 y: y - 1 1724 }; 1725 1726 }; 1727 1728 1729 var cleanHex = function (hex) { 1730 1731 // 1732 // Turns a dirty hex string into clean, 6-character hex color 1733 // 1734 hex = hex.replace(/[^A-Fa-f0-9]/, ''); 1735 1736 if (hex.length == 3) { 1737 hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; 1738 } 1739 1740 return hex.length === 6 ? hex : null; 1741 1742 }; 1743 1744 1745 var hsb2rgb = function (hsb) { 1746 var rgb = {}; 1747 var h = Math.round(hsb.h); 1748 var s = Math.round(hsb.s * 255 / 100); 1749 var v = Math.round(hsb.b * 255 / 100); 1750 if (s == 0) { 1751 rgb.r = rgb.g = rgb.b = v; 1752 } else { 1753 var t1 = v; 1754 var t2 = (255 - s) * v / 255; 1755 var t3 = (t1 - t2) * (h % 60) / 60; 1756 if (h == 360) h = 0; 1757 if (h < 60) { 1758 rgb.r = t1; 1759 rgb.b = t2; 1760 rgb.g = t2 + t3; 1761 } else if (h < 120) { 1762 rgb.g = t1; 1763 rgb.b = t2; 1764 rgb.r = t1 - t3; 1765 } else if (h < 180) { 1766 rgb.g = t1; 1767 rgb.r = t2; 1768 rgb.b = t2 + t3; 1769 } else if (h < 240) { 1770 rgb.b = t1; 1771 rgb.r = t2; 1772 rgb.g = t1 - t3; 1773 } else if (h < 300) { 1774 rgb.b = t1; 1775 rgb.g = t2; 1776 rgb.r = t2 + t3; 1777 } else if (h < 360) { 1778 rgb.r = t1; 1779 rgb.g = t2; 1780 rgb.b = t1 - t3; 1781 } else { 1782 rgb.r = 0; 1783 rgb.g = 0; 1784 rgb.b = 0; 1785 } 1786 } 1787 return { 1788 r: Math.round(rgb.r), 1789 g: Math.round(rgb.g), 1790 b: Math.round(rgb.b) 1791 }; 1792 }; 1793 1794 1795 var rgb2hex = function (rgb) { 1796 1797 var hex = [ 1798 rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; 1799 $.each(hex, function (nr, val) { 1800 if (val.length == 1) hex[nr] = '0' + val; 1801 }); 1802 1803 return hex.join(''); 1804 }; 1805 1806 1807 var hex2rgb = function (hex) { 1808 var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16); 1809 1810 return { 1811 r: hex >> 16, 1812 g: (hex & 0x00FF00) >> 8, 1813 b: (hex & 0x0000FF) 1814 }; 1815 }; 1816 1817 1818 var rgb2hsb = function (rgb) { 1819 var hsb = { 1820 h: 0, 1821 s: 0, 1822 b: 0 1823 }; 1824 var min = Math.min(rgb.r, rgb.g, rgb.b); 1825 var max = Math.max(rgb.r, rgb.g, rgb.b); 1826 var delta = max - min; 1827 hsb.b = max; 1828 hsb.s = max != 0 ? 255 * delta / max : 0; 1829 if (hsb.s != 0) { 1830 if (rgb.r == max) { 1831 hsb.h = (rgb.g - rgb.b) / delta; 1832 } else if (rgb.g == max) { 1833 hsb.h = 2 + (rgb.b - rgb.r) / delta; 1834 } else { 1835 hsb.h = 4 + (rgb.r - rgb.g) / delta; 1836 } 1837 } else { 1838 hsb.h = -1; 1839 } 1840 hsb.h *= 60; 1841 if (hsb.h < 0) { 1842 hsb.h += 360; 1843 } 1844 hsb.s *= 100 / 255; 1845 hsb.b *= 100 / 255; 1846 return hsb; 1847 }; 1848 1849 1850 var hex2hsb = function (hex) { 1851 var hsb = rgb2hsb(hex2rgb(hex)); 1852 // Zero out hue marker for black, white, and grays (saturation === 0) 1853 if (hsb.s === 0) hsb.h = 360; 1854 return hsb; 1855 }; 1856 1857 1858 var hsb2hex = function (hsb) { 1859 return rgb2hex(hsb2rgb(hsb)); 1860 }; 1861 1862 1863 // 1864 // Handle calls to $([selector]).miniColors() 1865 // 1866 switch (o) { 1867 1868 case 'readonly': 1869 1870 $(this).each(function () { 1871 $(this).attr('readonly', data); 1872 }); 1873 1874 return $(this); 1875 1876 break; 1877 1878 case 'disabled': 1879 1880 $(this).each(function () { 1881 if (data) { 1882 disable($(this)); 1883 } else { 1884 enable($(this)); 1885 } 1886 }); 1887 1888 return $(this); 1889 1890 case 'value': 1891 1892 $(this).each(function () { 1893 if(typeof data !== 'string'){ 1894 data = hsb2hex(data); 1895 } 1896 $(this).val(data).trigger('keyup'); 1897 }); 1898 1899 return $(this); 1900 1901 break; 1902 1903 case 'destroy': 1904 1905 $(this).each(function () { 1906 destroy($(this)); 1907 }); 1908 1909 return $(this); 1910 1911 default: 1912 1913 if (!o) o = {}; 1914 1915 $(this).each(function () { 1916 1917 // Must be called on an input element 1918 if ($(this)[0].tagName.toLowerCase() !== 'input') return; 1919 1920 // If a trigger is present, the control was already created 1921 if ($(this).data('trigger')) return; 1922 1923 // Create the control 1924 create($(this), o, data); 1925 1926 }); 1927 1928 return $(this); 1929 1930 } 1931 1932 1933 }; 1934 1935})(jQuery); 1936 1937 1938 1939/*----------------------------------------------------------------------*/ 1940/* 1941/*----------------------------------------------------------------------*/ 1942 1943 1944 1945/* 1946 * jQuery Iframe Transport Plugin 1.2.1 1947 * https://github.com/blueimp/jQuery-File-Upload 1948 * 1949 * Copyright 2011, Sebastian Tschan 1950 * https://blueimp.net 1951 * 1952 * Licensed under the MIT license: 1953 * http://creativecommons.org/licenses/MIT/ 1954 */ 1955 1956/*jslint unparam: true */ 1957/*global jQuery */ 1958 1959(function ($) { 1960 'use strict'; 1961 1962 // Helper variable to create unique names for the transport iframes: 1963 var counter = 0; 1964 1965 // The iframe transport accepts three additional options: 1966 // options.fileInput: a jQuery collection of file input fields 1967 // options.paramName: the parameter name for the file form data, 1968 // overrides the name property of the file input field(s) 1969 // options.formData: an array of objects with name and value properties, 1970 // equivalent to the return data of .serializeArray(), e.g.: 1971 // [{name: a, value: 1}, {name: b, value: 2}] 1972 $.ajaxTransport('iframe', function (options, originalOptions, jqXHR) { 1973 if (options.type === 'POST' || options.type === 'GET') { 1974 var form, 1975 iframe; 1976 return { 1977 send: function (headers, completeCallback) { 1978 form = $('<form style="display:none;"></form>'); 1979 // javascript:false as initial iframe src 1980 // prevents warning popups on HTTPS in IE6. 1981 // IE versions below IE8 cannot set the name property of 1982 // elements that have already been added to the DOM, 1983 // so we set the name along with the iframe HTML markup: 1984 iframe = $( 1985 '<iframe src="javascript:false;" name="iframe-transport-' + 1986 (counter += 1) + '"></iframe>' 1987 ).bind('load', function () { 1988 var fileInputClones; 1989 iframe 1990 .unbind('load') 1991 .bind('load', function () { 1992 var response; 1993 // Wrap in a try/catch block to catch exceptions thrown 1994 // when trying to access cross-domain iframe contents: 1995 try { 1996 response = iframe.contents(); 1997 } catch (e) { 1998 response = $(); 1999 } 2000 // The complete callback returns the 2001 // iframe content document as response object: 2002 completeCallback( 2003 200, 2004 'success', 2005 {'iframe': response} 2006 ); 2007 // Fix for IE endless progress bar activity bug 2008 // (happens on form submits to iframe targets): 2009 $('<iframe src="javascript:false;"></iframe>') 2010 .appendTo(form); 2011 form.remove(); 2012 }); 2013 form 2014 .prop('target', iframe.prop('name')) 2015 .prop('action', options.url) 2016 .prop('method', options.type); 2017 if (options.formData) { 2018 $.each(options.formData, function (index, field) { 2019 $('<input type="hidden"/>') 2020 .prop('name', field.name) 2021 .val(field.value) 2022 .appendTo(form); 2023 }); 2024 } 2025 if (options.fileInput && options.fileInput.length && 2026 options.type === 'POST') { 2027 fileInputClones = options.fileInput.clone(); 2028 // Insert a clone for each file input field: 2029 options.fileInput.after(function (index) { 2030 return fileInputClones[index]; 2031 }); 2032 if (options.paramName) { 2033 options.fileInput.each(function () { 2034 $(this).prop('name', options.paramName); 2035 }); 2036 } 2037 // Appending the file input fields to the hidden form 2038 // removes them from their original location: 2039 form 2040 .append(options.fileInput) 2041 .prop('enctype', 'multipart/form-data') 2042 // enctype must be set as encoding for IE: 2043 .prop('encoding', 'multipart/form-data'); 2044 } 2045 form.submit(); 2046 // Insert the file input fields at their original location 2047 // by replacing the clones with the originals: 2048 if (fileInputClones && fileInputClones.length) { 2049 options.fileInput.each(function (index, input) { 2050 var clone = $(fileInputClones[index]); 2051 $(input).prop('name', clone.prop('name')); 2052 clone.replaceWith(input); 2053 }); 2054 } 2055 }); 2056 form.append(iframe).appendTo('body'); 2057 }, 2058 abort: function () { 2059 if (iframe) { 2060 // javascript:false as iframe src aborts the request 2061 // and prevents warning popups on HTTPS in IE6. 2062 // concat is used to avoid the "Script URL" JSLint error: 2063 iframe 2064 .unbind('load') 2065 .prop('src', 'javascript'.concat(':false;')); 2066 } 2067 if (form) { 2068 form.remove(); 2069 } 2070 } 2071 }; 2072 } 2073 });
2074 2075 // The iframe transport returns the iframe content document as response. 2076 // The following adds converters from iframe to text, json, html, and script: 2077 $.ajaxSetup({ 2078 converters: { 2079 'iframe text': function (iframe) { 2080 return iframe.text(); 2081 }, 2082 'iframe json': function (iframe) { 2083 return $.parseJSON(iframe.text()); 2084 }, 2085 'iframe html': function (iframe) { 2086 return iframe.find('body').html(); 2087 }, 2088 'iframe script': function (iframe) { 2089 return $.globalEval(iframe.text()); 2090 } 2091 } 2092 }); 2093 2094}(jQuery)); 2095 2096 2097/* 2098 * jQuery File Upload Plugin 5.0.2 2099 * https://github.com/blueimp/jQuery-File-Upload 2100 * 2101 * Copyright 2010, Sebastian Tschan 2102 * https://blueimp.net 2103 * 2104 * Licensed under the MIT license: 2105 * http://creativecommons.org/licenses/MIT/ 2106 */ 2107 2108/*jslint nomen: true, unparam: true, regexp: true */ 2109/*global document, XMLHttpRequestUpload, Blob, File, FormData, location, jQuery */ 2110 2111(function ($) { 2112 'use strict'; 2113 2114 // The fileupload widget listens for change events on file input fields 2115 // defined via fileInput setting and drop events of the given dropZone. 2116 // In addition to the default jQuery Widget methods, the fileupload widget 2117 // exposes the "add" and "send" methods, to add or directly send files 2118 // using the fileupload API. 2119 // By default, files added via file input selection, drag & drop or 2120 // "add" method are uploaded immediately, but it is possible to override 2121 // the "add" callback option to queue file uploads. 2122 $.widget('blueimp.fileupload', { 2123 2124 options: { 2125 // The namespace used for event handler binding on the dropZone and 2126 // fileInput collections. 2127 // If not set, the name of the widget ("fileupload") is used. 2128 namespace: undefined, 2129 // The drop target collection, by the default the complete document. 2130 // Set to null or an empty collection to disable drag & drop support: 2131 dropZone: $(document), 2132 // The file input field collection, that is listened for change events. 2133 // If undefined, it is set to the file input fields inside 2134 // of the widget element on plugin initialization. 2135 // Set to null or an empty collection to disable the change listener. 2136 fileInput: undefined, 2137 // By default, the file input field is replaced with a clone after 2138 // each input field change event. This is required for iframe transport 2139 // queues and allows change events to be fired for the same file 2140 // selection, but can be disabled by setting the following option to false: 2141 replaceFileInput: true, 2142 // The parameter name for the file form data (the request argument name). 2143 // If undefined or empty, the name property of the file input field is 2144 // used, or "files[]" if the file input name property is also empty: 2145 paramName: undefined, 2146 // By default, each file of a selection is uploaded using an individual 2147 // request for XHR type uploads. Set to false to upload file 2148 // selections in one request each: 2149 singleFileUploads: true, 2150 // Set the following option to true to issue all file upload requests 2151 // in a sequential order: 2152 sequentialUploads: false, 2153 // Set the following option to true to force iframe transport uploads: 2154 forceIframeTransport: false, 2155 // By default, XHR file uploads are sent as multipart/form-data. 2156 // The iframe transport is always using multipart/form-data. 2157 // Set to false to enable non-multipart XHR uploads: 2158 multipart: true, 2159 // To upload large files in smaller chunks, set the following option 2160 // to a preferred maximum chunk size. If set to 0, null or undefined, 2161 // or the browser does not support the required Blob API, files will 2162 // be uploaded as a whole. 2163 maxChunkSize: undefined, 2164 // When a non-multipart upload or a chunked multipart upload has been 2165 // aborted, this option can be used to resume the upload by setting 2166 // it to the size of the already uploaded bytes. This option is most 2167 // useful when modifying the options object inside of the "add" or 2168 // "send" callbacks, as the options are cloned for each file upload. 2169 uploadedBytes: undefined, 2170 // By default, failed (abort or error) file uploads are removed from the 2171 // global progress calculation. Set the following option to fal
2171se to 2172 // prevent recalculating the global progress data: 2173 recalculateProgress: true, 2174 2175 // Additional form data to be sent along with the file uploads can be set 2176 // using this option, which accepts an array of objects with name and 2177 // value properties, a function returning such an array, a FormData 2178 // object (for XHR file uploads), or a simple object. 2179 // The form of the first fileInput is given as parameter to the function: 2180 formData: function (form) { 2181 return form.serializeArray(); 2182 }, 2183 2184 // The add callback is invoked as soon as files are added to the fileupload 2185 // widget (via file input selection, drag & drop or add API call). 2186 // If the singleFileUploads option is enabled, this callback will be 2187 // called once for each file in the selection for XHR file uplaods, else 2188 // once for each file selection. 2189 // The upload starts when the submit method is invoked on the data parameter. 2190 // The data object contains a files property holding the added files 2191 // and allows to override plugin options as well as define ajax settings. 2192 // Listeners for this callback can also be bound the following way: 2193 // .bind('fileuploadadd', func); 2194 // data.submit() returns a Promise object and allows to attach additional 2195 // handlers using jQuery's Deferred callbacks: 2196 // data.submit().done(func).fail(func).always(func); 2197 add: function (e, data) { 2198 data.submit(); 2199 }, 2200 2201 // Other callbacks: 2202 // Callback for the start of each file upload request: 2203 // send: function (e, data) {}, // .bind('fileuploadsend', func); 2204 // Callback for successful uploads: 2205 // done: function (e, data) {}, // .bind('fileuploaddone', func); 2206 // Callback for failed (abort or error) uploads: 2207 // fail: function (e, data) {}, // .bind('fileuploadfail', func); 2208 // Callback for completed (success, abort or error) requests: 2209 // always: function (e, data) {}, // .bind('fileuploadalways', func); 2210 // Callback for upload progress events: 2211 // progress: function (e, data) {}, // .bind('fileuploadprogress', func); 2212 // Callback for global upload progress events: 2213 // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func); 2214 // Callback for uploads start, equivalent to the global ajaxStart event: 2215 // start: function (e) {}, // .bind('fileuploadstart', func); 2216 // Callback for uploads stop, equivalent to the global ajaxStop event: 2217 // stop: function (e) {}, // .bind('fileuploadstop', func); 2218 // Callback for change events of the fileInput collection: 2219 // change: function (e, data) {}, // .bind('fileuploadchange', func); 2220 // Callback for drop events of the dropZone collection: 2221 // drop: function (e, data) {}, // .bind('fileuploaddrop', func); 2222 // Callback for dragover events of the dropZone collection: 2223 // dragover: function (e) {}, // .bind('fileuploaddragover', func); 2224 2225 // The plugin options are used as settings object for the ajax calls. 2226 // The following are jQuery ajax settings required for the file uploads: 2227 processData: false, 2228 contentType: false, 2229 cache: false 2230 }, 2231 2232 // A list of options that require a refresh after assigning a new value: 2233 _refreshOptionsList: ['namespace', 'dropZone', 'fileInput'], 2234 2235 _isXHRUpload: function (options) { 2236 var undef = 'undefined'; 2237 return !options.forceIframeTransport && 2238 typeof XMLHttpRequestUpload !== undef && typeof File !== undef && 2239 (!options.multipart || typeof FormData !== undef); 2240 }, 2241 2242 _getFormData: function (options) { 2243 var formData; 2244 if (typeof options.formData === 'function') { 2245 return options.formData(options.form); 2246 } else if ($.isArray(options.formData)) { 2247 return options.formData; 2248 } else if (options.formData) { 2249 formData = []; 2250 $.each(options.formData, function (name, value) { 2251 formData.push({name: name, value: value}); 2252 }); 2253 return formData; 2254 } 2255 return []; 2256 }, 2257 2258 _getTotal: function (files) { 2259 var total = 0; 2260 $.each(files, function (index, file) { 2261 total += file.size || 1; 2262 }); 2263 return total; 2264 }, 2265 2266 _onProgress: function (e, data) { 2267 if (e.lengthComputable) { 2268 var total = data.total || this._getTotal(data.files), 2269 loaded = parseInt( 2270 e.loaded / e.total * (data.chunkSize || total), 2271 10 2272 ) + (data.uploadedBytes || 0); 2273 this._loaded += loaded - (data.loaded || data.uploadedBytes || 0); 2274 data.lengthComputable = true; 2275 data.loaded = loaded; 2276 data.total = total; 2277 // Trigger a custom progress event with a total data property set 2278 // to the file size(s) of the current upload and a loaded data 2279 // property calculated accordingly: 2280 this._trigger('progress', e, data); 2281 // Trigger a global progress event for all current file uploads, 2282 // including ajax calls queued for sequential file uploads: 2283 this._trigger('progressall', e, { 2284 lengthComputable: true, 2285 loaded: this._loaded, 2286 total: this._total 2287 }); 2288 } 2289 }, 2290 2291 _initProgressListener: function (options) { 2292 var that = this, 2293 xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); 2294 // Accesss to the native XHR object is required to add event listeners 2295 // for the upload progress event: 2296 if (xhr.upload && xhr.upload.addEventListener) { 2297 xhr.upload.addEventListener('progress', function (e) { 2298 that._onProgress(e, options); 2299 }, false); 2300 options.xhr = function () { 2301 return xhr; 2302 }; 2303 } 2304 }, 2305 2306 _initXHRData: function (options) { 2307 var formData, 2308 file = options.files[0]; 2309 if (!options.multipart || options.blob) { 2310 // For non-multipart uploads and chunked uploads, 2311 // file meta data is not part of the request body, 2312 // so we transmit this data as part of the HTTP headers. 2313 // For cross domain requests, these headers must be allowed 2314 // via Access-Control-Allow-Headers or removed using 2315 // the beforeSend callback: 2316 options.headers = $.extend(options.headers, { 2317 'X-File-Name': file.name, 2318 'X-File-Type': file.type, 2319 'X-File-Size': file.size 2320 }); 2321 if (!options.blob) { 2322 // Non-chunked non-multipart upload: 2323 options.contentType = file.type; 2324 options.data = file; 2325 } else if (!options.multipart) { 2326 // Chunked non-multipart upload: 2327 options.contentType = 'application/octet-stream'; 2328 options.data = options.blob; 2329 } 2330 } 2331 if (options.multipart && typeof FormData !== 'undefined') { 2332 if (options.formData instanceof FormData) { 2333 formData = options.formData; 2334 } else { 2335 formData = new FormData(); 2336 $.each(this._getFormData(options), function (index, field) { 2337 formData.append(field.name, field.value); 2338 }); 2339 } 2340 if (options.blob) { 2341 formData.append(options.paramName, options.blob); 2342 } else { 2343 $.each(options.files, function (index, file) { 2344 // File objects are also Blob instances. 2345 // This check allows the tests to run with 2346 // dummy objects: 2347 if (file instanceof Blob) { 2348 formData.append(options.paramName, file); 2349 } 2350 }); 2351 } 2352 options.data = formData; 2353 } 2354 // Blob reference is not needed anymore, free memory: 2355 options.blob = null; 2356 }, 2357 2358 _initIframeSettings: function (options) { 2359 // Setting the dataType to iframe enables the iframe transport: 2360 options.dataType = 'iframe ' + (options.dataType || ''); 2361 // The iframe transport accepts a serialized array as form data: 2362 options.formData = this._getFormData(options); 2363 }, 2364 2365 _initDataSettings: function (options) { 2366 if (this._isXHRUpload(options)) { 2367 if (!this._chunkedUpload(options, true)) { 2368 if (!options.data) { 2369 this._initXHRData(options); 2370 } 2371 this._initProgressListener(options); 2372 } 2373 } else { 2374 this._initIframeSettings(options); 2375 } 2376 }, 2377 2378 _initFormSettings: function (options) { 2379 // Retrieve missing options from the input field and the 2380 // associated form, if available: 2381 if (!options.form || !options.form.length) { 2382 options.form = $(options.fileInput.prop('form'));
2383 } 2384 if (!options.paramName) { 2385 options.paramName = options.fileInput.prop('name') || 2386 'files[]'; 2387 } 2388 if (!options.url) { 2389 options.url = options.form.prop('action') || location.href; 2390 } 2391 // The HTTP request method must be "POST" or "PUT": 2392 options.type = (options.type || options.form.prop('method') || '') 2393 .toUpperCase(); 2394 if (options.type !== 'POST' && options.type !== 'PUT') { 2395 options.type = 'POST'; 2396 } 2397 }, 2398 2399 _getAJAXSettings: function (data) { 2400 var options = $.extend({}, this.options, data); 2401 this._initFormSettings(options); 2402 this._initDataSettings(options); 2403 return options; 2404 }, 2405 2406 // Maps jqXHR callbacks to the equivalent 2407 // methods of the given Promise object: 2408 _enhancePromise: function (promise) { 2409 promise.success = promise.done; 2410 promise.error = promise.fail; 2411 promise.complete = promise.always; 2412 return promise; 2413 }, 2414 2415 // Creates and returns a Promise object enhanced with 2416 // the jqXHR methods abort, success, error and complete: 2417 _getXHRPromise: function (resolveOrReject, context, args) { 2418 var dfd = $.Deferred(), 2419 promise = dfd.promise(); 2420 context = context || this.options.context || promise; 2421 if (resolveOrReject === true) { 2422 dfd.resolveWith(context, args); 2423 } else if (resolveOrReject === false) { 2424 dfd.rejectWith(context, args); 2425 } 2426 promise.abort = dfd.promise; 2427 return this._enhancePromise(promise); 2428 }, 2429 2430 // Uploads a file in multiple, sequential requests 2431 // by splitting the file up in multiple blob chunks. 2432 // If the second parameter is true, only tests if the file 2433 // should be uploaded in chunks, but does not invoke any 2434 // upload requests: 2435 _chunkedUpload: function (options, testOnly) { 2436 var that = this, 2437 file = options.files[0], 2438 fs = file.size, 2439 ub = options.uploadedBytes = options.uploadedBytes || 0, 2440 mcs = options.maxChunkSize || fs, 2441 // Use the Blob methods with the slice implementation 2442 // according to the W3C Blob API specification: 2443 slice = file.webkitSlice || file.mozSlice || file.slice, 2444 upload, 2445 n, 2446 jqXHR, 2447 pipe; 2448 if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || 2449 options.data) { 2450 return false; 2451 } 2452 if (testOnly) { 2453 return true; 2454 } 2455 if (ub >= fs) { 2456 file.error = 'uploadedBytes'; 2457 return this._getXHRPromise(false); 2458 } 2459 // n is the number of blobs to upload, 2460 // calculated via filesize, uploaded bytes and max chunk size: 2461 n = Math.ceil((fs - ub) / mcs); 2462 // The chunk upload method accepting the chunk number as parameter: 2463 upload = function (i) { 2464 if (!i) { 2465 return that._getXHRPromise(true); 2466 } 2467 // Upload the blobs in sequential order: 2468 return upload(i -= 1).pipe(function () { 2469 // Clone the options object for each chunk upload: 2470 var o = $.extend({}, options); 2471 o.blob = slice.call( 2472 file, 2473 ub + i * mcs, 2474 ub + (i + 1) * mcs 2475 ); 2476 // Store the current chunk size, as the blob itself 2477 // will be dereferenced after data processing: 2478 o.chunkSize = o.blob.size; 2479 // Process the upload data (the blob and potential form data): 2480 that._initXHRData(o); 2481 // Add progress listeners for this chunk upload: 2482 that._initProgressListener(o); 2483 jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context)) 2484 .done(function () { 2485 // Create a progress event if upload is done and 2486 // no progress event has been invoked for this chunk: 2487 if (!o.loaded) { 2488 that._onProgress($.Event('progress', { 2489 lengthComputable: true, 2490 loaded: o.chunkSize, 2491 total: o.chunkSize 2492 }), o); 2493 } 2494 options.uploadedBytes = o.uploadedBytes 2495 += o.chunkSize; 2496 }); 2497 return jqXHR; 2498 }); 2499 }; 2500 // Return the piped Promise object, enhanced with an abort method, 2501 // which is delegated to the jqXHR object of the current upload, 2502 // and jqXHR callbacks mapped to the equivalent Promise methods: 2503 pipe = upload(n); 2504 pipe.abort = function () { 2505 return jqXHR.abort(); 2506 }; 2507 return this._enhancePromise(pipe); 2508 }, 2509 2510 _beforeSend: function (e, data) { 2511 if (this._active === 0) { 2512 // the start callback is triggered when an upload starts 2513 // and no other uploads are currently running, 2514 // equivalent to the global ajaxStart event: 2515 this._trigger('start'); 2516 } 2517 this._active += 1; 2518 // Initialize the global progress values: 2519 this._loaded += data.uploadedBytes || 0; 2520 this._total += this._getTotal(data.files); 2521 }, 2522 2523 _onDone: function (result, textStatus, jqXHR, options) { 2524 if (!this._isXHRUpload(options)) { 2525 // Create a progress event for each iframe load: 2526 this._onProgress($.Event('progress', { 2527 lengthComputable: true, 2528 loaded: 1, 2529 total: 1 2530 }), options); 2531 } 2532 options.result = result; 2533 options.textStatus = textStatus; 2534 options.jqXHR = jqXHR; 2535 this._trigger('done', null, options); 2536 }, 2537 2538 _onFail: function (jqXHR, textStatus, errorThrown, options) { 2539 options.jqXHR = jqXHR; 2540 options.textStatus = textStatus; 2541 options.errorThrown = errorThrown; 2542 this._trigger('fail', null, options); 2543 if (options.recalculateProgress) { 2544 // Remove the failed (error or abort) file upload from 2545 // the global progress calculation: 2546 this._loaded -= options.loaded || options.uploadedBytes || 0;
2547 this._total -= options.total || this._getTotal(options.files); 2548 } 2549 }, 2550 2551 _onAlways: function (result, textStatus, jqXHR, errorThrown, options) { 2552 this._active -= 1; 2553 options.result = result; 2554 options.textStatus = textStatus; 2555 options.jqXHR = jqXHR; 2556 options.errorThrown = errorThrown; 2557 this._trigger('always', null, options); 2558 if (this._active === 0) { 2559 // The stop callback is triggered when all uploads have 2560 // been completed, equivalent to the global ajaxStop event: 2561 this._trigger('stop'); 2562 // Reset the global progress values: 2563 this._loaded = this._total = 0; 2564 } 2565 }, 2566 2567 _onSend: function (e, data) { 2568 var that = this, 2569 jqXHR, 2570 pipe, 2571 options = that._getAJAXSettings(data), 2572 send = function (resolve, args) { 2573 jqXHR = jqXHR || ( 2574 (resolve !== false && 2575 that._trigger('send', e, options) !== false && 2576 (that._chunkedUpload(options) || $.ajax(options))) || 2577 that._getXHRPromise(false, options.context, args) 2578 ).done(function (result, textStatus, jqXHR) { 2579 that._onDone(result, textStatus, jqXHR, options); 2580 }).fail(function (jqXHR, textStatus, errorThrown) { 2581 that._onFail(jqXHR, textStatus, errorThrown, options); 2582 }).always(function (a1, a2, a3) { 2583 if (!a3 || typeof a3 === 'string') { 2584 that._onAlways(undefined, a2, a1, a3, options); 2585 } else { 2586 that._onAlways(a1, a2, a3, undefined, options); 2587 } 2588 }); 2589 return jqXHR; 2590 }; 2591 this._beforeSend(e, options); 2592 if (this.options.sequentialUploads) { 2593 // Return the piped Promise object, enhanced with an abort method, 2594 // which is delegated to the jqXHR object of the current upload, 2595 // and jqXHR callbacks mapped to the equivalent Promise methods: 2596 pipe = (this._sequence = this._sequence.pipe(send, send)); 2597 pipe.abort = function () { 2598 if (!jqXHR) { 2599 return send(false, [undefined, 'abort', 'abort']); 2600 } 2601 return jqXHR.abort(); 2602 }; 2603 return this._enhancePromise(pipe); 2604 } 2605 return send(); 2606 }, 2607 2608 _onAdd: function (e, data) { 2609 var that = this, 2610 result = true, 2611 options = $.extend({}, this.options, data); 2612 if (options.singleFileUploads && this._isXHRUpload(options)) { 2613 $.each(data.files, function (index, file) { 2614 var newData = $.extend({}, data, {files: [file]}); 2615 newData.submit = function () { 2616 return that._onSend(e, newData); 2617 }; 2618 return (result = that._trigger('add', e, newData)); 2619 }); 2620 return result; 2621 } else if (data.files.length) { 2622 data = $.extend({}, data); 2623 data.submit = function () { 2624 return that._onSend(e, data); 2625 }; 2626 return this._trigger('add', e, data); 2627 } 2628 }, 2629 2630 // File Normalization for Gecko 1.9.1 (Firefox 3.5) support: 2631 _normalizeFile: function (index, file) { 2632 if (file.name === undefined && file.size === undefined) { 2633 file.name = file.fileName; 2634 file.size = file.fileSize; 2635 } 2636 }, 2637 2638 _replaceFileInput: function (input) { 2639 var inputClone = input.clone(true); 2640 $('<form></form>').append(inputClone)[0].reset(); 2641 // Detaching allows to insert the fileInput on another form 2642 // without loosing the file input value: 2643 input.after(inputClone).detach(); 2644 // Replace the original file input element in the fileInput 2645 // collection with the clone, which has been copied including 2646 // event handlers: 2647 this.options.fileInput = this.options.fileInput.map(function (i, el) { 2648 if (el === input[0]) { 2649 return inputClone[0]; 2650 } 2651 return el; 2652 }); 2653 }, 2654 2655 _onChange: function (e) { 2656 var that = e.data.fileupload, 2657 data = { 2658 files: $.each($.makeArray(e.target.files), that._normalizeFile), 2659 fileInput: $(e.target), 2660 form: $(e.target.form) 2661 }; 2662 if (!data.files.length) { 2663 // If the files property is not available, the browser does not 2664 // support the File API and we add a pseudo File object with 2665 // the input value as name with path information removed: 2666 data.files = [{name: e.target.value.replace(/^.*\\/, '')}]; 2667 } 2668 // Store the form reference as jQuery data for other event handlers, 2669 // as the form property is not available after replacing the file input
2669: 2670 if (data.form.length) { 2671 data.fileInput.data('blueimp.fileupload.form', data.form); 2672 } else { 2673 data.form = data.fileInput.data('blueimp.fileupload.form'); 2674 } 2675 if (that.options.replaceFileInput) { 2676 that._replaceFileInput(data.fileInput); 2677 } 2678 if (that._trigger('change', e, data) === false || 2679 that._onAdd(e, data) === false) { 2680 return false; 2681 } 2682 }, 2683 2684 _onDrop: function (e) { 2685 var that = e.data.fileupload, 2686 dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer, 2687 data = { 2688 files: $.each( 2689 $.makeArray(dataTransfer && dataTransfer.files), 2690 that._normalizeFile 2691 ) 2692 }; 2693 if (that._trigger('drop', e, data) === false || 2694 that._onAdd(e, data) === false) { 2695 return false; 2696 } 2697 e.preventDefault(); 2698 }, 2699 2700 _onDragOver: function (e) { 2701 var that = e.data.fileupload, 2702 dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer; 2703 if (that._trigger('dragover', e) === false) { 2704 return false; 2705 } 2706 if (dataTransfer) { 2707 dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy'; 2708 } 2709 e.preventDefault(); 2710 }, 2711 2712 _initEventHandlers: function () { 2713 var ns = this.options.namespace || this.name; 2714 this.options.dropZone 2715 .bind('dragover.' + ns, {fileupload: this}, this._onDragOver) 2716 .bind('drop.' + ns, {fileupload: this}, this._onDrop); 2717 this.options.fileInput 2718 .bind('change.' + ns, {fileupload: this}, this._onChange); 2719 }, 2720 2721 _destroyEventHandlers: function () { 2722 var ns = this.options.namespace || this.name; 2723 this.options.dropZone 2724 .unbind('dragover.' + ns, this._onDragOver) 2725 .unbind('drop.' + ns, this._onDrop); 2726 this.options.fileInput 2727 .unbind('change.' + ns, this._onChange); 2728 }, 2729 2730 _beforeSetOption: function (key, value) { 2731 //this._destroyEventHandlers(); 2732 }, 2733 2734 _afterSetOption: function (key, value) { 2735 var options = this.options; 2736 if (!options.fileInput) { 2737 options.fileInput = $(); 2738 } 2739 if (!options.dropZone) { 2740 options.dropZone = $(); 2741 } 2742 this._initEventHandlers(); 2743 }, 2744 2745 _setOption: function (key, value) { 2746 var refresh = $.inArray(key, this._refreshOptionsList) !== -1; 2747 if (refresh) { 2748 this._beforeSetOption(key, value); 2749 } 2750 $.Widget.prototype._setOption.call(this, key, value); 2751 if (refresh) { 2752 this._afterSetOption(key, value); 2753 } 2754 }, 2755 2756 _create: function () { 2757 var options = this.options; 2758 if (options.fileInput === undefined) { 2759 options.fileInput = this.element.is('input:file') ? 2760 this.element : this.element.find('input:file'); 2761 } else if (!options.fileInput) { 2762 options.fileInput = $(); 2763 } 2764 if (!options.dropZone) { 2765 options.dropZone = $(); 2766 } 2767 this._sequence = this._getXHRPromise(true); 2768 this._active = this._loaded = this._total = 0; 2769 this._initEventHandlers(); 2770 }, 2771 2772 destroy: function () { 2773 // this._destroyEventHandlers(); 2774 //$.Widget.prototype.destroy.call(this); 2775 }, 2776 2777 enable: function () { 2778 $.Widget.prototype.enable.call(this); 2779 this._initEventHandlers(); 2780 }, 2781 2782 disable: function () { 2783 this._destroyEventHandlers(); 2784 $.Widget.prototype.disable.call(this); 2785 }, 2786 2787 // This method is exposed to the widget API and allows adding files 2788 // using the fileupload API. The data parameter accepts an object which 2789 // must have a files property and can contain additional options: 2790 // .fileupload('add', {files: filesList}); 2791 add: function (data) { 2792 if (!data || this.options.disabled) { 2793 return; 2794 } 2795 data.files = $.each($.makeArray(data.files), this._normalizeFile); 2796 this._onAdd(null, data); 2797 }, 2798 2799 // This method is exposed to the widget API and allows sending files 2800 // using the fileupload API. The data parameter accepts an object which 2801 // must have a files property and can contain additional options: 2802 // .fileupload('send', {files: filesList}); 2803 // The method returns a Promise object for the file upload call. 2804 send: function (data) { 2805 if (data && !this.options.disabled) { 2806 data.files = $.each($.makeArray(data.files), this._normalizeFile); 2807 if (data.files.length) { 2808 return this._onSend(null, data); 2809 } 2810 } 2811 return this._getXHRPromise(false, data && data.context); 2812 } 2813 2814 });
2815 2816}(jQuery)); 2817 2818 2819/* 2820* FancyBox - jQuery Plugin 2821* Simple and fancy lightbox alternative 2822* 2823* Examples and documentation at: http://fancybox.net 2824* 2825* Copyright (c) 2008 - 2010 Janis Skarnelis 2826* 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. 2827* 2828* Version: 1.3.4 (11/11/2010) 2829* Requires: jQuery v1.3+ 2830* 2831* Dual licensed under the MIT and GPL licenses: 2832* http://www.opensource.org/licenses/mit-license.php 2833* http://www.gnu.org/licenses/gpl.html 2834*/ 2835 2836;(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>'); 2837F()}},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)|| 2838c=="#")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= 2839false;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", 2840function(){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+ 2841'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+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== 2842"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+ 2843";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");
2843b(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, 2844opacity: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? 2845d.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}); 2846y=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== 2847i.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()); 2848f.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== 284937||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"]()}});if(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"); 2850s&&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); 2851f.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)};
2851if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c); 2852j.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== 2853"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"), 285410)||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)}; 2855b.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= 28560,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+ 28571)};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= 2858true;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");b(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; 2859b(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- 2860d.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); 2861D.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()}); 2862b.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)}}}; 2863b.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", 2864easingOut:"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); 2865 2866 2867 2868/* 2869 * ----------------------------- JSTORAGE ------------------------------------- 2870 * Simple local storage wrapper to save data on the browser side, supporting 2871 * all major browsers - IE6+, Firefox2+, Safari4+, Chrome4+ and Opera 10.5+ 2872 * 2873 * Copyright (c) 2010 Andris Reinman, [email protected]
2874 * Project homepage: www.jstorage.info 2875 * 2876 * Licensed under MIT-style license: 2877 * 2878 * Permission is hereby granted, free of charge, to any person obtaining a copy 2879 * of this software and associated documentation files (the "Software"), to deal 2880 * in the Software without restriction, including without limitation the rights 2881 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 2882 * copies of the Software, and to permit persons to whom the Software is 2883 * furnished to do so, subject to the following conditions: 2884 * 2885 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2886 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2887 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2888 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2889 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2890 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2891 * SOFTWARE. 2892 */ 2893 2894/** 2895 * $.jStorage 2896 * 2897 * USAGE: 2898 * 2899 * jStorage requires Prototype, MooTools or jQuery! If jQuery is used, then 2900 * jQuery-JSON (http://code.google.com/p/jquery-json/) is also needed. 2901 * (jQuery-JSON needs to be loaded BEFORE jStorage!) 2902 * 2903 * Methods: 2904 * 2905 * -set(key, value) 2906 * $.jStorage.set(key, value) -> saves a value 2907 * 2908 * -get(key[, default]) 2909 * value = $.jStorage.get(key [, default]) -> 2910 * retrieves value if key exists, or default if it doesn't 2911 * 2912 * -deleteKey(key) 2913 * $.jStorage.deleteKey(key) -> removes a key from the storage 2914 * 2915 * -flush() 2916 * $.jStorage.flush() -> clears the cache 2917 * 2918 * -storageObj() 2919 * $.jStorage.storageObj() -> returns a read-ony copy of the actual storage 2920 * 2921 * -storageSize() 2922 * $.jStorage.storageSize() -> returns the size of the storage in bytes 2923 * 2924 * -index() 2925 * $.jStorage.index() -> returns the used keys as an array 2926 * 2927 * -storageAvailable() 2928 * $.jStorage.storageAvailable() -> returns true if storage is available 2929 * 2930 * -reInit() 2931 * $.jStorage.reInit() -> reloads the data from browser storage 2932 * 2933 * <value> can be any JSON-able value, including objects and arrays. 2934 * 2935 **/ 2936 2937 2938(function($){ 2939 if(!$ || !($.toJSON || Object.toJSON || window.JSON) && !$.browser.msie){ 2940 throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!"); 2941 } 2942 2943 var 2944 /* This is the object, that holds the cached values */ 2945 _storage = {}, 2946 2947 /* Actual browser storage (localStorage or globalStorage['domain']) */ 2948 _storage_service = {jStorage:"{}"}, 2949 2950 /* DOM element for older IE versions, holds userData behavior */ 2951 _storage_elm = null, 2952 2953 /* How much space does the storage take */ 2954 _storage_size = 0, 2955 2956 /* function to encode objects to JSON strings */ 2957 json_encode = $.toJSON || Object.toJSON || (window.JSON && (JSON.encode || JSON.stringify)), 2958 2959 /* function to decode objects from JSON strings */ 2960 json_decode = $.evalJSON || (window.JSON && (JSON.decode || JSON.parse)) || function(str){ 2961 return String(str).evalJSON(); 2962 }, 2963 2964 /* which backend is currently used */ 2965 _backend = false; 2966 2967 /** 2968 * XML encoding and decoding as XML nodes can't be JSON'ized 2969 * XML nodes are encoded and decoded if the node is the value to be saved 2970 * but not if it's as a property of another object 2971 * Eg. - 2972 * $.jStorage.set("key", xmlNode); // IS OK 2973 * $.jStorage.set("key", {xml: xmlNode}); // NOT OK 2974 */ 2975 _XMLService = { 2976 2977 /** 2978 * Validates a XML node to be XML 2979 * based on jQuery.isXML function 2980 */ 2981 isXML: function(elm){ 2982 var documentElement = (elm ? elm.ownerDocument || elm : 0).documentElement; 2983 return documentElement ? documentElement.nodeName !== "HTML" : false; 2984 }, 2985 2986 /** 2987 * Encodes a XML node to string
2988 * based on http://www.mercurytide.co.uk/news/article/issues-when-working-ajax/ 2989 */ 2990 encode: function(xmlNode) { 2991 if(!this.isXML(xmlNode)){ 2992 return false; 2993 } 2994 try{ // Mozilla, Webkit, Opera 2995 return new XMLSerializer().serializeToString(xmlNode); 2996 }catch(E1) { 2997 try { // IE 2998 return xmlNode.xml; 2999 }catch(E2){} 3000 } 3001 return false; 3002 }, 3003 3004 /** 3005 * Decodes a XML node from string 3006 * loosely based on http://outwestmedia.com/jquery-plugins/xmldom/ 3007 */ 3008 decode: function(xmlString){ 3009 var dom_parser = ("DOMParser" in window && (new DOMParser()).parseFromString) || 3010 (window.ActiveXObject && function(_xmlString) { 3011 var xml_doc = new ActiveXObject('Microsoft.XMLDOM'); 3012 xml_doc.async = 'false'; 3013 xml_doc.loadXML(_xmlString); 3014 return xml_doc; 3015 }), 3016 resultXML; 3017 if(!dom_parser){ 3018 return false; 3019 } 3020 resultXML = dom_parser.call("DOMParser" in window && (new DOMParser()) || window, xmlString, 'text/xml'); 3021 return this.isXML(resultXML)?resultXML:false; 3022 } 3023 }; 3024 3025 ////////////////////////// PRIVATE METHODS //////////////////////// 3026 3027 /** 3028 * Initialization function. Detects if the browser supports DOM Storage 3029 * or userData behavior and behaves accordingly. 3030 * @returns undefined 3031 */ 3032 function _init(){ 3033 /* Check if browser supports localStorage */ 3034 if("localStorage" in window){ 3035 try { 3036 if(window.localStorage) { 3037 _storage_service = window.localStorage; 3038 _backend = "localStorage"; 3039 } 3040 } catch(E3) {/* Firefox fails when touching localStorage and cookies are disabled */} 3041 } 3042 /* Check if browser supports globalStorage */ 3043 else if("globalStorage" in window){ 3044 try { 3045 if(window.globalStorage) { 3046 _storage_service = window.globalStorage[window.location.hostname]; 3047 _backend = "globalStorage"; 3048 } 3049 } catch(E4) {/* Firefox fails when touching localStorage and cookies are disabled */} 3050 } 3051 /* Check if browser supports userData behavior */ 3052 else { 3053 _storage_elm = document.createElement('link'); 3054 if(_storage_elm.addBehavior){ 3055 3056 /* Use a DOM element to act as userData storage */ 3057 _storage_elm.style.behavior = 'url(#default#userData)'; 3058 3059 /* userData element needs to be inserted into the DOM! */ 3060 document.getElementsByTagName('head')[0].appendChild(_storage_elm); 3061 3062 _storage_elm.load("jStorage"); 3063 var data = "{}"; 3064 try{ 3065 data = _storage_elm.getAttribute("jStorage"); 3066 }catch(E5){} 3067 _storage_service.jStorage = data; 3068 _backend = "userDataBehavior"; 3069 }else{ 3070 _storage_elm = null; 3071 return; 3072 } 3073 } 3074 3075 _load_storage(); 3076 } 3077 3078 /** 3079 * Loads the data from the storage based on the supported mechanism 3080 * @returns undefined 3081 */ 3082 function _load_storage(){ 3083 /* if jStorage string is retrieved, then decode it */ 3084 if(_storage_service.jStorage){ 3085 try{ 3086 _storage = json_decode(String(_storage_service.jStorage)); 3087 }catch(E6){_storage_service.jStorage = "{}";} 3088 }else{ 3089 _storage_service.jStorage = "{}"; 3090 } 3091 _storage_size = _storage_service.jStorage?String(_storage_service.jStorage).length:0; 3092 } 3093 3094 /** 3095 * This functions provides the "save" mechanism to store the jStorage object 3096 * @returns undefined 3097 */ 3098 function _save(){ 3099 try{ 3100 _storage_service.jStorage = json_encode(_storage); 3101 // If userData is used as the storage engine, additional 3102 if(_storage_elm) { 3103 _storage_elm.setAttribute("jStorage",_storage_service.jStorage); 3104 _storage_elm.save("jStorage"); 3105 } 3106 _storage_size = _storage_service.jStorage?String(_storage_service.jStorage).length:0; 3107 }catch(E7){/* probably cache is full, nothing is saved this way*/} 3108 } 3109 3110 /** 3111 * Function checks if a key is set and is string or numberic 3112 */ 3113 function _checkKey(key){ 3114 if(!key || (typeof key != "string" && typeof key != "number")){ 3115 throw new TypeError('Key name must be string or numeric'); 3116 } 3117 return true; 3118 } 3119
3120 ////////////////////////// PUBLIC INTERFACE ///////////////////////// 3121 3122 $.jStorage = { 3123 /* Version number */ 3124 version: "0.1.5.2", 3125 3126 /** 3127 * Sets a key's value. 3128 * 3129 * @param {String} key - Key to set. If this value is not set or not 3130 * a string an exception is raised. 3131 * @param value - Value to set. This can be any value that is JSON 3132 * compatible (Numbers, Strings, Objects etc.). 3133 * @returns the used value 3134 */ 3135 set: function(key, value){ 3136 _checkKey(key); 3137 if(_XMLService.isXML(value)){ 3138 value = {_is_xml:true,xml:_XMLService.encode(value)}; 3139 } 3140 _storage[key] = value; 3141 _save(); 3142 return value; 3143 }, 3144 3145 /** 3146 * Looks up a key in cache 3147 * 3148 * @param {String} key - Key to look up. 3149 * @param {mixed} def - Default value to return, if key didn't exist. 3150 * @returns the key value, default value or <null> 3151 */ 3152 get: function(key, def){ 3153 _checkKey(key); 3154 if(key in _storage){ 3155 if(_storage[key] && typeof _storage[key] == "object" && 3156 _storage[key]._is_xml && 3157 _storage[key]._is_xml){ 3158 return _XMLService.decode(_storage[key].xml); 3159 }else{ 3160 return _storage[key]; 3161 } 3162 } 3163 return typeof(def) == 'undefined' ? null : def; 3164 }, 3165 3166 /** 3167 * Deletes a key from cache. 3168 * 3169 * @param {String} key - Key to delete. 3170 * @returns true if key existed or false if it didn't 3171 */ 3172 deleteKey: function(key){ 3173 _checkKey(key); 3174 if(key in _storage){ 3175 delete _storage[key]; 3176 _save(); 3177 return true; 3178 } 3179 return false; 3180 }, 3181 3182 /** 3183 * Deletes everything in cache. 3184 * 3185 * @returns true 3186 */ 3187 flush: function(){ 3188 _storage = {}; 3189 _save(); 3190 return true; 3191 }, 3192 3193 /** 3194 * Returns a read-only copy of _storage 3195 * 3196 * @returns Object 3197 */ 3198 storageObj: function(){ 3199 function F() {} 3200 F.prototype = _storage; 3201 return new F(); 3202 }, 3203 3204 /** 3205 * Returns an index of all used keys as an array 3206 * ['key1', 'key2',..'keyN'] 3207 * 3208 * @returns Array 3209 */ 3210 index: function(){ 3211 var index = [], i; 3212 for(i in _storage){ 3213 if(_storage.hasOwnProperty(i)){ 3214 index.push(i); 3215 } 3216 } 3217 return index; 3218 }, 3219 3220 /** 3221 * How much space in bytes does the storage take? 3222 * 3223 * @returns Number 3224 */ 3225 storageSize: function(){ 3226 return _storage_size; 3227 }, 3228 3229 /** 3230 * Which backend is currently in use? 3231 * 3232 * @returns String 3233 */ 3234 currentBackend: function(){ 3235 return _backend; 3236 }, 3237 3238 /** 3239 * Test if storage is available 3240 * 3241 * @returns Boolean 3242 */ 3243 storageAvailable: function(){ 3244 return !!_backend; 3245 }, 3246 3247 /** 3248 * Reloads the data from browser storage 3249 * 3250 * @returns undefined 3251 */ 3252 reInit: function(){ 3253 var new_storage_elm, data; 3254 if(_storage_elm && _storage_elm.addBehavior){ 3255 new_storage_elm = document.createElement('link'); 3256 3257 _storage_elm.parentNode.replaceChild(new_storage_elm, _storage_elm); 3258 _storage_elm = new_storage_elm; 3259 3260 /* Use a DOM element to act as userData storage */ 3261 _storage_elm.style.behavior = 'url(#default#userData)'; 3262 3263 /* userData element needs to be inserted into the DOM! */ 3264 document.getElementsByTagName('head')[0].appendChild(_storage_elm); 3265 3266 _storage_elm.load("jStorage"); 3267 data = "{}"; 3268 try{ 3269 data = _storage_elm.getAttribute("jStorage"); 3270 }catch(E5){} 3271 _storage_service.jStorage = data; 3272 _backend = "userDataBehavior"; 3273 } 3274 3275 _load_storage(); 3276 } 3277 }; 3278 3279 // Initialize jStorage 3280 _init(); 3281 3282})(window.jQuery || window.$); 3283 3284/** 3285 * jQuery custom checkboxes 3286 * 3287 * Copyright (c) 2008 Khavilo Dmitry (http://widowmaker.kiev.ua/checkbox/) 3288 * Licensed under the MIT License: 3289 * http://www.opensource.org/licenses/mit-license.php 3290 * 3291 * @version 1.3.0 Beta 1 3292 * @author Khavilo Dmitry 3293 * @mailto [email protected] 3294 * modified for White Label by Xaver Birsak revaxarts.com
3295**/ 3296 3297(function($){ 3298 /* Little trick to remove event bubbling that causes events recursion */ 3299 var CB = function(e) 3300 { 3301 if (!e) var e = window.event; 3302 e.cancelBubble = true; 3303 if (e.stopPropagation) e.stopPropagation(); 3304 }; 3305 3306 $.fn.checkbox = function(options) { 3307 3308 /* Default settings */ 3309 var settings = { 3310 cls: 'jquery-checkbox' /* checkbox */ 3311 }; 3312 3313 /* Processing settings */ 3314 settings = $.extend(settings, options || {}); 3315 3316 /* Adds check/uncheck & disable/enable events */ 3317 var addEvents = function(object) 3318 { 3319 var checked = object.checked; 3320 var disabled = object.disabled; 3321 var $object = $(object); 3322 3323 if ( object.stateInterval ) 3324 clearInterval(object.stateInterval); 3325 3326 object.stateInterval = setInterval( 3327 function() 3328 { 3329 if ( object.disabled != disabled ) 3330 $object.trigger( (disabled = !!object.disabled) ? 'disable' : 'enable'); 3331 if ( object.checked != checked ) 3332 $object.trigger( (checked = !!object.checked) ? 'check' : 'uncheck'); 3333 }, 3334 10 /* in miliseconds. Low numbers this can decrease performance on slow computers, high will increase responce time */ 3335 ); 3336 return $object; 3337 }; 3338 3339 /* Wrapping all passed elements */ 3340 return this.each(function() 3341 { 3342 var ch = this; /* Reference to DOM Element*/ 3343 var $ch = addEvents(ch),/* Adds custom events and returns, jQuery enclosed object */ 3344 elClass = ($(ch).is(':radio')) ? 'radio' : 'checkbox'; 3345 3346 /* Removing wrapper if already applied */ 3347 if (ch.wrapper) ch.wrapper.remove(); 3348 3349 /* Creating wrapper for checkbox and assigning "hover" event */ 3350 ch.wrapper = $('<span class="' + settings.cls + ' ' + elClass + '"><span><span class="checkboxplaceholder"></span></span></span>'); 3351 ch.wrapperInner = ch.wrapper.children('span:eq(0)'); 3352 ch.wrapper.bind({ 3353 "click" : function(e) { $ch.trigger('click');return false; }, 3354 "mouseover" : function(e) { ch.wrapperInner.addClass('hover'); }, 3355 "mouseout" : function(e) { ch.wrapperInner.removeClass('hover'); }, 3356 "mousedown" : function(e) { ch.wrapperInner.addClass('pressed'); }, 3357 "mouseup" : function(e) { ch.wrapperInner.removeClass('pressed'); } 3358 }); 3359 3360 /* Wrapping checkbox */ 3361 $ch.css({position: 'absolute', zIndex: -1, visibility: 'hidden'}).after(ch.wrapper); 3362 3363 /* Ttying to find "our" label */ 3364 var label = false; 3365/* if ($ch.attr('id')) { 3366 label = $('label[for='+$ch.attr('id')+']'); 3367 if (!label.length) label = false; 3368 } 3369*/ if (!label) { 3370 label = $ch.closest('label'); 3371 if (!label.length) label = false; 3372 } 3373 /* Label found, applying event hanlers */ 3374 if (label) { 3375 label.bind({ 3376 "click" : function(e) { $ch.trigger('click'); return false; }, 3377 "mouseover" : function(e) { ch.wrapper.trigger('mouseover'); }, 3378 "mouseout" : function(e) { ch.wrapper.trigger('mouseout'); }, 3379 "mousedown" : function(e) { ch.wrapper.addClass('pressed'); }, 3380 "mouseup" : function(e) { ch.wrapper.removeClass('pressed'); } 3381 }); 3382 } 3383 3384 $ch.bind('disable', function() { ch.wrapperInner.addClass('disabled');}).bind('enable', function() { ch.wrapperInner.removeClass( 'disabled' );}); 3385 $ch.bind('check', function() { 3386 if(ch.name=="chkEmailConfirmatiom" || ch.name=="chkTranscripts"){ 3387 SetPerference(ch); 3388 } 3389 ch.wrapper.addClass('checked' ); 3390 // $(ch).attr('checked',true); 3391 }).bind('uncheck', function() { 3392 3393 if(ch.name=="chkEmailConfirmatiom" || ch.name=="chkTranscripts"){ 3394 SetPerference(ch); 3395 } 3396 ch.wrapper.removeClass( 'checked' ); 3397 // $(ch).attr('checked',false); 3398 }); 3399 3400 /* Firefox antiselection hack */ 3401 if ( window.getSelection ) 3402 ch.wrapper.css('MozUserSelect', 'none'); 3403 3404 /* Applying checkbox state */ 3405 if ( ch.checked ) 3406 ch.wrapper.addClass('checked'); 3407 if ( ch.disabled ) 3408 ch.wrapperInner.addClass('disabled'); 3409 }); 3410 } 3411})(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.