vendor: 42,015 bytes, lines 1-1097
1/* 2 * Modernizr tests which native CSS3 and HTML5 features are available in 3 * the current UA and makes the results available to you in two ways: 4 * as properties on a global Modernizr object, and as classes on the 5 * <html> element. This information allows you to progressively enhance 6 * your pages with a granular level of control over the experience. 7 * 8 * Modernizr has an optional (not included) conditional resource loader 9 * called Modernizr.load(), based on Yepnope.js (yepnopejs.com). 10 * To get a build that includes Modernizr.load(), as well as choosing 11 * which tests to include, go to www.modernizr.com/download/ 12 * 13 * Authors Faruk Ates, Paul Irish, Alex Sexton 14 * Contributors Ryan Seddon, Ben Alman 15 */ 16 17window.Modernizr = (function (window, document, undefined) { 18 19 var version = '2.8.3', 20 Modernizr = {}, 21 /*>>cssclasses*/ 22 // option for enabling the HTML classes to be added 23 enableClasses = true, 24 /*>>cssclasses*/ 25 26 docElement = document.documentElement, 27 /** 28 * Create our "modernizr" element that we do most feature tests on. 29 */ 30 mod = 'modernizr', 31 modElem = document.createElement(mod), 32 mStyle = modElem.style, 33 /** 34 * Create the input element for various Web Forms feature tests. 35 */ 36 inputElem /*>>inputelem*/ = document.createElement('input') /*>>inputelem*/, 37 /*>>smile*/ 38 smile = ':)', 39 /*>>smile*/ 40 41 toString = {}.toString, 42 // TODO :: make the prefixes more granular 43 /*>>prefixes*/ 44 // List of property values to set for css tests. See ticket #21 45 prefixes = ' -webkit- -moz- -o- -ms- '.split(' '), 46 /*>>prefixes*/ 47 48 /*>>domprefixes*/ 49 // Following spec is to expose vendor-specific style properties as: 50 // elem.style.WebkitBorderRadius 51 // and the following would be incorrect: 52 // elem.style.webkitBorderRadius 53 54 // Webkit ghosts their properties in lowercase but Opera & Moz do not. 55 // Microsoft uses a lowercase `ms` instead of the correct `Ms` in IE8+ 56 // erik.eae.net/archives/2008/03/10/21.48.10/ 57 58 // More here: github.com/Modernizr/Modernizr/issues/issue/21 59 omPrefixes = 'Webkit Moz O ms', 60 cssomPrefixes = omPrefixes.split(' '), 61 domPrefixes = omPrefixes.toLowerCase().split(' '), 62 /*>>domprefixes*/ 63 64 /*>>ns*/ 65 ns = { 'svg': 'http://www.w3.org/2000/svg' }, 66 /*>>ns*/ 67 68 tests = {}, 69 inputs = {}, 70 attrs = {}, 71 classes = [], 72 slice = classes.slice, 73 featureName, // used in testing loop 74 75 76 /*>>teststyles*/ 77 // Inject element with style element and some CSS rules 78 injectElementWithStyles = function (rule, callback, nodes, testnames) { 79 80 var style, ret, node, docOverflow, 81 div = document.createElement('div'), 82 // After page load injecting a fake body doesn't work so check if body exists 83 body = document.body, 84 // IE6 and 7 won't return offsetWidth or offsetHeight unless it's in the body element, so we fake it. 85 fakeBody = body || document.createElement('body'); 86 87 if (parseInt(nodes, 10)) { 88 // In order not to give false positives we create a node for each test 89 // This also allows the method to scale for unspecified uses 90 while (nodes--) { 91 node = document.createElement('div'); 92 node.id = testnames ? testnames[nodes] : mod + (nodes + 1); 93 div.appendChild(node); 94 } 95 } 96 97 // <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed 98 // when injected with innerHTML. To get around this you need to prepend the 'NoScope' element 99 // with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements. 100 // msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx 101 // Documents served as xml will throw if using ­ so use xml friendly encoded version. See issue #277 102 style = ['­', '<style id="s', mod, '">', rule, '</style>'].join(''); 103 div.id = mod; 104 // IE6 will false positive on some tests due to the style element inside the test div somehow interfering offsetHeight, so insert it into body or fakebody. 105 // Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270 106 (body ? div : fakeBody).innerHTML += style; 107 fakeBody.appendChild(div); 108 if (!body) { 109 //avoid crashing IE8, if background image is used 110 fakeBody.style.background = ''; 111 //Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible 112 fakeBody.style.overflow = 'hidden'; 113 docOverflow = docElement.style.overflow; 114 docElement.style.overflow = 'hidden'; 115 docElement.appendChild(fakeBody); 116 } 117 118 ret = callback(div, rule); 119 // If this is done after page load we don't want to remove the body so check if body exists 120 if (!body) { 121 fakeBody.parentNode.removeChild(fakeBody); 122 docElement.style.overflow = docOverflow; 123 } else { 124 div.parentNode.removeChild(div); 125 } 126 127 return !!ret; 128 129 }, 130 /*>>teststyles*/ 131 132 /*>>mq*/ 133 // adapted from matchMedia polyfill 134 // by Scott Jehl and Paul Irish 135 // gist.github.com/786768 136 testMediaQuery = function (mq) { 137 138 var matchMedia = window.matchMedia || window.msMatchMedia; 139 if (matchMedia) { 140 return matchMedia(mq) && matchMedia(mq).matches || false; 141 } 142 143 var bool; 144 145 injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function (node) { 146 bool = (window.getComputedStyle ? 147 getComputedStyle(node, null) : 148 node.currentStyle)['position'] == 'absolute'; 149 }); 150 151 return bool; 152 153 }, 154 /*>>mq*/ 155 156 157 /*>>hasevent*/ 158 // 159 // isEventSupported determines if a given element supports the given event 160 // kangax.github.com/iseventsupported/ 161 // 162 // The following results are known incorrects: 163 // Modernizr.hasEvent("webkitTransitionEnd", elem) // false negative 164 // Modernizr.hasEvent("textInput") // in Webkit. github.com/Modernizr/Modernizr/issues/333 165 // ... 166 isEventSupported = (function () { 167 168 var TAGNAMES = { 169 'select': 'input', 'change': 'input', 170 'submit': 'form', 'reset': 'form', 171 'error': 'img', 'load': 'img', 'abort': 'img' 172 }; 173 174 function isEventSupported(eventName, element) { 175 176 element = element || document.createElement(TAGNAMES[eventName] || 'div'); 177 eventName = 'on' + eventName; 178 179 // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those 180 var isSupported = eventName in element; 181 182 if (!isSupported) { 183 // If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element 184 if (!element.setAttribute) { 185 element = document.createElement('div'); 186 } 187 if (element.setAttribute && element.removeAttribute) { 188 element.setAttribute(eventName, ''); 189 isSupported = is(element[eventName], 'function'); 190 191 // If property was created, "remove it" (by setting value to `undefined`) 192 if (!is(element[eventName], 'undefined')) { 193 element[eventName] = undefined; 194 } 195 element.removeAttribute(eventName); 196 } 197 } 198 199 element = null; 200 return isSupported; 201 } 202 return isEventSupported; 203 })(), 204 /*>>hasevent*/ 205 206 // TODO :: Add flag for hasownprop ? didn't last time 207 208 // hasOwnProperty shim by kangax needed for Safari 2.0 support 209 _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp; 210 211 if (!is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined')) { 212 hasOwnProp = function (object, property) { 213 return _hasOwnProperty.call(object, property); 214 }; 215 } 216 else { 217 hasOwnProp = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */ 218 return ((property in object) && is(object.constructor.prototype[property], 'undefined')); 219 }; 220 } 221 222 // Adapted from ES5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js 223 // es5.github.com/#x15.3.4.5 224 225 if (!Function.prototype.bind) { 226 Function.prototype.bind = function bind(that) { 227 228 var target = this; 229 230 if (typeof target != "function") { 231 throw new TypeError(); 232 } 233 234 var args = slice.call(arguments, 1), 235 bound = function () { 236 237 if (this instanceof bound) { 238 239 var F = function () { 240 }; 241 F.prototype = target.prototype; 242 var self = new F(); 243 244 var result = target.apply( 245 self, 246 args.concat(slice.call(arguments)) 247 ); 248 if (Object(result) === result) { 249 return result; 250 } 251 return self; 252 253 } else { 254 255 return target.apply( 256 that, 257 args.concat(slice.call(arguments)) 258 ); 259 260 } 261 262 }; 263 264 return bound; 265 }; 266 } 267 268 /** 269 * setCss applies given styles to the Modernizr DOM node. 270 */ 271 function setCss(str) { 272 mStyle.cssText = str; 273 } 274 275 /** 276 * setCssAll extrapolates all vendor-specific css strings. 277 */ 278 function setCssAll(str1, str2) { 279 return setCss(prefixes.join(str1 + ';') + (str2 || '')); 280 } 281 282 /** 283 * is returns a boolean for if typeof obj is exactly type. 284 */ 285 function is(obj, type) { 286 return typeof obj === type; 287 } 288 289 /** 290 * contains returns a boolean for if substr is found within str. 291 */ 292 function contains(str, substr) { 293 return !!~('' + str).indexOf(substr); 294 } 295 296 /*>>testprop*/ 297 298 // testProps is a generic CSS / DOM property test. 299 300 // In testing support for a given CSS property, it's legit to test: 301 // `elem.style[styleName] !== undefined` 302 // If the property is supported it will return an empty string, 303 // if unsupported it will return undefined. 304 305 // We'll take advantage of this quick test and skip setting a style 306 // on our modernizr element, but instead just testing undefined vs 307 // empty string. 308 309 // Because the testing of the CSS property names (with "-", as 310 // opposed to the camelCase DOM properties) is non-portable and 311 // non-standard but works in WebKit and IE (but not Gecko or Opera), 312 // we explicitly reject properties with dashes so that authors 313 // developing in WebKit or IE first don't end up with 314 // browser-specific content by accident. 315 316 function testProps(props, prefixed) { 317 for (var i in props) { 318 var prop = props[i]; 319 if (!contains(prop, "-") && mStyle[prop] !== undefined) { 320 return prefixed == 'pfx' ? prop : true; 321 } 322 } 323 return false; 324 } 325 /*>>testprop*/ 326 327 // TODO :: add testDOMProps 328 /** 329 * testDOMProps is a generic DOM property test; if a browser supports 330 * a certain property, it won't return undefined for it. 331 */ 332 function testDOMProps(props, obj, elem) { 333 for (var i in props) { 334 var item = obj[props[i]]; 335 if (item !== undefined) { 336 337 // return the property name as a string 338 if (elem === false) 339 return props[i]; 340 341 // let's bind a function 342 if (is(item, 'function')) { 343 // default to autobind unless override 344 return item.bind(elem || obj); 345 } 346 347 // return the unbound function or obj or value 348 return item; 349 } 350 } 351 return false; 352 } 353 354 /*>>testallprops*/ 355 /** 356 * testPropsAll tests a list of DOM properties we want to check against. 357 * We specify literally ALL possible (known and/or likely) properties on 358 * the element including the non-vendor prefixed one, for forward- 359 * compatibility. 360 */ 361 function testPropsAll(prop, prefixed, elem) { 362 363 var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), 364 props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' '); 365 366 // did they call .prefixed('boxSizing') or are we just testing a prop? 367 if (is(prefixed, "string") || is(prefixed, "undefined")) { 368 return testProps(props, prefixed); 369 370 // otherwise, they called .prefixed('requestAnimationFrame', window[, elem]) 371 } else { 372 props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' '); 373 return testDOMProps(props, prefixed, elem); 374 } 375 } 376 /*>>testallprops*/ 377 378 379 /** 380 * Tests 381 * ----- 382 */ 383 384 // The *new* flexbox 385 // dev.w3.org/csswg/css3-flexbox 386 387 tests['flexbox'] = function () { 388 return testPropsAll('flexWrap'); 389 }; 390 391 // The *old* flexbox 392 // www.w3.org/TR/2009/WD-css3-flexbox-20090723/ 393 394 tests['flexboxlegacy'] = function () { 395 return testPropsAll('boxDirection'); 396 }; 397 398 // On the S60 and BB Storm, getContext exists, but always returns undefined 399 // so we actually have to call getContext() to verify 400 // github.com/Modernizr/Modernizr/issues/issue/97/ 401 402 tests['canvas'] = function () { 403 var elem = document.createElement('canvas'); 404 return !!(elem.getContext && elem.getContext('2d')); 405 }; 406 407 tests['canvastext'] = function () { 408 return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function')); 409 }; 410 411 // webk.it/70117 is tracking a legit WebGL feature detect proposal 412 413 // We do a soft detect which may false positive in order to avoid 414 // an expensive context creation: bugzil.la/732441 415 416 tests['webgl'] = function () { 417 return !!window.WebGLRenderingContext; 418 }; 419 420 /* 421 * The Modernizr.touch test only indicates if the browser supports 422 * touch events, which does not necessarily reflect a touchscreen 423 * device, as evidenced by tablets running Windows 7 or, alas, 424 * the Palm Pre / WebOS (touch) phones. 425 * 426 * Additionally, Chrome (desktop) used to lie about its support on this, 427 * but that has since been rectified: crbug.com/36415 428 * 429 * We also test for Firefox 4 Multitouch Support. 430 * 431 * For more info, see: modernizr.github.com/Modernizr/touch.html 432 */ 433 434 tests['touch'] = function () { 435 var bool; 436 437 if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) { 438 bool = true; 439 } else { 440 injectElementWithStyles(['@media (', prefixes.join('touch-enabled),('), mod, ')', '{#modernizr{top:9px;position:absolute}}'].join(''), function (node) { 441 bool = node.offsetTop === 9; 442 }); 443 } 444 445 return bool; 446 }; 447 448 449 // geolocation is often considered a trivial feature detect... 450 // Turns out, it's quite tricky to get right: 451 // 452 // Using !!navigator.geolocation does two things we don't want. It: 453 // 1. Leaks memory in IE9: github.com/Modernizr/Modernizr/issues/513 454 // 2. Disables page caching in WebKit: webk.it/43956 455 // 456 // Meanwhile, in Firefox < 8, an about:config setting could expose 457 // a false positive that would throw an exception: bugzil.la/688158 458 459 tests['geolocation'] = function () { 460 return 'geolocation' in navigator; 461 }; 462 463 464 tests['postmessage'] = function () { 465 return !!window.postMessage; 466 }; 467 468 469 // Chrome incognito mode used to throw an exception when using openDatabase 470 // It doesn't anymore. 471 tests['websqldatabase'] = function () { 472 return !!window.openDatabase; 473 }; 474 475 // Vendors had inconsistent prefixing with the experimental Indexed DB: 476 // - Webkit's implementation is accessible through webkitIndexedDB 477 // - Firefox shipped moz_indexedDB before FF4b9, but since then has been mozIndexedDB 478 // For speed, we don't test the legacy (and beta-only) indexedDB 479 tests['indexedDB'] = function () { 480 return !!testPropsAll("indexedDB", window); 481 }; 482 483 // documentMode logic from YUI to filter out IE8 Compat Mode 484 // which false positives. 485 tests['hashchange'] = function () { 486 return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7); 487 }; 488 489 // Per 1.6: 490 // This used to be Modernizr.historymanagement but the longer 491 // name has been deprecated in favor of a shorter and property-matching one. 492 // The old API is still available in 1.6, but as of 2.0 will throw a warning, 493 // and in the first release thereafter disappear entirely. 494 tests['history'] = function () { 495 return !!(window.history && history.pushState); 496 }; 497 498 tests['draganddrop'] = function () { 499 var div = document.createElement('div'); 500 return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div); 501 }; 502 503 // FF3.6 was EOL'ed on 4/24/12, but the ESR version of FF10 504 // will be supported until FF19 (2/12/13), at which time, ESR becomes FF17. 505 // FF10 still uses prefixes, so check for it until then. 506 // for more ESR info, see: mozilla.org/en-US/firefox/organizations/faq/ 507 tests['websockets'] = function () { 508 return 'WebSocket' in window || 'MozWebSocket' in window; 509 }; 510 511 512 // css-tricks.com/rgba-browser-support/ 513 tests['rgba'] = function () { 514 // Set an rgba() color and check the returned value 515 516 setCss('background-color:rgba(150,255,150,.5)'); 517 518 return contains(mStyle.backgroundColor, 'rgba'); 519 }; 520 521 tests['hsla'] = function () { 522 // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally, 523 // except IE9 who retains it as hsla 524 525 setCss('background-color:hsla(120,40%,100%,.5)'); 526 527 return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla'); 528 }; 529 530 tests['multiplebgs'] = function () { 531 // Setting multiple images AND a color on the background shorthand property 532 // and then querying the style.background property value for the number of 533 // occurrences of "url(" is a reliable method for detecting ACTUAL support for this! 534 535 setCss('background:url(https://),url(https://),red url(https://)'); 536 537 // If the UA supports multiple backgrounds, there should be three occurrences 538 // of the string "url(" in the return value for elemStyle.background 539 540 return (/(url\s*\(.*?){3}/).test(mStyle.background); 541 }; 542 543 544 545 // this will false positive in Opera Mini 546 // github.com/Modernizr/Modernizr/issues/396 547 548 tests['backgroundsize'] = function () { 549 return testPropsAll('backgroundSize'); 550 }; 551 552 tests['borderimage'] = function () { 553 return testPropsAll('borderImage'); 554 }; 555 556 557 // Super comprehensive table about all the unique implementations of 558 // border-radius: muddledramblings.com/table-of-css3-border-radius-compliance 559 560 tests['borderradius'] = function () { 561 return testPropsAll('borderRadius'); 562 }; 563 564 // WebOS unfortunately false positives on this test. 565 tests['boxshadow'] = function () { 566 return testPropsAll('boxShadow'); 567 }; 568 569 // FF3.0 will false positive on this test 570 tests['textshadow'] = function () { 571 return document.createElement('div').style.textShadow === ''; 572 }; 573 574 575 tests['opacity'] = function () { 576 // Browsers that actually have CSS Opacity implemented have done so 577 // according to spec, which means their return values are within the 578 // range of [0.0,1.0] - including the leading zero. 579 580 setCssAll('opacity:.55'); 581 582 // The non-literal . in this regex is intentional: 583 // German Chrome returns this value as 0,55 584 // github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632 585 return (/^0.55$/).test(mStyle.opacity); 586 }; 587 588 589 // Note, Android < 4 will pass this test, but can only animate 590 // a single property at a time 591 // goo.gl/v3V4Gp 592 tests['cssanimations'] = function () { 593 return testPropsAll('animationName'); 594 }; 595 596 597 tests['csscolumns'] = function () { 598 return testPropsAll('columnCount'); 599 }; 600 601 602 tests['cssgradients'] = function () { 603 /** 604 * For CSS Gradients syntax, please see: 605 * webkit.org/blog/175/introducing-css-gradients/ 606 * developer.mozilla.org/en/CSS/-moz-linear-gradient 607 * developer.mozilla.org/en/CSS/-moz-radial-gradient 608 * dev.w3.org/csswg/css3-images/#gradients- 609 */ 610 611 var str1 = 'background-image:', 612 str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));', 613 str3 = 'linear-gradient(left top,#9f9, white);'; 614 615 setCss( 616 // legacy webkit syntax (FIXME: remove when syntax not in use anymore) 617 (str1 + '-webkit- '.split(' ').join(str2 + str1) + 618 // standard syntax // trailing 'background-image:' 619 prefixes.join(str3 + str1)).slice(0, -str1.length) 620 ); 621 622 return contains(mStyle.backgroundImage, 'gradient'); 623 }; 624 625 626 tests['cssreflections'] = function () { 627 return testPropsAll('boxReflect'); 628 }; 629 630 631 tests['csstransforms'] = function () { 632 return !!testPropsAll('transform'); 633 }; 634 635 636 tests['csstransforms3d'] = function () { 637 638 var ret = !!testPropsAll('perspective'); 639 640 // Webkit's 3D transforms are passed off to the browser's own graphics renderer. 641 // It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in 642 // some conditions. As a result, Webkit typically recognizes the syntax but 643 // will sometimes throw a false positive, thus we must do a more thorough check: 644 if (ret && 'webkitPerspective' in docElement.style) { 645 646 // Webkit allows this media query to succeed only if the feature is enabled. 647 // `@media (transform-3d),(-webkit-transform-3d){ ... }` 648 injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function (node, rule) { 649 ret = node.offsetLeft === 9 && node.offsetHeight === 3; 650 }); 651 } 652 return ret; 653 }; 654 655 656 tests['csstransitions'] = function () { 657 return testPropsAll('transition'); 658 }; 659 660 661 /*>>fontface*/ 662 // @font-face detection routine by Diego Perini 663 // javascript.nwbox.com/CSSSupport/ 664 665 // false positives: 666 // WebOS github.com/Modernizr/Modernizr/issues/342 667 // WP7 github.com/Modernizr/Modernizr/issues/538 668 tests['fontface'] = function () { 669 var bool; 670 671 injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function (node, rule) { 672 var style = document.getElementById('smodernizr'), 673 sheet = style.sheet || style.styleSheet, 674 cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : ''; 675 676 bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0; 677 }); 678 679 return bool; 680 }; 681 /*>>fontface*/ 682 683 // CSS generated content detection 684 tests['generatedcontent'] = function () { 685 var bool; 686 687 injectElementWithStyles(['#', mod, '{font:0/0 a}#', mod, ':after{content:"', smile, '";visibility:hidden;font:3px/1 a}'].join(''), function (node) { 688 bool = node.offsetHeight >= 3; 689 }); 690 691 return bool; 692 }; 693 694 695 696 // These tests evaluate support of the video/audio elements, as well as 697 // testing what types of content they support. 698 // 699 // We're using the Boolean constructor here, so that we can extend the value 700 // e.g. Modernizr.video // true 701 // Modernizr.video.ogg // 'probably' 702 // 703 // Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845 704 // thx to NielsLeenheer and zcorpan 705 706 // Note: in some older browsers, "no" was a return value instead of empty string. 707 // It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2 708 // It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5 709 710 tests['video'] = function () { 711 var elem = document.createElement('video'), 712 bool = false; 713 714 // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224 715 try { 716 if (bool = !!elem.canPlayType) { 717 bool = new Boolean(bool); 718 bool.ogg = elem.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, ''); 719 720 // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 721 bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, ''); 722 723 bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, ''); 724 } 725 726 } catch (e) { 727 } 728 729 return bool; 730 }; 731 732 tests['audio'] = function () { 733 var elem = document.createElement('audio'), 734 bool = false; 735 736 try { 737 if (bool = !!elem.canPlayType) { 738 bool = new Boolean(bool); 739 bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''); 740 bool.mp3 = elem.canPlayType('audio/mpeg;').replace(/^no$/, ''); 741 742 // Mimetypes accepted: 743 // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements 744 // bit.ly/iphoneoscodecs 745 bool.wav = elem.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''); 746 bool.m4a = (elem.canPlayType('audio/x-m4a;') || 747 elem.canPlayType('audio/aac;')).replace(/^no$/, ''); 748 } 749 } catch (e) { 750 } 751 752 return bool; 753 }; 754 755 756 // In FF4, if disabled, window.localStorage should === null. 757 758 // Normally, we could not test that directly and need to do a 759 // `('localStorage' in window) && ` test first because otherwise Firefox will 760 // throw bugzil.la/365772 if cookies are disabled 761 762 // Also in iOS5 Private Browsing mode, attempting to use localStorage.setItem 763 // will throw the exception: 764 // QUOTA_EXCEEDED_ERRROR DOM Exception 22. 765 // Peculiarly, getItem and removeItem calls do not throw. 766 767 // Because we are forced to try/catch this, we'll go aggressive. 768 769 // Just FWIW: IE8 Compat mode supports these features completely: 770 // www.quirksmode.org/dom/html5.html 771 // But IE8 doesn't support either with local files 772 773 tests['localstorage'] = function () { 774 try { 775 localStorage.setItem(mod, mod); 776 localStorage.removeItem(mod); 777 return true; 778 } catch (e) { 779 return false; 780 } 781 }; 782 783 tests['sessionstorage'] = function () { 784 try { 785 sessionStorage.setItem(mod, mod); 786 sessionStorage.removeItem(mod); 787 return true; 788 } catch (e) { 789 return false; 790 } 791 }; 792 793 794 tests['webworkers'] = function () { 795 return !!window.Worker; 796 }; 797 798 799 tests['applicationcache'] = function () { 800 return !!window.applicationCache; 801 }; 802 803 804 // Thanks to Erik Dahlstrom 805 tests['svg'] = function () { 806 return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect; 807 }; 808 809 // specifically for SVG inline in HTML, not within XHTML 810 // test page: paulirish.com/demo/inline-svg 811 tests['inlinesvg'] = function () { 812 var div = document.createElement('div'); 813 div.innerHTML = '<svg/>'; 814 return (div.firstChild && div.firstChild.namespaceURI) == ns.svg; 815 }; 816 817 // SVG SMIL animation 818 tests['smil'] = function () { 819 return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate'))); 820 }; 821 822 // This test is only for clip paths in SVG proper, not clip paths on HTML content 823 // demo: srufaculty.sru.edu/david.dailey/svg/newstuff/clipPath4.svg 824 825 // However read the comments to dig into applying SVG clippaths to HTML content here: 826 // github.com/Modernizr/Modernizr/issues/213#issuecomment-1149491 827 tests['svgclippaths'] = function () { 828 return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath'))); 829 }; 830 831 /*>>webforms*/ 832 // input features and input types go directly onto the ret object, bypassing the tests loop. 833 // Hold this guy to execute in a moment. 834 function webforms() { 835 /*>>input*/ 836 // Run through HTML5's new input attributes to see if the UA understands any. 837 // We're using f which is the <input> element created early on 838 // Mike Taylr has created a comprehensive resource for testing these attributes 839 // when applied to all input types: 840 // miketaylr.com/code/input-type-attr.html 841 // spec: www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary 842 843 // Only input placeholder is tested while textarea's placeholder is not. 844 // Currently Safari 4 and Opera 11 have support only for the input placeholder 845 // Both tests are available in feature-detects/forms-placeholder.js 846 Modernizr['input'] = (function (props) { 847 for (var i = 0, len = props.length; i < len; i++) { 848 attrs[props[i]] = !!(props[i] in inputElem); 849 } 850 if (attrs.list) { 851 // safari false positive's on datalist: webk.it/74252 852 // see also github.com/Modernizr/Modernizr/issues/146 853 attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement); 854 } 855 return attrs; 856 })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' ')); 857 /*>>input*/ 858 859 /*>>inputtypes*/ 860 // Run through HTML5's new input types to see if the UA understands any. 861 // This is put behind the tests runloop because it doesn't return a 862 // true/false like all the other tests; instead, it returns an object 863 // containing each input type with its corresponding true/false value 864 865 // Big thanks to @miketaylr for the html5 forms expertise. miketaylr.com/ 866 Modernizr['inputtypes'] = (function (props) { 867 868 for (var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++) { 869 870 inputElem.setAttribute('type', inputElemType = props[i]); 871 bool = inputElem.type !== 'text'; 872 873 // We first check to see if the type we give it sticks.. 874 // If the type does, we feed it a textual value, which shouldn't be valid. 875 // If the value doesn't stick, we know there's input sanitization which infers a custom UI 876 if (bool) { 877 878 inputElem.value = smile; 879 inputElem.style.cssText = 'position:absolute;visibility:hidden;'; 880 881 if (/^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined) { 882 883 docElement.appendChild(inputElem); 884 defaultView = document.defaultView; 885 886 // Safari 2-4 allows the smiley as a value, despite making a slider 887 bool = defaultView.getComputedStyle && 888 defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' && 889 // Mobile android web browser has false positive, so must 890 // check the height to see if the widget is actually there. 891 (inputElem.offsetHeight !== 0); 892 893 docElement.removeChild(inputElem); 894 895 } else if (/^(search|tel)$/.test(inputElemType)) { 896 // Spec doesn't define any special parsing or detectable UI 897 // behaviors so we pass these through as true 898 899 // Interestingly, opera fails the earlier test, so it doesn't 900 // even make it here. 901 902 } else if (/^(url|email)$/.test(inputElemType)) { 903 // Real url and email support comes with prebaked validation. 904 bool = inputElem.checkValidity && inputElem.checkValidity() === false; 905 906 } else { 907 // If the upgraded input compontent rejects the :) text, we got a winner 908 bool = inputElem.value != smile; 909 } 910 } 911 912 inputs[props[i]] = !!bool; 913 } 914 return inputs; 915 })('search tel url email datetime date month week time datetime-local number range color'.split(' ')); 916 /*>>inputtypes*/ 917 } 918 /*>>webforms*/ 919 920 921 // End of test definitions 922 // ----------------------- 923 924 925 926 // Run through all tests and detect their support in the current UA. 927 // todo: hypothetically we could be doing an array of tests and use a basic loop here. 928 for (var feature in tests) { 929 if (hasOwnProp(tests, feature)) { 930 // run the test, throw the return value into the Modernizr, 931 // then based on that boolean, define an appropriate className 932 // and push it into an array of classes we'll join later. 933 featureName = feature.toLowerCase(); 934 Modernizr[featureName] = tests[feature](); 935 936 classes.push((Modernizr[featureName] ? '' : 'no-') + featureName); 937 } 938 } 939 940 /*>>webforms*/ 941 // input tests need to run. 942 Modernizr.input || webforms(); 943 /*>>webforms*/ 944 945 946 /** 947 * addTest allows the user to define their own feature tests 948 * the result will be added onto the Modernizr object, 949 * as well as an appropriate className set on the html element 950 * 951 * @param feature - String naming the feature 952 * @param test - Function returning true if feature is supported, false if not 953 */ 954 Modernizr.addTest = function (feature, test) { 955 if (typeof feature == 'object') { 956 for (var key in feature) { 957 if (hasOwnProp(feature, key)) { 958 Modernizr.addTest(key, feature[key]); 959 } 960 } 961 } else { 962 963 feature = feature.toLowerCase(); 964 965 if (Modernizr[feature] !== undefined) { 966 // we're going to quit if you're trying to overwrite an existing test 967 // if we were to allow it, we'd do this: 968 // var re = new RegExp("\\b(no-)?" + feature + "\\b"); 969 // docElement.className = docElement.className.replace( re, '' ); 970 // but, no rly, stuff 'em. 971 return Modernizr; 972 } 973 974 test = typeof test == 'function' ? test() : test; 975 976 if (typeof enableClasses !== "undefined" && enableClasses) { 977 docElement.className += ' ' + (test ? '' : 'no-') + feature; 978 } 979 Modernizr[feature] = test; 980 981 } 982 983 return Modernizr; // allow chaining. 984 }; 985 986 987 // Reset modElem.cssText to nothing to reduce memory footprint. 988 setCss(''); 989 modElem = inputElem = null; 990 991 /*>>shiv*/ 992 /** 993 * @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 994 */ 995 ; 996 (function (window, document) { 997 /*jshint evil:true */ 998 /** version */ 999 var version = '3.7.0'; 1000 1001 /** Preset options */ 1002 var options = window.html5 || {}; 1003 1004 /** Used to skip problem elements */ 1005 var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; 1006 1007 /** Not all elements can be cloned in IE **/ 1008 var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; 1009 1010 /** Detect whether the browser supports default html5 styles */ 1011 var supportsHtml5Styles; 1012 1013 /** Name of the expando, to work with multiple documents or to re-shiv one document */ 1014 var expando = '_html5shiv'; 1015 1016 /** The id for the the documents expando */ 1017 var expanID = 0; 1018 1019 /** Cached data for each document */ 1020 var expandoData = {}; 1021 1022 /** Detect whether the browser supports unknown elements */ 1023 var supportsUnknownElements; 1024 1025 (function () { 1026 try { 1027 var a = document.createElement('a'); 1028 a.innerHTML = '<xyz></xyz>'; 1029 //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles 1030 supportsHtml5Styles = ('hidden' in a); 1031 1032 supportsUnknownElements = a.childNodes.length == 1 || (function () { 1033 // assign a false positive if unable to shiv 1034 (document.createElement)('a'); 1035 var frag = document.createDocumentFragment(); 1036 return ( 1037 typeof frag.cloneNode == 'undefined' || 1038 typeof frag.createDocumentFragment == 'undefined' || 1039 typeof frag.createElement == 'undefined' 1040 ); 1041 }()); 1042 } catch (e) { 1043 // assign a false positive if detection fails => unable to shiv 1044 supportsHtml5Styles = true; 1045 supportsUnknownElements = true; 1046 } 1047 1048 }()); 1049 1050 /*--------------------------------------------------------------------------*/ 1051 1052 /** 1053 * Creates a style sheet with the given CSS text and adds it to the document. 1054 * @private 1055 * @param {Document} ownerDocument The document. 1056 * @param {String} cssText The CSS text. 1057 * @returns {StyleSheet} The style element. 1058 */ 1059 function addStyleSheet(ownerDocument, cssText) { 1060 var p = ownerDocument.createElement('p'), 1061 parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; 1062 1063 p.innerHTML = 'x<style>' + cssText + '</style>'; 1064 return parent.insertBefore(p.lastChild, parent.firstChild); 1065 } 1066 1067 /** 1068 * Returns the value of `html5.elements` as an array. 1069 * @private 1070 * @returns {Array} An array of shived element node names. 1071 */ 1072 function getElements() { 1073 var elements = html5.elements; 1074 return typeof elements == 'string' ? elements.split(' ') : elements; 1075 } 1076 1077 /** 1078 * Returns the data associated to the given document 1079 * @private 1080 * @param {Document} ownerDocument The document. 1081 * @returns {Object} An object of data. 1082 */ 1083 function getExpandoData(ownerDocument) { 1084 var data = expandoData[ownerDocument[expando]]; 1085 if (!data) { 1086 data = {}; 1087 expanID++; 1088 ownerDocument[expando] = expanID; 1089 expandoData[expanID] = data; 1090 } 1091 return data; 1092 } 1093 1094 /** 1095 * returns a shived element for the given nodeName and document 1096 * @memberOf html5 1097 * @param {String}
vendor: 4,672 bytes, lines 1097-1208
1097 nodeName name of the element 1098 * @param {Document} ownerDocument The context document. 1099 * @returns {Object} The shived element. 1100 */ 1101 function createElement(nodeName, ownerDocument, data) { 1102 if (!ownerDocument) { 1103 ownerDocument = document; 1104 } 1105 if (supportsUnknownElements) { 1106 return ownerDocument.createElement(nodeName); 1107 } 1108 if (!data) { 1109 data = getExpandoData(ownerDocument); 1110 } 1111 var node; 1112 1113 if (data.cache[nodeName]) { 1114 node = data.cache[nodeName].cloneNode(); 1115 } else if (saveClones.test(nodeName)) { 1116 node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); 1117 } else { 1118 node = data.createElem(nodeName); 1119 } 1120 1121 // Avoid adding some elements to fragments in IE < 9 because 1122 // * Attributes like `name` or `type` cannot be set/changed once an element 1123 // is inserted into a document/fragment 1124 // * Link elements with `src` attributes that are inaccessible, as with 1125 // a 403 response, will cause the tab/window to crash 1126 // * Script elements appended to fragments will execute when their `src` 1127 // or `text` property is set 1128 return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; 1129 } 1130 1131 /** 1132 * returns a shived DocumentFragment for the given document 1133 * @memberOf html5 1134 * @param {Document} ownerDocument The context document. 1135 * @returns {Object} The shived DocumentFragment. 1136 */ 1137 function createDocumentFragment(ownerDocument, data) { 1138 if (!ownerDocument) { 1139 ownerDocument = document; 1140 } 1141 if (supportsUnknownElements) { 1142 return ownerDocument.createDocumentFragment(); 1143 } 1144 data = data || getExpandoData(ownerDocument); 1145 var clone = data.frag.cloneNode(), 1146 i = 0, 1147 elems = getElements(), 1148 l = elems.length; 1149 for (; i < l; i++) { 1150 clone.createElement(elems[i]); 1151 } 1152 return clone; 1153 } 1154 1155 /** 1156 * Shivs the `createElement` and `createDocumentFragment` methods of the document. 1157 * @private 1158 * @param {Document|DocumentFragment} ownerDocument The document. 1159 * @param {Object} data of the document. 1160 */ 1161 function shivMethods(ownerDocument, data) { 1162 if (!data.cache) { 1163 data.cache = {}; 1164 data.createElem = ownerDocument.createElement; 1165 data.createFrag = ownerDocument.createDocumentFragment; 1166 data.frag = data.createFrag(); 1167 } 1168 1169 1170 ownerDocument.createElement = function (nodeName) { 1171 //abort shiv 1172 if (!html5.shivMethods) { 1173 return data.createElem(nodeName); 1174 } 1175 return createElement(nodeName, ownerDocument, data); 1176 }; 1177 1178 ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' + 1179 'var n=f.cloneNode(),c=n.createElement;' + 1180 'h.shivMethods&&(' + 1181 // unroll the `createElement` calls 1182 getElements().join().replace(/[\w\-]+/g, function (nodeName) { 1183 data.createElem(nodeName); 1184 data.frag.createElement(nodeName); 1185 return 'c("' + nodeName + '")'; 1186 }) + 1187 ');return n}' 1188 )(html5, data.frag); 1189 } 1190 1191 /*--------------------------------------------------------------------------*/ 1192 1193 /** 1194 * Shivs the given document. 1195 * @memberOf html5 1196 * @param {Document} ownerDocument The document to shiv. 1197 * @returns {Document} The shived document. 1198 */ 1199 function shivDocument(ownerDocument) { 1200 if (!ownerDocument) { 1201 ownerDocument = document; 1202 } 1203 var data = getExpandoData(ownerDocument); 1204 1205 if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) { 1206 data.hasCSS = !!addStyleSheet(ownerDocument, 1207 // corrects block display not defined in IE6/7/8/9 1208 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{dis
1208play:block}' + 1209 // adds styling not present in IE6/7/8/9 1210 'mark{background:#FF0;color:#000}' + 1211 // hides non-rendered elements 1212 'template{display:none}' 1213 ); 1214 } 1215 if (!supportsUnknownElements) { 1216 shivMethods(ownerDocument, data); 1217 } 1218 return ownerDocument; 1219 } 1220 1221 /*--------------------------------------------------------------------------*/ 1222 1223 /** 1224 * The `html5` object is exposed so that more elements can be shived and 1225 * existing shiving can be detected on iframes. 1226 * @type Object 1227 * @example 1228 * 1229 * // options can be changed before the script is included 1230 * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false }; 1231 */ 1232 var html5 = { 1233 /** 1234 * An array or space separated string of node names of the elements to shiv. 1235 * @memberOf html5 1236 * @type Array|String 1237 */ 1238 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video', 1239 /** 1240 * current version of html5shiv 1241 */ 1242 'version': version, 1243 /** 1244 * A flag to indicate that the HTML5 style sheet should be inserted. 1245 * @memberOf html5 1246 * @type Boolean 1247 */ 1248 'shivCSS': (options.shivCSS !== false), 1249 /** 1250 * Is equal to true if a browser supports creating unknown/HTML5 elements 1251 * @memberOf html5 1252 * @type boolean 1253 */ 1254 'supportsUnknownElements': supportsUnknownElements, 1255 /** 1256 * A flag to indicate that the document's `createElement` and `createDocumentFragment` 1257 * methods should be overwritten. 1258 * @memberOf html5 1259 * @type Boolean 1260 */ 1261 'shivMethods': (options.shivMethods !== false), 1262 /** 1263 * A string to describe the type of `html5` object ("default" or "default print"). 1264 * @memberOf html5
1265 * @type String 1266 */ 1267 'type': 'default', 1268 // shivs the document according to the specified `html5` object options 1269 'shivDocument': shivDocument, 1270 //creates a shived element 1271 createElement: createElement, 1272 //creates a shived documentFragment 1273 createDocumentFragment: createDocumentFragment 1274 }; 1275 1276 /*--------------------------------------------------------------------------*/ 1277 1278 // expose html5 1279 window.html5 = html5; 1280 1281 // shiv the document 1282 shivDocument(document); 1283 1284 }(this, document)); 1285 /*>>shiv*/ 1286 1287 // Assign private properties to the return object with prefix 1288 Modernizr._version = version; 1289 1290 // expose these for the plugin API. Look in the source for how to join() them against your input 1291 /*>>prefixes*/ 1292 Modernizr._prefixes = prefixes; 1293 /*>>prefixes*/ 1294 /*>>domprefixes*/ 1295 Modernizr._domPrefixes = domPrefixes; 1296 Modernizr._cssomPrefixes = cssomPrefixes; 1297 /*>>domprefixes*/ 1298 1299 /*>>mq*/ 1300 // Modernizr.mq tests a given media query, live against the current state of the window 1301 // A few important notes: 1302 // * If a browser does not support media queries at all (eg. oldIE) the mq() will always return false 1303 // * A max-width or orientation query will be evaluated against the current state, which may change later. 1304 // * You must specify values. Eg. If you are testing support for the min-width media query use: 1305 // Modernizr.mq('(min-width:0)') 1306 // usage: 1307 // Modernizr.mq('only screen and (max-width:768)') 1308 Modernizr.mq = testMediaQuery; 1309 /*>>mq*/ 1310 1311 /*>>hasevent*/ 1312 // Modernizr.hasEvent() detects support for a given event, with an optional element to test on 1313 // Modernizr.hasEvent('gesturestart', elem) 1314 Modernizr.hasEvent = isEventSupported; 1315 /*>>hasevent*/ 1316 1317 /*>>testprop*/ 1318 // Modernizr.testProp() investigates whether a given style property is recognized 1319 // Note that the property names must be provided in the camelCase variant. 1320 // Modernizr.testProp('pointerEvents') 1321 Modernizr.testProp = function (prop) { 1322 return testProps([prop]); 1323 }; 1324 /*>>testprop*/ 1325 1326 /*>>testallprops*/ 1327 // Modernizr.testAllProps() investigates whether a given style property, 1328 // or any of its vendor-prefixed variants, is recognized 1329 // Note that the property names must be provided in the camelCase variant. 1330 // Modernizr.testAllProps('boxSizing') 1331 Modernizr.testAllProps = testPropsAll; 1332 /*>>testallprops*/ 1333 1334 1335 /*>>teststyles*/ 1336 // Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards 1337 // Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... }) 1338 Modernizr.testStyles = injectElementWithStyles; 1339 /*>>teststyles*/ 1340 1341 1342 /*>>prefixed*/ 1343 // Modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input 1344 // Modernizr.prefixed('boxSizing') // 'MozBoxSizing' 1345 1346 // Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style. 1347 // Return values will also be the camelCase variant, if you need to translate that to hypenated style use: 1348 // 1349 // str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-'); 1350 1351 // If you're trying to ascertain which transition end event to bind to, you might do something like... 1352 // 1353 // var transEndEventNames = { 1354 // 'WebkitTransition' : 'webkitTransitionEnd', 1355 // 'MozTransition' : 'transitionend', 1356 // 'OTransition' : 'oTransitionEnd', 1357 // 'msTransition' : 'MSTransitionEnd', 1358 // 'transition' : 'transitionend' 1359 // }, 1360 // transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ]; 1361 1362 Modernizr.prefixed = function (prop, obj, elem) { 1363 if (!obj) { 1364 return testPropsAll(prop, 'pfx'); 1365 } else { 1366 // Testing DOM property e.g. Modernizr.prefixed('requestAnimationFrame', window) // 'mozRequestAnimationFrame' 1367 return testPropsAll(prop, obj, elem); 1368 } 1369 }; 1370 /*>>prefixed*/ 1371 1372 1373 /*>>cssclasses*/ 1374 // Remove "no-js" class from <html> element, if it exists: 1375 docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') + 1376 // Add the new classes to the <html> element. 1377 (enableClasses ? ' js ' + classes.join(' ') : ''); 1378 /*>>cssclasses*/ 1379 1380 return Modernizr; 1381 1382})(this, this.document); 1383; 1384; 1385(function (root, factory) { 1386 if (typeof define === 'function' && define.amd) { 1387 define(['jquery'], factory); 1388 } else if (typeof exports === 'object') { 1389 module.exports = factory(require('jquery')); 1390 } else { 1391 root.sortable = factory(root.jQuery); 1392 } 1393}(this, function ($) { 1394 /* 1395 * HTML5 Sortable jQuery Plugin 1396 * https://github.com/voidberg/html5sortable 1397 *
1398 * Original code copyright 2012 Ali Farhadi. 1399 * This version is mantained by Alexandru Badiu <[email protected]> & Lukas Oppermann <[email protected]> 1400 * 1401 * 1402 * Released under the MIT license. 1403 */ 1404 'use strict'; 1405 /* 1406 * variables global to the plugin 1407 */ 1408 var dragging; 1409 var draggingHeight; 1410 var placeholders = $(); 1411 var sortables = []; 1412 /* 1413 * remove event handlers from items 1414 * @param [jquery Collection] items 1415 * @info event.h5s (jquery way of namespacing events, to bind multiple handlers to the event) 1416 */ 1417 var _removeItemEvents = function (items) { 1418 items.off('dragstart.h5s'); 1419 items.off('dragend.h5s'); 1420 items.off('selectstart.h5s'); 1421 items.off('dragover.h5s'); 1422 items.off('dragenter.h5s'); 1423 items.off('drop.h5s'); 1424 }; 1425 /* 1426 * remove event handlers from sortable 1427 * @param [jquery Collection] sortable 1428 * @info event.h5s (jquery way of namespacing events, to bind multiple handlers to the event) 1429 */ 1430 var _removeSortableEvents = function (sortable) { 1431 sortable.off('dragover.h5s'); 1432 sortable.off('dragenter.h5s'); 1433 sortable.off('drop.h5s'); 1434 }; 1435 /* 1436 * attache ghost to dataTransfer object 1437 * @param [event] original event 1438 * @param [object] ghost-object with item, x and y coordinates 1439 */ 1440 var _attachGhost = function (event, ghost) { 1441 // this needs to be set for HTML5 drag & drop to work 1442 event.dataTransfer.effectAllowed = 'move'; 1443 event.dataTransfer.setData('text', ''); 1444 1445 // check if setDragImage method is available 1446 if (event.dataTransfer.setDragImage) { 1447 event.dataTransfer.setDragImage(ghost.item, ghost.x, ghost.y); 1448 } 1449 }; 1450 /** 1451 * _addGhostPos clones the dragged item and adds it as a Ghost item 1452 * @param [object] event - the event fired when dragstart is triggered 1453 * @param [object] ghost - .item = node, draggedItem = jQuery collection 1454 */ 1455 var _addGhostPos = function (e, ghost) { 1456 if (!ghost.x) { 1457 ghost.x = parseInt(e.pageX - ghost.draggedItem.offset().left); 1458 } 1459 if (!ghost.y) { 1460 ghost.y = parseInt(e.pageY - ghost.draggedItem.offset().top); 1461 } 1462 return ghost; 1463 }; 1464 /** 1465 * _makeGhost decides which way to make a ghost and passes it to attachGhost 1466 * @param [jQuery selection] $draggedItem - the item that the user drags 1467 */ 1468 var _makeGhost = function ($draggedItem) { 1469 return { 1470 item: $draggedItem[0], 1471 draggedItem: $draggedItem 1472 }; 1473 }; 1474 /** 1475 * _getGhost constructs ghost and attaches it to dataTransfer 1476 * @param [event] event - the original drag event object 1477 * @param [jQuery selection] $draggedItem - the item that the user drags 1478 * @param [object] ghostOpt - the ghost options 1479 */ 1480 // TODO: could $draggedItem be replaced by event.target in all instances 1481 var _getGhost = function (event, $draggedItem) { 1482 // add ghost item & draggedItem to ghost object 1483 var ghost = _makeGhost($draggedItem); 1484 // attach ghost position 1485 ghost = _addGhostPos(event, ghost); 1486 // attach ghost to dataTransfer 1487 _attachGhost(event, ghost); 1488 }; 1489 /* 1490 * return options if not set on sortable already 1491 * @param [object] soptions 1492 * @param [object] options 1493 */ 1494 var _getOptions = function (soptions, options) { 1495 if (typeof soptions === 'undefined') { 1496 return options; 1497 } 1498 return soptions; 1499 }; 1500 /* 1501 * remove data from sortable 1502 * @param [jquery Collection] a single sortable 1503 */ 1504 var _removeSortableData = function (sortable) { 1505 sortable.removeData('opts'); 1506 sortable.removeData('connectWith'); 1507 sortable.removeData('items'); 1508 sortable.removeAttr('aria-dropeffect'); 1509 }; 1510 /* 1511 * remove data from items 1512 * @param [jquery Collection] items 1513 */ 1514 var _removeItemData = function (items) { 1515 items.removeAttr('aria-grabbed'); 1516 items.removeAttr('draggable'); 1517 items.removeAttr('role'); 1518 }; 1519 /* 1520 * check if two lists are connected 1521 * @param [jquery Collection] items 1522 */ 1523 var _listsConnected = function (curList, destList) { 1524 if (curList[0] === destList[0]) { 1525 return true; 1526 } 1527 if (curList.data('connectWith') !== undefined) { 1528 return curList.data('connectWith') === destList.data('connectWith'); 1529 } 1530 return false; 1531 }; 1532 /* 1533 * destroy the sortable 1534 * @param [jquery Collection] a single sortable 1535 */ 1536 var _destroySortable = function (sortable) { 1537 var opts = sortable.data('opts') || {}; 1538 var items = sortable.children(opts.items); 1539 var handles = opts.handle ? items.find(opts.handle) : items; 1540 // remove event handlers & data from sortable 1541 _removeSortableEvents(sortable); 1542 _removeSortableData(sortable); 1543 // remove event handlers & data from items 1544 handles.off('mousedown.h5s'); 1545 _removeItemEvents(items); 1546 _removeItemData(items); 1547 }; 1548 /* 1549 * enable the sortable 1550 * @param [jquery Collection] a single sortable 1551 */ 1552 var _enableSortable = function (sortable) { 1553 var opts = sortable.data('opts'); 1554 var items = sortable.children(opts.items); 1555 var handles = opts.handle ? items.find(opts.handle) : items; 1556 sortable.attr('aria-dropeffect', 'move'); 1557 handles.attr('draggable', 'true'); 1558 // IE FIX for ghost 1559 // can be disabled as it has the side effect that other events 1560 // (e.g. click) will be ignored 1561 var spanEl = (document || window.document).createElement('span'); 1562 if (typeof spanEl.dragDrop === 'function' && !opts.disableIEFix) { 1563 handles.on('mousedown.h5s', function () { 1564 if (items.index(this) !== -1) { 1565 this.dragDrop(); 1566 } else { 1567 $(this).parents(opts.items)[0].dragDrop(); 1568 } 1569 }); 1570 } 1571 }; 1572 /* 1573 * disable the sortable 1574 * @param [jquery Collection] a single sortable 1575 */ 1576 var _disableSortable = function (sortable) { 1577 var opts = sortable.data('opts'); 1578 var items = sortable.children(opts.items); 1579 var handles = opts.handle ? items.find(opts.handle) : items; 1580 sortable.attr('aria-dropeffect', 'none'); 1581 handles.attr('draggable', false); 1582 handles.off('mousedown.h5s'); 1583 }; 1584 /* 1585 * reload the sortable 1586 * @param [jquery Collection] a single sortable
1587 * @description events need to be removed to not be double bound 1588 */ 1589 var _reloadSortable = function (sortable) { 1590 var opts = sortable.data('opts'); 1591 var items = sortable.children(opts.items); 1592 var handles = opts.handle ? items.find(opts.handle) : items; 1593 // remove event handlers from items 1594 _removeItemEvents(items); 1595 handles.off('mousedown.h5s'); 1596 // remove event handlers from sortable 1597 _removeSortableEvents(sortable); 1598 }; 1599 /* 1600 * public sortable object 1601 * @param [object|string] options|method 1602 */ 1603 var sortable = function (selector, options) { 1604 1605 var $sortables = $(selector); 1606 var method = String(options); 1607 1608 options = $.extend({ 1609 connectWith: false, 1610 placeholder: null, 1611 // dragImage can be null or a jQuery element 1612 dragImage: null, 1613 disableIEFix: false, 1614 placeholderClass: 'sortable-placeholder', 1615 draggingClass: 'sortable-dragging', 1616 hoverClass: false 1617 }, options); 1618 1619 /* TODO: maxstatements should be 25, fix and remove line below */ 1620 /*jshint maxstatements:false */ 1621 return $sortables.each(function () { 1622 1623 var $sortable = $(this); 1624 1625 if (/enable|disable|destroy/.test(method)) { 1626 sortable[method]($sortable); 1627 return; 1628 } 1629 1630 // get options & set options on sortable 1631 options = _getOptions($sortable.data('opts'), options); 1632 $sortable.data('opts', options); 1633 // reset sortable 1634 _reloadSortable($sortable); 1635 // initialize 1636 var items = $sortable.children(options.items); 1637 var index; 1638 var startParent; 1639 var newParent; 1640 var placeholder = (options.placeholder === null) ? $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="' + options.placeholderClass + '"/>') : $(options.placeholder).addClass(options.placeholderClass); 1641 1642 // setup sortable ids 1643 if (!$sortable.attr('data-sortable-id')) { 1644 var id = sortables.length; 1645 sortables[id] = $sortable; 1646 $sortable.attr('data-sortable-id', id); 1647 items.attr('data-item-sortable-id', id); 1648 } 1649 1650 $sortable.data('items', options.items); 1651 placeholders = placeholders.add(placeholder); 1652 if (options.connectWith) { 1653 $sortable.data('connectWith', options.connectWith); 1654 } 1655 1656 _enableSortable($sortable); 1657 items.attr('role', 'option'); 1658 items.attr('aria-grabbed', 'false'); 1659 1660 // Mouse over class 1661 if (options.hoverClass) { 1662 var hoverClass = 'sortable-over'; 1663 if (typeof options.hoverClass === 'string') { 1664 hoverClass = options.hoverClass; 1665 } 1666 1667 items.hover(function () { 1668 $(this).addClass(hoverClass); 1669 }, function () { 1670 $(this).removeClass(hoverClass); 1671 }); 1672 } 1673 1674 // Handle drag events on draggable items 1675 items.on('dragstart.h5s', function (e) { 1676 e.stopImmediatePropagation(); 1677 1678 if (options.dragImage) { 1679 _attachGhost(e.originalEvent, { 1680 item: options.dragImage, 1681 x: 0, 1682 y: 0 1683 }); 1684 console.log('WARNING: dragImage option is deprecated' + 1685 ' and will be removed in the future!'); 1686 } else { 1687 // add transparent clone or other ghost to cursor 1688 _getGhost(e.originalEvent, $(this), options.dragImage); 1689 } 1690 // cache selsection & add attr for dragging 1691 dragging = $(this); 1692 dragging.addClass(options.draggingClass); 1693 dragging.attr('aria-grabbed', 'true'); 1694 // grab values 1695 index = dragging.index(); 1696 draggingHeight = dragging.height(); 1697 startParent = $(this).parent(); 1698 // trigger sortstar update 1699 dragging.parent().triggerHandler('sortstart', { 1700 item: dragging, 1701 placeholder: placeholder, 1702 startparent: startParent 1703 }); 1704 }); 1705 // Handle drag events on draggable items 1706 items.on('dragend.h5s', function () { 1707 if (!dragging) { 1708 return; 1709 } 1710 // remove dragging attributes and show item 1711 dragging.removeClass(options.draggingClass); 1712 dragging.attr('aria-grabbed', 'false'); 1713 dragging.show(); 1714 1715 placeholders.detach(); 1716 newParent = $(this).parent(); 1717 dragging.parent().triggerHandler('sortstop', { 1718 item: dragging, 1719 startparent: startParent, 1720 }); 1721 if (index !== dragging.index() || 1722 startParent.get(0) !== newParent.get(0)) { 1723 dragging.parent().triggerHandler('sortupdate', { 1724 item: dragging, 1725 index: newParent.children(newParent.data('items')).index(dragging), 1726 oldindex: items.index(dragging), 1727 elementIndex: dragging.index(), 1728 oldElementIndex: index, 1729 startparent: startParent, 1730 endparent: newParent 1731 }); 1732 } 1733 dragging = null; 1734 draggingHeight = null; 1735 }); 1736 // Handle drop event on sortable & placeholder 1737 // TODO: REMOVE placeholder????? 1738 $(this).add([placeholder]).on('drop.h5s', function (e) { 1739 if (!_listsConnected($sortable, $(dragging).parent())) { 1740 return; 1741 } 1742 1743 e.stopPropagation(); 1744 placeholders.filter(':visible').after(dragging); 1745 dragging.trigger('dragend.h5s'); 1746 return false; 1747 }); 1748 1749 // Handle dragover and dragenter events on draggable items 1750 items.add([this]).on('dragover.h5s dragenter.h5s', function (e) { 1751 if (!_listsConnected($sortable, $(dragging).parent())) { 1752 return; 1753 } 1754 1755 e.preventDefault(); 1756 e.originalEvent.dataTransfer.dropEffect = 'move'; 1757 if (items.is(this)) { 1758 var thisHeight = $(this).height(); 1759 if (options.forcePlaceholderSize) { 1760 placeholder.height(draggingHeight); 1761 } 1762 1763 // Check if $(this) is bigger than the draggable. If it is, we have to define a dead zone to prevent flickering 1764 if (thisHeight > draggingHeight) { 1765 // Dead zone? 1766 var deadZone = thisHeight - draggingHeight; 1767 var offsetTop = $(this).offset().top; 1768 if (placeholder.index() < $(this).index() && 1769 e.originalEvent.pageY < offsetTop + deadZone) { 1770 return false; 1771 } 1772 if (placeholder.index() > $(this).index() && 1773 e.originalEvent.pageY > offsetTop + thisHeight - deadZone) { 1774 return false; 1775 } 1776 } 1777 1778 dragging.hide(); 1779 if (placeholder.index() < $(this).index()) { 1780 $(this).after(placeholder); 1781 } else { 1782 $(this).before(placeholder); 1783 } 1784 placeholders.not(placeholder).detach(); 1785 } else { 1786 if (!placeholders.is(this) && !$(this).children(options.items).length) { 1787 placeholders.detach(); 1788 $(this).append(placeholder); 1789 } 1790 } 1791 return false; 1792 }); 1793 }); 1794 }; 1795 1796 sortable.destroy = function (sortable) { 1797 _destroySortable(sortable); 1798 }; 1799 1800 sortable.enable = function (sortable) { 1801 _enableSortable(sortable); 1802 }; 1803 1804 sortable.disable = function (sortable) { 1805 _disableSortable(sortable); 1806 }; 1807 1808 $.fn.sortable = function (options) { 1809 return sortable(this, options); 1810 }; 1811 1812 return sortable; 1813})); 1814; 1815if (typeof jQuery === 'undefined') { 1816 throw new Error('Bootstrap\'s JavaScript requires jQuery') 1817} 1818 1819/* ======================================================================== 1820 * Bootstrap: transition.js v3.2.0 1821 * http://getbootstrap.com/javascript/#transitions 1822 * ======================================================================== 1823 * Copyright 2011-2014 Twitter, Inc. 1824 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 1825 * ======================================================================== */ 1826 1827 1828+function ($) { 1829 'use strict'; 1830
vendor: 5,256 bytes, lines 1831-2015
1831 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 1832 // ============================================================ 1833 1834 function transitionEnd() { 1835 var el = document.createElement('bootstrap') 1836 1837 var transEndEventNames = { 1838 WebkitTransition: 'webkitTransitionEnd', 1839 MozTransition: 'transitionend', 1840 OTransition: 'oTransitionEnd otransitionend', 1841 transition: 'transitionend' 1842 } 1843 1844 for (var name in transEndEventNames) { 1845 if (el.style[name] !== undefined) { 1846 return { end: transEndEventNames[name] } 1847 } 1848 } 1849 1850 return false // explicit for ie8 ( ._.) 1851 } 1852 1853 // http://blog.alexmaccaw.com/css-transitions 1854 $.fn.emulateTransitionEnd = function (duration) { 1855 var called = false 1856 var $el = this 1857 $(this).one('bsTransitionEnd', function () { 1858 called = true 1859 }) 1860 var callback = function () { 1861 if (!called) 1862 $($el).trigger($.support.transition.end) 1863 } 1864 setTimeout(callback, duration) 1865 return this 1866 } 1867 1868 $(function () { 1869 $.support.transition = transitionEnd() 1870 1871 if (!$.support.transition) 1872 return 1873 1874 $.event.special.bsTransitionEnd = { 1875 bindType: $.support.transition.end, 1876 delegateType: $.support.transition.end, 1877 handle: function (e) { 1878 if ($(e.target).is(this)) 1879 return e.handleObj.handler.apply(this, arguments) 1880 } 1881 } 1882 }) 1883 1884}(jQuery); 1885 1886/* ======================================================================== 1887 * Bootstrap: alert.js v3.2.0 1888 * http://getbootstrap.com/javascript/#alerts 1889 * ======================================================================== 1890 * Copyright 2011-2014 Twitter, Inc. 1891 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 1892 * ======================================================================== */ 1893 1894 1895+function ($) { 1896 'use strict'; 1897 1898 // ALERT CLASS DEFINITION 1899 // ====================== 1900 1901 var dismiss = '[data-dismiss="alert"]' 1902 var Alert = function (el) { 1903 $(el).on('click', dismiss, this.close) 1904 } 1905 1906 Alert.VERSION = '3.2.0' 1907 1908 Alert.prototype.close = function (e) { 1909 var $this = $(this) 1910 var selector = $this.attr('data-target') 1911 1912 if (!selector) { 1913 selector = $this.attr('href') 1914 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 1915 } 1916 1917 var $parent = $(selector) 1918 1919 if (e) 1920 e.preventDefault() 1921 1922 if (!$parent.length) { 1923 $parent = $this.hasClass('alert') ? $this : $this.parent() 1924 } 1925 1926 $parent.trigger(e = $.Event('close.bs.alert')) 1927 1928 if (e.isDefaultPrevented()) 1929 return 1930 1931 $parent.removeClass('in') 1932 1933 function removeElement() { 1934 // detach from parent, fire event then clean up data 1935 $parent.detach().trigger('closed.bs.alert').remove() 1936 } 1937 1938 $.support.transition && $parent.hasClass('fade') ? 1939 $parent 1940 .one('bsTransitionEnd', removeElement) 1941 .emulateTransitionEnd(150) : 1942 removeElement() 1943 } 1944 1945 1946 // ALERT PLUGIN DEFINITION 1947 // ======================= 1948 1949 function Plugin(option) { 1950 return this.each(function () { 1951 var $this = $(this) 1952 var data = $this.data('bs.alert') 1953 1954 if (!data) 1955 $this.data('bs.alert', (data = new Alert(this))) 1956 if (typeof option == 'string') 1957 data[option].call($this) 1958 }) 1959 } 1960 1961 var old = $.fn.alert 1962 1963 $.fn.alert = Plugin 1964 $.fn.alert.Constructor = Alert 1965 1966 1967 // ALERT NO CONFLICT 1968 // ================= 1969 1970 $.fn.alert.noConflict = function () { 1971 $.fn.alert = old 1972 return this 1973 } 1974 1975 1976 // ALERT DATA-API 1977 // ============== 1978 1979 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 1980 1981}(jQuery); 1982 1983/* ======================================================================== 1984 * Bootstrap: button.js v3.2.0 1985 * http://getbootstrap.com/javascript/#buttons 1986 * ======================================================================== 1987 * Copyright 2011-2014 Twitter, Inc. 1988 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 1989 * ======================================================================== */ 1990 1991 1992+function ($) { 1993 'use strict'; 1994 1995 // BUTTON PUBLIC CLASS DEFINITION 1996 // ============================== 1997 1998 var Button = function (element, options) { 1999 this.$element = $(element) 2000 this.options = $.extend({}, Button.DEFAULTS, options) 2001 this.isLoading = false 2002 } 2003 2004 Button.VERSION = '3.2.0' 2005 2006 Button.DEFAULTS = { 2007 loadingText: 'loading...' 2008 } 2009 2010 Button.prototype.setState = function (state) { 2011 var d = 'disabled' 2012 var $el = this.$element 2013 var val = $el.is('input') ? 'val' : 'html' 2014 var data = $el.data() 2015
2016 state = state + 'Text' 2017 2018 if (data.resetText == null) 2019 $el.data('resetText', $el[val]()) 2020 2021 $el[val](data[state] == null ? this.options[state] : data[state]) 2022 2023 // push to event loop to allow forms to submit 2024 setTimeout($.proxy(function () { 2025 if (state == 'loadingText') { 2026 this.isLoading = true 2027 $el.addClass(d).attr(d, d) 2028 } else if (this.isLoading) { 2029 this.isLoading = false 2030 $el.removeClass(d).removeAttr(d) 2031 } 2032 }, this), 0) 2033 } 2034 2035 Button.prototype.toggle = function () { 2036 var changed = true 2037 var $parent = this.$element.closest('[data-toggle="buttons"]') 2038 2039 if ($parent.length) { 2040 var $input = this.$element.find('input') 2041 if ($input.prop('type') == 'radio') { 2042 if ($input.prop('checked') && this.$element.hasClass('active')) 2043 changed = false 2044 else 2045 $parent.find('.active').removeClass('active') 2046 } 2047 if (changed) 2048 $input.prop('checked', !this.$element.hasClass('active')).trigger('change') 2049 } 2050 2051 if (changed) 2052 this.$element.toggleClass('active') 2053 } 2054 2055 2056 // BUTTON PLUGIN DEFINITION 2057 // ======================== 2058 2059 function Plugin(option) { 2060 return this.each(function () { 2061 var $this = $(this) 2062 var data = $this.data('bs.button') 2063 var options = typeof option == 'object' && option 2064 2065 if (!data) 2066 $this.data('bs.button', (data = new Button(this, options))) 2067 2068 if (option == 'toggle') 2069 data.toggle() 2070 else if (option) 2071 data.setState(option) 2072 }) 2073 } 2074 2075 var old = $.fn.button 2076 2077 $.fn.button = Plugin 2078 $.fn.button.Constructor = Button 2079 2080 2081 // BUTTON NO CONFLICT 2082 // ================== 2083 2084 $.fn.button.noConflict = function () { 2085 $.fn.button = old 2086 return this 2087 } 2088 2089 2090 // BUTTON DATA-API 2091 // =============== 2092 2093 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 2094 var $btn = $(e.target) 2095 if (!$btn.hasClass('btn')) 2096 $btn = $btn.closest('.btn') 2097 Plugin.call($btn, 'toggle') 2098 e.preventDefault() 2099 }) 2100 2101}(jQuery); 2102 2103/* ======================================================================== 2104 * Bootstrap: carousel.js v3.2.0 2105 * http://getbootstrap.com/javascript/#carousel 2106 * ======================================================================== 2107 * Copyright 2011-2014 Twitter, Inc. 2108 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 2109 * ======================================================================== */ 2110 2111 2112+function ($) { 2113 'use strict'; 2114 2115 // CAROUSEL CLASS DEFINITION 2116 // ========================= 2117 2118 var Carousel = function (element, options) { 2119 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this)) 2120 this.$indicators = this.$element.find('.carousel-indicators') 2121 this.options = options 2122 this.paused = 2123 this.sliding = 2124 this.interval = 2125 this.$active = 2126 this.$items = null 2127 2128 this.options.pause == 'hover' && this.$element 2129 .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) 2130 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) 2131 } 2132 2133 Carousel.VERSION = '3.2.0' 2134 2135 Carousel.DEFAULTS = { 2136 interval: 5000, 2137 pause: 'hover', 2138 wrap: true 2139 } 2140 2141 Carousel.prototype.keydown = function (e) { 2142 switch (e.which) { 2143 case 37: 2144 this.prev(); 2145 break 2146 case 39: 2147 this.next(); 2148 break 2149 default: 2150 return 2151 } 2152 2153 e.preventDefault() 2154 } 2155 2156 Carousel.prototype.cycle = function (e) { 2157 e || (this.paused = false) 2158 2159 this.interval && clearInterval(this.interval) 2160 2161 this.options.interval 2162 && !this.paused 2163 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) 2164 2165 return this 2166 } 2167 2168 Carousel.prototype.getItemIndex = function (item) { 2169 this.$items = item.parent().children('.item') 2170 return this.$items.index(item || this.$active) 2171 } 2172 2173 Carousel.prototype.to = function (pos) { 2174 var that = this 2175 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) 2176 2177 if (pos > (this.$items.length - 1) || pos < 0) 2178 return 2179 2180 if (this.sliding) 2181 return this.$element.one('slid.bs.carousel', function () { 2182 that.to(pos) 2183 }) // yes, "slid" 2184 if (activeIndex == pos) 2185 return this.pause().cycle() 2186 2187 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) 2188 } 2189 2190 Carousel.prototype.pause = function (e) { 2191 e || (this.paused = true) 2192 2193 if (this.$element.find('.next, .prev').length && $.support.transition) { 2194 this.$element.trigger($.support.transition.end) 2195 this.cycle(true) 2196 } 2197 2198 this.interval = clearInterval(this.interval) 2199 2200 return this 2201 } 2202 2203 Carousel.prototype.next = function () { 2204 if (this.sliding) 2205 return 2206 return this.slide('next') 2207 } 2208 2209 Carousel.prototype.prev = function () { 2210 if (this.sliding) 2211 return 2212 return this.slide('prev') 2213 } 2214 2215 Carousel.prototype.slide = function (type, next) { 2216 var $active = this.$element.find('.item.active') 2217 var $next = next || $active[type]() 2218 var isCycling = this.interval 2219 var direction = type == 'next' ? 'left' : 'right' 2220 var fallback = type == 'next' ? 'first' : 'last' 2221 var that = this 2222 2223 if (!$next.length) { 2224 if (!this.options.wrap) 2225 return 2226 $next = this.$element.find('.item')[fallback]() 2227 } 2228 2229 if ($next.hasClass('active')) 2230 return (this.sliding = false) 2231 2232 var relatedTarget = $next[0] 2233 var slideEvent = $.Event('slide.bs.carousel', { 2234 relatedTarget: relatedTarget, 2235 direction: direction 2236 }) 2237 this.$element.trigger(slideEvent) 2238 if (slideEvent.isDefaultPrevented()) 2239 return 2240 2241 this.sliding = true 2242 2243 isCycling && this.pause() 2244 2245 if (this.$indicators.length) { 2246 this.$indicators.find('.active').removeClass('active') 2247 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) 2248 $nextIndicator && $nextIndicator.addClass('active') 2249 } 2250 2251 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
vendor: 28,427 bytes, lines 2252-3155
2252 if ($.support.transition && this.$element.hasClass('slide')) { 2253 $next.addClass(type) 2254 $next[0].offsetWidth // force reflow 2255 $active.addClass(direction) 2256 $next.addClass(direction) 2257 $active 2258 .one('bsTransitionEnd', function () { 2259 $next.removeClass([type, direction].join(' ')).addClass('active') 2260 $active.removeClass(['active', direction].join(' ')) 2261 that.sliding = false 2262 setTimeout(function () { 2263 that.$element.trigger(slidEvent) 2264 }, 0) 2265 }) 2266 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) 2267 } else { 2268 $active.removeClass('active') 2269 $next.addClass('active') 2270 this.sliding = false 2271 this.$element.trigger(slidEvent) 2272 } 2273 2274 isCycling && this.cycle() 2275 2276 return this 2277 } 2278 2279 2280 // CAROUSEL PLUGIN DEFINITION 2281 // ========================== 2282 2283 function Plugin(option) { 2284 return this.each(function () { 2285 var $this = $(this) 2286 var data = $this.data('bs.carousel') 2287 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) 2288 var action = typeof option == 'string' ? option : options.slide 2289 2290 if (!data) 2291 $this.data('bs.carousel', (data = new Carousel(this, options))) 2292 if (typeof option == 'number') 2293 data.to(option) 2294 else if (action) 2295 data[action]() 2296 else if (options.interval) 2297 data.pause().cycle() 2298 }) 2299 } 2300 2301 var old = $.fn.carousel 2302 2303 $.fn.carousel = Plugin 2304 $.fn.carousel.Constructor = Carousel 2305 2306 2307 // CAROUSEL NO CONFLICT 2308 // ==================== 2309 2310 $.fn.carousel.noConflict = function () { 2311 $.fn.carousel = old 2312 return this 2313 } 2314 2315 2316 // CAROUSEL DATA-API 2317 // ================= 2318 2319 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { 2320 var href 2321 var $this = $(this) 2322 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 2323 if (!$target.hasClass('carousel')) 2324 return 2325 var options = $.extend({}, $target.data(), $this.data()) 2326 var slideIndex = $this.attr('data-slide-to') 2327 if (slideIndex) 2328 options.interval = false 2329 2330 Plugin.call($target, options) 2331 2332 if (slideIndex) { 2333 $target.data('bs.carousel').to(slideIndex) 2334 } 2335 2336 e.preventDefault() 2337 }) 2338 2339 $(window).on('load', function () { 2340 $('[data-ride="carousel"]').each(function () { 2341 var $carousel = $(this) 2342 Plugin.call($carousel, $carousel.data()) 2343 }) 2344 }) 2345 2346}(jQuery); 2347 2348/* ======================================================================== 2349 * Bootstrap: collapse.js v3.2.0 2350 * http://getbootstrap.com/javascript/#collapse 2351 * ======================================================================== 2352 * Copyright 2011-2014 Twitter, Inc. 2353 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 2354 * ======================================================================== */ 2355 2356 2357+function ($) { 2358 'use strict'; 2359 2360 // COLLAPSE PUBLIC CLASS DEFINITION 2361 // ================================ 2362 2363 var Collapse = function (element, options) { 2364 this.$element = $(element) 2365 this.options = $.extend({}, Collapse.DEFAULTS, options) 2366 this.transitioning = null 2367 2368 if (this.options.parent) 2369 this.$parent = $(this.options.parent) 2370 if (this.options.toggle) 2371 this.toggle() 2372 } 2373 2374 Collapse.VERSION = '3.2.0' 2375 2376 Collapse.DEFAULTS = { 2377 toggle: true 2378 } 2379 2380 Collapse.prototype.dimension = function () { 2381 var hasWidth = this.$element.hasClass('width') 2382 return hasWidth ? 'width' : 'height' 2383 } 2384 2385 Collapse.prototype.show = function () { 2386 if (this.transitioning || this.$element.hasClass('in')) 2387 return 2388 2389 var startEvent = $.Event('show.bs.collapse') 2390 this.$element.trigger(startEvent) 2391 if (startEvent.isDefaultPrevented()) 2392 return 2393 2394 var actives = this.$parent && this.$parent.find('> .panel > .in') 2395 2396 if (actives && actives.length) { 2397 var hasData = actives.data('bs.collapse') 2398 if (hasData && hasData.transitioning) 2399 return 2400 Plugin.call(actives, 'hide') 2401 hasData || actives.data('bs.collapse', null) 2402 } 2403 2404 var dimension = this.dimension() 2405 2406 this.$element 2407 .removeClass('collapse') 2408 .addClass('collapsing')[dimension](0) 2409 2410 this.transitioning = 1 2411 2412 var complete = function () { 2413 this.$element 2414 .removeClass('collapsing') 2415 .addClass('collapse in')[dimension]('') 2416 this.transitioning = 0 2417 this.$element 2418 .trigger('shown.bs.collapse') 2419 } 2420 2421 if (!$.support.transition) 2422 return complete.call(this) 2423 2424 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 2425 2426 this.$element 2427 .one('bsTransitionEnd', $.proxy(complete, this)) 2428 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize]) 2429 } 2430 2431 Collapse.prototype.hide = function () { 2432 if (this.transitioning || !this.$element.hasClass('in')) 2433 return 2434 2435 var startEvent = $.Event('hide.bs.collapse') 2436 this.$element.trigger(startEvent) 2437 if (startEvent.isDefaultPrevented()) 2438 return 2439 2440 var dimension = this.dimension() 2441 2442 this.$element[dimension](this.$element[dimension]())[0].offsetHeight 2443 2444 this.$element 2445 .addClass('collapsing') 2446 .removeClass('collapse') 2447 .removeClass('in') 2448 2449 this.transitioning = 1 2450 2451 var complete = function () { 2452 this.transitioning = 0 2453 this.$element 2454 .trigger('hidden.bs.collapse') 2455 .removeClass('collapsing') 2456 .addClass('collapse') 2457 } 2458 2459 if (!$.support.transition) 2460 return complete.call(this) 2461 2462 this.$element 2463 [dimension](0) 2464 .one('bsTransitionEnd', $.proxy(complete, this)) 2465 .emulateTransitionEnd(350) 2466 } 2467 2468 Collapse.prototype.toggle = function () { 2469 this[this.$element.hasClass('in') ? 'hide' : 'show']() 2470 } 2471 2472 2473 // COLLAPSE PLUGIN DEFINITION 2474 // ========================== 2475 2476 function Plugin(option) { 2477 return this.each(function () { 2478 var $this = $(this) 2479 var data = $this.data('bs.collapse') 2480 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 2481 2482 if (!data && options.toggle && option == 'show') 2483 option = !option 2484 if (!data) 2485 $this.data('bs.collapse', (data = new Collapse(this, options))) 2486 if (typeof option == 'string') 2487 data[option]() 2488 }) 2489 } 2490 2491 var old = $.fn.collapse 2492 2493 $.fn.collapse = Plugin 2494 $.fn.collapse.Constructor = Collapse 2495 2496 2497 // COLLAPSE NO CONFLICT 2498 // ==================== 2499 2500 $.fn.collapse.noConflict = function () { 2501 $.fn.collapse = old 2502 return this 2503 } 2504 2505 2506 // COLLAPSE DATA-API 2507 // ================= 2508 2509 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { 2510 var href 2511 var $this = $(this) 2512 var target = $this.attr('data-target') 2513 || e.preventDefault() 2514 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 2515 var $target = $(target) 2516 var data = $target.data('bs.collapse') 2517 var option = data ? 'toggle' : $this.data() 2518 var parent = $this.attr('data-parent') 2519 var $parent = parent && $(parent) 2520 2521 if (!data || !data.transitioning) { 2522 if ($parent) 2523 $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed') 2524 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') 2525 } 2526 2527 Plugin.call($target, option) 2528 }) 2529 2530}(jQuery); 2531 2532/* ======================================================================== 2533 * Bootstrap: dropdown.js v3.2.0 2534 * http://getbootstrap.com/javascript/#dropdowns 2535 * ======================================================================== 2536 * Copyright 2011-2014 Twitter, Inc. 2537 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 2538 * ======================================================================== */ 2539 2540 2541+function ($) { 2542 'use strict'; 2543 2544 // DROPDOWN CLASS DEFINITION 2545 // ========================= 2546 2547 var backdrop = '.dropdown-backdrop' 2548 var toggle = '[data-toggle="dropdown"]' 2549 var Dropdown = function (element) { 2550 $(element).on('click.bs.dropdown', this.toggle) 2551 } 2552 2553 Dropdown.VERSION = '3.2.0' 2554 2555 Dropdown.prototype.toggle = function (e) { 2556 var $this = $(this) 2557 2558 if ($this.is('.disabled, :disabled')) 2559 return 2560 2561 var $parent = getParent($this) 2562 var isActive = $parent.hasClass('open') 2563 2564 clearMenus() 2565 2566 if (!isActive) { 2567 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 2568 // if mobile we use a backdrop because click events don't delegate 2569 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) 2570 } 2571 2572 var relatedTarget = { relatedTarget: this } 2573 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) 2574 2575 if (e.isDefaultPrevented()) 2576 return 2577 2578 $this.trigger('focus') 2579 2580 $parent 2581 .toggleClass('open') 2582 .trigger('shown.bs.dropdown', relatedTarget) 2583 } 2584 2585 return false 2586 } 2587 2588 Dropdown.prototype.keydown = function (e) { 2589 if (!/(38|40|27)/.test(e.keyCode)) 2590 return 2591 2592 var $this = $(this) 2593 2594 e.preventDefault() 2595 e.stopPropagation() 2596 2597 if ($this.is('.disabled, :disabled')) 2598 return 2599 2600 var $parent = getParent($this) 2601 var isActive = $parent.hasClass('open') 2602 2603 if (!isActive || (isActive && e.keyCode == 27)) { 2604 if (e.which == 27) 2605 $parent.find(toggle).trigger('focus') 2606 return $this.trigger('click') 2607 } 2608 2609 var desc = ' li:not(.divider):visible a' 2610 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc) 2611 2612 if (!$items.length) 2613 return 2614 2615 var index = $items.index($items.filter(':focus')) 2616 2617 if (e.keyCode == 38 && index > 0) 2618 index-- // up 2619 if (e.keyCode == 40 && index < $items.length - 1) 2620 index++ // down 2621 if (!~index) 2622 index = 0 2623 2624 $items.eq(index).trigger('focus') 2625 } 2626 2627 function clearMenus(e) { 2628 if (e && e.which === 3) 2629 return 2630 $(backdrop).remove() 2631 $(toggle).each(function () { 2632 var $parent = getParent($(this)) 2633 var relatedTarget = { relatedTarget: this } 2634 if (!$parent.hasClass('open')) 2635 return 2636 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) 2637 if (e.isDefaultPrevented()) 2638 return 2639 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) 2640 }) 2641 } 2642 2643 function getParent($this) { 2644 var selector = $this.attr('data-target') 2645 2646 if (!selector) { 2647 selector = $this.attr('href') 2648 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 2649 } 2650 2651 var $parent = selector && $(selector) 2652 2653 return $parent && $parent.length ? $parent : $this.parent() 2654 } 2655 2656 2657 // DROPDOWN PLUGIN DEFINITION 2658 // ========================== 2659 2660 function Plugin(option) { 2661 return this.each(function () { 2662 var $this = $(this) 2663 var data = $this.data('bs.dropdown') 2664 2665 if (!data) 2666 $this.data('bs.dropdown', (data = new Dropdown(this))) 2667 if (typeof option == 'string') 2668 data[option].call($this) 2669 }) 2670 } 2671 2672 var old = $.fn.dropdown 2673 2674 $.fn.dropdown = Plugin 2675 $.fn.dropdown.Constructor = Dropdown 2676 2677 2678 // DROPDOWN NO CONFLICT 2679 // ==================== 2680 2681 $.fn.dropdown.noConflict = function () { 2682 $.fn.dropdown = old 2683 return this 2684 } 2685 2686 2687 // APPLY TO STANDARD DROPDOWN ELEMENTS 2688 // =================================== 2689 2690 $(document) 2691 .on('click.bs.dropdown.data-api', clearMenus) 2692 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { 2693 e.stopPropagation() 2694 }) 2695 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) 2696 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown) 2697 2698}(jQuery); 2699 2700/* ======================================================================== 2701 * Bootstrap: modal.js v3.2.0 2702 * http://getbootstrap.com/javascript/#modals 2703 * ======================================================================== 2704 * Copyright 2011-2014 Twitter, Inc. 2705 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 2706 * ======================================================================== */ 2707 2708 2709+function ($) { 2710 'use strict'; 2711 2712 // MODAL CLASS DEFINITION 2713 // ====================== 2714 2715 var Modal = function (element, options) { 2716 this.options = options 2717 this.$body = $(document.body) 2718 this.$element = $(element) 2719 this.$backdrop = 2720 this.isShown = null 2721 this.scrollbarWidth = 0 2722 2723 if (this.options.remote) { 2724 this.$element 2725 .find('.modal-content') 2726 .load(this.options.remote, $.proxy(function () { 2727 this.$element.trigger('loaded.bs.modal') 2728 }, this)) 2729 } 2730 } 2731 2732 Modal.VERSION = '3.2.0' 2733 2734 Modal.DEFAULTS = { 2735 backdrop: true, 2736 keyboard: true, 2737 show: true 2738 } 2739 2740 Modal.prototype.toggle = function (_relatedTarget) { 2741 return this.isShown ? this.hide() : this.show(_relatedTarget) 2742 } 2743 2744 Modal.prototype.show = function (_relatedTarget) { 2745 var that = this 2746 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 2747 2748 this.$element.trigger(e) 2749 2750 if (this.isShown || e.isDefaultPrevented()) 2751 return 2752 2753 this.isShown = true 2754 2755 this.checkScrollbar() 2756 this.$body.addClass('modal-open') 2757 2758 this.setScrollbar() 2759 this.escape() 2760 2761 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 2762 2763 this.backdrop(function () { 2764 var transition = $.support.transition && that.$element.hasClass('fade') 2765 2766 if (!that.$element.parent().length) { 2767 that.$element.appendTo(that.$body) // don't move modals dom position 2768 } 2769 2770 that.$element 2771 .show() 2772 .scrollTop(0) 2773 2774 if (transition) { 2775 that.$element[0].offsetWidth // force reflow 2776 } 2777 2778 that.$element 2779 .addClass('in') 2780 .attr('aria-hidden', false) 2781 2782 that.enforceFocus() 2783 2784 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 2785 2786 transition ? 2787 that.$element.find('.modal-dialog') // wait for modal to slide in 2788 .one('bsTransitionEnd', function () { 2789 that.$element.trigger('focus').trigger(e) 2790 }) 2791 .emulateTransitionEnd(300) : 2792 that.$element.trigger('focus').trigger(e) 2793 }) 2794 } 2795 2796 Modal.prototype.hide = function (e) { 2797 if (e) 2798 e.preventDefault() 2799 2800 e = $.Event('hide.bs.modal') 2801 2802 this.$element.trigger(e) 2803 2804 if (!this.isShown || e.isDefaultPrevented()) 2805 return 2806 2807 this.isShown = false 2808 2809 this.$body.removeClass('modal-open') 2810 2811 this.resetScrollbar() 2812 this.escape() 2813 2814 $(document).off('focusin.bs.modal') 2815 2816 this.$element 2817 .removeClass('in') 2818 .attr('aria-hidden', true) 2819 .off('click.dismiss.bs.modal') 2820 2821 $.support.transition && this.$element.hasClass('fade') ? 2822 this.$element 2823 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 2824 .emulateTransitionEnd(300) : 2825 this.hideModal() 2826 } 2827 2828 Modal.prototype.enforceFocus = function () { 2829 $(document) 2830 .off('focusin.bs.modal') // guard against infinite focus loop 2831 .on('focusin.bs.modal', $.proxy(function (e) { 2832 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { 2833 this.$element.trigger('focus') 2834 } 2835 }, this)) 2836 } 2837 2838 Modal.prototype.escape = function () { 2839 if (this.isShown && this.options.keyboard) { 2840 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { 2841 e.which == 27 && this.hide() 2842 }, this)) 2843 } else if (!this.isShown) { 2844 this.$element.off('keyup.dismiss.bs.modal') 2845 } 2846 } 2847 2848 Modal.prototype.hideModal = function () { 2849 var that = this 2850 this.$element.hide() 2851 this.backdrop(function () { 2852 that.$element.trigger('hidden.bs.modal') 2853 }) 2854 } 2855 2856 Modal.prototype.removeBackdrop = function () { 2857 this.$backdrop && this.$backdrop.remove() 2858 this.$backdrop = null 2859 } 2860 2861 Modal.prototype.backdrop = function (callback) { 2862 var that = this 2863 var animate = this.$element.hasClass('fade') ? 'fade' : '' 2864 2865 if (this.isShown && this.options.backdrop) { 2866 var doAnimate = $.support.transition && animate 2867 2868 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') 2869 .appendTo(this.$body) 2870 2871 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 2872 if (e.target !== e.currentTarget) 2873 return 2874 this.options.backdrop == 'static' 2875 ? this.$element[0].focus.call(this.$element[0]) 2876 : this.hide.call(this) 2877 }, this)) 2878 2879 if (doAnimate) 2880 this.$backdrop[0].offsetWidth // force reflow 2881 2882 this.$backdrop.addClass('in') 2883 2884 if (!callback) 2885 return 2886 2887 doAnimate ? 2888 this.$backdrop 2889 .one('bsTransitionEnd', callback) 2890 .emulateTransitionEnd(150) : 2891 callback() 2892 2893 } else if (!this.isShown && this.$backdrop) { 2894 this.$backdrop.removeClass('in') 2895 2896 var callbackRemove = function () { 2897 that.removeBackdrop() 2898 callback && callback() 2899 } 2900 $.support.transition && this.$element.hasClass('fade') ? 2901 this.$backdrop 2902 .one('bsTransitionEnd', callbackRemove) 2903 .emulateTransitionEnd(150) : 2904 callbackRemove() 2905 2906 } else if (callback) { 2907 callback() 2908 } 2909 } 2910 2911 Modal.prototype.checkScrollbar = function () { 2912 if (document.body.clientWidth >= window.innerWidth) 2913 return 2914 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar() 2915 } 2916 2917 Modal.prototype.setScrollbar = function () { 2918 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 2919 if (this.scrollbarWidth) 2920 this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 2921 } 2922 2923 Modal.prototype.resetScrollbar = function () { 2924 this.$body.css('padding-right', '') 2925 } 2926 2927 Modal.prototype.measureScrollbar = function () { // thx walsh 2928 var scrollDiv = document.createElement('div') 2929 scrollDiv.className = 'modal-scrollbar-measure' 2930 this.$body.append(scrollDiv) 2931 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 2932 this.$body[0].removeChild(scrollDiv) 2933 return scrollbarWidth 2934 } 2935 2936 2937 // MODAL PLUGIN DEFINITION 2938 // ======================= 2939 2940 function Plugin(option, _relatedTarget) { 2941 return this.each(function () { 2942 var $this = $(this) 2943 var data = $this.data('bs.modal') 2944 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 2945 2946 if (!data) 2947 $this.data('bs.modal', (data = new Modal(this, options))) 2948 if (typeof option == 'string') 2949 data[option](_relatedTarget) 2950 else if (options.show) 2951 data.show(_relatedTarget) 2952 }) 2953 } 2954 2955 var old = $.fn.modal 2956 2957 $.fn.modal = Plugin 2958 $.fn.modal.Constructor = Modal 2959 2960 2961 // MODAL NO CONFLICT 2962 // ================= 2963 2964 $.fn.modal.noConflict = function () { 2965 $.fn.modal = old 2966 return this 2967 } 2968 2969 2970 // MODAL DATA-API 2971 // ============== 2972 2973 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 2974 var $this = $(this) 2975 var href = $this.attr('href') 2976 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 2977 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 2978 2979 if ($this.is('a')) 2980 e.preventDefault() 2981 2982 $target.one('show.bs.modal', function (showEvent) { 2983 if (showEvent.isDefaultPrevented()) 2984 return // only register focus restorer if modal will actually get shown 2985 $target.one('hidden.bs.modal', function () { 2986 $this.is(':visible') && $this.trigger('focus') 2987 }) 2988 }) 2989 Plugin.call($target, option, this) 2990 }) 2991 2992}(jQuery); 2993 2994/* ======================================================================== 2995 * Bootstrap: tooltip.js v3.2.0 2996 * http://getbootstrap.com/javascript/#tooltip 2997 * Inspired by the original jQuery.tipsy by Jason Frame 2998 * ======================================================================== 2999 * Copyright 2011-2014 Twitter, Inc. 3000 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 3001 * ======================================================================== */ 3002 3003 3004+function ($) { 3005 'use strict'; 3006 3007 // TOOLTIP PUBLIC CLASS DEFINITION 3008 // =============================== 3009 3010 var Tooltip = function (element, options) { 3011 this.type = 3012 this.options = 3013 this.enabled = 3014 this.timeout = 3015 this.hoverState = 3016 this.$element = null 3017 3018 this.init('tooltip', element, options) 3019 } 3020 3021 Tooltip.VERSION = '3.2.0' 3022 3023 Tooltip.DEFAULTS = { 3024 animation: true, 3025 placement: 'top', 3026 selector: false, 3027 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', 3028 trigger: 'hover focus', 3029 title: '', 3030 delay: 0, 3031 html: false, 3032 container: false, 3033 viewport: { 3034 selector: 'body', 3035 padding: 0 3036 } 3037 } 3038 3039 Tooltip.prototype.init = function (type, element, options) { 3040 this.enabled = true 3041 this.type = type 3042 this.$element = $(element) 3043 this.options = this.getOptions(options) 3044 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport) 3045 3046 var triggers = this.options.trigger.split(' ') 3047 3048 for (var i = triggers.length; i--;) { 3049 var trigger = triggers[i] 3050 3051 if (trigger == 'click') { 3052 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 3053 } else if (trigger != 'manual') { 3054 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' 3055 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' 3056 3057 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 3058 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 3059 } 3060 } 3061 3062 this.options.selector ? 3063 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 3064 this.fixTitle() 3065 } 3066 3067 Tooltip.prototype.getDefaults = function () { 3068 return Tooltip.DEFAULTS 3069 } 3070 3071 Tooltip.prototype.getOptions = function (options) { 3072 options = $.extend({}, this.getDefaults(), this.$element.data(), options) 3073 3074 if (options.delay && typeof options.delay == 'number') { 3075 options.delay = { 3076 show: options.delay, 3077 hide: options.delay 3078 } 3079 } 3080 3081 return options 3082 } 3083 3084 Tooltip.prototype.getDelegateOptions = function () { 3085 var options = {} 3086 var defaults = this.getDefaults() 3087 3088 this._options && $.each(this._options, function (key, value) { 3089 if (defaults[key] != value) 3090 options[key] = value 3091 }) 3092 3093 return options 3094 } 3095 3096 Tooltip.prototype.enter = function (obj) { 3097 var self = obj instanceof this.constructor ? 3098 obj : $(obj.currentTarget).data('bs.' + this.type) 3099 3100 if (!self) { 3101 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 3102 $(obj.currentTarget).data('bs.' + this.type, self) 3103 } 3104 3105 clearTimeout(self.timeout) 3106 3107 self.hoverState = 'in' 3108 3109 if (!self.options.delay || !self.options.delay.show) 3110 return self.show() 3111 3112 self.timeout = setTimeout(function () { 3113 if (self.hoverState == 'in') 3114 self.show() 3115 }, self.options.delay.show) 3116 } 3117 3118 Tooltip.prototype.leave = function (obj) { 3119 var self = obj instanceof this.constructor ? 3120 obj : $(obj.currentTarget).data('bs.' + this.type) 3121 3122 if (!self) { 3123 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 3124 $(obj.currentTarget).data('bs.' + this.type, self) 3125 } 3126 3127 clearTimeout(self.timeout) 3128 3129 self.hoverState = 'out' 3130 3131 if (!self.options.delay || !self.options.delay.hide) 3132 return self.hide() 3133 3134 self.timeout = setTimeout(function () { 3135 if (self.hoverState == 'out') 3136 self.hide() 3137 }, self.options.delay.hide) 3138 } 3139 3140 Tooltip.prototype.show = function () { 3141 var e = $.Event('show.bs.' + this.type) 3142 3143 if (this.hasContent() && this.enabled) { 3144 this.$element.trigger(e) 3145 3146 var inDom = $.contains(document.documentElement, this.$element[0]) 3147 if (e.isDefaultPrevented() || !inDom) 3148 return 3149 var that = this 3150 3151 var $tip = this.tip() 3152 3153 var tipId = this.getUID(this.type) 3154 3155 this.setContent()
3156 $tip.attr('id', tipId) 3157 this.$element.attr('aria-describedby', tipId) 3158 3159 if (this.options.animation) 3160 $tip.addClass('fade') 3161 3162 var placement = typeof this.options.placement == 'function' ? 3163 this.options.placement.call(this, $tip[0], this.$element[0]) : 3164 this.options.placement 3165 3166 var autoToken = /\s?auto?\s?/i 3167 var autoPlace = autoToken.test(placement) 3168 if (autoPlace) 3169 placement = placement.replace(autoToken, '') || 'top' 3170 3171 $tip 3172 .detach() 3173 .css({ top: 0, left: 0, display: 'block' }) 3174 .addClass(placement) 3175 .data('bs.' + this.type, this) 3176 3177 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) 3178 3179 var pos = this.getPosition() 3180 var actualWidth = $tip[0].offsetWidth 3181 var actualHeight = $tip[0].offsetHeight 3182 3183 if (autoPlace) { 3184 var orgPlacement = placement 3185 var $parent = this.$element.parent() 3186 var parentDim = this.getPosition($parent) 3187 3188 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' : 3189 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' : 3190 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' : 3191 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' : 3192 placement 3193 3194 $tip 3195 .removeClass(orgPlacement) 3196 .addClass(placement) 3197 } 3198 3199 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) 3200 3201 this.applyPlacement(calculatedOffset, placement) 3202 3203 var complete = function () { 3204 that.$element.trigger('shown.bs.' + that.type) 3205 that.hoverState = null 3206 } 3207 3208 $.support.transition && this.$tip.hasClass('fade') ? 3209 $tip 3210 .one('bsTransitionEnd', complete) 3211 .emulateTransitionEnd(150) : 3212 complete() 3213 } 3214 } 3215 3216 Tooltip.prototype.applyPlacement = function (offset, placement) { 3217 var $tip = this.tip() 3218 var width = $tip[0].offsetWidth 3219 var height = $tip[0].offsetHeight 3220 3221 // manually read margins because getBoundingClientRect includes difference 3222 var marginTop = parseInt($tip.css('margin-top'), 10) 3223 var marginLeft = parseInt($tip.css('margin-left'), 10) 3224 3225 // we must check for NaN for ie 8/9 3226 if (isNaN(marginTop)) 3227 marginTop = 0 3228 if (isNaN(marginLeft)) 3229 marginLeft = 0 3230 3231 offset.top = offset.top + marginTop 3232 offset.left = offset.left + marginLeft 3233 3234 // $.fn.offset doesn't round pixel values 3235 // so we use setOffset directly with our own function B-0 3236 $.offset.setOffset($tip[0], $.extend({ 3237 using: function (props) { 3238 $tip.css({ 3239 top: Math.round(props.top), 3240 left: Math.round(props.left) 3241 }) 3242 } 3243 }, offset), 0) 3244 3245 $tip.addClass('in') 3246 3247 // check to see if placing tip in new offset caused the tip to resize itself 3248 var actualWidth = $tip[0].offsetWidth 3249 var actualHeight = $tip[0].offsetHeight 3250 3251 if (placement == 'top' && actualHeight != height) { 3252 offset.top = offset.top + height - actualHeight 3253 } 3254 3255 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight) 3256 3257 if (delta.left) 3258 offset.left += delta.left 3259 else 3260 offset.top += delta.top 3261 3262 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight 3263 var arrowPosition = delta.left ? 'left' : 'top' 3264 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight' 3265 3266 $tip.offset(offset) 3267 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition) 3268 } 3269 3270 Tooltip.prototype.replaceArrow = function (delta, dimension, position) { 3271 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '') 3272 } 3273 3274 Tooltip.prototype.setContent = function () { 3275 var $tip = this.tip() 3276 var title = this.getTitle() 3277 3278 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) 3279 $tip.removeClass('fade in top bottom left right') 3280 } 3281 3282 Tooltip.prototype.hide = function () { 3283 var that = this 3284 var $tip = this.tip() 3285 var e = $.Event('hide.bs.' + this.type) 3286 3287 this.$element.removeAttr('aria-describedby') 3288 3289 function complete() { 3290 if (that.hoverState != 'in') 3291 $tip.detach() 3292 that.$element.trigger('hidden.bs.' + that.type) 3293 } 3294 3295 this.$element.trigger(e) 3296 3297 if (e.isDefaultPrevented()) 3298 return 3299 3300 $tip.removeClass('in') 3301 3302 $.support.transition && this.$tip.hasClass('fade') ? 3303 $tip 3304 .one('bsTransitionEnd', complete) 3305 .emulateTransitionEnd(150) : 3306 complete() 3307 3308 this.hoverState = null 3309 3310 return this 3311 } 3312 3313 Tooltip.prototype.fixTitle = function () { 3314 var $e = this.$element 3315 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') { 3316 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') 3317 } 3318 } 3319 3320 Tooltip.prototype.hasContent = function () { 3321 return this.getTitle() 3322 } 3323 3324 Tooltip.prototype.getPosition = function ($element) { 3325 $element = $element || this.$element 3326 var el = $element[0] 3327 var isBody = el.tagName == 'BODY' 3328 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, { 3329 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(), 3330 width: isBody ? $(window).width() : $element.outerWidth(), 3331 height: isBody ? $(window).height() : $element.outerHeight() 3332 }, isBody ? { top: 0, left: 0 } : $element.offset()) 3333 } 3334 3335 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { 3336 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : 3337 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : 3338 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : 3339 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } 3340 3341 } 3342 3343 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) { 3344 var delta = { top: 0, left: 0 } 3345 if (!this.$viewport) 3346 return delta 3347 3348 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0 3349 var viewportDimensions = this.getPosition(this.$viewport) 3350 3351 if (/right|left/.test(placement)) { 3352 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll 3353 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight 3354 if (topEdgeOffset < viewportDimensions.top) { // top overflow 3355 delta.top = viewportDimensions.top - topEdgeOffset 3356 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow 3357 delta.top = viewportDimensions.top + viewportDimensions.height - bottom
vendor: 15,936 bytes, lines 3357-3901
3357EdgeOffset 3358 } 3359 } else { 3360 var leftEdgeOffset = pos.left - viewportPadding 3361 var rightEdgeOffset = pos.left + viewportPadding + actualWidth 3362 if (leftEdgeOffset < viewportDimensions.left) { // left overflow 3363 delta.left = viewportDimensions.left - leftEdgeOffset 3364 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow 3365 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset 3366 } 3367 } 3368 3369 return delta 3370 } 3371 3372 Tooltip.prototype.getTitle = function () { 3373 var title 3374 var $e = this.$element 3375 var o = this.options 3376 3377 title = $e.attr('data-original-title') 3378 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 3379 3380 return title 3381 } 3382 3383 Tooltip.prototype.getUID = function (prefix) { 3384 do 3385 prefix += ~~(Math.random() * 1000000) 3386 while (document.getElementById(prefix)) 3387 return prefix 3388 } 3389 3390 Tooltip.prototype.tip = function () { 3391 return (this.$tip = this.$tip || $(this.options.template)) 3392 } 3393 3394 Tooltip.prototype.arrow = function () { 3395 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) 3396 } 3397 3398 Tooltip.prototype.validate = function () { 3399 if (!this.$element[0].parentNode) { 3400 this.hide() 3401 this.$element = null 3402 this.options = null 3403 } 3404 } 3405 3406 Tooltip.prototype.enable = function () { 3407 this.enabled = true 3408 } 3409 3410 Tooltip.prototype.disable = function () { 3411 this.enabled = false 3412 } 3413 3414 Tooltip.prototype.toggleEnabled = function () { 3415 this.enabled = !this.enabled 3416 } 3417 3418 Tooltip.prototype.toggle = function (e) { 3419 var self = this 3420 if (e) { 3421 self = $(e.currentTarget).data('bs.' + this.type) 3422 if (!self) { 3423 self = new this.constructor(e.currentTarget, this.getDelegateOptions()) 3424 $(e.currentTarget).data('bs.' + this.type, self) 3425 } 3426 } 3427 3428 self.tip().hasClass('in') ? self.leave(self) : self.enter(self) 3429 } 3430 3431 Tooltip.prototype.destroy = function () { 3432 clearTimeout(this.timeout) 3433 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) 3434 } 3435 3436 3437 // TOOLTIP PLUGIN DEFINITION 3438 // ========================= 3439 3440 function Plugin(option) { 3441 return this.each(function () { 3442 var $this = $(this) 3443 var data = $this.data('bs.tooltip') 3444 var options = typeof option == 'object' && option 3445 3446 if (!data && option == 'destroy') 3447 return 3448 if (!data) 3449 $this.data('bs.tooltip', (data = new Tooltip(this, options))) 3450 if (typeof option == 'string') 3451 data[option]() 3452 }) 3453 } 3454 3455 var old = $.fn.tooltip 3456 3457 $.fn.tooltip = Plugin 3458 $.fn.tooltip.Constructor = Tooltip 3459 3460 3461 // TOOLTIP NO CONFLICT 3462 // =================== 3463 3464 $.fn.tooltip.noConflict = function () { 3465 $.fn.tooltip = old 3466 return this 3467 } 3468 3469}(jQuery); 3470 3471/* ======================================================================== 3472 * Bootstrap: popover.js v3.2.0 3473 * http://getbootstrap.com/javascript/#popovers 3474 * ======================================================================== 3475 * Copyright 2011-2014 Twitter, Inc. 3476 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 3477 * ======================================================================== */ 3478 3479 3480+function ($) { 3481 'use strict'; 3482 3483 // POPOVER PUBLIC CLASS DEFINITION 3484 // =============================== 3485 3486 var Popover = function (element, options) { 3487 this.init('popover', element, options) 3488 } 3489 3490 if (!$.fn.tooltip) 3491 throw new Error('Popover requires tooltip.js') 3492 3493 Popover.VERSION = '3.2.0' 3494 3495 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { 3496 placement: 'right', 3497 trigger: 'click', 3498 content: '', 3499 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 3500 }) 3501 3502 3503 // NOTE: POPOVER EXTENDS tooltip.js 3504 // ================================ 3505 3506 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype) 3507 3508 Popover.prototype.constructor = Popover 3509 3510 Popover.prototype.getDefaults = function () { 3511 return Popover.DEFAULTS 3512 } 3513 3514 Popover.prototype.setContent = function () { 3515 var $tip = this.tip() 3516 var title = this.getTitle() 3517 var content = this.getContent() 3518 3519 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) 3520 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events 3521 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text' 3522 ](content) 3523 3524 $tip.removeClass('fade top bottom left right in') 3525 3526 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do 3527 // this manually by checking the contents. 3528 if (!$tip.find('.popover-title').html()) 3529 $tip.find('.popover-title').hide() 3530 } 3531 3532 Popover.prototype.hasContent = function () { 3533 return this.getTitle() || this.getContent() 3534 } 3535 3536 Popover.prototype.getContent = function () { 3537 var $e = this.$element 3538 var o = this.options 3539 3540 return $e.attr('data-content') 3541 || (typeof o.content == 'function' ? 3542 o.content.call($e[0]) : 3543 o.content) 3544 } 3545 3546 Popover.prototype.arrow = function () { 3547 return (this.$arrow = this.$arrow || this.tip().find('.arrow')) 3548 } 3549 3550 Popover.prototype.tip = function () { 3551 if (!this.$tip) 3552 this.$tip = $(this.options.template) 3553 return this.$tip 3554 } 3555 3556 3557 // POPOVER PLUGIN DEFINITION 3558 // ========================= 3559 3560 function Plugin(option) { 3561 return this.each(function () { 3562 var $this = $(this) 3563 var data = $this.data('bs.popover') 3564 var options = typeof option == 'object' && option 3565 3566 if (!data && option == 'destroy') 3567 return 3568 if (!data) 3569 $this.data('bs.popover', (data = new Popover(this, options))) 3570 if (typeof option == 'string') 3571 data[option]() 3572 }) 3573 } 3574 3575 var old = $.fn.popover 3576 3577 $.fn.popover = Plugin 3578 $.fn.popover.Constructor = Popover 3579 3580 3581 // POPOVER NO CONFLICT 3582 // =================== 3583 3584 $.fn.popover.noConflict = function () { 3585 $.fn.popover = old 3586 return this 3587 } 3588 3589}(jQuery); 3590 3591/* ======================================================================== 3592 * Bootstrap: scrollspy.js v3.2.0 3593 * http://getbootstrap.com/javascript/#scrollspy 3594 * ======================================================================== 3595 * Copyright 2011-2014 Twitter, Inc. 3596 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 3597 * ======================================================================== */ 3598 3599 3600+function ($) { 3601 'use strict'; 3602 3603 // SCROLLSPY CLASS DEFINITION 3604 // ========================== 3605 3606 function ScrollSpy(element, options) { 3607 var process = $.proxy(this.process, this) 3608 3609 this.$body = $('body') 3610 this.$scrollElement = $(element).is('body') ? $(window) : $(element) 3611 this.options = $.extend({}, ScrollSpy.DEFAULTS, options) 3612 this.selector = (this.options.target || '') + ' .nav li > a' 3613 this.offsets = [] 3614 this.targets = [] 3615 this.activeTarget = null 3616 this.scrollHeight = 0 3617 3618 this.$scrollElement.on('scroll.bs.scrollspy', process) 3619 this.refresh() 3620 this.process() 3621 } 3622 3623 ScrollSpy.VERSION = '3.2.0' 3624 3625 ScrollSpy.DEFAULTS = { 3626 offset: 10 3627 } 3628 3629 ScrollSpy.prototype.getScrollHeight = function () { 3630 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight) 3631 } 3632 3633 ScrollSpy.prototype.refresh = function () { 3634 var offsetMethod = 'offset' 3635 var offsetBase = 0 3636 3637 if (!$.isWindow(this.$scrollElement[0])) { 3638 offsetMethod = 'position' 3639 offsetBase = this.$scrollElement.scrollTop() 3640 } 3641 3642 this.offsets = [] 3643 this.targets = [] 3644 this.scrollHeight = this.getScrollHeight() 3645 3646 var self = this 3647 3648 this.$body 3649 .find(this.selector) 3650 .map(function () { 3651 var $el = $(this) 3652 var href = $el.data('target') || $el.attr('href') 3653 var $href = /^#./.test(href) && $(href) 3654 3655 return ($href 3656 && $href.length 3657 && $href.is(':visible') 3658 && [[$href[offsetMethod]().top + offsetBase, href]]) || null 3659 }) 3660 .sort(function (a, b) { 3661 return a[0] - b[0] 3662 }) 3663 .each(function () { 3664 self.offsets.push(this[0]) 3665 self.targets.push(this[1]) 3666 }) 3667 } 3668 3669 ScrollSpy.prototype.process = function () { 3670 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset 3671 var scrollHeight = this.getScrollHeight() 3672 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height() 3673 var offsets = this.offsets 3674 var targets = this.targets 3675 var activeTarget = this.activeTarget 3676 var i 3677 3678 if (this.scrollHeight != scrollHeight) { 3679 this.refresh() 3680 } 3681 3682 if (scrollTop >= maxScroll) { 3683 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i) 3684 } 3685 3686 if (activeTarget && scrollTop <= offsets[0]) { 3687 return activeTarget != (i = targets[0]) && this.activate(i) 3688 } 3689 3690 for (i = offsets.length; i--;) { 3691 activeTarget != targets[i] 3692 && scrollTop >= offsets[i] 3693 && (!offsets[i + 1] || scrollTop <= offsets[i + 1]) 3694 && this.activate(targets[i]) 3695 } 3696 } 3697 3698 ScrollSpy.prototype.activate = function (target) { 3699 this.activeTarget = target 3700 3701 $(this.selector) 3702 .parentsUntil(this.options.target, '.active') 3703 .removeClass('active') 3704 3705 var selector = this.selector + 3706 '[data-target="' + target + '"],' + 3707 this.selector + '[href="' + target + '"]' 3708 3709 var active = $(selector) 3710 .parents('li') 3711 .addClass('active') 3712 3713 if (active.parent('.dropdown-menu').length) { 3714 active = active 3715 .closest('li.dropdown') 3716 .addClass('active') 3717 } 3718 3719 active.trigger('activate.bs.scrollspy') 3720 } 3721 3722 3723 // SCROLLSPY PLUGIN DEFINITION 3724 // =========================== 3725 3726 function Plugin(option) { 3727 return this.each(function () { 3728 var $this = $(this) 3729 var data = $this.data('bs.scrollspy') 3730 var options = typeof option == 'object' && option 3731 3732 if (!data) 3733 $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) 3734 if (typeof option == 'string') 3735 data[option]() 3736 }) 3737 } 3738 3739 var old = $.fn.scrollspy 3740 3741 $.fn.scrollspy = Plugin 3742 $.fn.scrollspy.Constructor = ScrollSpy 3743 3744 3745 // SCROLLSPY NO CONFLICT 3746 // ===================== 3747 3748 $.fn.scrollspy.noConflict = function () { 3749 $.fn.scrollspy = old 3750 return this 3751 } 3752 3753 3754 // SCROLLSPY DATA-API 3755 // ================== 3756 3757 $(window).on('load.bs.scrollspy.data-api', function () { 3758 $('[data-spy="scroll"]').each(function () { 3759 var $spy = $(this) 3760 Plugin.call($spy, $spy.data()) 3761 }) 3762 }) 3763 3764}(jQuery); 3765 3766/* ======================================================================== 3767 * Bootstrap: tab.js v3.2.0 3768 * http://getbootstrap.com/javascript/#tabs 3769 * ======================================================================== 3770 * Copyright 2011-2014 Twitter, Inc. 3771 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 3772 * ======================================================================== */ 3773 3774 3775+function ($) { 3776 'use strict'; 3777 3778 // TAB CLASS DEFINITION 3779 // ==================== 3780 3781 var Tab = function (element) { 3782 this.element = $(element) 3783 } 3784 3785 Tab.VERSION = '3.2.0' 3786 3787 Tab.prototype.show = function () { 3788 var $this = this.element 3789 var $ul = $this.closest('ul:not(.dropdown-menu)') 3790 var selector = $this.data('target') 3791 3792 if (!selector) { 3793 selector = $this.attr('href') 3794 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 3795 } 3796 3797 if ($this.parent('li').hasClass('active')) 3798 return 3799 3800 var previous = $ul.find('.active:last a')[0] 3801 var e = $.Event('show.bs.tab', { 3802 relatedTarget: previous 3803 }) 3804 3805 $this.trigger(e) 3806 3807 if (e.isDefaultPrevented()) 3808 return 3809 3810 var $target = $(selector) 3811 3812 this.activate($this.closest('li'), $ul) 3813 this.activate($target, $target.parent(), function () { 3814 $this.trigger({ 3815 type: 'shown.bs.tab', 3816 relatedTarget: previous 3817 }) 3818 }) 3819 } 3820 3821 Tab.prototype.activate = function (element, container, callback) { 3822 var $active = container.find('> .active') 3823 var transition = callback 3824 && $.support.transition 3825 && $active.hasClass('fade') 3826 3827 function next() { 3828 $active 3829 .removeClass('active') 3830 .find('> .dropdown-menu > .active') 3831 .removeClass('active') 3832 3833 element.addClass('active') 3834 3835 if (transition) { 3836 element[0].offsetWidth // reflow for transition 3837 element.addClass('in') 3838 } else { 3839 element.removeClass('fade') 3840 } 3841 3842 if (element.parent('.dropdown-menu')) { 3843 element.closest('li.dropdown').addClass('active') 3844 } 3845 3846 callback && callback() 3847 } 3848 3849 transition ? 3850 $active 3851 .one('bsTransitionEnd', next) 3852 .emulateTransitionEnd(150) : 3853 next() 3854 3855 $active.removeClass('in') 3856 } 3857 3858 3859 // TAB PLUGIN DEFINITION 3860 // ===================== 3861 3862 function Plugin(option) { 3863 return this.each(function () { 3864 var $this = $(this) 3865 var data = $this.data('bs.tab') 3866 3867 if (!data) 3868 $this.data('bs.tab', (data = new Tab(this))) 3869 if (typeof option == 'string') 3870 data[option]() 3871 }) 3872 } 3873 3874 var old = $.fn.tab 3875 3876 $.fn.tab = Plugin 3877 $.fn.tab.Constructor = Tab 3878 3879 3880 // TAB NO CONFLICT 3881 // =============== 3882 3883 $.fn.tab.noConflict = function () { 3884 $.fn.tab = old 3885 return this 3886 } 3887 3888 3889 // TAB DATA-API 3890 // ============ 3891 3892 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { 3893 e.preventDefault() 3894 Plugin.call($(this), 'show') 3895 }) 3896 3897}(jQuery); 3898 3899/* ======================================================================== 3900 * Bootstrap: affix.js v3.2.0 3901 * http://getbootstrap.com/javascript/#affix
3902 * ======================================================================== 3903 * Copyright 2011-2014 Twitter, Inc. 3904 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 3905 * ======================================================================== */ 3906 3907 3908+function ($) { 3909 'use strict'; 3910 3911 // AFFIX CLASS DEFINITION 3912 // ====================== 3913 3914 var Affix = function (element, options) { 3915 this.options = $.extend({}, Affix.DEFAULTS, options) 3916 3917 this.$target = $(this.options.target) 3918 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) 3919 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) 3920 3921 this.$element = $(element) 3922 this.affixed = 3923 this.unpin = 3924 this.pinnedOffset = null 3925 3926 this.checkPosition() 3927 } 3928 3929 Affix.VERSION = '3.2.0' 3930 3931 Affix.RESET = 'affix affix-top affix-bottom' 3932 3933 Affix.DEFAULTS = { 3934 offset: 0, 3935 target: window 3936 } 3937 3938 Affix.prototype.getPinnedOffset = function () { 3939 if (this.pinnedOffset) 3940 return this.pinnedOffset 3941 this.$element.removeClass(Affix.RESET).addClass('affix') 3942 var scrollTop = this.$target.scrollTop() 3943 var position = this.$element.offset() 3944 return (this.pinnedOffset = position.top - scrollTop) 3945 } 3946 3947 Affix.prototype.checkPositionWithEventLoop = function () { 3948 setTimeout($.proxy(this.checkPosition, this), 1) 3949 } 3950 3951 Affix.prototype.checkPosition = function () { 3952 if (!this.$element.is(':visible')) 3953 return 3954 3955 var scrollHeight = $(document).height() 3956 var scrollTop = this.$target.scrollTop() 3957 var position = this.$element.offset() 3958 var offset = this.options.offset 3959 var offsetTop = offset.top 3960 var offsetBottom = offset.bottom 3961 3962 if (typeof offset != 'object') 3963 offsetBottom = offsetTop = offset 3964 if (typeof offsetTop == 'function') 3965 offsetTop = offset.top(this.$element) 3966 if (typeof offsetBottom == 'function') 3967 offsetBottom = offset.bottom(this.$element) 3968 3969 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : 3970 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : 3971 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false 3972 3973 if (this.affixed === affix) 3974 return 3975 if (this.unpin != null) 3976 this.$element.css('top', '') 3977 3978 var affixType = 'affix' + (affix ? '-' + affix : '') 3979 var e = $.Event(affixType + '.bs.affix') 3980 3981 this.$element.trigger(e) 3982 3983 if (e.isDefaultPrevented()) 3984 return 3985 3986 this.affixed = affix 3987 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null 3988 3989 this.$element 3990 .removeClass(Affix.RESET) 3991 .addClass(affixType) 3992 .trigger($.Event(affixType.replace('affix', 'affixed'))) 3993 3994 if (affix == 'bottom') { 3995 this.$element.offset({ 3996 top: scrollHeight - this.$element.height() - offsetBottom 3997 }) 3998 } 3999 } 4000 4001 4002 // AFFIX PLUGIN DEFINITION 4003 // ======================= 4004 4005 function Plugin(option) { 4006 return this.each(function () { 4007 var $this = $(this) 4008 var data = $this.data('bs.affix') 4009 var options = typeof option == 'object' && option 4010 4011 if (!data) 4012 $this.data('bs.affix', (data = new Affix(this, options))) 4013 if (typeof option == 'string') 4014 data[option]() 4015 }) 4016 } 4017 4018 var old = $.fn.affix 4019 4020 $.fn.affix = Plugin 4021 $.fn.affix.Constructor = Affix 4022 4023 4024 // AFFIX NO CONFLICT 4025 // ================= 4026 4027 $.fn.affix.noConflict = function () { 4028 $.fn.affix = old 4029 return this 4030 } 4031 4032 4033 // AFFIX DATA-API 4034 // ============== 4035 4036 $(window).on('load', function () { 4037 $('[data-spy="affix"]').each(function () { 4038 var $spy = $(this) 4039 var data = $spy.data() 4040 4041 data.offset = data.offset || {} 4042 4043 if (data.offsetBottom) 4044 data.offset.bottom = data.offsetBottom 4045 if (data.offsetTop) 4046 data.offset.top = data.offsetTop 4047 4048 Plugin.call($spy, data) 4049 }) 4050 }) 4051 4052}(jQuery); 4053;/*global ActiveXObject */ 4054 4055// AMD support 4056(function (factory) { 4057 if (typeof define === 'function' && define.amd) { 4058 // using AMD; register as anon module 4059 define(['jquery'], factory); 4060 } else { 4061 // no AMD; invoke directly 4062 factory((typeof (jQuery) != 'undefined') ? jQuery : window.Zepto); 4063 } 4064} 4065 4066 (function ($) { 4067 "use strict"; 4068 4069 /* 4070 Usage Note: 4071 ----------- 4072 Do not use both ajaxSubmit and ajaxForm on the same form. These 4073 functions are mutually exclusive. Use ajaxSubmit if you want 4074 to bind your own submit handler to the form. For example, 4075 4076 $(document).ready(function() { 4077 $('#myForm').on('submit', function(e) { 4078 e.preventDefault(); // <-- important 4079 $(this).ajaxSubmit({ 4080 target: '#output' 4081 }); 4082 }); 4083 }); 4084 4085 Use ajaxForm when you want the plugin to manage all the event binding 4086 for you. For example, 4087 4088 $(document).ready(function() { 4089 $('#myForm').ajaxForm({ 4090 target: '#output' 4091 }); 4092 }); 4093 4094 You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
4095 form does not have to exist when you invoke ajaxForm: 4096 4097 $('#myForm').ajaxForm({ 4098 delegation: true, 4099 target: '#output' 4100 }); 4101 4102 When using ajaxForm, the ajaxSubmit function will be invoked for you 4103 at the appropriate time. 4104 */ 4105 4106 /** 4107 * Feature detection 4108 */ 4109 var feature = {}; 4110 feature.fileapi = $("<input type='file'/>").get(0).files !== undefined; 4111 feature.formdata = window.FormData !== undefined; 4112 4113 var hasProp = !!$.fn.prop; 4114 4115 // attr2 uses prop when it can but checks the return type for 4116 // an expected string. this accounts for the case where a form 4117 // contains inputs with names like "action" or "method"; in those 4118 // cases "prop" returns the element 4119 $.fn.attr2 = function () { 4120 if (!hasProp) 4121 return this.attr.apply(this, arguments); 4122 var val = this.prop.apply(this, arguments); 4123 if ((val && val.jquery) || typeof val === 'string') 4124 return val; 4125 return this.attr.apply(this, arguments); 4126 }; 4127 4128 /** 4129 * ajaxSubmit() provides a mechanism for immediately submitting 4130 * an HTML form using AJAX. 4131 */ 4132 $.fn.ajaxSubmit = function (options) { 4133 /*jshint scripturl:true */ 4134 4135 // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) 4136 if (!this.length) { 4137 log('ajaxSubmit: skipping submit process - no element selected'); 4138 return this; 4139 } 4140 4141 var method, action, url, $form = this; 4142 4143 if (typeof options == 'function') { 4144 options = { success: options }; 4145 } 4146 else if (options === undefined) { 4147 options = {}; 4148 } 4149 4150 method = options.type || this.attr2('method'); 4151 action = options.url || this.attr2('action'); 4152 4153 url = (typeof action === 'string') ? $.trim(action) : ''; 4154 url = url || window.location.href || ''; 4155 if (url) { 4156 // clean url (don't include hash vaue) 4157 url = (url.match(/^([^#]+)/) || [])[1]; 4158 } 4159 4160 options = $.extend(true, { 4161 url: url, 4162 success: $.ajaxSettings.success, 4163 type: method || $.ajaxSettings.type, 4164 iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' 4165 }, options); 4166 4167 // hook for manipulating the form data before it is extracted; 4168 // convenient for use with rich editors like tinyMCE or FCKEditor 4169 var veto = {}; 4170 this.trigger('form-pre-serialize', [this, options, veto]); 4171 if (veto.veto) { 4172 log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); 4173 return this; 4174 } 4175 4176 // provide opportunity to alter form data before it is serialized 4177 if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { 4178 log('ajaxSubmit: submit aborted via beforeSerialize callback'); 4179 return this; 4180 } 4181 4182 var traditional = options.traditional; 4183 if (traditional === undefined) { 4184 traditional = $.ajaxSettings.traditional; 4185 } 4186 4187 var elements = []; 4188 var qx, a = this.formToArray(options.semantic, elements); 4189 if (options.data) { 4190 options.extraData = options.data; 4191 qx = $.param(options.data, traditional); 4192 } 4193 4194 // give pre-submit callback an opportunity to abort the submit 4195 if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { 4196 log('ajaxSubmit: submit aborted via beforeSubmit callback'); 4197 return this; 4198 } 4199 4200 // fire vetoable 'validate' event 4201 this.trigger('form-submit-validate', [a, this, options, veto]); 4202 if (veto.veto) { 4203 log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); 4204 return this; 4205 } 4206 4207 var q = $.param(a, traditional); 4208 if (qx) { 4209 q = (q ? (q + '&' + qx) : qx); 4210 } 4211 if (options.type.toUpperCase() == 'GET') { 4212 options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; 4213 options.data = null; // data is null for 'get' 4214 } 4215 else { 4216 options.data = q; // data is the query string for 'post' 4217 } 4218 4219 var callbacks = []; 4220 if (options.resetForm) { 4221 callbacks.push(function () { 4222 $form.resetForm(); 4223 }); 4224 } 4225 if (options.clearForm) { 4226 callbacks.push(function () { 4227 $form.clearForm(options.includeHidden); 4228 }); 4229 } 4230 4231 // perform a load on the target only if dataType is not provided 4232 if (!options.dataType && options.target) { 4233 var oldSuccess = options.success || function () { 4234 }; 4235 callbacks.push(function (data) { 4236 var fn = options.replaceTarget ? 'replaceWith' : 'html'; 4237 $(options.target)[fn](data).each(oldSuccess, arguments); 4238 }); 4239 } 4240 else if (options.success) { 4241 callbacks.push(options.success); 4242 } 4243 4244 options.success = function (data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg 4245 var context = options.context || this; // jQuery 1.4+ supports scope context 4246 for (var i = 0, max = callbacks.length; i < max; i++) { 4247 callbacks[i].apply(context, [data, status, xhr || $form, $form]); 4248 } 4249 }; 4250 4251 if (options.error) { 4252 var oldError = options.error; 4253 options.error = function (xhr, status, error) { 4254 var context = options.context || this; 4255 oldError.apply(context, [xhr, status, error, $form]); 4256 }; 4257 } 4258 4259 if (options.complete) { 4260 var oldComplete = options.complete; 4261 options.complete = function (xhr, status) { 4262 var context = options.context || this; 4263 oldComplete.apply(context, [xhr, status, $form]); 4264 }; 4265 } 4266 4267 // are there files to upload? 4268 4269 // [value] (issue #113), also see comment: 4270 // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 4271 var fileInputs = $('input[type=file]:enabled', this).filter(function () { 4272 return $(this).val() !== ''; 4273 }); 4274 4275 var hasFileInputs = fileInputs.length > 0;
4276 var mp = 'multipart/form-data'; 4277 var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); 4278 4279 var fileAPI = feature.fileapi && feature.formdata; 4280 log("fileAPI :" + fileAPI); 4281 var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; 4282 4283 var jqxhr; 4284 4285 // options.iframe allows user to force iframe mode 4286 // 06-NOV-09: now defaulting to iframe mode if file input is detected 4287 if (options.iframe !== false && (options.iframe || shouldUseFrame)) { 4288 // hack to fix Safari hang (thanks to Tim Molendijk for this) 4289 // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d 4290 if (options.closeKeepAlive) { 4291 $.get(options.closeKeepAlive, function () { 4292 jqxhr = fileUploadIframe(a); 4293 }); 4294 } 4295 else { 4296 jqxhr = fileUploadIframe(a); 4297 } 4298 } 4299 else if ((hasFileInputs || multipart) && fileAPI) { 4300 jqxhr = fileUploadXhr(a); 4301 } 4302 else { 4303 jqxhr = $.ajax(options); 4304 } 4305 4306 $form.removeData('jqxhr').data('jqxhr', jqxhr); 4307 4308 // clear element array 4309 for (var k = 0; k < elements.length; k++) 4310 elements[k] = null; 4311 4312 // fire 'notify' event 4313 this.trigger('form-submit-notify', [this, options]); 4314 return this; 4315 4316 // utility fn for deep serialization 4317 function deepSerialize(extraData) { 4318 var serialized = $.param(extraData, options.traditional).split('&'); 4319 var len = serialized.length; 4320 var result = []; 4321 var i, part; 4322 for (i = 0; i < len; i++) { 4323 // #252; undo param space replacement 4324 serialized[i] = serialized[i].replace(/\+/g, ' '); 4325 part = serialized[i].split('='); 4326 // #278; use array instead of object storage, favoring array serializations 4327 result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); 4328 } 4329 return result; 4330 } 4331 4332 // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) 4333 function fileUploadXhr(a) { 4334 var formdata = new FormData(); 4335 4336 for (var i = 0; i < a.length; i++) { 4337 formdata.append(a[i].name, a[i].value); 4338 } 4339 4340 if (options.extraData) { 4341 var serializedData = deepSerialize(options.extraData); 4342 for (i = 0; i < serializedData.length; i++) 4343 if (serializedData[i]) 4344 formdata.append(serializedData[i][0], serializedData[i][1]); 4345 } 4346 4347 options.data = null; 4348 4349 var s = $.extend(true, {}, $.ajaxSettings, options, { 4350 contentType: false, 4351 processData: false, 4352 cache: false, 4353 type: method || 'POST' 4354 }); 4355 4356 if (options.uploadProgress) { 4357 // workaround because jqXHR does not expose upload property 4358 s.xhr = function () { 4359 var xhr = $.ajaxSettings.xhr(); 4360 if (xhr.upload) { 4361 xhr.upload.addEventListener('progress', function (event) { 4362 var percent = 0; 4363 var position = event.loaded || event.position; /*event.position is deprecated*/ 4364 var total = event.total; 4365 if (event.lengthComputable) { 4366 percent = Math.ceil(position / total * 100); 4367 } 4368 options.uploadProgress(event, position, total, percent); 4369 }, false); 4370 } 4371 return xhr; 4372 }; 4373 } 4374 4375 s.data = null; 4376 var beforeSend = s.beforeSend; 4377 s.beforeSend = function (xhr, o) { 4378 //Send FormData() provided by user 4379 if (options.formData) 4380 o.data = options.formData; 4381 else 4382 o.data = formdata; 4383 if (beforeSend)
4384 beforeSend.call(this, xhr, o); 4385 }; 4386 return $.ajax(s); 4387 } 4388 4389 // private function for handling file uploads (hat tip to YAHOO!) 4390 function fileUploadIframe(a) { 4391 var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; 4392 var deferred = $.Deferred(); 4393 4394 // #341 4395 deferred.abort = function (status) { 4396 xhr.abort(status); 4397 }; 4398 4399 if (a) { 4400 // ensure that every serialized input is still enabled 4401 for (i = 0; i < elements.length; i++) { 4402 el = $(elements[i]); 4403 if (hasProp) 4404 el.prop('disabled', false); 4405 else 4406 el.removeAttr('disabled'); 4407 } 4408 } 4409 4410 s = $.extend(true, {}, $.ajaxSettings, options); 4411 s.context = s.context || s; 4412 id = 'jqFormIO' + (new Date().getTime()); 4413 if (s.iframeTarget) { 4414 $io = $(s.iframeTarget); 4415 n = $io.attr2('name'); 4416 if (!n) 4417 $io.attr2('name', id); 4418 else 4419 id = n; 4420 } 4421 else { 4422 $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />'); 4423 $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); 4424 } 4425 io = $io[0]; 4426 4427 4428 xhr = {// mock object 4429 aborted: 0, 4430 responseText: null, 4431 responseXML: null, 4432 status: 0, 4433 statusText: 'n/a', 4434 getAllResponseHeaders: function () { 4435 }, 4436 getResponseHeader: function () { 4437 }, 4438 setRequestHeader: function () { 4439 }, 4440 abort: function (status) { 4441 var e = (status === 'timeout' ? 'timeout' : 'aborted'); 4442 log('aborting upload... ' + e); 4443 this.aborted = 1; 4444 4445 try { // #214, #257 4446 if (io.contentWindow.document.execCommand) { 4447 io.contentWindow.document.execCommand('Stop'); 4448 } 4449 } 4450 catch (ignore) { 4451 } 4452 4453 $io.attr('src', s.iframeSrc); // abort op in progress 4454 xhr.error = e; 4455 if (s.error) 4456 s.error.call(s.context, xhr, e, status); 4457 if (g) 4458 $.event.trigger("ajaxError", [xhr, s, e]); 4459 if (s.complete) 4460 s.complete.call(s.context, xhr, e); 4461 } 4462 }; 4463 4464 g = s.global; 4465 // trigger ajax global events so that activity/block indicators work like normal 4466 if (g && 0 === $.active++) { 4467 $.event.trigger("ajaxStart"); 4468 } 4469 if (g) { 4470 $.event.trigger("ajaxSend", [xhr, s]); 4471 } 4472 4473 if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { 4474 if (s.global) { 4475 $.active--; 4476 } 4477 deferred.reject(); 4478 return deferred; 4479 } 4480 if (xhr.aborted) { 4481 deferred.reject(); 4482 return deferred; 4483 } 4484 4485 // add submitting element to data if we know it 4486 sub = form.clk; 4487 if (sub) { 4488 n = sub.name; 4489 if (n && !sub.disabled) { 4490 s.extraData = s.extraData || {}; 4491 s.extraData[n] = sub.value; 4492 if (sub.type == "image") { 4493 s.extraData[n + '.x'] = form.clk_x; 4494 s.extraData[n + '.y'] = form.clk_y; 4495 } 4496 } 4497 } 4498 4499 var CLIENT_TIMEOUT_ABORT = 1; 4500 var SERVER_ABORT = 2; 4501 4502 function getDoc(frame) { 4503 /* it looks like contentWindow or contentDocument do not 4504 * carry the protocol property in ie8, when running under ssl 4505 * frame.document is the only valid response document, since 4506 * the protocol is know but not on the other two objects. strange? 4507 * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy 4508 */ 4509 4510 var doc = null; 4511 4512 // IE8 cascading access check 4513 try { 4514 if (frame.contentWindow) { 4515 doc = frame.contentWindow.document; 4516 } 4517 } catch (err) { 4518 // IE8 access denied under ssl & missing protocol 4519 log('cannot get iframe.contentWindow document: ' + err); 4520 } 4521 4522 if (doc) { // successful getting content 4523 return doc; 4524 } 4525 4526 try { // simply checking may throw in ie8 under ssl or mismatched protocol 4527 doc = frame.contentDocument ? frame.contentDocument : frame.document; 4528 } catch (err) { 4529 // last attempt 4530 log('cannot get iframe.contentDocument: ' + err); 4531 doc = frame.document; 4532 } 4533 return doc; 4534 } 4535 4536 // Rails CSRF hack (thanks to Yvan Barthelemy) 4537 var csrf_token = $('meta[name=csrf-token]').attr('content'); 4538 var csrf_param = $('meta[name=csrf-param]').attr('content'); 4539 if (csrf_param && csrf_token) { 4540 s.extraData = s.extraData || {}; 4541 s.extraData[csrf_param] = csrf_token; 4542 } 4543 4544 // take a breath so that pending repaints get some cpu time before the upload starts 4545 function doSubmit() { 4546 // make sure form attrs are set 4547 var t = $form.attr2('target'), a = $form.attr2('action'); 4548 4549 // update form attrs in IE friendly way 4550 form.setAttribute('target', id); 4551 if (!method || /post/i.test(method)) { 4552 form.setAttribute('method', 'POST'); 4553 } 4554 if (a != s.url) { 4555 form.setAttribute('action', s.url); 4556 } 4557 4558 // ie borks in some cases when setting encoding 4559 if (!s.skipEncodingOverride && (!method || /post/i.test(method))) { 4560 $form.attr({ 4561 encoding: 'multipart/form-data', 4562 enctype: 'multipart/form-data' 4563 }); 4564 } 4565 4566 // support timout 4567 if (s.timeout) { 4568 timeoutHandle = setTimeout(function () { 4569 timedOut = true; 4570 cb(CLIENT_TIMEOUT_ABORT); 4571 }, s.timeout); 4572 } 4573 4574 // look for server aborts 4575 function checkState() { 4576 try { 4577 var state = getDoc(io).readyState; 4578 log('state = ' + state); 4579 if (state && state.toLowerCase() == 'uninitialized') 4580 setTimeout(checkState, 50); 4581 } 4582 catch (e) { 4583 log('Server abort: ', e, ' (', e.name, ')'); 4584 cb(SERVER_ABORT); 4585 if (timeoutHandle) 4586 clearTimeout(timeoutHandle); 4587 timeoutHandle = undefined; 4588 } 4589 } 4590 4591 // add "extra" data to form if provided in options 4592 var extraInputs = []; 4593 try { 4594 if (s.extraData) { 4595 for (var n in s.extraData) { 4596 if (s.extraData.hasOwnProperty(n)) { 4597 // if using the $.param format that allows for multiple values with the same name 4598 if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { 4599 extraInputs.push( 4600 $('<input type="hidden" name="' + s.extraData[n].name + '">').val(s.extraData[n].value) 4601 .appendTo(form)[0]); 4602 } else { 4603 extraInputs.push( 4604 $('<input type="hidden" name="' + n + '">').val(s.extraData[n]) 4605 .appendTo(form)[0]); 4606 } 4607 } 4608 } 4609 } 4610 4611 if (!s.iframeTarget) { 4612 // add iframe to doc and submit the form 4613 $io.appendTo('body'); 4614 } 4615 if (io.attachEvent) 4616 io.attachEvent('onload', cb); 4617 else 4618 io.addEventListener('load', cb, false); 4619 setTimeout(checkState, 15); 4620 4621 try { 4622 form.submit(); 4623 } catch (err) { 4624 // just in case form has element with name/id of 'submit' 4625 var submitFn = document.createElement('form').submit; 4626 submitFn.apply(form); 4627 } 4628 } 4629 finally { 4630 // reset attrs and remove "extra" input elements 4631 form.setAttribute('action', a); 4632 if (t) { 4633 form.setAttribute('target', t); 4634 } else { 4635 $form.removeAttr('target'); 4636 } 4637 $(extraInputs).remove(); 4638 } 4639 } 4640 4641 if (s.forceSync) { 4642 doSubmit(); 4643 } 4644 else { 4645 setTimeout(doSubmit, 10); // this lets dom updates render
4646 } 4647 4648 var data, doc, domCheckCount = 50, callbackProcessed; 4649 4650 function cb(e) { 4651 if (xhr.aborted || callbackProcessed) { 4652 return; 4653 } 4654 4655 doc = getDoc(io); 4656 if (!doc) { 4657 log('cannot access response document'); 4658 e = SERVER_ABORT; 4659 } 4660 if (e === CLIENT_TIMEOUT_ABORT && xhr) { 4661 xhr.abort('timeout'); 4662 deferred.reject(xhr, 'timeout'); 4663 return; 4664 } 4665 else if (e == SERVER_ABORT && xhr) { 4666 xhr.abort('server abort'); 4667 deferred.reject(xhr, 'error', 'server abort'); 4668 return; 4669 } 4670 4671 if (!doc || doc.location.href == s.iframeSrc) { 4672 // response not received yet 4673 if (!timedOut) 4674 return; 4675 } 4676 if (io.detachEvent) 4677 io.detachEvent('onload', cb); 4678 else 4679 io.removeEventListener('load', cb, false); 4680 4681 var status = 'success', errMsg; 4682 try { 4683 if (timedOut) { 4684 throw 'timeout'; 4685 } 4686 4687 var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); 4688 log('isXml=' + isXml); 4689 if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) { 4690 if (--domCheckCount) { 4691 // in some browsers (Opera) the iframe DOM is not always traversable when 4692 // the onload callback fires, so we loop a bit to accommodate 4693 log('requeing onLoad callback, DOM not available'); 4694 setTimeout(cb, 250); 4695 return; 4696 } 4697 // let this fall through because server response could be an empty document 4698 //log('Could not access iframe DOM after mutiple tries.'); 4699 //throw 'DOMException: not available'; 4700 } 4701 4702 //log('response detected'); 4703 var docRoot = doc.body ? doc.body : doc.documentElement; 4704 xhr.responseText = docRoot ? docRoot.innerHTML : null; 4705 xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; 4706 if (isXml) 4707 s.dataType = 'xml'; 4708 xhr.getResponseHeader = function (header) { 4709 var headers = { 'content-type': s.dataType }; 4710 return headers[header.toLowerCase()]; 4711 }; 4712 // support for XHR 'status' & 'statusText' emulation : 4713 if (docRoot) { 4714 xhr.status = Number(docRoot.getAttribute('status')) || xhr.status; 4715 xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText; 4716 } 4717 4718 var dt = (s.dataType || '').toLowerCase(); 4719 var scr = /(json|script|text)/.test(dt); 4720 if (scr || s.textarea) { 4721 // see if user embedded response in textarea 4722 var ta = doc.getElementsByTagName('textarea')[0]; 4723 if (ta) { 4724 xhr.responseText = ta.value; 4725 // support for XHR 'status' & 'statusText' emulation : 4726 xhr.status = Number(ta.getAttribute('status')) || xhr.status; 4727 xhr.statusText = ta.getAttribute('statusText') || xhr.statusText; 4728 } 4729 else if (scr) { 4730 // account for browsers injecting pre around json response 4731 var pre = doc.getElementsByTagName('pre')[0]; 4732 var b = doc.getElementsByTagName('body')[0]; 4733 if (pre) { 4734 xhr.responseText = pre.textContent ? pre.textContent : pre.innerText; 4735 } 4736 else if (b) { 4737 xhr.responseText = b.textContent ? b.textContent : b.innerText; 4738 } 4739 } 4740 } 4741 else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) { 4742 xhr.responseXML = toXml(xhr.responseText); 4743 } 4744 4745 try { 4746 data = httpData(xhr, dt, s); 4747 } 4748 catch (err) { 4749 status = 'parsererror'; 4750 xhr.error = errMsg = (err || status); 4751 } 4752 } 4753 catch (err) { 4754 log('error caught: ', err); 4755 status = 'error'; 4756 xhr.error = errMsg = (err || status); 4757 } 4758 4759 if (xhr.aborted) { 4760 log('upload aborted'); 4761 status = null; 4762 } 4763 4764 if (xhr.status) { // we've set xhr.status 4765 status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error'; 4766 } 4767 4768 // ordering of these callbacks/triggers is odd, but that's how $.ajax does it 4769 if (status === 'success') { 4770 if (s.success) 4771 s.success.call(s.context, data, 'success', xhr); 4772 deferred.resolve(xhr.responseText, 'success', xhr); 4773 if (g) 4774 $.event.trigger("ajaxSuccess", [xhr, s]); 4775 } 4776 else if (status) { 4777 if (errMsg === undefined) 4778 errMsg = xhr.statusText; 4779 if (s.error) 4780 s.error.call(s.context, xhr, status, errMsg); 4781 deferred.reject(xhr, 'error', errMsg); 4782 if (g) 4783 $.event.trigger("ajaxError", [xhr, s, errMsg]); 4784 } 4785 4786 if (g)
4787 $.event.trigger("ajaxComplete", [xhr, s]); 4788 4789 if (g && !--$.active) { 4790 $.event.trigger("ajaxStop"); 4791 } 4792 4793 if (s.complete) 4794 s.complete.call(s.context, xhr, status); 4795 4796 callbackProcessed = true; 4797 if (s.timeout) 4798 clearTimeout(timeoutHandle); 4799 4800 // clean up 4801 setTimeout(function () { 4802 if (!s.iframeTarget) 4803 $io.remove(); 4804 else //adding else to clean up existing iframe response. 4805 $io.attr('src', s.iframeSrc); 4806 xhr.responseXML = null; 4807 }, 100); 4808 } 4809 4810 var toXml = $.parseXML || function (s, doc) { // use parseXML if available (jQuery 1.5+) 4811 if (window.ActiveXObject) { 4812 doc = new ActiveXObject('Microsoft.XMLDOM'); 4813 doc.async = 'false'; 4814 doc.loadXML(s); 4815 } 4816 else { 4817 doc = (new DOMParser()).parseFromString(s, 'text/xml'); 4818 } 4819 return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null; 4820 }; 4821 var parseJSON = $.parseJSON || function (s) { 4822 /*jslint evil:true */ 4823 return window['eval']('(' + s + ')'); 4824 }; 4825 4826 var httpData = function (xhr, type, s) { // mostly lifted from jq1.4.4 4827 4828 var ct = xhr.getResponseHeader('content-type') || '', 4829 xml = type === 'xml' || !type && ct.indexOf('xml') >= 0, 4830 data = xml ? xhr.responseXML : xhr.responseText; 4831 4832 if (xml && data.documentElement.nodeName === 'parsererror') { 4833 if ($.error) 4834 $.error('parsererror'); 4835 } 4836 if (s && s.dataFilter) { 4837 data = s.dataFilter(data, type); 4838 } 4839 if (typeof data === 'string') { 4840 if (type === 'json' || !type && ct.indexOf('json') >= 0) { 4841 data = parseJSON(data); 4842 } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) { 4843 $.globalEval(data); 4844 } 4845 } 4846 return data; 4847 }; 4848 4849 return deferred; 4850 } 4851 }; 4852 4853 /** 4854 * ajaxForm() provides a mechanism for fully automating form submission. 4855 * 4856 * The advantages of using this method instead of ajaxSubmit() are: 4857 * 4858 * 1: This method will include coordinates for <input type="image" /> elements (if the element 4859 * is used to submit the form). 4860 * 2. This method will include the submit element's name/value data (for the element that was 4861 * used to submit the form). 4862 * 3. This method binds the submit() method to the form for you. 4863 * 4864 * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely 4865 * passes the options argument along after properly binding events for submit elements and 4866 * the form itself. 4867 */ 4868 $.fn.ajaxForm = function (options) { 4869 options = options || {}; 4870 options.delegation = options.delegation && $.isFunction($.fn.on); 4871 4872 // in jQuery 1.3+ we can fix mistakes with the ready state 4873 if (!options.delegation && this.length === 0) { 4874 var o = { s: this.selector, c: this.context }; 4875 if (!$.isReady && o.s) { 4876 log('DOM not ready, queuing ajaxForm'); 4877 $(function () { 4878 $(o.s, o.c).ajaxForm(options); 4879 }); 4880 return this; 4881 } 4882 // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() 4883 log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); 4884 return this; 4885 } 4886 4887 if (options.delegation) { 4888 $(document) 4889 .off('submit.form-plugin', this.selector, doAjaxSubmit) 4890 .off('click.form-plugin', this.selector, captureSubmittingElement) 4891 .on('submit.form-plugin', this.selector, options, doAjaxSubmit) 4892 .on('click.form-plugin', this.selector, options, captureSubmittingElement); 4893 return this; 4894 } 4895 4896 return this.ajaxFormUnbind() 4897 .bind('submit.form-plugin', options, doAjaxSubmit) 4898 .bind('click.form-plugin', options, captureSubmittingElement); 4899 }; 4900 4901 // private event handlers 4902 function doAjaxSubmit(e) { 4903 /*jshint validthis:true */ 4904 var options = e.data; 4905 if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed 4906 e.preventDefault(); 4907 $(e.target).ajaxSubmit(options); // #365 4908 } 4909 } 4910 4911 function captureSubmittingElement(e) { 4912 /*jshint validthis:true */ 4913 var target = e.target; 4914 var $el = $(target); 4915 if (!($el.is("[type=submit],[type=image]"))) { 4916 // is this a child element of the submit el? (ex: a span within a button) 4917 var t = $el.closest('[type=submit]'); 4918 if (t.length === 0) { 4919 return; 4920 } 4921 target = t[0]; 4922 } 4923 var form = this; 4924 form.clk = target; 4925 if (target.type == 'image') { 4926 if (e.offsetX !== undefined) { 4927 form.clk_x = e.offsetX; 4928 form.clk_y = e.offsetY; 4929 } else if (typeof $.fn.offset == 'function') { 4930 var offset = $el.offset(); 4931 form.clk_x = e.pageX - offset.left; 4932 form.clk_y = e.pageY - offset.top; 4933 } else { 4934 form.clk_x = e.pageX - target.offsetLeft; 4935 form.clk_y = e.pageY - target.offsetTop; 4936 } 4937 } 4938 // clear form vars 4939 setTimeout(function () { 4940 form.clk = form.clk_x = form.clk_y = null; 4941 }, 100); 4942 } 4943 4944 4945 // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm 4946 $.fn.ajaxFormUnbind = function () { 4947 return this.unbind('submit.form-plugin click.form-plugin'); 4948 }; 4949 4950 /** 4951 * formToArray() gathers form element data into an array of objects that can 4952 * be passed to any of the following ajax functions: $.get, $.post, or load. 4953 * Each object in the array has both a 'name' and 'value' property. An example of 4954 * an array for a simple login form might be: 4955 * 4956 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] 4957 * 4958 * It is this array that is passed to pre-submit callback functions provided to the 4959 * ajaxSubmit() and ajaxForm() methods. 4960 */ 4961 $.fn.formToArray = function (semantic, elements) { 4962 var a = []; 4963 if (this.length === 0) { 4964 return a; 4965 } 4966 4967 var form = this[0]; 4968 var els = semantic ? form.getElementsByTagName('*') : form.elements; 4969 if (!els) { 4970 return a; 4971 } 4972 4973 var i, j, n, v, el, max, jmax; 4974 for (i = 0, max = els.length; i < max; i++) { 4975 el = els[i]; 4976 n = el.name; 4977 if (!n || el.disabled) { 4978 continue; 4979 } 4980 4981 if (semantic && form.clk && el.type == "image") { 4982 // handle image inputs on the fly when semantic == true 4983 if (form.clk == el) { 4984 a.push({ name: n, value: $(el).val(), type: el.type }); 4985 a.push({ name: n + '.x', value: form.clk_x }
4985, { name: n + '.y', value: form.clk_y }); 4986 } 4987 continue; 4988 } 4989 4990 v = $.fieldValue(el, true); 4991 if (v && v.constructor == Array) { 4992 if (elements) 4993 elements.push(el); 4994 for (j = 0, jmax = v.length; j < jmax; j++) { 4995 a.push({ name: n, value: v[j] }); 4996 } 4997 } 4998 else if (feature.fileapi && el.type == 'file') { 4999 if (elements) 5000 elements.push(el); 5001 var files = el.files; 5002 if (files.length) { 5003 for (j = 0; j < files.length; j++) { 5004 a.push({ name: n, value: files[j], type: el.type }); 5005 } 5006 } 5007 else { 5008 // #180 5009 a.push({ name: n, value: '', type: el.type }); 5010 } 5011 } 5012 else if (v !== null && typeof v != 'undefined') { 5013 if (elements) 5014 elements.push(el); 5015 a.push({ name: n, value: v, type: el.type, required: el.required }); 5016 } 5017 } 5018 5019 if (!semantic && form.clk) { 5020 // input type=='image' are not found in elements array! handle it here 5021 var $input = $(form.clk), input = $input[0]; 5022 n = input.name; 5023 if (n && !input.disabled && input.type == 'image') { 5024 a.push({ name: n, value: $input.val() }); 5025 a.push({ name: n + '.x', value: form.clk_x }, { name: n + '.y', value: form.clk_y }); 5026 } 5027 } 5028 return a; 5029 }; 5030 5031 /** 5032 * Serializes form data into a 'submittable' string. This method will return a string 5033 * in the format: name1=value1&name2=value2 5034 */ 5035 $.fn.formSerialize = function (semantic) { 5036 //hand off to jQuery.param for proper encoding 5037 return $.param(this.formToArray(semantic)); 5038 }; 5039 5040 /** 5041 * Serializes all field elements in the jQuery object into a query string. 5042 * This method will return a string in the format: name1=value1&name2=value2 5043 */ 5044 $.fn.fieldSerialize = function (successful) { 5045 var a = []; 5046 this.each(function () { 5047 var n = this.name; 5048 if (!n) { 5049 return; 5050 } 5051 var v = $.fieldValue(this, successful); 5052 if (v && v.constructor == Array) { 5053 for (var i = 0, max = v.length; i < max; i++) { 5054 a.push({ name: n, value: v[i] }); 5055 } 5056 } 5057 else if (v !== null && typeof v != 'undefined') { 5058 a.push({ name: this.name, value: v }); 5059 } 5060 }); 5061 //hand off to jQuery.param for proper encoding 5062 return $.param(a); 5063 }; 5064 5065 /** 5066 * Returns the value(s) of the element in the matched set. For example, consider the following form: 5067 * 5068 * <form><fieldset> 5069 * <input name="A" type="text" /> 5070 * <input name="A" type="text" /> 5071 * <input name="B" type="checkbox" value="B1" /> 5072 * <input name="B" type="checkbox" value="B2"/> 5073 * <input name="C" type="radio" value="C1" /> 5074 * <input name="C" type="radio" value="C2" /> 5075 * </fieldset></form> 5076 * 5077 * var v = $('input[type=text]').fieldValue(); 5078 * // if no values are entered into the text inputs 5079 * v == ['',''] 5080 * // if values entered into the text inputs are 'foo' and 'bar' 5081 * v == ['foo','bar'] 5082 * 5083 * var v = $('input[type=checkbox]').fieldValue(); 5084 * // if neither checkbox is checked 5085 * v === undefined 5086 * // if both checkboxes are checked 5087 * v == ['B1', 'B2'] 5088 * 5089 * var v = $('input[type=radio]').fieldValue(); 5090 * // if neither radio is checked 5091 * v === undefined 5092 * // if first radio is checked 5093 * v == ['C1'] 5094 * 5095 * The successful argument controls whether or not the field element must be 'successful' 5096 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-control
5096s). 5097 * The default value of the successful argument is true. If this value is false the value(s) 5098 * for each element is returned. 5099 * 5100 * Note: This method *always* returns an array. If no valid value can be determined the 5101 * array will be empty, otherwise it will contain one or more values. 5102 */ 5103 $.fn.fieldValue = function (successful) { 5104 for (var val = [], i = 0, max = this.length; i < max; i++) { 5105 var el = this[i]; 5106 var v = $.fieldValue(el, successful); 5107 if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) { 5108 continue; 5109 } 5110 if (v.constructor == Array) 5111 $.merge(val, v); 5112 else 5113 val.push(v); 5114 } 5115 return val; 5116 }; 5117 5118 /** 5119 * Returns the value of the field element. 5120 */ 5121 $.fieldValue = function (el, successful) { 5122 var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); 5123 if (successful === undefined) { 5124 successful = true; 5125 } 5126 5127 if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || 5128 (t == 'checkbox' || t == 'radio') && !el.checked || 5129 (t == 'submit' || t == 'image') && el.form && el.form.clk != el || 5130 tag == 'select' && el.selectedIndex == -1)) { 5131 return null; 5132 } 5133 5134 if (tag == 'select') { 5135 var index = el.selectedIndex; 5136 if (index < 0) { 5137 return null; 5138 } 5139 var a = [], ops = el.options; 5140 var one = (t == 'select-one'); 5141 var max = (one ? index + 1 : ops.length); 5142 for (var i = (one ? index : 0); i < max; i++) { 5143 var op = ops[i]; 5144 if (op.selected) { 5145 var v = op.value; 5146 if (!v) { // extra pain for IE... 5147 v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; 5148 } 5149 if (one) { 5150 return v; 5151 } 5152 a.push(v); 5153 } 5154 } 5155 return a; 5156 } 5157 return $(el).val(); 5158 }; 5159 5160 /** 5161 * Clears the form data. Takes the following actions on the form's input fields: 5162 * - input text fields will have their 'value' property set to the empty string 5163 * - select elements will have their 'selectedIndex' property set to -1 5164 * - checkbox and radio inputs will have their 'checked' property set to false 5165 * - inputs of type submit, button, reset, and hidden will *not* be effected 5166 * - button elements will *not* be effected 5167 */ 5168 $.fn.clearForm = function (includeHidden) { 5169 return this.each(function () { 5170 $('input,select,textarea', this).clearFields(includeHidden); 5171 }); 5172 }; 5173 5174 /** 5175 * Clears the selected form elements. 5176 */ 5177 $.fn.clearFields = $.fn.clearInputs = function (includeHidden) { 5178 var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list 5179 return this.each(function () { 5180 var t = this.type, tag = this.tagName.toLowerCase(); 5181 if (re.test(t) || tag == 'textarea') { 5182 this.value = ''; 5183 } 5184 else if (t == 'checkbox' || t == 'radio') { 5185 this.checked = false; 5186 } 5187 else if (tag == 'select') { 5188 this.selectedIndex = -1; 5189 } 5190 else if (t == "file") { 5191 if (/MSIE/.test(navigator.userAgent)) { 5192 $(this).replaceWith($(this).clone(true)); 5193 } else { 5194 $(this).val(''); 5195 } 5196 } 5197 else if (includeHidden) { 5198 // includeHidden can be the value true, or it can be a selector string 5199 // indicating a special test; for example: 5200 // $('#myForm').clearForm('.special:hidden')
5201 // the above would clean hidden inputs that have the class of 'special' 5202 if ((includeHidden === true && /hidden/.test(t)) || 5203 (typeof includeHidden == 'string' && $(this).is(includeHidden))) 5204 this.value = ''; 5205 } 5206 }); 5207 }; 5208 5209 /** 5210 * Resets the form data. Causes all form elements to be reset to their original value. 5211 */ 5212 $.fn.resetForm = function () { 5213 return this.each(function () { 5214 // guard against an input with the name of 'reset' 5215 // note that IE reports the reset function as an 'object' 5216 if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) { 5217 this.reset(); 5218 } 5219 }); 5220 }; 5221 5222 /** 5223 * Enables or disables any matching elements. 5224 */ 5225 $.fn.enable = function (b) { 5226 if (b === undefined) { 5227 b = true; 5228 } 5229 return this.each(function () { 5230 this.disabled = !b; 5231 }); 5232 }; 5233 5234 /** 5235 * Checks/unchecks any matching checkboxes or radio buttons and 5236 * selects/deselects and matching option elements. 5237 */ 5238 $.fn.selected = function (select) { 5239 if (select === undefined) { 5240 select = true; 5241 } 5242 return this.each(function () { 5243 var t = this.type; 5244 if (t == 'checkbox' || t == 'radio') { 5245 this.checked = select; 5246 } 5247 else if (this.tagName.toLowerCase() == 'option') { 5248 var $sel = $(this).parent('select'); 5249 if (select && $sel[0] && $sel[0].type == 'select-one') { 5250 // deselect all other options 5251 $sel.find('option').selected(false); 5252 } 5253 this.selected = select; 5254 } 5255 }); 5256 }; 5257 5258 // expose debug var 5259 $.fn.ajaxSubmit.debug = false; 5260 5261 // helper fn for console logging 5262 function log() { 5263 if (!$.fn.ajaxSubmit.debug) 5264 return; 5265 var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, ''); 5266 if (window.console && window.console.log) { 5267 window.console.log(msg); 5268 } 5269 else if (window.opera && window.opera.postError) { 5270 window.opera.postError(msg); 5271 } 5272 } 5273 5274 })); 5275 5276; 5277; 5278!function (name, context, definition) { 5279 if (typeof module !== 'undefined') 5280 module.exports = definition(name, context) 5281 else if (typeof define === 'function' && typeof define.amd === 'object') 5282 define(definition) 5283 else 5284 context[name] = definition(name, context) 5285}('humane', this, function (name, context) { 5286 var win = window 5287 var doc = document 5288 5289 var ENV = { 5290 on: function (el, type, cb) { 5291 'addEventListener' in win ? el.addEventListener(type, cb, false) : el.attachEvent('on' + type, cb) 5292 }, 5293 off: function (el, type, cb) { 5294 'removeEventListener' in win ? el.removeEventListener(type, cb, false) : el.detachEvent('on' + type, cb) 5295 }, 5296 bind: function (fn, ctx) { 5297 return function () { 5298 fn.apply(ctx, arguments) 5299 } 5300 }, 5301 isArray: Array.isArray || function (obj) { 5302 return Object.prototype.toString.call(obj) === '[object Array]' 5303 }, 5304 config: function (preferred, fallback) { 5305 return preferred != null ? preferred : fallback 5306 }, 5307 transSupport: false, 5308 useFilter: /msie [678]/i.test(navigator.userAgent), // sniff, sniff 5309 _checkTransition: function () { 5310 var el = doc.createElement('div') 5311 var vendors = { webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' } 5312 5313 for (var vendor in vendors) 5314 if (vendor + 'Transition' in el.style) {
5315 this.vendorPrefix = vendors[vendor] 5316 this.transSupport = true 5317 } 5318 } 5319 } 5320 ENV._checkTransition() 5321 5322 var Humane = function (o) { 5323 o || (o = {}) 5324 this.queue = [] 5325 this.baseCls = o.baseCls || 'humane' 5326 this.addnCls = o.addnCls || '' 5327 this.timeout = 'timeout' in o ? o.timeout : 2500 5328 this.waitForMove = o.waitForMove || false 5329 this.clickToClose = o.clickToClose || false 5330 this.timeoutAfterMove = o.timeoutAfterMove || false 5331 this.container = o.container 5332 5333 try { 5334 this._setupEl() 5335 } // attempt to setup elements 5336 catch (e) { 5337 ENV.on(win, 'load', ENV.bind(this._setupEl, this)) // dom wasn't ready, wait till ready 5338 } 5339 } 5340 5341 Humane.prototype = { 5342 constructor: Humane, 5343 _setupEl: function () { 5344 var el = doc.createElement('div') 5345 el.style.display = 'none' 5346 if (!this.container) { 5347 if (doc.body) 5348 this.container = doc.body; 5349 else 5350 throw 'document.body is null' 5351 } 5352 this.container.appendChild(el) 5353 this.el = el 5354 this.removeEvent = ENV.bind(function () { 5355 var timeoutAfterMove = ENV.config(this.currentMsg.timeoutAfterMove, this.timeoutAfterMove) 5356 if (!timeoutAfterMove) { 5357 this.remove() 5358 } else { 5359 setTimeout(ENV.bind(this.remove, this), timeoutAfterMove) 5360 } 5361 }, this) 5362 5363 this.transEvent = ENV.bind(this._afterAnimation, this) 5364 this._run() 5365 }, 5366 _afterTimeout: function () { 5367 if (!ENV.config(this.currentMsg.waitForMove, this.waitForMove)) 5368 this.remove() 5369 5370 else if (!this.removeEventsSet) { 5371 ENV.on(doc.body, 'mousemove', this.removeEvent) 5372 ENV.on(doc.body, 'click', this.removeEvent) 5373 ENV.on(doc.body, 'keypress', this.removeEvent) 5374 ENV.on(doc.body, 'touchstart', this.removeEvent) 5375 this.removeEventsSet = true 5376 } 5377 }, 5378 _run: function () { 5379 if (this._animating || !this.queue.length || !this.el) 5380 return 5381 5382 this._animating = true 5383 if (this.currentTimer) { 5384 clearTimeout(this.currentTimer) 5385 this.currentTimer = null 5386 } 5387 5388 var msg = this.queue.shift() 5389 var clickToClose = ENV.config(msg.clickToClose, this.clickToClose) 5390 5391 if (clickToClose) { 5392 ENV.on(this.el, 'click', this.removeEvent) 5393 ENV.on(this.el, 'touchstart', this.removeEvent) 5394 } 5395 5396 var timeout = ENV.config(msg.timeout, this.timeout) 5397 5398 if (timeout > 0) 5399 this.currentTimer = setTimeout(ENV.bind(this._afterTimeout, this), timeout) 5400 5401 if (ENV.isArray(msg.html)) 5402 msg.html = '<ul><li>' + msg.html.join('<li>') + '</ul>' 5403 5404 this.el.innerHTML = msg.html 5405 this.currentMsg = msg 5406 this.el.className = this.baseCls 5407 if (ENV.transSupport) { 5408 this.el.style.display = 'block' 5409 setTimeout(ENV.bind(this._showMsg, this), 50) 5410 } else { 5411 this._showMsg() 5412 } 5413 setTimeout(ENV.bind(this._showTimer, this), 800) 5414 5415 }, 5416 _setOpacity: function (opacity) { 5417 if (ENV.useFilter) { 5418 try { 5419 this.el.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = opacity * 100 5420 } catch (err) { 5421 } 5422 } else { 5423 this.el.style.opacity = String(opacity) 5424 } 5425 }, 5426 _showTimer: function () { 5427 this.el 5428 }, 5429 _showMsg: function () { 5430 var addnCls = ENV.config(this.currentMsg.addnCls, this.addnCls) 5431 if (ENV.transSupport) { 5432 this.el.className = this.baseCls + ' ' + addnCls + ' ' + this.baseCls + '-animate' 5433 } 5434 else { 5435 var opacity = 0 5436 this.el.className = this.baseCls + ' ' + addnCls + ' ' + this.baseCls + '-js-animate' 5437 this._setOpacity(0) // reset value so hover states work 5438 this.el.style.display = 'block' 5439 5440 var self = this 5441 var interval = setInterval(function () { 5442 if (opacity < 1) { 5443 opacity += 0.1 5444 if (opacity > 1) 5445 opacity = 1 5446 self._setOpacity(opacity) 5447 } 5448 else 5449 clearInterval(interval) 5450 }, 30) 5451 } 5452 }, 5453 _hideMsg: function () { 5454 var addnCls = ENV.config(this.currentMsg.addnCls, this.addnCls) 5455 if (ENV.transSupport) { 5456 this.el.className = this.baseCls + ' ' + addnCls 5457 ENV.on(this.el, ENV.vendorPrefix ? ENV.vendorPrefix + 'TransitionEnd' : 'transitionend', this.transEvent) 5458 } 5459 else { 5460 var opacity = 1 5461 var self = this 5462 var interval = setInterval(function () { 5463 if (opacity > 0) { 5464 opacity -= 0.1 5465 if (opacity < 0) 5466 opacity = 0 5467 self._setOpacity(opacity); 5468 } 5469 else { 5470 self.el.className = self.baseCls + ' ' + addnCls 5471 clearInterval(interval) 5472 self._afterAnimation() 5473 } 5474 }, 30) 5475 } 5476 }, 5477 _afterAnimation: function () { 5478 if (ENV.transSupport) 5479 ENV.off(this.el, ENV.vendorPrefix ? ENV.vendorPrefix + 'TransitionEnd' : 'transitionend', this.transEvent) 5480 5481 if (this.currentMsg.cb) 5482 this.currentMsg.cb() 5483 this.el.style.display = 'none' 5484 5485 this._animating = false 5486 this._run() 5487 }, 5488 remove: function (e) { 5489 var cb = typeof e == 'function' ? e : null 5490 5491 ENV.off(doc.body, 'mousemove', this.removeEvent) 5492 ENV.off(doc.body, 'click', this.removeEvent) 5493 ENV.off(doc.body, 'keypress', this.removeEvent) 5494 ENV.off(doc.body, 'touchstart', this.removeEvent) 5495 ENV.off(this.el, 'click', this.removeEvent) 5496 ENV.off(this.el, 'touchstart', this.removeEvent) 5497 this.removeEventsSet = false 5498 5499 if (cb && this.currentMsg) 5500 this.currentMsg.cb = cb 5501 if (this._animating) 5502 this._hideMsg() 5503 else if (cb) 5504 cb() 5505 }, 5506 log: function (html, o, cb, defaults) { 5507 var msg = {} 5508 if (defaults) 5509 for (var opt in defaults) 5510 msg[opt] = defaults[opt] 5511 5512 if (typeof o == 'function') 5513 cb = o 5514 else if (o) 5515 for (var opt in o) 5516 msg[opt] = o[opt] 5517 5518 msg.html = html 5519 if (cb) 5520 msg.cb = cb 5521 this.queue.push(msg) 5522 this._run() 5523 return this 5524 }, 5525 spawn: function (defaults) { 5526 var self = this 5527 return function (html, o, cb) { 5528 self.log.call(self, html, o, cb, defaults) 5529 return self 5530 } 5531 }, 5532 create: function (o) { 5533 return new Humane(o) 5534 } 5535 } 5536 return new Humane() 5537}); 5538; 5539+(function (window, $, undefined) { 5540 'use strict'; 5541 5542 var support = { 5543 calc: false 5544 }; 5545 5546 /* 5547 * Public Function 5548 */ 5549 5550 $.fn.rrssb = function (options) { 5551 5552 // Settings that $.rrssb() will accept. 5553 var settings = $.extend({ 5554 description: undefined, 5555 emailAddress: undefined, 5556 emailBody: undefined, 5557 emailSubject: undefined, 5558 image: undefined, 5559 title: undefined, 5560 url: undefined 5561 }, options); 5562 5563 // use some sensible defaults if they didn't specify email settings 5564 settings.emailSubject = settings.emailSubject || settings.title; 5565 settings.emailBody = settings.emailBody || 5566 (
5567 (settings.description ? settings.description : '') + 5568 (settings.url ? '\n\n' + settings.url : '') 5569 ); 5570 5571 // Return the encoded strings if the settings have been changed. 5572 for (var key in settings) { 5573 if (settings.hasOwnProperty(key) && settings[key] !== undefined) { 5574 settings[key] = encodeString(settings[key]); 5575 } 5576 } 5577 ; 5578 5579 if (settings.url !== undefined) { 5580 $(this).find('.rrssb-facebook a').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + settings.url); 5581 $(this).find('.rrssb-tumblr a').attr('href', 'http://tumblr.com/share/link?url=' + settings.url + (settings.title !== undefined ? '&name=' + settings.title : '') + (settings.description !== undefined ? '&description=' + settings.description : '')); 5582 $(this).find('.rrssb-linkedin a').attr('href', 'http://www.linkedin.com/shareArticle?mini=true&url=' + settings.url + (settings.title !== undefined ? '&title=' + settings.title : '') + (settings.description !== undefined ? '&summary=' + settings.description : '')); 5583 $(this).find('.rrssb-twitter a').attr('href', 'https://twitter.com/intent/tweet?text=' + (settings.description !== undefined ? settings.description : '') + '%20' + settings.url); 5584 $(this).find('.rrssb-hackernews a').attr('href', 'https://news.ycombinator.com/submitlink?u=' + settings.url + (settings.title !== undefined ? '&text=' + settings.title : '')); 5585 $(this).find('.rrssb-reddit a').attr('href', 'http://www.reddit.com/submit?url=' + settings.url + (settings.description !== undefined ? '&text=' + settings.description : '') + (settings.title !== undefined ? '&title=' + settings.title : '')); 5586 $(this).find('.rrssb-googleplus a').attr('href', 'https://plus.google.com/share?url=' + (settings.description !== undefined ? settings.description : '') + '%20' + settings.url); 5587 $(this).find('.rrssb-pinterest a').attr('href', 'http://pinterest.com/pin/create/button/?url=' + settings.url + ((settings.image !== undefined) ? '&media=' + settings.image : '') + (settings.description !== undefined ? '&description=' + settings.description : '')); 5588 $(this).find('.rrssb-pocket a').attr('href', 'https://getpocket.com/save?url=' + settings.url); 5589 $(this).find('.rrssb-github a').attr('href', settings.url); 5590 $(this).find('.rrssb-print a').attr('href', 'javascript:window.print()'); 5591 $(this).find('.rrssb-whatsapp a').attr('href', 'whatsapp://send?text=' + (settings.description !== undefined ? settings.description + '%20' : (settings.title !== undefined ? settings.title + '%20' : '')) + settings.url); 5592 } 5593 5594 if (settings.emailAddress !== undefined || settings.emailSubject) { 5595 $(this).find('.rrssb-email a').attr('href', 'mailto:' + (settings.emailAddress ? settings.emailAddress : '') + '?' + (settings.emailSubject !== undefined ? 'subject=' + settings.emailSubject : '') + (settings.emailBody !== undefined ? '&body=' + settings.emailBody : '')); 5596 } 5597 5598 }; 5599 5600 /* 5601 * Utility functions 5602 */ 5603 var detectCalcSupport = function () { 5604 //detect if calc is natively supported. 5605 var el = $('<div>'); 5606 var calcProps = [ 5607 'calc', 5608 '-webkit-calc', 5609 '-moz-calc' 5610 ]; 5611 5612 $('body').append(el); 5613 5614 for (var i = 0; i < calcProps.length; i++) { 5615 el.css('width', calcProps[i] + '(1px)'); 5616 if (el.width() === 1) { 5617 support.calc = calcProps[i]; 5618 break; 5619 } 5620 } 5621 5622 el.remove(); 5623 }; 5624 5625 var encodeString = function (string) { 5626 // Recursively decode string first to ensure we aren't double encoding. 5627 if (string !== undefined && string !== null) { 5628 if (string.match(/%[0-9a-f]{2}/i) !== null) { 5629 string = decodeURIComponent(string); 5630 encodeString(string); 5631 } else { 5632 return encodeURIComponent(string); 5633 } 5634 } 5635 }; 5636 5637 var setPercentBtns = function () { 5638 // loop through each instance of buttons 5639 $('.rrssb-buttons').each(function (index) { 5640 var self = $(this); 5641 var buttons = $('li:visible', self); 5642 var numOfButtons = buttons.length; 5643 var initBtnWidth = 100 / numOfButtons; 5644 5645 // set initial width of buttons 5646 buttons.css('width', initBtnWidth + '%').attr('data-initwidth', initBtnWidth); 5647 }); 5648 }; 5649 5650 var makeExtremityBtns = function () { 5651 // loop through each instance of buttons 5652 $('.rrssb-buttons').each(function (index) { 5653 var self = $(this); 5654 //get button width 5655 var containerWidth = self.width(); 5656 var buttonWidth = $('li', self).not('.small').eq(0).width(); 5657 var buttonCountSmall = $('li.small', self).length; 5658 5659 // enlarge buttons if they get wide enough 5660 if (buttonWidth > 170 && buttonCountSmall < 1) { 5661 self.addClass('large-format'); 5662 var fontSize = buttonWidth / 12 + 'px'; 5663 self.css('font-size', fontSize); 5664 } else { 5665 self.removeClass('large-format'); 5666 self.css('font-size', ''); 5667 } 5668 5669 if (containerWidth < buttonCountSmall * 25) { 5670 self.removeClass('small-format').addClass('tiny-format'); 5671 } else { 5672 self.removeClass('tiny-format'); 5673 } 5674 }); 5675 }; 5676 5677 var backUpFromSmall = function () { 5678 // loop through each instance of buttons 5679 $('.rrssb-buttons').each(function (index) { 5680 var self = $(this); 5681 5682 var buttons = $('li', self); 5683 var smallButtons = buttons.filter('.small'); 5684 var totalBtnSze = 0; 5685 var totalTxtSze = 0; 5686 var upCandidate = smallButtons.eq(0); 5687 var nextBackUp = parseFloat(upCandidate.attr('data-size')) + 55; 5688 var smallBtnCount = smallButtons.length; 5689 5690 if (smallBtnCount === buttons.length) { 5691 var btnCalc = smallBtnCount * 42; 5692 var containerWidth = self.width(); 5693 5694 if ((btnCalc + nextBackUp) < containerWidth) { 5695 self.removeClass('small-format'); 5696 smallButtons.eq(0).removeClass('small'); 5697 5698 sizeSmallBtns(); 5699 } 5700 5701 } else { 5702 buttons.not('.small').each(function (index) { 5703 var button = $(this); 5704 var txtWidth = parseFloat(button.attr('data-size')) + 55; 5705 var btnWidth = parseFloat(button.width()); 5706 5707 totalBtnSze = totalBtnSze + btnWidth; 5708 totalTxtSze = totalTxtSze + txtWidth; 5709 }); 5710 5711 var spaceLeft = totalBtnSze - totalTxtSze; 5712 5713 if (nextBackUp < spaceLeft) { 5714 upCandidate.removeClass('small'); 5715 sizeSmallBtns(); 5716 } 5717 } 5718 }); 5719 }; 5720 5721 var checkSize = function (init) { 5722 // loop through each instance of buttons 5723 $('.rrssb-buttons').each(function (index) { 5724 5725 var self = $(this); 5726 var buttons = $('li', self); 5727 5728 // get buttons in reverse order and loop through each 5729 $(buttons.get().reverse()).each(function (index, count) { 5730 5731 var button = $(this); 5732 5733 if (button.hasClass('small') === false) { 5734 var txtWidth = parseFloat(button.attr('data-size')) + 55; 5735 var btnWidth = parseFloat(button.width()); 5736 5737 if (txtWidth > btnWidth) { 5738 var btn2small = buttons.not('.small').last(); 5739 $(btn2small).addClass('small'); 5740 sizeSmallBtns(); 5741 } 5742 } 5743 5744 if (!--count) 5745 backUpFromSmall(); 5746 }); 5747 }); 5748 5749 // if first time running, put it through the magic layout 5750 if (init === true) { 5751 rrssbMagicLayout(sizeSmallBtns); 5752 } 5753 }; 5754 5755 var sizeSmallBtns = function () { 5756 // loop through each instance of buttons 5757 $('.rrssb-buttons').each(function (index) { 5758 var self = $(this); 5759 var regButtonCount; 5760 var regPercent; 5761 var pixelsOff; 5762 var magicWidth; 5763 var smallBtnFraction; 5764 var buttons = $('li', self); 5765 var smallButtons = buttons.filter('.small'); 5766 5767 // readjust buttons for small display 5768 var smallBtnCount = smallButtons.length; 5769 5770 // make sure there are small buttons 5771 if (smallBtnCount > 0 && smallBtnCount !== buttons.length) { 5772 self.removeClass('small-format'); 5773 5774 //make sure small buttons are square when not all small 5775 smallButtons.css('width', '42px'); 5776 pixelsOff = smallBtnCount * 42; 5777 regButtonCount = buttons.not('.small').length; 5778 regPercent = 100 / regButtonCount; 5779 smallBtnFraction = pixelsOff / regButtonCount; 5780 5781 // if calc is not supported. calculate the width on the fly. 5782 if (support.calc === false) { 5783 magicWidth = ((self.innerWidth() - 1) / regButtonCount) - smallBtnFraction; 5784 magicWidth = Math.floor(magicWidth * 1000) / 1000; 5785 magicWidth += 'px'; 5786 } else { 5787 magicWidth = support.calc + '(' + regPercent + '% - ' + smallBtnFraction + 'px)'; 5788 } 5789 5790 buttons.not('.small').css('width', magicWidth); 5791 5792 } else if (smallBtnCount === buttons.length) { 5793 // if all buttons are small, change back to percentage 5794 self.addClass('small-format'); 5795 setPercentBtns(); 5796 } else { 5797 self.removeClass('small-format'); 5798 setPercentBtns(); 5799 } 5800 }); //end loop 5801 5802 makeExtremityBtns(); 5803 }; 5804 5805 var rrssbInit = function () { 5806 $('.rrssb-buttons').each(function (index) { 5807 $(this).addClass('rrssb-' + (index + 1)); 5808 }); 5809 5810 detectCalcSupport(); 5811 5812 setPercentBtns(); 5813 5814 // grab initial text width of each button and add as data attr
5815 $('.rrssb-buttons li .rrssb-text').each(function (index) { 5816 var buttonTxt = $(this); 5817 var txtWdth = buttonTxt.width(); 5818 buttonTxt.closest('li').attr('data-size', txtWdth); 5819 }); 5820 5821 checkSize(true); 5822 }; 5823 5824 var rrssbMagicLayout = function (callback) { 5825 //remove small buttons before each conversion try 5826 $('.rrssb-buttons li.small').removeClass('small'); 5827 5828 checkSize(); 5829 5830 callback(); 5831 }; 5832 5833 var popupCenter = function (url, title, w, h) { 5834 // Fixes dual-screen position Most browsers Firefox 5835 var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; 5836 var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; 5837 5838 var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; 5839 var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; 5840 5841 var left = ((width / 2) - (w / 2)) + dualScreenLeft; 5842 var top = ((height / 3) - (h / 3)) + dualScreenTop; 5843 5844 var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); 5845
5846 // Puts focus on the newWindow 5847 if (newWindow && newWindow.focus) { 5848 newWindow.focus(); 5849 } 5850 }; 5851 5852 var waitForFinalEvent = (function () { 5853 var timers = {}; 5854 return function (callback, ms, uniqueId) { 5855 if (!uniqueId) { 5856 uniqueId = "Don't call this twice without a uniqueId"; 5857 } 5858 if (timers[uniqueId]) { 5859 clearTimeout(timers[uniqueId]); 5860 } 5861 timers[uniqueId] = setTimeout(callback, ms); 5862 }; 5863 })(); 5864 5865 // init load 5866 $(document).ready(function () { 5867 5868 5869 /* 5870 * Event listners 5871 */ 5872 5873 try { 5874 $(document).on('click', '.rrssb-buttons a.popup', {}, function popUp(e) { 5875 var self = $(this); 5876 popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470); 5877 e.preventDefault(); 5878 }); 5879 } 5880 catch (e) { // catching this adds partial support for jQuery 1.3 5881 } 5882 5883 // resize function 5884 $(window).resize(function () { 5885 5886 rrssbMagicLayout(sizeSmallBtns); 5887 5888 waitForFinalEvent(function () { 5889 rrssbMagicLayout(sizeSmallBtns); 5890 }, 200, "finished resizing"); 5891 }); 5892 5893 rrssbInit(); 5894 }); 5895 5896 // Make global 5897 window.rrssbInit = rrssbInit; 5898 5899})(window, jQuery); 5900; 5901(function ($) { 5902 'use strict'; 5903 5904 var _currentSpinnerId = 0; 5905 5906 function _scopedEventName(name, id) { 5907 return name + '.touchspin_' + id; 5908 } 5909 5910 function _scopeEventNames(names, id) { 5911 return $.map(names, function (name) { 5912 return _scopedEventName(name, id); 5913 }); 5914 } 5915 5916 $.fn.TouchSpin = function (options) { 5917 5918 if (options === 'destroy') { 5919 this.each(function () { 5920 var originalinput = $(this), 5921 originalinput_data = originalinput.data(); 5922 $(document).off(_scopeEventNames([ 5923 'mouseup', 5924 'touchend', 5925 'touchcancel', 5926 'mousemove', 5927 'touchmove', 5928 'scroll', 5929 'scrollstart'], originalinput_data.spinnerid).join(' ')); 5930 }); 5931 return; 5932 } 5933 5934 var defaults = { 5935 min: 0, 5936 max: 100, 5937 initval: '', 5938 step: 1, 5939 decimals: 0, 5940 stepinterval: 100, 5941 forcestepdivisibility: 'round', // none | floor | round | ceil 5942 stepintervaldelay: 500,
5943 verticalbuttons: false, 5944 verticalupclass: 'glyphicon glyphicon-chevron-up', 5945 verticaldownclass: 'glyphicon glyphicon-chevron-down', 5946 prefix: '', 5947 postfix: '', 5948 prefix_extraclass: '', 5949 postfix_extraclass: '', 5950 booster: true, 5951 boostat: 10, 5952 maxboostedstep: false, 5953 mousewheel: true, 5954 buttondown_class: 'btn btn-default', 5955 buttonup_class: 'btn btn-default', 5956 buttondown_txt: '-', 5957 buttonup_txt: '+' 5958 }; 5959 5960 var attributeMap = { 5961 min: 'min', 5962 max: 'max', 5963 initval: 'init-val', 5964 step: 'step', 5965 decimals: 'decimals', 5966 stepinterval: 'step-interval', 5967 verticalbuttons: 'vertical-buttons', 5968 verticalupclass: 'vertical-up-class', 5969 verticaldownclass: 'vertical-down-class', 5970 forcestepdivisibility: 'force-step-divisibility', 5971 stepintervaldelay: 'step-interval-delay', 5972 prefix: 'prefix', 5973 postfix: 'postfix', 5974 prefix_extraclass: 'prefix-extra-class', 5975 postfix_extraclass: 'postfix-extra-class', 5976 booster: 'booster', 5977 boostat: 'boostat', 5978 maxboostedstep: 'max-boosted-step', 5979 mousewheel: 'mouse-wheel', 5980 buttondown_class: 'button-down-class', 5981 buttonup_class: 'button-up-class', 5982 buttondown_txt: 'button-down-txt', 5983 buttonup_txt: 'button-up-txt' 5984 }; 5985 5986 return this.each(function () { 5987 5988 var settings, 5989 originalinput = $(this), 5990 originalinput_data = originalinput.data(), 5991 container, 5992 elements, 5993 value, 5994 downSpinTimer, 5995 upSpinTimer, 5996 downDelayTimeout, 5997 upDelayTimeout, 5998 spincount = 0, 5999 spinning = false; 6000 6001 init(); 6002 6003 6004 function init() { 6005 if (originalinput.data('alreadyinitialized')) { 6006 return; 6007 } 6008 6009 originalinput.data('alreadyinitialized', true); 6010 _currentSpinnerId += 1; 6011 originalinput.data('spinnerid', _currentSpinnerId); 6012 6013 6014 if (!originalinput.is('input')) { 6015 console.log('Must be an input.'); 6016 return; 6017 } 6018 6019 _initSettings(); 6020 _setInitval(); 6021 _checkValue(); 6022 _buildHtml(); 6023 _initElements(); 6024 _hideEmptyPrefixPostfix(); 6025 _bindEvents(); 6026 _bindEventsInterface(); 6027 elements.input.css('display', 'block'); 6028 } 6029 6030 function _setInitval() { 6031 if (settings.initval !== '' && originalinput.val() === '') { 6032 originalinput.val(settings.initval); 6033 } 6034 } 6035 6036 function changeSettings(newsettings) { 6037 _updateSettings(newsettings); 6038 _checkValue(); 6039 6040 var value = elements.input.val(); 6041 6042 if (value !== '') { 6043 value = Number(elements.input.val()); 6044 elements.input.val(value.toFixed(settings.decimals)); 6045 } 6046 } 6047 6048 function _initSettings() { 6049 settings = $.extend({}, defaults, originalinput_data, _parseAttributes(), options); 6050 } 6051 6052 function _parseAttributes() { 6053 var data = {}; 6054 $.each(attributeMap, function (key, value) { 6055 var attrName = 'bts-' + value + ''; 6056 if (originalinput.is('[data-' + attrName + ']')) { 6057 data[key] = originalinput.data(attrName); 6058 } 6059 }); 6060 return data; 6061 } 6062 6063 function _updateSettings(newsettings) { 6064 settings = $.extend({}, settings, newsettings); 6065 } 6066 6067 function _buildHtml() { 6068 var initval = originalinput.val(), 6069 parentelement = originalinput.parent(); 6070 6071 if (initval !== '') { 6072 initval = Number(initval).toFixed(settings.decimals); 6073 } 6074 6075 originalinput.data('initvalue', initval).val(initval); 6076 originalinput.addClass('form-control'); 6077 6078 if (parentelement.hasClass('input-group')) { 6079 _advanceInputGroup(parentelement); 6080 } 6081 else { 6082 _buildInputGroup(); 6083 } 6084 } 6085 6086 function _advanceInputGroup(parentelement) { 6087 parentelement.addClass('bootstrap-touchspin'); 6088 6089 var prev = originalinput.prev(), 6090 next = originalinput.next(); 6091 6092 var downhtml, 6093 uphtml, 6094 prefixhtml = '<span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span>', 6095 postfixhtml = '<span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span>'; 6096 6097 if (prev.hasClass('input-group-btn')) { 6098 downhtml = '<button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button>'; 6099 prev.append(downhtml); 6100 } 6101 else { 6102 downhtml = '<span class="input-group-btn"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button></span>'; 6103 $(downhtml).insertBefore(originalinput); 6104 } 6105 6106 if (next.hasClass('input-group-btn')) { 6107 uphtml = '<button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button>'; 6108 next.prepend(uphtml); 6109 } 6110 else { 6111 uphtml = '<span class="input-group-btn"><button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button></span>'; 6112 $(uphtml).insertAfter(originalinput); 6113 } 6114 6115 $(prefixhtml).insertBefore(originalinput); 6116 $(postfixhtml).insertAfter(originalinput); 6117 6118 container = parentelement; 6119 } 6120 6121 function _buildInputGroup() { 6122 var html; 6123 6124 if (settings.verticalbuttons) { 6125 html = '<div class="input-group bootstrap-touchspin"><span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span><span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span><span class="input-group-btn-vertical"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-up" type="button"><i class="' + settings.verticalupclass + '"></i></button><button class="' + settings.buttonup_class + ' bootstrap-touchspin-down" type="button"><i class="' + settings.verticaldownclass + '"></i></button></span></div>'; 6126 } 6127 else { 6128 html = '<div class="input-group bootstrap-touchspin"><span class="input-group-btn"><button class="' + settings.buttondown_class + ' bootstrap-touchspin-down" type="button">' + settings.buttondown_txt + '</button></span><span class="input-group-addon bootstrap-touchspin-prefix">' + settings.prefix + '</span><span class="input-group-addon bootstrap-touchspin-postfix">' + settings.postfix + '</span><span class="input-group-btn"><button class="' + settings.buttonup_class + ' bootstrap-touchspin-up" type="button">' + settings.buttonup_txt + '</button></span></div>'; 6129 } 6130 6131 container = $(html).insertBefore(originalinput); 6132 6133 $('.bootstrap-touchspin-prefix', container).after(originalinput); 6134 6135 if (originalinput.hasClass('input-sm')) { 6136 container.addClass('input-group-sm'); 6137 } 6138 else if (originalinput.hasClass('input-lg')) { 6139 container.addClass('input-group-lg'); 6140 } 6141 } 6142 6143 function _initElements() { 6144 elements = { 6145 down: $('.bootstrap-touchspin-down', container), 6146 up: $('.bootstrap-touchspin-up', container), 6147 input: $('input', container), 6148 prefix: $('.bootstrap-touchspin-prefix', container).addClass(settings.prefix_extraclass), 6149 postfix: $('.bootstrap-touchspin-postfix', container).addClass(settings.postfix_extraclass) 6150 }; 6151 } 6152 6153 function _hideEmptyPrefixPostfix() { 6154 if (settings.prefix === '') { 6155 elements.prefix.hide(); 6156 } 6157 6158 if (settings.postfix === '') { 6159 elements.postfix.hide(); 6160 } 6161 } 6162 6163 function _bindEvents() { 6164 originalinput.on('keydown', function (ev) { 6165 var code = ev.keyCode || ev.which; 6166 6167 if (code === 38) { 6168 if (spinning !== 'up') { 6169 upOnce(); 6170 startUpSpin(); 6171 } 6172 ev.preventDefault(); 6173 } 6174 else if (code === 40) { 6175 if (spinning !== 'down') { 6176 downOnce(); 6177 startDownSpin(); 6178 } 6179 ev.preventDefault(); 6180 } 6181 }); 6182 6183 originalinput.on('keyup', function (ev) { 6184 var code = ev.keyCode || ev.which; 6185 6186 if (code === 38) { 6187 stopSpin(); 6188 } 6189 else if (code === 40) { 6190 stopSpin(); 6191 } 6192 }); 6193 6194 originalinput.on('blur', function () { 6195 _checkValue(); 6196 }); 6197 6198 elements.down.on('keydown', function (ev) { 6199 var code = ev.keyCode || ev.which; 6200 6201 if (code === 32 || code === 13) { 6202 if (spinning !== 'down') { 6203 downOnce(); 6204 startDownSpin(); 6205 } 6206 ev.preventDefault(); 6207 } 6208 }); 6209 6210 elements.down.on('keyup', function (ev) { 6211 var code = ev.keyCode || ev.which; 6212 6213 if (code === 32 || code === 13) { 6214 stopSpin(); 6215 } 6216 }); 6217 6218 elements.up.on('keydown', function (ev) { 6219 var code = ev.keyCode || ev.which; 6220 6221 if (code === 32 || code === 13) { 6222 if (spinning !== 'up') { 6223 upOnce(); 6224 startUpSpin(); 6225 } 6226 ev.preventDefault(); 6227 } 6228 }); 6229 6230 elements.up.on('keyup', function (ev) { 6231 var code = ev.keyCode || ev.which; 6232 6233 if (code === 32 || code === 13) { 6234 stopSpin(); 6235 } 6236 }); 6237 6238 elements.down.on('mousedown.touchspin', function (ev) { 6239 elements.down.off('touchstart.touchspin'); // android 4 workaround 6240 6241 if (originalinput.is(':disabled')) { 6242 return; 6243 } 6244 6245 downOnce(); 6246 startDownSpin(); 6247 6248 ev.preventDefault(); 6249 ev.stopPropagation(); 6250 }); 6251 6252 elements.down.on('touchstart.touchspin', function (ev) { 6253 elements.down.off('mousedown.touchspin'); // android 4 workaround 6254 6255 if (originalinput.is(':disabled')) { 6256 return; 6257 } 6258 6259 downOnce(); 6260 startDownSpin(); 6261 6262 ev.preventDefault(); 6263 ev.stopPropagation(); 6264 }); 6265 6266 elements.up.on('mousedown.touchspin', function (ev) { 6267 elements.up.off('touchstart.touchspin'); // android 4 workaround 6268 6269 if (originalinput.is(':disabled')) { 6270 return; 6271 } 6272 6273 upOnce(); 6274 startUpSpin(); 6275 6276 ev.preventDefault(); 6277 ev.stopPropagation(); 6278 }); 6279 6280 elements.up.on('touchstart.touchspin', function (ev) { 6281 elements.up.off('mousedown.touchspin'); // android 4 workaround 6282 6283 if (originalinput.is(':disabled')) { 6284 return; 6285 } 6286 6287 upOnce(); 6288 startUpSpin(); 6289 6290 ev.preventDefault(); 6291 ev.stopPropagation(); 6292 }); 6293 6294 elements.up.on('mouseout touchleave touchend touchcancel', function (ev) { 6295 if (!spinning) { 6296 return; 6297 } 6298 6299 ev.stopPropagation(); 6300 stopSpin(); 6301 }); 6302 6303 elements.down.on('mouseout touchleave touchend touchcancel', function (ev) { 6304 if (!spinning) { 6305 return; 6306 } 6307 6308 ev.stopPropagation(); 6309 stopSpin(); 6310 }); 6311 6312 elements.down.on('mousemove touchmove', function (ev) { 6313 if (!spinning) { 6314 return; 6315 } 6316 6317 ev.stopPropagation(); 6318 ev.preventDefault(); 6319 }); 6320 6321 elements.up.on('mousemove touchmove', function (ev) { 6322 if (!spinning) { 6323 return; 6324 } 6325 6326 ev.stopPropagation(); 6327 ev.preventDefault(); 6328 }); 6329 6330 $(document).on(_scopeEventNames(['mouseup', 'touchend', 'touchcancel'], _currentSpinnerId).join(' '), function (ev) { 6331 if (!spinning) { 6332 return; 6333 } 6334 6335 ev.preventDefault(); 6336 stopSpin(); 6337 }); 6338 6339 $(document).on(_scopeEventNames(['mousemove', 'touchmove', 'scroll', 'scrollstart'], _currentSpinnerId).join(' '), function (ev) { 6340 if (!spinning) { 6341 return; 6342 } 6343 6344 ev.preventDefault(); 6345 stopSpin(); 6346 }); 6347 6348 originalinput.on('mousewheel DOMMouseScroll', function (ev) { 6349 if (!settings.mousewheel || !originalinput.is(':focus')) { 6350 return; 6351 } 6352 6353 var delta = ev.originalEvent.wheelDelta || -ev.originalEvent.deltaY || -ev.originalEvent.detail; 6354 6355 ev.stopPropagation(); 6356 ev.preventDefault(); 6357 6358 if (delta < 0) { 6359 downOnce(); 6360 } 6361 else { 6362 upOnce(); 6363 } 6364 }); 6365 } 6366 6367 function _bindEventsInterface() { 6368 originalinput.on('touchspin.uponce', function () { 6369
6369 stopSpin(); 6370 upOnce(); 6371 }); 6372 6373 originalinput.on('touchspin.downonce', function () { 6374 stopSpin(); 6375 downOnce(); 6376 }); 6377 6378 originalinput.on('touchspin.startupspin', function () { 6379 startUpSpin(); 6380 }); 6381 6382 originalinput.on('touchspin.startdownspin', function () { 6383 startDownSpin(); 6384 }); 6385 6386 originalinput.on('touchspin.stopspin', function () { 6387 stopSpin(); 6388 }); 6389 6390 originalinput.on('touchspin.updatesettings', function (e, newsettings) { 6391 changeSettings(newsettings); 6392 }); 6393 } 6394 6395 function _forcestepdivisibility(value) { 6396 switch (settings.forcestepdivisibility) { 6397 case 'round': 6398 return (Math.round(value / settings.step) * settings.step).toFixed(settings.decimals); 6399 case 'floor': 6400 return (Math.floor(value / settings.step) * settings.step).toFixed(settings.decimals); 6401 case 'ceil': 6402 return (Math.ceil(value / settings.step) * settings.step).toFixed(settings.decimals); 6403 default: 6404 return value; 6405 } 6406 } 6407 6408 function _checkValue() { 6409 var val, parsedval, returnval; 6410 6411 val = originalinput.val(); 6412 6413 if (val === '') { 6414 return; 6415 } 6416 6417 if (settings.decimals > 0 && val === '.') { 6418 return; 6419 } 6420 6421 parsedval = parseFloat(val); 6422 6423 if (isNaN(parsedval)) { 6424 parsedval = 0; 6425 } 6426 6427 returnval = parsedval; 6428 6429 if (parsedval.toString() !== val) { 6430 returnval = parsedval; 6431 } 6432 6433 if (parsedval < settings.min) { 6434 returnval = settings.min; 6435 } 6436 6437 if (parsedval > settings.max) { 6438 returnval = settings.max; 6439 } 6440 6441 returnval = _forcestepdivisibility(returnval); 6442 6443 if (Number(val).toString() !== returnval.toString()) { 6444 originalinput.val(returnval); 6445 originalinput.trigger('change'); 6446 } 6447 } 6448 6449 function _getBoostedStep() { 6450 if (!settings.booster) { 6451 return settings.step; 6452 } 6453 else { 6454 var boosted = Math.pow(2, Math.floor(spincount / settings.boostat)) * settings.step; 6455 6456 if (settings.maxboostedstep) { 6457 if (boosted > settings.maxboostedstep) { 6458 boosted = settings.maxboostedstep; 6459 value = Math.round((value / boosted)) * boosted; 6460 } 6461 } 6462 6463 return Math.max(settings.step, boosted); 6464 } 6465 } 6466 6467 function upOnce() { 6468 _checkValue(); 6469 6470 value = parseFloat(elements.input.val()); 6471 if (isNaN(value)) { 6472 value = 0; 6473 } 6474 6475 var initvalue = value, 6476 boostedstep = _getBoostedStep(); 6477 6478 value = value + boostedstep; 6479 6480 if (value > settings.max) { 6481 value = settings.max; 6482 originalinput.trigger('touchspin.on.max'); 6483 stopSpin(); 6484 } 6485 6486 elements.input.val(Number(value).toFixed(settings.decimals)); 6487 6488 if (initvalue !== value) { 6489 originalinput.trigger('change'); 6490 } 6491 } 6492 6493 function downOnce() { 6494 _checkValue(); 6495 6496 value = parseFloat(elements.input.val()); 6497 if (isNaN(value)) { 6498 value = 0; 6499 } 6500 6501 var initvalue = value, 6502 boostedstep = _getBoostedStep(); 6503 6504 value = value - boostedstep; 6505 6506 if (value < settings.min) { 6507 value = settings.min; 6508 originalinput.trigger('touchspin.on.min'); 6509 stopSpin(); 6510 } 6511 6512 elements.input.val(value.toFixed(settings.decimals)); 6513 6514 if (initvalue !== value) { 6515 originalinput.trigger('change'); 6516 } 6517 } 6518 6519 function startDownSpin() { 6520 stopSpin(); 6521 6522 spincount = 0; 6523 spinning = 'down'; 6524 6525 originalinput.trigger('touchspin.on.startspin'); 6526 originalinput.trigger('touchspin.on.startdownspin'); 6527 6528 downDelayTimeout = setTimeout(function () { 6529 downSpinTimer = setInterval(function () { 6530 spincount++; 6531 downOnce(); 6532 }, settings.stepinterval); 6533 }, settings.stepintervaldelay); 6534 } 6535 6536 function startUpSpin() { 6537 stopSpin(); 6538 6539 spincount = 0; 6540 spinning = 'up'; 6541 6542 originalinput.trigger('touchspin.on.startspin'); 6543 originalinput.trigger('touchspin.on.startupspin'); 6544 6545 upDelayTimeout = setTimeout(function () { 6546 upSpinTimer = setInterval(function () { 6547 spincount++; 6548 upOnce(); 6549 }, settings.stepinterval); 6550 }, settings.stepintervaldelay); 6551 } 6552 6553 function stopSpin() { 6554 clearTimeout(downDelayTimeout); 6555 clearTimeout(upDelayTimeout); 6556 clearInterval(downSpinTimer); 6557 clearInterval(upSpinTimer); 6558 6559 switch (spinning) { 6560 case 'up': 6561 originalinput.trigger('touchspin.on.stopupspin'); 6562 originalinput.trigger('touchspin.on.stopspin'); 6563 break; 6564 case 'down': 6565 originalinput.trigger('touchspin.on.stopdownspin'); 6566 originalinput.trigger('touchspin.on.stopspin'); 6567 break; 6568 } 6569 6570 spincount = 0; 6571 spinning = false; 6572 } 6573 6574 }); 6575 6576 }; 6577 6578})(jQuery); 6579; 6580$.DateTimePicker = $.DateTimePicker || { 6581 name: "DateTimePicker", 6582 i18n: {}, // Internationalization Objects 6583 6584 defaults: //Plugin Defaults 6585 { 6586 mode: "date", 6587 defaultDate: null, 6588 dateSeparator: "-", 6589 timeSeparator: ":", 6590 timeMeridiemSeparator: " ", 6591 dateTimeSeparator: " ", 6592 monthYearSeparator: " ", 6593 dateTimeFormat: "dd-MM-yyyy HH:mm",
vendor: 3,365 bytes, lines 6594-6674
6594 dateFormat: "dd-MM-yyyy", 6595 timeFormat: "HH:mm", 6596 maxDate: null, 6597 minDate: null, 6598 maxTime: null, 6599 minTime: null, 6600 maxDateTime: null, 6601 minDateTime: null, 6602 shortDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 6603 fullDayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 6604 shortMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 6605 fullMonthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], 6606 labels: null, /*{"year": "Year", "month": "Month", "day": "Day", "hour": "Hour", "minutes": "Minutes", "seconds": "Seconds", "meridiem": "Meridiem"}*/ 6607 6608 minuteInterval: 1, 6609 roundOffMinutes: true, 6610 secondsInterval: 1, 6611 roundOffSeconds: true, 6612 titleContentDate: "Set Date", 6613 titleContentTime: "Set Time", 6614 titleContentDateTime: "Set Date & Time", 6615 buttonsToDisplay: ["HeaderCloseButton", "SetButton", "ClearButton"], 6616 setButtonContent: "Set", 6617 clearButtonContent: "Clear", 6618 incrementButtonContent: "+", 6619 decrementButtonContent: "-", 6620 setValueInTextboxOnEveryClick: false, 6621 animationDuration: 400, 6622 isPopup: true, 6623 parentElement: "body", 6624 language: "", 6625 init: null, // init(oDateTimePicker) 6626 addEventHandlers: null, // addEventHandlers(oDateTimePicker) 6627 beforeShow: null, // beforeShow(oInputElement) 6628 afterShow: null, // afterShow(oInputElement) 6629 beforeHide: null, // beforeHide(oInputElement) 6630 afterHide: null, // afterHide(oInputElement) 6631 buttonClicked: null, // buttonClicked(sButtonType, oInputElement) where sButtonType = "SET"|"CLEAR"|"CANCEL"|"TAB" 6632 settingValueOfElement: null, // settingValueOfElement(sValue, dDateTime, oInputElement) 6633 formatHumanDate: null, // formatHumanDate(oDateTime, sMode, sFormat) 6634 6635 parseDateTimeString: null, // parseDateTimeString(sDateTime, sMode, oInputField) 6636 formatDateTimeString: null, // formatDateTimeString(oDateTime, sMode, oInputField) 6637 }, 6638 dataObject: // Temporary Variables For Calculation Specific to DateTimePicker Instance 6639 { 6640 dCurrentDate: new Date(), 6641 iCurrentDay: 0, 6642 iCurrentMonth: 0, 6643 iCurrentYear: 0, 6644 iCurrentHour: 0, 6645 iCurrentMinutes: 0, 6646 iCurrentSeconds: 0, 6647 sCurrentMeridiem: "", 6648 iMaxNumberOfDays: 0, 6649 sDateFormat: "", 6650 sTimeFormat: "", 6651 sDateTimeFormat: "", 6652 dMinValue: null, 6653 dMaxValue: null, 6654 sArrInputDateFormats: [], 6655 sArrInputTimeFormats: [], 6656 sArrInputDateTimeFormats: [], 6657 bArrMatchFormat: [], 6658 bDateMode: false, 6659 bTimeMode: false, 6660 bDateTimeMode: false, 6661 oInputElement: null, 6662 iTabIndex: 0, 6663 bElemFocused: false, 6664 bIs12Hour: false 6665 } 6666 6667}; 6668 6669$.cf = { 6670 _isValid: function (sValue) { 6671 return (sValue !== undefined && sValue !== null && sValue !== ""); 6672 }, 6673 _compare: function (sString1, sString2) { 6674 var bString1 = (sString1 !== undefined && sString1 !== null),
vendor: 41,941 bytes, lines 6675-7543
6675 bString2 = (sString2 !== undefined && sString2 !== null); 6676 if (bString1 && bString2) { 6677 if (sString1.toLowerCase() === sString2.toLowerCase()) 6678 return true; 6679 else 6680 return false; 6681 } 6682 else 6683 return false; 6684 } 6685 6686}; 6687 6688(function (factory) { 6689 if (typeof define === 'function' && define.amd) { 6690 // AMD. Register as an anonymous module. 6691 define(['jquery'], factory); 6692 } 6693 else if (typeof exports === 'object') { 6694 // Node/CommonJS 6695 module.exports = factory(require('jquery')); 6696 } 6697 else { 6698 // Browser globals 6699 factory(jQuery); 6700 } 6701}(function ($) { 6702 "use strict"; 6703 6704 function DateTimePicker(element, options) { 6705 this.element = element; 6706 6707 var sLanguage = ""; 6708 sLanguage = ($.cf._isValid(options) && $.cf._isValid(options.language)) ? options.language : $.DateTimePicker.defaults.language; 6709 this.settings = $.extend({}, $.DateTimePicker.defaults, $.DateTimePicker.i18n[sLanguage], options); 6710 this.options = options; 6711 6712 this.oData = $.extend({}, $.DateTimePicker.dataObject); 6713 this._defaults = $.DateTimePicker.defaults; 6714 this._name = $.DateTimePicker.name; 6715 6716 this.init(); 6717 } 6718 6719 $.fn.DateTimePicker = function (options) { 6720 var oDTP = $(this).data(), 6721 sArrDataKeys = oDTP ? Object.keys(oDTP) : [], 6722 iKey, sKey; 6723 6724 if (typeof options === "string") { 6725 if ($.cf._isValid(oDTP)) { 6726 if (options === "destroy") { 6727 if (sArrDataKeys.length > 0) { 6728 for (iKey in sArrDataKeys) { 6729 sKey = sArrDataKeys[iKey]; 6730 if (sKey.search("plugin_DateTimePicker") !== -1) { 6731 $(document).unbind("click.DateTimePicker"); 6732 $(document).unbind("keydown.DateTimePicker"); 6733 $(document).unbind("keyup.DateTimePicker"); 6734 6735 $(this).children().remove(); 6736 $(this).removeData(); 6737 $(this).unbind(); 6738 $(this).removeClass("dtpicker-overlay dtpicker-mobile"); 6739 6740 oDTP = oDTP[sKey]; 6741 6742 console.log("Destroyed DateTimePicker Object"); 6743 console.log(oDTP); 6744 6745 break; 6746 } 6747 } 6748 } 6749 else { 6750 console.log("No DateTimePicker Object Defined For This Element"); 6751 } 6752 } 6753 else if (options === "object") { 6754 if (sArrDataKeys.length > 0) { 6755 for (iKey in sArrDataKeys) { 6756 sKey = sArrDataKeys[iKey]; 6757 if (sKey.search("plugin_DateTimePicker") !== -1) { 6758 return oDTP[sKey]; 6759 } 6760 } 6761 } 6762 else { 6763 console.log("No DateTimePicker Object Defined For This Element"); 6764 } 6765 } 6766 } 6767 } 6768 else { 6769 return this.each(function () { 6770 $.removeData(this, "plugin_DateTimePicker"); 6771 if (!$.data(this, "plugin_DateTimePicker")) 6772 $.data(this, "plugin_DateTimePicker", new DateTimePicker(this, options)); 6773 }); 6774 } 6775 }; 6776 6777 DateTimePicker.prototype = { 6778 // Public Method 6779 init: function () { 6780 var oDTP = this; 6781 6782 oDTP._setDateFormatArray(); // Set DateFormatArray 6783 oDTP._setTimeFormatArray(); // Set TimeFormatArray 6784 oDTP._setDateTimeFormatArray(); // Set DateTimeFormatArray 6785 6786 if (oDTP.settings.isPopup) { 6787 oDTP._createPicker(); 6788 $(oDTP.element).addClass("dtpicker-mobile"); 6789 } 6790 6791 if (oDTP.settings.init) 6792 oDTP.settings.init.call(oDTP); 6793 6794 oDTP._addEventHandlersForInput(); 6795 }, 6796 _setDateFormatArray: function () { 6797 var oDTP = this; 6798 6799 oDTP.oData.sArrInputDateFormats = []; 6800 var sDate = ""; 6801 6802 // 0 - "dd-MM-yyyy" 6803 sDate = "dd" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "yyyy"; 6804 oDTP.oData.sArrInputDateFormats.push(sDate); 6805 6806 // 1 - "MM-dd-yyyy" 6807 sDate = "MM" + oDTP.settings.dateSeparator + "dd" + oDTP.settings.dateSeparator + "yyyy"; 6808 oDTP.oData.sArrInputDateFormats.push(sDate); 6809 6810 // 2 - "yyyy-MM-dd" 6811 sDate = "yyyy" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "dd"; 6812 oDTP.oData.sArrInputDateFormats.push(sDate); 6813 6814 // 3 - "dd-MMM-yyyy" 6815 sDate = "dd" + oDTP.settings.dateSeparator + "MMM" + oDTP.settings.dateSeparator + "yyyy"; 6816 oDTP.oData.sArrInputDateFormats.push(sDate); 6817 6818 // 4 - "MM yyyy" 6819 sDate = "MM" + oDTP.settings.monthYearSeparator + "yyyy"; 6820 oDTP.oData.sArrInputDateFormats.push(sDate); 6821 6822 // 5 - "MMM yyyy" 6823 sDate = "MMM" + oDTP.settings.monthYearSeparator + "yyyy"; 6824 oDTP.oData.sArrInputDateFormats.push(sDate); 6825 6826 // 6 - "MMM yyyy" 6827 sDate = "MMMM" + oDTP.settings.monthYearSeparator + "yyyy"; 6828 oDTP.oData.sArrInputDateFormats.push(sDate); 6829 }, 6830 _setTimeFormatArray: function () { 6831 var oDTP = this; 6832 6833 oDTP.oData.sArrInputTimeFormats = []; 6834 var sTime = ""; 6835 6836 // 0 - "hh:mm:ss AA" 6837 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss" + oDTP.settings.timeMeridiemSeparator + "AA"; 6838 oDTP.oData.sArrInputTimeFormats.push(sTime); 6839 6840 // 1 - "HH:mm:ss" 6841 sTime = "HH" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss"; 6842 oDTP.oData.sArrInputTimeFormats.push(sTime); 6843 6844 // 2 - "hh:mm AA" 6845 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeMeridiemSeparator + "AA"; 6846 oDTP.oData.sArrInputTimeFormats.push(sTime); 6847 6848 // 3 - "HH:mm" 6849 sTime = "HH" + oDTP.settings.timeSeparator + "mm"; 6850 oDTP.oData.sArrInputTimeFormats.push(sTime); 6851 }, 6852 _setDateTimeFormatArray: function () { 6853 var oDTP = this; 6854 6855 oDTP.oData.sArrInputDateTimeFormats = []; 6856 var sDate = "", sTime = "", sDateTime = ""; 6857 6858 // 0 - "dd-MM-yyyy HH:mm:ss" 6859 sDate = "dd" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "yyyy"; 6860 sTime = "HH" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss"; 6861 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6862 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6863 6864 // 1 - "dd-MM-yyyy hh:mm:ss AA" 6865 sDate = "dd" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "yyyy"; 6866 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss" + oDTP.settings.timeMeridiemSeparator + "AA"; 6867 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6868 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6869 6870 // 2 - "MM-dd-yyyy HH:mm:ss" 6871 sDate = "MM" + oDTP.settings.dateSeparator + "dd" + oDTP.settings.dateSeparator + "yyyy"; 6872 sTime = "HH" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss"; 6873 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6874 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6875 6876 // 3 - "MM-dd-yyyy hh:mm:ss AA" 6877 sDate = "MM" + oDTP.settings.dateSeparator + "dd" + oDTP.settings.dateSeparator + "yyyy"; 6878 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss" + oDTP.settings.timeMeridiemSeparator + "AA"; 6879 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6880 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6881 6882 // 4 - "yyyy-MM-dd HH:mm:ss" 6883 sDate = "yyyy" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "dd"; 6884 sTime = "HH" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss"; 6885 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6886 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6887 6888 // 5 - "yyyy-MM-dd hh:mm:ss AA" 6889 sDate = "yyyy" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "dd"; 6890 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss" + oDTP.settings.timeMeridiemSeparator + "AA"; 6891 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6892 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6893 6894 // 6 - "dd-MMM-yyyy hh:mm:ss" 6895 sDate = "dd" + oDTP.settings.dateSeparator + "MMM" + oDTP.settings.dateSeparator + "yyyy"; 6896 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss"; 6897 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6898 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6899 6900 // 7 - "dd-MMM-yyyy hh:mm:ss AA" 6901 sDate = "dd" + oDTP.settings.dateSeparator + "MMM" + oDTP.settings.dateSeparator + "yyyy"; 6902 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeSeparator + "ss" + oDTP.settings.timeMeridiemSeparator + "AA"; 6903 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6904 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6905 6906 //-------------- 6907 6908 // 8 - "dd-MM-yyyy HH:mm" 6909 sDate = "dd" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "yyyy"; 6910 sTime = "HH" + oDTP.settings.timeSeparator + "mm"; 6911 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6912 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6913 6914 // 9 - "dd-MM-yyyy hh:mm AA" 6915 sDate = "dd" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "yyyy"; 6916 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeMeridiemSeparator + "AA"; 6917 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6918 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6919 6920 // 10 - "MM-dd-yyyy HH:mm" 6921 sDate = "MM" + oDTP.settings.dateSeparator + "dd" + oDTP.settings.dateSeparator + "yyyy"; 6922 sTime = "HH" + oDTP.settings.timeSeparator + "mm"; 6923 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6924 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6925 6926 // 11 - "MM-dd-yyyy hh:mm AA" 6927 sDate = "MM" + oDTP.settings.dateSeparator + "dd" + oDTP.settings.dateSeparator + "yyyy"; 6928 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeMeridiemSeparator + "AA"; 6929 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6930 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6931 6932 // 12 - "yyyy-MM-dd HH:mm" 6933 sDate = "yyyy" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "dd"; 6934 sTime = "HH" + oDTP.settings.timeSeparator + "mm"; 6935 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6936 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6937 6938 // 13 - "yyyy-MM-dd hh:mm AA" 6939 sDate = "yyyy" + oDTP.settings.dateSeparator + "MM" + oDTP.settings.dateSeparator + "dd"; 6940 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeMeridiemSeparator + "AA"; 6941 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6942 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6943 6944 // 14 - "dd-MMM-yyyy hh:mm" 6945 sDate = "dd" + oDTP.settings.dateSeparator + "MMM" + oDTP.settings.dateSeparator + "yyyy"; 6946 sTime = "hh" + oDTP.settings.timeSeparator + "mm"; 6947 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6948 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6949 6950 // 15 - "dd-MMM-yyyy hh:mm AA" 6951 sDate = "dd" + oDTP.settings.dateSeparator + "MMM" + oDTP.settings.dateSeparator + "yyyy"; 6952 sTime = "hh" + oDTP.settings.timeSeparator + "mm" + oDTP.settings.timeMeridiemSeparator + "AA"; 6953 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 6954 oDTP.oData.sArrInputDateTimeFormats.push(sDateTime); 6955 }, 6956 _matchFormat: function (sMode, sFormat) { 6957 var oDTP = this; 6958 6959 oDTP.oData.bArrMatchFormat = []; 6960 oDTP.oData.bDateMode = false; 6961 oDTP.oData.bTimeMode = false; 6962 oDTP.oData.bDateTimeMode = false; 6963 var oArrInput = [], iTempIndex; 6964 6965 sMode = $.cf._isValid(sMode) ? sMode : oDTP.settings.mode; 6966 if ($.cf._compare(sMode, "date")) { 6967 sFormat = $.cf._isValid(sFormat) ? sFormat : oDTP.oData.sDateFormat; 6968 oDTP.oData.bDateMode = true; 6969 oArrInput = oDTP.oData.sArrInputDateFormats; 6970 } 6971 else if ($.cf._compare(sMode, "time")) { 6972 sFormat = $.cf._isValid(sFormat) ? sFormat : oDTP.oData.sTimeFormat; 6973 oDTP.oData.bTimeMode = true; 6974 oArrInput = oDTP.oData.sArrInputTimeFormats; 6975 } 6976 else if ($.cf._compare(sMode, "datetime")) { 6977 sFormat = $.cf._isValid(sFormat) ? sFormat : oDTP.oData.sDateTimeFormat; 6978 oDTP.oData.bDateTimeMode = true; 6979 oArrInput = oDTP.oData.sArrInputDateTimeFormats; 6980 } 6981 6982 for (iTempIndex = 0; iTempIndex < oArrInput.length; iTempIndex++) { 6983 oDTP.oData.bArrMatchFormat.push( 6984 $.cf._compare(sFormat, oArrInput[iTempIndex]) 6985 ); 6986 } 6987 }, 6988 _setMatchFormat: function (iArgsLength, sMode, sFormat) { 6989 var oDTP = this; 6990 6991 if (iArgsLength > 0) 6992 oDTP._matchFormat(sMode, sFormat); 6993 }, 6994 _createPicker: function () { 6995 var oDTP = this; 6996 6997 $(oDTP.element).addClass("dtpicker-overlay"); 6998 $(".dtpicker-overlay").click(function (e) { 6999 oDTP._hidePicker(""); 7000 }); 7001 7002 var sTempStr = ""; 7003 sTempStr += "<div class='dtpicker-bg'>"; 7004 sTempStr += "<div class='dtpicker-cont'>"; 7005 sTempStr += "<div class='dtpicker-content'>"; 7006 sTempStr += "<div class='dtpicker-subcontent'>"; 7007 sTempStr += "</div>"; 7008 sTempStr += "</div>"; 7009 sTempStr += "</div>"; 7010 sTempStr += "</div>"; 7011 $(oDTP.element).html(sTempStr); 7012 }, 7013 _addEventHandlersForInput: function () { 7014 var oDTP = this; 7015 7016 oDTP.oData.oInputElement = null; 7017 7018 $(oDTP.settings.parentElement).find("input[type='date'], input[type='time'], input[type='datetime']").each(function () { 7019 $(this).attr("data-field", $(this).attr("type")); 7020 $(this).attr("type", "text"); 7021 }); 7022 7023 var sel = "[data-field='date'], [data-field='time'], [data-field='datetime']"; 7024 $(oDTP.settings.parentElement).off("focus", sel, oDTP._inputFieldFocus); 7025 $(oDTP.settings.parentElement).on("focus", sel, { "obj": oDTP }, oDTP._inputFieldFocus); 7026 7027 $(oDTP.settings.parentElement).off("click", sel, oDTP._inputFieldClick); 7028 $(oDTP.settings.parentElement).on("click", sel, { "obj": oDTP }, oDTP._inputFieldClick); 7029 7030 if (oDTP.settings.addEventHandlers) //this is not an event-handler really. Its just a function called 7031 oDTP.settings.addEventHandlers.call(oDTP); // which could add EventHandlers 7032 }, 7033 _inputFieldFocus: function (e) { 7034 var oDTP = e.data.obj; 7035 oDTP.showDateTimePicker(this); 7036 oDTP.oData.bMouseDown = false; 7037 }, 7038 _inputFieldClick: function (e) { 7039 var oDTP = e.data.obj; 7040 if (!$.cf._compare($(this).prop("tagName"), "input")) { 7041 oDTP.showDateTimePicker(this); 7042 } 7043 e.stopPropagation(); 7044 }, 7045 // Public Method 7046 getDateObjectForInputField: function (oInputField) { 7047 var oDTP = this; 7048 7049 if ($.cf._isValid(oInputField)) { 7050 var sDateTime = oDTP._getValueOfElement(oInputField), 7051 sMode = $(oInputField).data("field"), 7052 sFormat = "", 7053 dInput; 7054 7055 if (!$.cf._isValid(sMode)) 7056 sMode = oDTP.settings.mode; 7057 if (!oDTP.settings.formatDateTimeString) { 7058 sFormat = $(oInputField).data("format"); 7059 if (!$.cf._isValid(sFormat)) { 7060 if ($.cf._compare(sMode, "date")) 7061 sFormat = oDTP.settings.dateFormat; 7062 else if ($.cf._compare(sMode, "time")) 7063 sFormat = oDTP.settings.timeFormat; 7064 else if ($.cf._compare(sMode, "datetime")) 7065 sFormat = oDTP.settings.dateTimeFormat; 7066 } 7067 7068 oDTP._matchFormat(sMode, sFormat); 7069 7070 if ($.cf._compare(sMode, "date")) 7071 dInput = oDTP._parseDate(sDateTime); 7072 else if ($.cf._compare(sMode, "time")) 7073 dInput = oDTP._parseTime(sDateTime); 7074 else if ($.cf._compare(sMode, "datetime")) 7075 dInput = oDTP._parseDateTime(sDateTime); 7076 7077 } 7078 else { 7079 dInput = oDTP.settings.parseDateTimeString.call(oDTP, sDateTime, sMode, $(oInputField)); 7080 } 7081 7082 return dInput; 7083 } 7084 }, 7085 // Public Method 7086 setDateTimeStringInInputField: function (oInputField, dInput) { 7087 var oDTP = this; 7088 7089 dInput = dInput || oDTP.oData.dCurrentDate; 7090 7091 var oArrElements; 7092 if ($.cf._isValid(oInputField)) { 7093 oArrElements = []; 7094 if (typeof oInputField === "string") 7095 oArrElements.push(oInputField); 7096 else if (typeof oInputField === "object") 7097 oArrElements = oInputField; 7098 } 7099 else { 7100 if ($.cf._isValid(oDTP.settings.parentElement)) { 7101 oArrElements = $(oDTP.settings.parentElement).find("[data-field='date'], [data-field='time'], [data-field='datetime']"); 7102 } 7103 else { 7104 oArrElements = $("[data-field='date'], [data-field='time'], [data-field='datetime']"); 7105 } 7106 } 7107 7108 oArrElements.each(function () { 7109 var oElement = this, 7110 sMode, sFormat, bIs12Hour, sOutput; 7111 7112 sMode = $(oElement).data("field"); 7113 if (!$.cf._isValid(sMode)) 7114 sMode = oDTP.settings.mode; 7115 7116 sFormat = "Custom"; 7117 bIs12Hour = false; 7118 if (!oDTP.settings.formatDateTimeString) { 7119 sFormat = $(oElement).data("format"); 7120 if (!$.cf._isValid(sFormat)) { 7121 if ($.cf._compare(sMode, "date")) 7122 sFormat = oDTP.settings.dateFormat; 7123 else if ($.cf._compare(sMode, "time")) 7124 sFormat = oDTP.settings.timeFormat; 7125 else if ($.cf._compare(sMode, "datetime")) 7126 sFormat = oDTP.settings.dateTimeFormat; 7127 } 7128 7129 bIs12Hour = oDTP.getIs12Hour(sMode, sFormat); 7130 } 7131 7132 sOutput = oDTP._setOutput(sMode, sFormat, bIs12Hour, dInput, oElement); 7133 oDTP._setValueOfElement(sOutput, $(oElement)); 7134 }); 7135 }, 7136 // Public Method 7137 getDateTimeStringInFormat: function (sMode, sFormat, dInput) { 7138 var oDTP = this; 7139 return oDTP._setOutput(sMode, sFormat, oDTP.getIs12Hour(sMode, sFormat), dInput); 7140 }, 7141 // Public Method 7142 showDateTimePicker: function (oElement) { 7143 var oDTP = this; 7144 7145 if (oDTP.oData.oInputElement !== null) 7146 oDTP._hidePicker(0, oElement); 7147 else 7148 oDTP._showPicker(oElement); 7149 }, 7150 _setButtonAction: function (bFromTab) { 7151 var oDTP = this; 7152 7153 if (oDTP.oData.oInputElement !== null) { 7154 oDTP._setValueOfElement(oDTP._setOutput()); 7155 7156 if (bFromTab) { 7157 if (oDTP.settings.buttonClicked) 7158 oDTP.settings.buttonClicked.call(oDTP, "TAB", oDTP.oData.oInputElement); 7159 oDTP._hidePicker(0); 7160 } 7161 else 7162 oDTP._hidePicker(""); 7163 } 7164 }, 7165 _setOutput: function (sMode, sFormat, bIs12Hour, dCurrentDate, oElement) { 7166 var oDTP = this; 7167 7168 dCurrentDate = $.cf._isValid(dCurrentDate) ? dCurrentDate : oDTP.oData.dCurrentDate; 7169 bIs12Hour = bIs12Hour || oDTP.oData.bIs12Hour; 7170 7171 var oDTV = oDTP._setVariablesForDate(dCurrentDate, true, true); 7172 7173 var sOutput = "", 7174 oFDate = oDTP._formatDate(oDTV), 7175 oFTime = oDTP._formatTime(oDTV), 7176 oFDT = $.extend({}, oFDate, oFTime), 7177 sDateStr = "", sTimeStr = "", 7178 iArgsLength = Function.length, 7179 bAddSeconds; 7180 7181 if (oDTP.settings.formatDateTimeString) { 7182 sOutput = oDTP.settings.formatDateTimeString.call(oDTP, oFDT, sMode, oElement); 7183 } 7184 else { 7185 // Set bDate, bTime, bDateTime & bArrMatchFormat based on arguments of this function 7186 oDTP._setMatchFormat(iArgsLength, sMode, sFormat); 7187 7188 if (oDTP.oData.bDateMode) { 7189 if (oDTP.oData.bArrMatchFormat[0]) { 7190 sOutput = oFDT.dd + oDTP.settings.dateSeparator + oFDT.MM + oDTP.settings.dateSeparator + oFDT.yyyy; 7191 } 7192 else if (oDTP.oData.bArrMatchFormat[1]) { 7193 sOutput = oFDT.MM + oDTP.settings.dateSeparator + oFDT.dd + oDTP.settings.dateSeparator + oFDT.yyyy; 7194 } 7195 else if (oDTP.oData.bArrMatchFormat[2]) { 7196 sOutput = oFDT.yyyy + oDTP.settings.dateSeparator + oFDT.MM + oDTP.settings.dateSeparator + oFDT.dd; 7197 } 7198 else if (oDTP.oData.bArrMatchFormat[3]) { 7199 sOutput = oFDT.dd + oDTP.settings.dateSeparator + oFDT.monthShort + oDTP.settings.dateSeparator + oFDT.yyyy; 7200 } 7201 else if (oDTP.oData.bArrMatchFormat[4]) { 7202 sOutput = oFDT.MM + oDTP.settings.monthYearSeparator + oFDT.yyyy; 7203 } 7204 else if (oDTP.oData.bArrMatchFormat[5]) { 7205 sOutput = oFDT.monthShort + oDTP.settings.monthYearSeparator + oFDT.yyyy; 7206 } 7207 else if (oDTP.oData.bArrMatchFormat[6]) { 7208 sOutput = oFDT.month + oDTP.settings.monthYearSeparator + oFDT.yyyy; 7209 } 7210 } 7211 else if (oDTP.oData.bTimeMode) { 7212 if (oDTP.oData.bArrMatchFormat[0]) { 7213 sOutput = oFDT.hh + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeSeparator + oFDT.ss + oDTP.settings.timeMeridiemSeparator + oFDT.ME; 7214 } 7215 else if (oDTP.oData.bArrMatchFormat[1]) { 7216 sOutput = oFDT.HH + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeSeparator + oFDT.ss; 7217 } 7218 else if (oDTP.oData.bArrMatchFormat[2]) { 7219 sOutput = oFDT.hh + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeMeridiemSeparator + oFDT.ME; 7220 } 7221 else if (oDTP.oData.bArrMatchFormat[3]) { 7222 sOutput = oFDT.HH + oDTP.settings.timeSeparator + oFDT.mm; 7223 } 7224 } 7225 else if (oDTP.oData.bDateTimeMode) { 7226 // Date Part - "dd-MM-yyyy" 7227 if (oDTP.oData.bArrMatchFormat[0] || 7228 oDTP.oData.bArrMatchFormat[1] || 7229 oDTP.oData.bArrMatchFormat[8] || 7230 oDTP.oData.bArrMatchFormat[9]) { 7231 sDateStr = oFDT.dd + oDTP.settings.dateSeparator + oFDT.MM + oDTP.settings.dateSeparator + oFDT.yyyy; 7232 } 7233 // Date Part - "MM-dd-yyyy" 7234 else if (oDTP.oData.bArrMatchFormat[2] || 7235 oDTP.oData.bArrMatchFormat[3] || 7236 oDTP.oData.bArrMatchFormat[10] || 7237 oDTP.oData.bArrMatchFormat[11]) { 7238 sDateStr = oFDT.MM + oDTP.settings.dateSeparator + oFDT.dd + oDTP.settings.dateSeparator + oFDT.yyyy; 7239 } 7240 // Date Part - "yyyy-MM-dd" 7241 else if (oDTP.oData.bArrMatchFormat[4] || 7242 oDTP.oData.bArrMatchFormat[5] || 7243 oDTP.oData.bArrMatchFormat[12] || 7244 oDTP.oData.bArrMatchFormat[13]) { 7245 sDateStr = oFDT.yyyy + oDTP.settings.dateSeparator + oFDT.MM + oDTP.settings.dateSeparator + oFDT.dd; 7246 } 7247 // Date Part - "dd-MMM-yyyy" 7248 else if (oDTP.oData.bArrMatchFormat[6] || 7249 oDTP.oData.bArrMatchFormat[7] || 7250 oDTP.oData.bArrMatchFormat[14] || 7251 oDTP.oData.bArrMatchFormat[15]) { 7252 sDateStr = oFDT.dd + oDTP.settings.dateSeparator + oFDT.monthShort + oDTP.settings.dateSeparator + oFDT.yyyy; 7253 } 7254 7255 bAddSeconds = oDTP.oData.bArrMatchFormat[0] || 7256 oDTP.oData.bArrMatchFormat[1] || 7257 oDTP.oData.bArrMatchFormat[2] || 7258 oDTP.oData.bArrMatchFormat[3] || 7259 oDTP.oData.bArrMatchFormat[4] || 7260 oDTP.oData.bArrMatchFormat[5] || 7261 oDTP.oData.bArrMatchFormat[6] || 7262 oDTP.oData.bArrMatchFormat[7]; 7263 if (bIs12Hour) { 7264 if (bAddSeconds) { 7265 sTimeStr = oFDT.hh + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeSeparator + oFDT.ss + oDTP.settings.timeMeridiemSeparator + oFDT.ME; 7266 } 7267 else { 7268 sTimeStr = oFDT.hh + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeMeridiemSeparator + oFDT.ME; 7269 } 7270 } 7271 else { 7272 if (bAddSeconds) { 7273 sTimeStr = oFDT.HH + oDTP.settings.timeSeparator + oFDT.mm + oDTP.settings.timeSeparator + oFDT.ss; 7274 } 7275 else { 7276 sTimeStr = oFDT.HH + oDTP.settings.timeSeparator + oFDT.mm; 7277 } 7278 } 7279 7280 if (sDateStr !== "" && sTimeStr !== "") 7281 sOutput = sDateStr + oDTP.settings.dateTimeSeparator + sTimeStr; 7282 } 7283 7284 // Reset bDate, bTime, bDateTime & bArrMatchFormat to original values 7285 oDTP._setMatchFormat(iArgsLength); 7286 } 7287 7288 return sOutput; 7289 }, 7290 _clearButtonAction: function () { 7291 var oDTP = this; 7292 7293 if (oDTP.oData.oInputElement !== null) { 7294 oDTP._setValueOfElement(""); 7295 } 7296 oDTP._hidePicker(""); 7297 }, 7298 _setOutputOnIncrementOrDecrement: function () { 7299 var oDTP = this; 7300 7301 if ($.cf._isValid(oDTP.oData.oInputElement) && oDTP.settings.setValueInTextboxOnEveryClick) { 7302 oDTP._setValueOfElement(oDTP._setOutput()); 7303 } 7304 }, 7305 _showPicker: function (oElement) { 7306 var oDTP = this; 7307 7308 if (oDTP.oData.oInputElement === null) { 7309 oDTP.oData.oInputElement = oElement; 7310 oDTP.oData.iTabIndex = parseInt($(oElement).attr("tabIndex")); 7311 7312 var sMode = $(oElement).data("field") || "", 7313 sMinValue = $(oElement).data("min") || "", 7314 sMaxValue = $(oElement).data("max") || "", 7315 sFormat = $(oElement).data("format") || "", 7316 sView = $(oElement).data("view") || "", 7317 sStartEnd = $(oElement).data("startend") || "", 7318 sStartEndElem = $(oElement).data("startendelem") || "", 7319 sCurrent = oDTP._getValueOfElement(oElement) || ""; 7320 7321 if (sView !== "") { 7322 if ($.cf._compare(sView, "Popup")) 7323 oDTP.setIsPopup(true); 7324 else 7325 oDTP.setIsPopup(false); 7326 } 7327 7328 if (!oDTP.settings.isPopup) { 7329 oDTP._createPicker(); 7330 7331 var iElemTop = $(oDTP.oData.oInputElement).offset().top + $(oDTP.oData.oInputElement).outerHeight(), 7332 iElemLeft = $(oDTP.oData.oInputElement).offset().left, 7333 iElemWidth = $(oDTP.oData.oInputElement).outerWidth(); 7334 7335 $(oDTP.element).css({ position: "absolute", top: iElemTop, left: iElemLeft, width: iElemWidth, height: "auto" }); 7336 } 7337 7338 if (oDTP.settings.beforeShow) 7339 oDTP.settings.beforeShow.call(oDTP, oElement); 7340 7341 sMode = $.cf._isValid(sMode) ? sMode : oDTP.settings.mode; 7342 oDTP.settings.mode = sMode; 7343 if (!$.cf._isValid(sFormat)) { 7344 if ($.cf._compare(sMode, "date")) 7345 sFormat = oDTP.settings.dateFormat; 7346 else if ($.cf._compare(sMode, "time")) 7347 sFormat = oDTP.settings.timeFormat; 7348 else if ($.cf._compare(sMode, "datetime")) 7349 sFormat = oDTP.settings.dateTimeFormat; 7350 } 7351 7352 oDTP._matchFormat(sMode, sFormat); 7353 7354 oDTP.oData.dMinValue = null; 7355 oDTP.oData.dMaxValue = null; 7356 oDTP.oData.bIs12Hour = false; 7357 7358 var sMin, sMax, 7359 sTempDate, dTempDate, 7360 sTempTime, dTempTime, 7361 sTempDateTime, dTempDateTime; 7362 7363 if (oDTP.oData.bDateMode) { 7364 sMin = sMinValue || oDTP.settings.minDate; 7365 sMax = sMaxValue || oDTP.settings.maxDate; 7366 7367 oDTP.oData.sDateFormat = sFormat; 7368 7369 if ($.cf._isValid(sMin)) 7370 oDTP.oData.dMinValue = oDTP._parseDate(sMin); 7371 if ($.cf._isValid(sMax)) 7372 oDTP.oData.dMaxValue = oDTP._parseDate(sMax); 7373 7374 if (sStartEnd !== "" && ($.cf._compare(sStartEnd, "start") || $.cf._compare(sStartEnd, "end")) && sStartEndElem !== "") { 7375 if ($(sStartEndElem).length >= 1) { 7376 sTempDate = oDTP._getValueOfElement($(sStartEndElem)); 7377 if (sTempDate !== "") { 7378 if (oDTP.settings.parseDateTimeString) 7379 dTempDate = oDTP.settings.parseDateTimeString.call(oDTP, sTempDate, sMode, $(sStartEndElem)); 7380 else 7381 dTempDate = oDTP._parseDate(sTempDate); 7382 7383 if ($.cf._compare(sStartEnd, "start")) { 7384 if ($.cf._isValid(sMax)) { 7385 if (oDTP._compareDates(dTempDate, oDTP.oData.dMaxValue) < 0) 7386 oDTP.oData.dMaxValue = new Date(dTempDate); 7387 } 7388 else 7389 oDTP.oData.dMaxValue = new Date(dTempDate); 7390 } 7391 else if ($.cf._compare(sStartEnd, "end")) { 7392 if ($.cf._isValid(sMin)) { 7393 if (oDTP._compareDates(dTempDate, oDTP.oData.dMinValue) > 0) 7394 oDTP.oData.dMinValue = new Date(dTempDate); 7395 } 7396 else 7397 oDTP.oData.dMinValue = new Date(dTempDate); 7398 } 7399 } 7400 } 7401 } 7402 7403 if (oDTP.settings.parseDateTimeString) 7404 oDTP.oData.dCurrentDate = oDTP.settings.parseDateTimeString.call(oDTP, sCurrent, sMode, $(oElement)); 7405 else 7406 oDTP.oData.dCurrentDate = oDTP._parseDate(sCurrent); 7407 7408 oDTP.oData.dCurrentDate.setHours(0); 7409 oDTP.oData.dCurrentDate.setMinutes(0); 7410 oDTP.oData.dCurrentDate.setSeconds(0); 7411 } 7412 else if (oDTP.oData.bTimeMode) { 7413 sMin = sMinValue || oDTP.settings.minTime; 7414 sMax = sMaxValue || oDTP.settings.maxTime; 7415 7416 oDTP.oData.sTimeFormat = sFormat; 7417 oDTP.oData.bIs12Hour = oDTP.getIs12Hour(); 7418 7419 if ($.cf._isValid(sMin)) 7420 oDTP.oData.dMinValue = oDTP._parseTime(sMin); 7421 if ($.cf._isValid(sMax)) 7422 oDTP.oData.dMaxValue = oDTP._parseTime(sMax); 7423 7424 if (sStartEnd !== "" && ($.cf._compare(sStartEnd, "start") || $.cf._compare(sStartEnd, "end")) && sStartEndElem !== "") { 7425 if ($(sStartEndElem).length >= 1) { 7426 sTempTime = oDTP._getValueOfElement($(sStartEndElem)); 7427 if (sTempTime !== "") { 7428 if (oDTP.settings.parseDateTimeString) 7429 dTempDate = oDTP.settings.parseDateTimeString.call(oDTP, sTempTime, sMode, $(sStartEndElem)); 7430 else 7431 dTempTime = oDTP._parseTime(sTempTime); 7432 7433 if ($.cf._compare(sStartEnd, "start")) { 7434 dTempTime.setMinutes(dTempTime.getMinutes() - 1); 7435 if ($.cf._isValid(sMax)) { 7436 if (oDTP._compareTime(dTempTime, oDTP.oData.dMaxValue) === 2) 7437 oDTP.oData.dMaxValue = new Date(dTempTime); 7438 } 7439 else 7440 oDTP.oData.dMaxValue = new Date(dTempTime); 7441 } 7442 else if ($.cf._compare(sStartEnd, "end")) { 7443 dTempTime.setMinutes(dTempTime.getMinutes() + 1); 7444 if ($.cf._isValid(sMin)) { 7445 if (oDTP._compareTime(dTempTime, oDTP.oData.dMinValue) === 3) 7446 oDTP.oData.dMinValue = new Date(dTempTime); 7447 } 7448 else 7449 oDTP.oData.dMinValue = new Date(dTempTime); 7450 } 7451 } 7452 } 7453 } 7454 7455 if (oDTP.settings.parseDateTimeString) 7456 oDTP.oData.dCurrentDate = oDTP.settings.parseDateTimeString.call(oDTP, sCurrent, sMode, $(oElement)); 7457 else 7458 oDTP.oData.dCurrentDate = oDTP._parseTime(sCurrent); 7459 } 7460 else if (oDTP.oData.bDateTimeMode) { 7461 sMin = sMinValue || oDTP.settings.minDateTime; 7462 sMax = sMaxValue || oDTP.settings.maxDateTime; 7463 7464 oDTP.oData.sDateTimeFormat = sFormat; 7465 oDTP.oData.bIs12Hour = oDTP.getIs12Hour(); 7466 7467 if ($.cf._isValid(sMin)) 7468 oDTP.oData.dMinValue = oDTP._parseDateTime(sMin); 7469 if ($.cf._isValid(sMax)) 7470 oDTP.oData.dMaxValue = oDTP._parseDateTime(sMax); 7471 7472 if (sStartEnd !== "" && ($.cf._compare(sStartEnd, "start") || $.cf._compare(sStartEnd, "end")) && sStartEndElem !== "") { 7473 if ($(sStartEndElem).length >= 1) { 7474 sTempDateTime = oDTP._getValueOfElement($(sStartEndElem)); 7475 if (sTempDateTime !== "") { 7476 if (oDTP.settings.parseDateTimeString) 7477 dTempDateTime = oDTP.settings.parseDateTimeString.call(oDTP, sTempDateTime, sMode, $(sStartEndElem)); 7478 else 7479 dTempDateTime = oDTP._parseDateTime(sTempDateTime); 7480 7481 if ($.cf._compare(sStartEnd, "start")) { 7482 if ($.cf._isValid(sMax)) { 7483 if (oDTP._compareDateTime(dTempDateTime, oDTP.oData.dMaxValue) < 0) 7484 oDTP.oData.dMaxValue = new Date(dTempDateTime); 7485 } 7486 else 7487 oDTP.oData.dMaxValue = new Date(dTempDateTime); 7488 } 7489 else if ($.cf._compare(sStartEnd, "end")) { 7490 if ($.cf._isValid(sMin)) { 7491 if (oDTP._compareDateTime(dTempDateTime, oDTP.oData.dMinValue) > 0) 7492 oDTP.oData.dMinValue = new Date(dTempDateTime); 7493 } 7494 else 7495 oDTP.oData.dMinValue = new Date(dTempDateTime); 7496 } 7497 } 7498 } 7499 } 7500 7501 if (oDTP.settings.parseDateTimeString) 7502 oDTP.oData.dCurrentDate = oDTP.settings.parseDateTimeString.call(oDTP, sCurrent, sMode, $(oElement)); 7503 else 7504 oDTP.oData.dCurrentDate = oDTP._parseDateTime(sCurrent); 7505 } 7506 7507 oDTP._setVariablesForDate(); 7508 oDTP._modifyPicker(); 7509 $(oDTP.element).fadeIn(oDTP.settings.animationDuration); 7510 7511 if (oDTP.settings.afterShow) { 7512 setTimeout(function () { 7513 oDTP.settings.afterShow.call(oDTP, oElement); 7514 }, oDTP.settings.animationDuration); 7515 } 7516 } 7517 }, 7518 _hidePicker: function (iDuration, oElementToShow) { 7519 var oDTP = this; 7520 var oElement = oDTP.oData.oInputElement; 7521 7522 if (oDTP.settings.beforeHide) 7523 oDTP.settings.beforeHide.call(oDTP, oElement); 7524 7525 if (!$.cf._isValid(iDuration)) 7526 iDuration = oDTP.settings.animationDuration; 7527 7528 if ($.cf._isValid(oDTP.oData.oInputElement)) { 7529 $(oDTP.oData.oInputElement).blur(); 7530 oDTP.oData.oInputElement = null; 7531 } 7532 7533 $(oDTP.element).fadeOut(iDuration); 7534 if (iDuration === 0) { 7535 $(oDTP.element).find('.dtpicker-subcontent').html(""); 7536 } 7537 else { 7538 setTimeout(function () { 7539 $(oDTP.element).find('.dtpicker-subcontent').html(""); 7540 }, iDuration); 7541 } 7542 7543 $(document).unbind("click.DateTimePicker");
vendor: 11,888 bytes, lines 7544-7800
7544 $(document).unbind("keydown.DateTimePicker"); 7545 $(document).unbind("keyup.DateTimePicker"); 7546 7547 if (oDTP.settings.afterHide) { 7548 if (iDuration === 0) { 7549 oDTP.settings.afterHide.call(oDTP, oElement); 7550 } 7551 else { 7552 setTimeout(function () { 7553 oDTP.settings.afterHide.call(oDTP, oElement); 7554 }, iDuration); 7555 } 7556 } 7557 7558 if ($.cf._isValid(oElementToShow)) 7559 oDTP._showPicker(oElementToShow); 7560 }, 7561 _modifyPicker: function () { 7562 var oDTP = this; 7563 7564 var sTitleContent, iNumberOfColumns; 7565 var sArrFields = []; 7566 if (oDTP.oData.bDateMode) { 7567 sTitleContent = oDTP.settings.titleContentDate; 7568 iNumberOfColumns = 3; 7569 7570 if (oDTP.oData.bArrMatchFormat[0]) // "dd-MM-yyyy" 7571 { 7572 sArrFields = ["day", "month", "year"]; 7573 } 7574 else if (oDTP.oData.bArrMatchFormat[1]) // "MM-dd-yyyy" 7575 { 7576 sArrFields = ["month", "day", "year"]; 7577 } 7578 else if (oDTP.oData.bArrMatchFormat[2]) // "yyyy-MM-dd" 7579 { 7580 sArrFields = ["year", "month", "day"]; 7581 } 7582 else if (oDTP.oData.bArrMatchFormat[3]) // "dd-MMM-yyyy" 7583 { 7584 sArrFields = ["day", "month", "year"]; 7585 } 7586 else if (oDTP.oData.bArrMatchFormat[4]) // "MM-yyyy" 7587 { 7588 iNumberOfColumns = 2; 7589 sArrFields = ["month", "year"]; 7590 } 7591 else if (oDTP.oData.bArrMatchFormat[5]) // "MMM yyyy" 7592 { 7593 iNumberOfColumns = 2; 7594 sArrFields = ["month", "year"]; 7595 } 7596 else if (oDTP.oData.bArrMatchFormat[6]) // "MMMM yyyy" 7597 { 7598 iNumberOfColumns = 2; 7599 sArrFields = ["month", "year"]; 7600 } 7601 } 7602 else if (oDTP.oData.bTimeMode) { 7603 sTitleContent = oDTP.settings.titleContentTime; 7604 if (oDTP.oData.bArrMatchFormat[0]) // hh:mm:ss AA 7605 { 7606 iNumberOfColumns = 4; 7607 sArrFields = ["hour", "minutes", "seconds", "meridiem"]; 7608 } 7609 else if (oDTP.oData.bArrMatchFormat[1]) // HH:mm:ss 7610 { 7611 iNumberOfColumns = 3; 7612 sArrFields = ["hour", "minutes", "seconds"]; 7613 } 7614 else if (oDTP.oData.bArrMatchFormat[2]) // hh:mm AA 7615 { 7616 iNumberOfColumns = 3; 7617 sArrFields = ["hour", "minutes", "meridiem"]; 7618 } 7619 else if (oDTP.oData.bArrMatchFormat[3]) // HH:mm 7620 { 7621 iNumberOfColumns = 2; 7622 sArrFields = ["hour", "minutes"]; 7623 } 7624 } 7625 else if (oDTP.oData.bDateTimeMode) { 7626 sTitleContent = oDTP.settings.titleContentDateTime; 7627 7628 if (oDTP.oData.bArrMatchFormat[0]) { 7629 iNumberOfColumns = 6; 7630 sArrFields = ["day", "month", "year", "hour", "minutes", "seconds"]; 7631 } 7632 else if (oDTP.oData.bArrMatchFormat[1]) { 7633 iNumberOfColumns = 7; 7634 sArrFields = ["day", "month", "year", "hour", "minutes", "seconds", "meridiem"]; 7635 } 7636 else if (oDTP.oData.bArrMatchFormat[2]) { 7637 iNumberOfColumns = 6; 7638 sArrFields = ["month", "day", "year", "hour", "minutes", "seconds"]; 7639 } 7640 else if (oDTP.oData.bArrMatchFormat[3]) { 7641 iNumberOfColumns = 7; 7642 sArrFields = ["month", "day", "year", "hour", "minutes", "seconds", "meridiem"]; 7643 } 7644 else if (oDTP.oData.bArrMatchFormat[4]) { 7645 iNumberOfColumns = 6; 7646 sArrFields = ["year", "month", "day", "hour", "minutes", "seconds"]; 7647 } 7648 else if (oDTP.oData.bArrMatchFormat[5]) { 7649 iNumberOfColumns = 7; 7650 sArrFields = ["year", "month", "day", "hour", "minutes", "seconds", "meridiem"]; 7651 } 7652 else if (oDTP.oData.bArrMatchFormat[6]) { 7653 iNumberOfColumns = 6; 7654 sArrFields = ["day", "month", "year", "hour", "minutes", "seconds"]; 7655 } 7656 else if (oDTP.oData.bArrMatchFormat[7]) { 7657 iNumberOfColumns = 7; 7658 sArrFields = ["day", "month", "year", "hour", "minutes", "seconds", "meridiem"]; 7659 } 7660 else if (oDTP.oData.bArrMatchFormat[8]) { 7661 iNumberOfColumns = 5; 7662 sArrFields = ["day", "month", "year", "hour", "minutes"]; 7663 } 7664 else if (oDTP.oData.bArrMatchFormat[9]) { 7665 iNumberOfColumns = 6; 7666 sArrFields = ["day", "month", "year", "hour", "minutes", "meridiem"]; 7667 } 7668 else if (oDTP.oData.bArrMatchFormat[10]) { 7669 iNumberOfColumns = 5; 7670 sArrFields = ["month", "day", "year", "hour", "minutes"]; 7671 } 7672 else if (oDTP.oData.bArrMatchFormat[11]) { 7673 iNumberOfColumns = 6; 7674 sArrFields = ["month", "day", "year", "hour", "minutes", "meridiem"]; 7675 } 7676 else if (oDTP.oData.bArrMatchFormat[12]) { 7677 iNumberOfColumns = 5; 7678 sArrFields = ["year", "month", "day", "hour", "minutes"]; 7679 } 7680 else if (oDTP.oData.bArrMatchFormat[13]) { 7681 iNumberOfColumns = 6; 7682 sArrFields = ["year", "month", "day", "hour", "minutes", "meridiem"]; 7683 } 7684 else if (oDTP.oData.bArrMatchFormat[14]) { 7685 iNumberOfColumns = 5; 7686 sArrFields = ["day", "month", "year", "hour", "minutes"]; 7687 } 7688 else if (oDTP.oData.bArrMatchFormat[15]) { 7689 iNumberOfColumns = 6; 7690 sArrFields = ["day", "month", "year", "hour", "minutes", "meridiem"]; 7691 } 7692 } 7693 7694 7695 //-------------------------------------------------------------------- 7696 var sColumnClass = "dtpicker-comp" + iNumberOfColumns, 7697 bDisplayHeaderCloseButton = false, 7698 bDisplaySetButton = false, 7699 bDisplayClearButton = false, 7700 iTempIndex; 7701 7702 for (iTempIndex = 0; iTempIndex < oDTP.settings.buttonsToDisplay.length; iTempIndex++) { 7703 if ($.cf._compare(oDTP.settings.buttonsToDisplay[iTempIndex], "HeaderCloseButton")) 7704 bDisplayHeaderCloseButton = true; 7705 else if ($.cf._compare(oDTP.settings.buttonsToDisplay[iTempIndex], "SetButton")) 7706 bDisplaySetButton = true; 7707 else if ($.cf._compare(oDTP.settings.buttonsToDisplay[iTempIndex], "ClearButton")) 7708 bDisplayClearButton = true; 7709 } 7710 7711 var sHeader = ""; 7712 sHeader += "<div class='dtpicker-header'>"; 7713 sHeader += "<div class='dtpicker-title'>" + sTitleContent + "</div>"; 7714 if (bDisplayHeaderCloseButton) 7715 sHeader += "<a class='dtpicker-close'>×</a>"; 7716 sHeader += "<div class='dtpicker-value'></div>"; 7717 sHeader += "</div>"; 7718 7719 //-------------------------------------------------------------------- 7720 7721 var sDTPickerComp = ""; 7722 sDTPickerComp += "<div class='dtpicker-components'>"; 7723 7724 for (iTempIndex = 0; iTempIndex < iNumberOfColumns; iTempIndex++) { 7725 var sFieldName = sArrFields[iTempIndex]; 7726 7727 sDTPickerComp += "<div class='dtpicker-compOutline " + sColumnClass + "'>"; 7728 sDTPickerComp += "<div class='dtpicker-comp " + sFieldName + "'>"; 7729 sDTPickerComp += "<a class='dtpicker-compButton increment'>" + oDTP.settings.incrementButtonContent + "</a>"; 7730 sDTPickerComp += "<input type='text' class='dtpicker-compValue'></input>"; 7731 sDTPickerComp += "<a class='dtpicker-compButton decrement'>" + oDTP.settings.decrementButtonContent + "</a>"; 7732 if (oDTP.settings.labels) 7733 sDTPickerComp += "<div class='dtpicker-label'>" + oDTP.settings.labels[sFieldName] + "</div>"; 7734 sDTPickerComp += "</div>"; 7735 sDTPickerComp += "</div>"; 7736 } 7737 7738 sDTPickerComp += "</div>"; 7739 7740 //-------------------------------------------------------------------- 7741 7742 var sButtonContClass = ""; 7743 if (bDisplaySetButton && bDisplayClearButton) 7744 sButtonContClass = " dtpicker-twoButtons"; 7745 else 7746 sButtonContClass = " dtpicker-singleButton"; 7747 7748 var sDTPickerButtons = ""; 7749 sDTPickerButtons += "<div class='dtpicker-buttonCont" + sButtonContClass + "'>"; 7750 if (bDisplaySetButton) 7751 sDTPickerButtons += "<a class='dtpicker-button dtpicker-buttonSet'>" + oDTP.settings.setButtonContent + "</a>"; 7752 if (bDisplayClearButton) 7753 sDTPickerButtons += "<a class='dtpicker-button dtpicker-buttonClear'>" + oDTP.settings.clearButtonContent + "</a>"; 7754 sDTPickerButtons += "</div>"; 7755 7756 //-------------------------------------------------------------------- 7757 7758 var sTempStr = sHeader + sDTPickerComp + sDTPickerButtons; 7759 7760 $(oDTP.element).find('.dtpicker-subcontent').html(sTempStr); 7761 7762 oDTP._setCurrentDate(); 7763 oDTP._addEventHandlersForPicker(); 7764 }, 7765 _addEventHandlersForPicker: function () { 7766 var oDTP = this; 7767 7768 var myVar = setInterval(function () { myTimer() }, 1300); 7769 function myTimer() { 7770 $(document).on("click.DateTimePicker", function (e) { 7771 oDTP._hidePicker(""); // å¨chromeæééï¼å¨firefoxæ£å¸¸!! 7772 }); 7773 clearInterval(myVar); 7774 } 7775 7776 // $(document).on("click.DateTimePicker", function (e) 7777 // { 7778 // oDTP._hidePicker(""); // å¨chromeæééï¼å¨firefoxæ£å¸¸!! 7779 // }); 7780 7781 7782 $(document).on("keydown.DateTimePicker", function (e) { 7783 if (!$('.dtpicker-compValue').is(':focus') && parseInt(e.keyCode ? e.keyCode : e.which) === 9) { 7784 oDTP._setButtonAction(true); 7785 $("[tabIndex=" + (oDTP.oData.iTabIndex + 1) + "]").focus(); 7786 return false; 7787 } 7788 }); 7789 7790 $(document).on("keydown.DateTimePicker", function (e) { 7791 if (!$('.dtpicker-compValue').is(':focus') && parseInt(e.keyCode ? e.keyCode : e.which) !== 9) { 7792 oDTP._hidePicker(""); 7793 } 7794 }); 7795 7796 $(".dtpicker-cont *").click(function (e) { 7797 e.stopPropagation(); 7798 }); 7799 7800 $('.dtpicker-compValue').not('.month .dtpicker-compValue, .meri
vendor: 47,838 bytes, lines 7800-8737
7800diem .dtpicker-compValue').keyup(function () { 7801 this.value = this.value.replace(/[^0-9\.]/g, ''); 7802 }); 7803 7804 $('.dtpicker-compValue').focus(function () { 7805 oDTP.oData.bElemFocused = true; 7806 $(this).select(); 7807 }); 7808 7809 $('.dtpicker-compValue').blur(function () { 7810 oDTP._getValuesFromInputBoxes(); 7811 oDTP._setCurrentDate(); 7812 7813 oDTP.oData.bElemFocused = false; 7814 var $oParentElem = $(this).parent().parent(); 7815 setTimeout(function () { 7816 if ($oParentElem.is(':last-child') && !oDTP.oData.bElemFocused) { 7817 oDTP._setButtonAction(false); 7818 } 7819 }, 50); 7820 }); 7821 7822 $(".dtpicker-compValue").keyup(function (e) { 7823 var $oTextField = $(this), 7824 sTextBoxVal = $oTextField.val(), 7825 iLength = sTextBoxVal.length, 7826 sNewTextBoxVal; 7827 7828 if ($oTextField.parent().hasClass("day") || $oTextField.parent().hasClass("hour") || $oTextField.parent().hasClass("minutes") || $oTextField.parent().hasClass("meridiem")) { 7829 if (iLength > 2) { 7830 sNewTextBoxVal = sTextBoxVal.slice(0, 2); 7831 $oTextField.val(sNewTextBoxVal); 7832 } 7833 } 7834 else if ($oTextField.parent().hasClass("month")) { 7835 if (iLength > 3) { 7836 sNewTextBoxVal = sTextBoxVal.slice(0, 3); 7837 $oTextField.val(sNewTextBoxVal); 7838 } 7839 } 7840 else if ($oTextField.parent().hasClass("year")) { 7841 if (iLength > 4) { 7842 sNewTextBoxVal = sTextBoxVal.slice(0, 4); 7843 $oTextField.val(sNewTextBoxVal); 7844 } 7845 } 7846 7847 if (parseInt(e.keyCode ? e.keyCode : e.which) === 9) 7848 $(this).select(); 7849 }); 7850 7851 //----------------------------------------------------------------------- 7852 7853 $(oDTP.element).find('.dtpicker-close').click(function (e) { 7854 if (oDTP.settings.buttonClicked) 7855 oDTP.settings.buttonClicked.call(oDTP, "CLOSE", oDTP.oData.oInputElement); 7856 oDTP._hidePicker(""); 7857 }); 7858 7859 $(oDTP.element).find('.dtpicker-buttonSet').click(function (e) { 7860 if (oDTP.settings.buttonClicked) 7861 oDTP.settings.buttonClicked.call(oDTP, "SET", oDTP.oData.oInputElement); 7862 oDTP._setButtonAction(false); 7863 }); 7864 7865 $(oDTP.element).find('.dtpicker-buttonClear').click(function (e) { 7866 if (oDTP.settings.buttonClicked) 7867 oDTP.settings.buttonClicked.call(oDTP, "CLEAR", oDTP.oData.oInputElement); 7868 oDTP._clearButtonAction(); 7869 }); 7870 7871 // ---------------------------------------------------------------------------- 7872 7873 $(oDTP.element).find(".day .increment, .day .increment *").click(function (e) { 7874 oDTP.oData.iCurrentDay++; 7875 oDTP._setCurrentDate(); 7876 oDTP._setOutputOnIncrementOrDecrement(); 7877 }); 7878 7879 $(oDTP.element).find(".day .decrement, .day .decrement *").click(function (e) { 7880 oDTP.oData.iCurrentDay--; 7881 oDTP._setCurrentDate(); 7882 oDTP._setOutputOnIncrementOrDecrement(); 7883 }); 7884 7885 $(oDTP.element).find(".month .increment, .month .increment *").click(function (e) { 7886 oDTP.oData.iCurrentMonth++; 7887 oDTP._setCurrentDate(); 7888 oDTP._setOutputOnIncrementOrDecrement(); 7889 }); 7890 7891 $(oDTP.element).find(".month .decrement, .month .decrement *").click(function (e) { 7892 oDTP.oData.iCurrentMonth--; 7893 oDTP._setCurrentDate(); 7894 oDTP._setOutputOnIncrementOrDecrement(); 7895 }); 7896 7897 $(oDTP.element).find(".year .increment, .year .increment *").click(function (e) { 7898 oDTP.oData.iCurrentYear++; 7899 oDTP._setCurrentDate(); 7900 oDTP._setOutputOnIncrementOrDecrement(); 7901 }); 7902 7903 $(oDTP.element).find(".year .decrement, .year .decrement *").click(function (e) { 7904 oDTP.oData.iCurrentYear--; 7905 oDTP._setCurrentDate(); 7906 oDTP._setOutputOnIncrementOrDecrement(); 7907 }); 7908 7909 $(oDTP.element).find(".hour .increment, .hour .increment *").click(function (e) { 7910 oDTP.oData.iCurrentHour++; 7911 oDTP._setCurrentDate(); 7912 oDTP._setOutputOnIncrementOrDecrement(); 7913 }); 7914 7915 $(oDTP.element).find(".hour .decrement, .hour .decrement *").click(function (e) { 7916 oDTP.oData.iCurrentHour--; 7917 oDTP._setCurrentDate(); 7918 oDTP._setOutputOnIncrementOrDecrement(); 7919 }); 7920 7921 $(oDTP.element).find(".minutes .increment, .minutes .increment *").click(function (e) { 7922 oDTP.oData.iCurrentMinutes += oDTP.settings.minuteInterval; 7923 oDTP._setCurrentDate(); 7924 oDTP._setOutputOnIncrementOrDecrement(); 7925 }); 7926 7927 $(oDTP.element).find(".minutes .decrement, .minutes .decrement *").click(function (e) { 7928 oDTP.oData.iCurrentMinutes -= oDTP.settings.minuteInterval; 7929 oDTP._setCurrentDate(); 7930 oDTP._setOutputOnIncrementOrDecrement(); 7931 }); 7932 7933 $(oDTP.element).find(".seconds .increment, .seconds .increment *").click(function (e) { 7934 oDTP.oData.iCurrentSeconds += oDTP.settings.secondsInterval; 7935 oDTP._setCurrentDate(); 7936 oDTP._setOutputOnIncrementOrDecrement(); 7937 }); 7938 7939 $(oDTP.element).find(".seconds .decrement, .seconds .decrement *").click(function (e) { 7940 oDTP.oData.iCurrentSeconds -= oDTP.settings.secondsInterval; 7941 oDTP._setCurrentDate(); 7942 oDTP._setOutputOnIncrementOrDecrement(); 7943 }); 7944 7945 $(oDTP.element).find(".meridiem .dtpicker-compButton, .meridiem .dtpicker-compButton *").click(function (e) { 7946 if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "AM")) { 7947 oDTP.oData.sCurrentMeridiem = "PM"; 7948 oDTP.oData.iCurrentHour += 12; 7949 } 7950 else if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "PM")) { 7951 oDTP.oData.sCurrentMeridiem = "AM"; 7952 oDTP.oData.iCurrentHour -= 12; 7953 } 7954 oDTP._setCurrentDate(); 7955 oDTP._setOutputOnIncrementOrDecrement(); 7956 }); 7957 }, 7958 _adjustMinutes: function (iMinutes) { 7959 var oDTP = this; 7960 if (oDTP.settings.roundOffMinutes && oDTP.settings.minuteInterval !== 1) { 7961 iMinutes = (iMinutes % oDTP.settings.minuteInterval) ? (iMinutes - (iMinutes % oDTP.settings.minuteInterval) + oDTP.settings.minuteInterval) : iMinutes; 7962 } 7963 return iMinutes; 7964 }, 7965 _adjustSeconds: function (iSeconds) { 7966 var oDTP = this; 7967 if (oDTP.settings.roundOffSeconds && oDTP.settings.secondsInterval !== 1) { 7968 iSeconds = (iSeconds % oDTP.settings.secondsInterval) ? (iSeconds - (iSeconds % oDTP.settings.secondsInterval) + oDTP.settings.secondsInterval) : iSeconds; 7969 } 7970 return iSeconds; 7971 }, 7972 _getValueOfElement: function (oElem) { 7973 var oDTP = this; 7974 var sElemValue = ""; 7975 7976 if ($.cf._compare($(oElem).prop("tagName"), "INPUT")) 7977 sElemValue = $(oElem).val(); 7978 else 7979 sElemValue = $(oElem).html(); 7980 7981 return sElemValue; 7982 }, 7983 _setValueOfElement: function (sElemValue, $oElem) { 7984 var oDTP = this; 7985 7986 if (!$.cf._isValid($oElem)) 7987 $oElem = $(oDTP.oData.oInputElement); 7988 7989 if ($.cf._compare($oElem.prop("tagName"), "INPUT")) 7990 $oElem.val(sElemValue); 7991 else 7992 $oElem.html(sElemValue); 7993 7994 var dElemValue = oDTP.getDateObjectForInputField($oElem); 7995 7996 if (oDTP.settings.settingValueOfElement) 7997 oDTP.settings.settingValueOfElement.call(oDTP, sElemValue, dElemValue, $oElem); 7998 7999 $oElem.change(); 8000 8001 return sElemValue; 8002 }, 8003 //----------------------------------------------------------------- 8004 8005 _parseDate: function (sDate) { 8006 var oDTP = this; 8007 8008 var dTempDate = (oDTP.settings.defaultDate ? new Date(oDTP.settings.defaultDate) : new Date()), 8009 iDate = dTempDate.getDate(), 8010 iMonth = dTempDate.getMonth(), 8011 iYear = dTempDate.getFullYear(); 8012 8013 if ($.cf._isValid(sDate)) { 8014 var sArrDate; 8015 if (oDTP.oData.bArrMatchFormat[4] || oDTP.oData.bArrMatchFormat[5] || oDTP.oData.bArrMatchFormat[6]) 8016 sArrDate = sDate.split(oDTP.settings.monthYearSeparator); 8017 else 8018 sArrDate = sDate.split(oDTP.settings.dateSeparator); 8019 8020 if (oDTP.oData.bArrMatchFormat[0]) // "dd-MM-yyyy" 8021 { 8022 iDate = parseInt(sArrDate[0]); 8023 iMonth = parseInt(sArrDate[1] - 1); 8024 iYear = parseInt(sArrDate[2]); 8025 } 8026 else if (oDTP.oData.bArrMatchFormat[1]) // "MM-dd-yyyy" 8027 { 8028 iMonth = parseInt(sArrDate[0] - 1); 8029 iDate = parseInt(sArrDate[1]); 8030 iYear = parseInt(sArrDate[2]); 8031 } 8032 else if (oDTP.oData.bArrMatchFormat[2]) // "yyyy-MM-dd" 8033 { 8034 iYear = parseInt(sArrDate[0]); 8035 iMonth = parseInt(sArrDate[1] - 1); 8036 iDate = parseInt(sArrDate[2]); 8037 } 8038 else if (oDTP.oData.bArrMatchFormat[3]) // "dd-MMM-yyyy" 8039 { 8040 iDate = parseInt(sArrDate[0]); 8041 iMonth = oDTP._getShortMonthIndex(sArrDate[1]); 8042 iYear = parseInt(sArrDate[2]); 8043 } 8044 else if (oDTP.oData.bArrMatchFormat[4]) // "MM-yyyy" 8045 { 8046 iDate = 1; 8047 iMonth = parseInt(sArrDate[0]) - 1; 8048 iYear = parseInt(sArrDate[1]); 8049 } 8050 else if (oDTP.oData.bArrMatchFormat[5]) // "MMM yyyy" 8051 { 8052 iDate = 1; 8053 iMonth = oDTP._getShortMonthIndex(sArrDate[0]); 8054 iYear = parseInt(sArrDate[1]); 8055 } 8056 else if (oDTP.oData.bArrMatchFormat[6]) // "MMMM yyyy" 8057 { 8058 iDate = 1; 8059 iMonth = oDTP._getFullMonthIndex(sArrDate[0]); 8060 iYear = parseInt(sArrDate[1]); 8061 } 8062 } 8063 8064 dTempDate = new Date(iYear, iMonth, iDate, 0, 0, 0, 0); 8065 return dTempDate; 8066 }, 8067 _parseTime: function (sTime) { 8068 var oDTP = this; 8069 8070 var dTempDate = (oDTP.settings.defaultDate ? new Date(oDTP.settings.defaultDate) : new Date()), 8071 iDate = dTempDate.getDate(), 8072 iMonth = dTempDate.getMonth(), 8073 iYear = dTempDate.getFullYear(), 8074 iHour = dTempDate.getHours(), 8075 iMinutes = dTempDate.getMinutes(), 8076 iSeconds = dTempDate.getSeconds(), 8077 sArrTime, sMeridiem, sArrTimeComp, 8078 bShowSeconds = oDTP.oData.bArrMatchFormat[0] || 8079 oDTP.oData.bArrMatchFormat[1]; 8080 8081 iSeconds = bShowSeconds ? oDTP._adjustSeconds(iSeconds) : 0; 8082 8083 if ($.cf._isValid(sTime)) { 8084 if (oDTP.oData.bIs12Hour) { 8085 sArrTime = sTime.split(oDTP.settings.timeMeridiemSeparator); 8086 sTime = sArrTime[0]; 8087 sMeridiem = sArrTime[1]; 8088 8089 if (!($.cf._compare(sMeridiem, "AM") || $.cf._compare(sMeridiem, "PM"))) 8090 sMeridiem = ""; 8091 } 8092 8093 sArrTimeComp = sTime.split(oDTP.settings.timeSeparator); 8094 iHour = parseInt(sArrTimeComp[0]); 8095 iMinutes = parseInt(sArrTimeComp[1]); 8096 8097 if (bShowSeconds) { 8098 iSeconds = parseInt(sArrTimeComp[2]); 8099 iSeconds = oDTP._adjustSeconds(iSeconds); 8100 } 8101 8102 if (iHour === 12 && $.cf._compare(sMeridiem, "AM")) 8103 iHour = 0; 8104 else if (iHour < 12 && $.cf._compare(sMeridiem, "PM")) 8105 iHour += 12; 8106 } 8107 iMinutes = oDTP._adjustMinutes(iMinutes); 8108 8109 dTempDate = new Date(iYear, iMonth, iDate, iHour, iMinutes, iSeconds, 0); 8110 8111 return dTempDate; 8112 }, 8113 _parseDateTime: function (sDateTime) { 8114 var oDTP = this; 8115 8116 var dTempDate = (oDTP.settings.defaultDate ? new Date(oDTP.settings.defaultDate) : new Date()), 8117 iDate = dTempDate.getDate(), 8118 iMonth = dTempDate.getMonth(), 8119 iYear = dTempDate.getFullYear(), 8120 iHour = dTempDate.getHours(), 8121 iMinutes = dTempDate.getMinutes(), 8122 iSeconds = dTempDate.getSeconds(), 8123 sMeridiem = "", 8124 sArrDateTime, sArrDate, sTime, sArrTimeComp, sArrTime, 8125 bShowSeconds = oDTP.oData.bArrMatchFormat[0] || // "dd-MM-yyyy HH:mm:ss" 8126 oDTP.oData.bArrMatchFormat[1] || // ""dd-MM-yyyy hh:mm:ss AA" 8127 oDTP.oData.bArrMatchFormat[2] || // "MM-dd-yyyy HH:mm:ss" 8128 oDTP.oData.bArrMatchFormat[3] || // "MM-dd-yyyy hh:mm:ss AA" 8129 oDTP.oData.bArrMatchFormat[4] || // "yyyy-MM-dd HH:mm:ss" 8130 oDTP.oData.bArrMatchFormat[5] || // "yyyy-MM-dd hh:mm:ss AA" 8131 oDTP.oData.bArrMatchFormat[6] || // "dd-MMM-yyyy HH:mm:ss" 8132 oDTP.oData.bArrMatchFormat[7]; // "dd-MMM-yyyy hh:mm:ss AA" 8133 8134 iSeconds = bShowSeconds ? oDTP._adjustSeconds(iSeconds) : 0; 8135 8136 if ($.cf._isValid(sDateTime)) { 8137 sArrDateTime = sDateTime.split(oDTP.settings.dateTimeSeparator); 8138 sArrDate = sArrDateTime[0].split(oDTP.settings.dateSeparator); 8139 8140 if (oDTP.oData.bArrMatchFormat[0] || // "dd-MM-yyyy HH:mm:ss" 8141 oDTP.oData.bArrMatchFormat[1] || // ""dd-MM-yyyy hh:mm:ss AA" 8142 oDTP.oData.bArrMatchFormat[8] || // "dd-MM-yyyy HH:mm" 8143 oDTP.oData.bArrMatchFormat[9]) // "dd-MM-yyyy hh:mm AA" 8144 { 8145 iDate = parseInt(sArrDate[0]); 8146 iMonth = parseInt(sArrDate[1] - 1); 8147 iYear = parseInt(sArrDate[2]); 8148 } 8149 else if (oDTP.oData.bArrMatchFormat[2] || // "MM-dd-yyyy HH:mm:ss" 8150 oDTP.oData.bArrMatchFormat[3] || // "MM-dd-yyyy hh:mm:ss AA" 8151 oDTP.oData.bArrMatchFormat[10] || // "MM-dd-yyyy HH:mm" 8152 oDTP.oData.bArrMatchFormat[11]) // "MM-dd-yyyy hh:mm AA" 8153 { 8154 iMonth = parseInt(sArrDate[0] - 1); 8155 iDate = parseInt(sArrDate[1]); 8156 iYear = parseInt(sArrDate[2]); 8157 } 8158 else if (oDTP.oData.bArrMatchFormat[4] || // "yyyy-MM-dd HH:mm:ss" 8159 oDTP.oData.bArrMatchFormat[5] || // "yyyy-MM-dd hh:mm:ss AA" 8160 oDTP.oData.bArrMatchFormat[12] || // "yyyy-MM-dd HH:mm" 8161 oDTP.oData.bArrMatchFormat[13]) // "yyyy-MM-dd hh:mm AA" 8162 { 8163 iYear = parseInt(sArrDate[0]); 8164 iMonth = parseInt(sArrDate[1] - 1); 8165 iDate = parseInt(sArrDate[2]); 8166 } 8167 else if (oDTP.oData.bArrMatchFormat[6] || // "dd-MMM-yyyy HH:mm:ss" 8168 oDTP.oData.bArrMatchFormat[7] || // "dd-MMM-yyyy hh:mm:ss AA" 8169 oDTP.oData.bArrMatchFormat[14] || // "dd-MMM-yyyy HH:mm:ss" 8170 oDTP.oData.bArrMatchFormat[15]) // "dd-MMM-yyyy hh:mm:ss AA" 8171 { 8172 iDate = parseInt(sArrDate[0]); 8173 iMonth = oDTP._getShortMonthIndex(sArrDate[1]); 8174 iYear = parseInt(sArrDate[2]); 8175 } 8176 8177 sTime = sArrDateTime[1]; 8178 if ($.cf._isValid(sTime)) { 8179 if (oDTP.oData.bIs12Hour) { 8180 if ($.cf._compare(oDTP.settings.dateTimeSeparator, oDTP.settings.timeMeridiemSeparator) && (sArrDateTime.length === 3)) 8181 sMeridiem = sArrDateTime[2]; 8182 else { 8183 sArrTimeComp = sTime.split(oDTP.settings.timeMeridiemSeparator); 8184 sTime = sArrTimeComp[0]; 8185 sMeridiem = sArrTimeComp[1]; 8186 } 8187 8188 if (!($.cf._compare(sMeridiem, "AM") || $.cf._compare(sMeridiem, "PM"))) 8189 sMeridiem = ""; 8190 } 8191 8192 sArrTime = sTime.split(oDTP.settings.timeSeparator); 8193 8194 iHour = parseInt(sArrTime[0]); 8195 iMinutes = parseInt(sArrTime[1]); 8196 if (bShowSeconds) { 8197 iSeconds = parseInt(sArrTime[2]); 8198 } 8199 8200 if (iHour === 12 && $.cf._compare(sMeridiem, "AM")) 8201 iHour = 0; 8202 else if (iHour < 12 && $.cf._compare(sMeridiem, "PM")) 8203 iHour += 12; 8204 } 8205 } 8206 iMinutes = oDTP._adjustMinutes(iMinutes); 8207 8208 dTempDate = new Date(iYear, iMonth, iDate, iHour, iMinutes, iSeconds, 0); 8209 return dTempDate; 8210 }, 8211 _getShortMonthIndex: function (sMonthName) { 8212 var oDTP = this; 8213 8214 for (var iTempIndex = 0; iTempIndex < oDTP.settings.shortMonthNames.length; iTempIndex++) { 8215 if ($.cf._compare(sMonthName, oDTP.settings.shortMonthNames[iTempIndex])) 8216 return iTempIndex; 8217 } 8218 }, 8219 _getFullMonthIndex: function (sMonthName) { 8220 var oDTP = this; 8221 8222 for (var iTempIndex = 0; iTempIndex < oDTP.settings.fullMonthNames.length; iTempIndex++) { 8223 if ($.cf._compare(sMonthName, oDTP.settings.fullMonthNames[iTempIndex])) 8224 return iTempIndex; 8225 } 8226 }, 8227 // Public Method 8228 getIs12Hour: function (sMode, sFormat) { 8229 var oDTP = this; 8230 8231 var bIs12Hour = false, 8232 iArgsLength = Function.length; 8233 8234 oDTP._setMatchFormat(iArgsLength, sMode, sFormat); 8235 8236 if (oDTP.oData.bTimeMode) { 8237 bIs12Hour = oDTP.oData.bArrMatchFormat[0] || 8238 oDTP.oData.bArrMatchFormat[2]; 8239 } 8240 else if (oDTP.oData.bDateTimeMode) { 8241 bIs12Hour = oDTP.oData.bArrMatchFormat[1] || 8242 oDTP.oData.bArrMatchFormat[3] || 8243 oDTP.oData.bArrMatchFormat[5] || 8244 oDTP.oData.bArrMatchFormat[7] || 8245 oDTP.oData.bArrMatchFormat[9] || 8246 oDTP.oData.bArrMatchFormat[11] || 8247 oDTP.oData.bArrMatchFormat[13] || 8248 oDTP.oData.bArrMatchFormat[15]; 8249 } 8250 8251 oDTP._setMatchFormat(iArgsLength); 8252 8253 return bIs12Hour; 8254 }, 8255 //----------------------------------------------------------------- 8256 8257 _setVariablesForDate: function (dInput, bIncludeTime, bSetMeridiem) { 8258 var oDTP = this; 8259 8260 var dTemp, oDTV = {}, 8261 bValidInput = $.cf._isValid(dInput); 8262 if (bValidInput) { 8263 dTemp = new Date(dInput); 8264 if (!$.cf._isValid(bIncludeTime)) 8265 bIncludeTime = true; 8266 if (!$.cf._isValid(bSetMeridiem)) 8267 bSetMeridiem = true; 8268 } 8269 else { 8270 if (Object.prototype.toString.call(oDTP.oData.dCurrentDate) === '[object Date]' && isFinite(oDTP.oData.dCurrentDate)) 8271 dTemp = new Date(oDTP.oData.dCurrentDate); 8272 else 8273 dTemp = new Date(); 8274 8275 if (!$.cf._isValid(bIncludeTime)) 8276 bIncludeTime = (oDTP.oData.bTimeMode || oDTP.oData.bDateTimeMode); 8277 if (!$.cf._isValid(bSetMeridiem)) 8278 bSetMeridiem = oDTP.oData.bIs12Hour; 8279 } 8280 8281 oDTV.iCurrentDay = dTemp.getDate(); 8282 oDTV.iCurrentMonth = dTemp.getMonth(); 8283 oDTV.iCurrentYear = dTemp.getFullYear(); 8284 oDTV.iCurrentWeekday = dTemp.getDay(); 8285 8286 if (bIncludeTime) { 8287 oDTV.iCurrentHour = dTemp.getHours(); 8288 oDTV.iCurrentMinutes = dTemp.getMinutes(); 8289 oDTV.iCurrentSeconds = dTemp.getSeconds(); 8290 8291 if (bSetMeridiem) { 8292 oDTV.sCurrentMeridiem = oDTP._determineMeridiemFromHourAndMinutes(oDTV.iCurrentHour, oDTV.iCurrentMinutes); 8293 } 8294 } 8295 8296 if (bValidInput) 8297 return oDTV; 8298 else 8299 oDTP.oData = $.extend(oDTP.oData, oDTV); 8300 }, 8301 _getValuesFromInputBoxes: function () { 8302 var oDTP = this; 8303 8304 if (oDTP.oData.bDateMode || oDTP.oData.bDateTimeMode) { 8305 var sMonth, iMonth; 8306 8307 sMonth = $(oDTP.element).find(".month .dtpicker-compValue").val(); 8308 if (sMonth.length > 1) 8309 sMonth = sMonth.charAt(0).toUpperCase() + sMonth.slice(1); 8310 iMonth = oDTP.settings.shortMonthNames.indexOf(sMonth); 8311 if (iMonth !== -1) { 8312 oDTP.oData.iCurrentMonth = parseInt(iMonth); 8313 } 8314 else { 8315 if (sMonth.match("^[+|-]?[0-9]+$")) { 8316 oDTP.oData.iCurrentMonth = parseInt(sMonth - 1); 8317 } 8318 } 8319 8320 oDTP.oData.iCurrentDay = parseInt($(oDTP.element).find(".day .dtpicker-compValue").val()) || oDTP.oData.iCurrentDay; 8321 oDTP.oData.iCurrentYear = parseInt($(oDTP.element).find(".year .dtpicker-compValue").val()) || oDTP.oData.iCurrentYear; 8322 } 8323 8324 if (oDTP.oData.bTimeMode || oDTP.oData.bDateTimeMode) { 8325 var iTempHour, iTempMinutes, iTempSeconds, sMeridiem; 8326 8327 iTempHour = parseInt($(oDTP.element).find(".hour .dtpicker-compValue").val()); 8328 iTempMinutes = oDTP._adjustMinutes(parseInt($(oDTP.element).find(".minutes .dtpicker-compValue").val())); 8329 iTempSeconds = oDTP._adjustMinutes(parseInt($(oDTP.element).find(".seconds .dtpicker-compValue").val())); 8330 8331 oDTP.oData.iCurrentHour = isNaN(iTempHour) ? oDTP.oData.iCurrentHour : iTempHour; 8332 oDTP.oData.iCurrentMinutes = isNaN(iTempMinutes) ? oDTP.oData.iCurrentMinutes : iTempMinutes; 8333 oDTP.oData.iCurrentSeconds = isNaN(iTempSeconds) ? oDTP.oData.iCurrentSeconds : iTempSeconds; 8334 8335 if (oDTP.oData.iCurrentSeconds > 59) { 8336 oDTP.oData.iCurrentMinutes += oDTP.oData.iCurrentSeconds / 60; 8337 oDTP.oData.iCurrentSeconds = oDTP.oData.iCurrentSeconds % 60; 8338 } 8339 if (oDTP.oData.iCurrentMinutes > 59) { 8340 oDTP.oData.iCurrentHour += oDTP.oData.iCurrentMinutes / 60; 8341 oDTP.oData.iCurrentMinutes = oDTP.oData.iCurrentMinutes % 60; 8342 } 8343 8344 if (oDTP.oData.bIs12Hour) { 8345 if (oDTP.oData.iCurrentHour > 12) 8346 oDTP.oData.iCurrentHour = (oDTP.oData.iCurrentHour % 12); 8347 } 8348 else { 8349 if (oDTP.oData.iCurrentHour > 23) 8350 oDTP.oData.iCurrentHour = (oDTP.oData.iCurrentHour % 23); 8351 } 8352 8353 if (oDTP.oData.bIs12Hour) { 8354 sMeridiem = $(oDTP.element).find(".meridiem .dtpicker-compValue").val(); 8355 if ($.cf._compare(sMeridiem, "AM") || $.cf._compare(sMeridiem, "PM")) 8356 oDTP.oData.sCurrentMeridiem = sMeridiem; 8357 8358 if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "PM")) { 8359 if (oDTP.oData.iCurrentHour !== 12 && oDTP.oData.iCurrentHour < 13) 8360 oDTP.oData.iCurrentHour += 12; 8361 } 8362 if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "AM") && oDTP.oData.iCurrentHour === 12) 8363 oDTP.oData.iCurrentHour = 0; 8364 } 8365 } 8366 }, 8367 _setCurrentDate: function () { 8368 var oDTP = this; 8369 8370 if (oDTP.oData.bTimeMode || oDTP.oData.bDateTimeMode) { 8371 if (oDTP.oData.iCurrentSeconds > 59) { 8372 oDTP.oData.iCurrentMinutes += oDTP.oData.iCurrentSeconds / 60; 8373 oDTP.oData.iCurrentSeconds = oDTP.oData.iCurrentSeconds % 60; 8374 } 8375 else if (oDTP.oData.iCurrentSeconds < 0) { 8376 oDTP.oData.iCurrentMinutes -= oDTP.settings.minuteInterval; 8377 oDTP.oData.iCurrentSeconds += 60; 8378 } 8379 oDTP.oData.iCurrentMinutes = oDTP._adjustMinutes(oDTP.oData.iCurrentMinutes); 8380 oDTP.oData.iCurrentSeconds = oDTP._adjustSeconds(oDTP.oData.iCurrentSeconds); 8381 } 8382 8383 var dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0), 8384 bGTMaxDate = false, bLTMinDate = false, 8385 sFormat, oDate, oFormattedDate, oFormattedTime, 8386 sDate, sTime, sDateTime; 8387 8388 if (oDTP.oData.dMaxValue !== null) 8389 bGTMaxDate = (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()); 8390 if (oDTP.oData.dMinValue !== null) 8391 bLTMinDate = (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()); 8392 8393 if (bGTMaxDate || bLTMinDate) { 8394 var bCDGTMaxDate = false, bCDLTMinDate = false; 8395 if (oDTP.oData.dMaxValue !== null) 8396 bCDGTMaxDate = (oDTP.oData.dCurrentDate.getTime() > oDTP.oData.dMaxValue.getTime()); 8397 if (oDTP.oData.dMinValue !== null) 8398 bCDLTMinDate = (oDTP.oData.dCurrentDate.getTime() < oDTP.oData.dMinValue.getTime()); 8399 8400 if (!(bCDGTMaxDate || bCDLTMinDate)) 8401 dTempDate = new Date(oDTP.oData.dCurrentDate); 8402 else { 8403 if (bCDGTMaxDate) { 8404 dTempDate = new Date(oDTP.oData.dMaxValue); 8405 console.log("Info : Date/Time/DateTime you entered is later than Maximum value, so DateTimePicker is showing Maximum value in Input Field."); 8406 } 8407 if (bCDLTMinDate) { 8408 dTempDate = new Date(oDTP.oData.dMinValue); 8409 console.log("Info : Date/Time/DateTime you entered is earlier than Minimum value, so DateTimePicker is showing Minimum value in Input Field."); 8410 } 8411 console.log("Please enter proper Date/Time/DateTime values."); 8412 } 8413 } 8414 8415 oDTP.oData.dCurrentDate = new Date(dTempDate); 8416 oDTP._setVariablesForDate(); 8417 8418 oDate = {}; 8419 sDate = ""; 8420 sTime = ""; 8421 sDateTime = ""; 8422 8423 if (oDTP.oData.bDateMode || oDTP.oData.bDateTimeMode) { 8424 if (oDTP.oData.bDateMode && (oDTP.oData.bArrMatchFormat[4] || oDTP.oData.bArrMatchFormat[5] || oDTP.oData.bArrMatchFormat[6])) 8425 oDTP.oData.iCurrentDay = 1; 8426 8427 oFormattedDate = oDTP._formatDate(); 8428 8429 $(oDTP.element).find('.day .dtpicker-compValue').val(oFormattedDate.dd); 8430 8431 if (oDTP.oData.bDateMode) { 8432 if (oDTP.oData.bArrMatchFormat[4]) // "MM-yyyy" 8433 $(oDTP.element).find('.month .dtpicker-compValue').val(oFormattedDate.MM); 8434 else if (oDTP.oData.bArrMatchFormat[6]) // "MMMM yyyy" 8435 $(oDTP.element).find('.month .dtpicker-compValue').val(oFormattedDate.month); 8436 else 8437 $(oDTP.element).find('.month .dtpicker-compValue').val(oFormattedDate.monthShort); 8438 } 8439 else 8440 $(oDTP.element).find('.month .dtpicker-compValue').val(oFormattedDate.monthShort); 8441 8442 $(oDTP.element).find('.year .dtpicker-compValue').val(oFormattedDate.yyyy); 8443 8444 if (oDTP.settings.formatHumanDate) { 8445 oDate = $.extend(oDate, oFormattedDate); 8446 } 8447 else { 8448 if (oDTP.oData.bDateMode && (oDTP.oData.bArrMatchFormat[4] || oDTP.oData.bArrMatchFormat[5] || oDTP.oData.bArrMatchFormat[6])) { 8449 if (oDTP.oData.bArrMatchFormat[4]) 8450 sDate = oFormattedDate.MM + oDTP.settings.monthYearSeparator + oFormattedDate.yyyy; 8451 else if (oDTP.oData.bArrMatchFormat[5]) 8452 sDate = oFormattedDate.monthShort + oDTP.settings.monthYearSeparator + oFormattedDate.yyyy; 8453 else if (oDTP.oData.bArrMatchFormat[6]) 8454 sDate = oFormattedDate.month + oDTP.settings.monthYearSeparator + oFormattedDate.yyyy; 8455 } 8456 else 8457 sDate = oFormattedDate.dayShort + ", " + oFormattedDate.month + " " + oFormattedDate.dd + ", " + oFormattedDate.yyyy; 8458 } 8459 } 8460 if (oDTP.oData.bTimeMode || oDTP.oData.bDateTimeMode) { 8461 oFormattedTime = oDTP._formatTime(); 8462 8463 if (oDTP.oData.bIs12Hour) 8464 $(oDTP.element).find('.meridiem .dtpicker-compValue').val(oDTP.oData.sCurrentMeridiem); 8465 $(oDTP.element).find('.hour .dtpicker-compValue').val(oFormattedTime.hour); 8466 $(oDTP.element).find('.minutes .dtpicker-compValue').val(oFormattedTime.mm); 8467 $(oDTP.element).find('.seconds .dtpicker-compValue').val(oFormattedTime.ss); 8468 8469 if (oDTP.settings.formatHumanDate) { 8470 oDate = $.extend(oDate, oFormattedTime); 8471 } 8472 else { 8473 var bShowSecondsTime = (oDTP.oData.bTimeMode && ( 8474 oDTP.oData.bArrMatchFormat[0] || 8475 oDTP.oData.bArrMatchFormat[1])), 8476 bShowSecondsDateTime = (oDTP.oData.bDateTimeMode && 8477 (oDTP.oData.bArrMatchFormat[0] || 8478 oDTP.oData.bArrMatchFormat[1] || 8479 oDTP.oData.bArrMatchFormat[2] || 8480 oDTP.oData.bArrMatchFormat[3] || 8481 oDTP.oData.bArrMatchFormat[4] || 8482 oDTP.oData.bArrMatchFormat[5] || 8483 oDTP.oData.bArrMatchFormat[6] || 8484 oDTP.oData.bArrMatchFormat[7])); 8485 8486 if (bShowSecondsTime || bShowSecondsDateTime) 8487 sTime = oFormattedTime.hour + oDTP.settings.timeSeparator + oFormattedTime.mm + oDTP.settings.timeSeparator + oFormattedTime.ss; 8488 else 8489 sTime = oFormattedTime.hour + oDTP.settings.timeSeparator + oFormattedTime.mm; 8490 8491 if (oDTP.oData.bIs12Hour) 8492 sTime += oDTP.settings.timeMeridiemSeparator + oDTP.oData.sCurrentMeridiem; 8493 } 8494 } 8495 8496 if (oDTP.settings.formatHumanDate) { 8497 if (oDTP.oData.bDateTimeMode) 8498 sFormat = oDTP.oData.sDateFormat; 8499 else if (oDTP.oData.bDateMode) 8500 sFormat = oDTP.oData.sTimeFormat; 8501 else if (oDTP.oData.bTimeMode) 8502 sFormat = oDTP.oData.sDateTimeFormat; 8503 8504 sDateTime = oDTP.settings.formatHumanDate.call(oDTP, oDate, oDTP.settings.mode, sFormat); 8505 } 8506 else { 8507 if (oDTP.oData.bDateTimeMode) 8508 sDateTime = sDate + oDTP.settings.dateTimeSeparator + sTime; 8509 else if (oDTP.oData.bDateMode) 8510 sDateTime = sDate; 8511 else if (oDTP.oData.bTimeMode) 8512 sDateTime = sTime; 8513 } 8514 8515 $(oDTP.element).find('.dtpicker-value').html(sDateTime); 8516 8517 oDTP._setButtons(); 8518 }, 8519 _formatDate: function (oDTVP) { 8520 var oDTP = this; 8521 var oDTV = {}, 8522 sDay, sYear, 8523 iMonth, sMonth, sMonthShort, sMonthFull, 8524 iDayOfTheWeek, sDayOfTheWeek, sDayOfTheWeekFull; 8525 8526 if ($.cf._isValid(oDTVP)) 8527 oDTV = $.extend({}, oDTVP); 8528 else { 8529 oDTV.iCurrentDay = oDTP.oData.iCurrentDay; 8530 oDTV.iCurrentMonth = oDTP.oData.iCurrentMonth; 8531 oDTV.iCurrentYear = oDTP.oData.iCurrentYear; 8532 oDTV.iCurrentWeekday = oDTP.oData.iCurrentWeekday; 8533 } 8534 8535 sDay = oDTV.iCurrentDay; 8536 sDay = (sDay < 10) ? ("0" + sDay) : sDay; 8537 iMonth = oDTV.iCurrentMonth; 8538 sMonth = oDTV.iCurrentMonth + 1; 8539 sMonth = (sMonth < 10) ? ("0" + sMonth) : sMonth; 8540 sMonthShort = oDTP.settings.shortMonthNames[iMonth]; 8541 sMonthFull = oDTP.settings.fullMonthNames[iMonth]; 8542 sYear = oDTV.iCurrentYear; 8543 iDayOfTheWeek = oDTV.iCurrentWeekday; 8544 sDayOfTheWeek = oDTP.settings.shortDayNames[iDayOfTheWeek]; 8545 sDayOfTheWeekFull = oDTP.settings.fullDayNames[iDayOfTheWeek]; 8546 8547 return { 8548 "dd": sDay, 8549 "MM": sMonth, 8550 "monthShort": sMonthShort, 8551 "month": sMonthFull, 8552 "yyyy": sYear, 8553 "dayShort": sDayOfTheWeek, 8554 "day": sDayOfTheWeekFull 8555 }; 8556 }, 8557 _formatTime: function (oDTVP) { 8558 var oDTP = this; 8559 var oDTV = {}, 8560 iHour24, sHour24, iHour12, sHour12, sHour, 8561 sMinutes, sSeconds; 8562 8563 if ($.cf._isValid(oDTVP)) 8564 oDTV = $.extend({}, oDTVP); 8565 else { 8566 oDTV.iCurrentHour = oDTP.oData.iCurrentHour; 8567 oDTV.iCurrentMinutes = oDTP.oData.iCurrentMinutes; 8568 oDTV.iCurrentSeconds = oDTP.oData.iCurrentSeconds; 8569 oDTV.sCurrentMeridiem = oDTP.oData.sCurrentMeridiem; 8570 } 8571 8572 iHour24 = oDTV.iCurrentHour; 8573 sHour24 = (iHour24 < 10) ? ("0" + iHour24) : iHour24; 8574 sHour = sHour24; 8575 8576 iHour12 = oDTV.iCurrentHour; 8577 if (iHour12 > 12) 8578 iHour12 -= 12; 8579 if (sHour === "00") 8580 iHour12 = 12; 8581 sHour12 = (iHour12 < 10) ? ("0" + iHour12) : iHour12; 8582 if (oDTP.oData.bIs12Hour) 8583 sHour = sHour12; 8584 8585 sMinutes = oDTV.iCurrentMinutes; 8586 sMinutes = (sMinutes < 10) ? ("0" + sMinutes) : sMinutes; 8587 sSeconds = oDTV.iCurrentSeconds; 8588 sSeconds = (sSeconds < 10) ? ("0" + sSeconds) : sSeconds; 8589 8590 return { 8591 "H": iHour24, 8592 "HH": sHour24, 8593 "h": iHour12, 8594 "hh": sHour12, 8595 "hour": sHour, 8596 "m": oDTV.iCurrentMinutes, 8597 "mm": sMinutes, 8598 "s": oDTV.iCurrentSeconds, 8599 "ss": sSeconds, 8600 "ME": oDTV.sCurrentMeridiem 8601 }; 8602 }, 8603 _setButtons: function () { 8604 var oDTP = this; 8605 $(oDTP.element).find('.dtpicker-compButton').removeClass("dtpicker-compButtonDisable").addClass('dtpicker-compButtonEnable'); 8606 8607 var dTempDate; 8608 if (oDTP.oData.dMaxValue !== null) { 8609 if (oDTP.oData.bTimeMode) { 8610 // Decrement Hour 8611 if ((oDTP.oData.iCurrentHour + 1) > oDTP.oData.dMaxValue.getHours() || ((oDTP.oData.iCurrentHour + 1) === oDTP.oData.dMaxValue.getHours() && oDTP.oData.iCurrentMinutes > oDTP.oData.dMaxValue.getMinutes())) 8612 $(oDTP.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8613 8614 // Decrement Minutes 8615 if (oDTP.oData.iCurrentHour >= oDTP.oData.dMaxValue.getHours() && (oDTP.oData.iCurrentMinutes + 1) > oDTP.oData.dMaxValue.getMinutes()) 8616 $(oDTP.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8617 } 8618 else { 8619 // Increment Day 8620 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, (oDTP.oData.iCurrentDay + 1), oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8621 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8622 $(oDTP.element).find(".day .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8623 8624 // Increment Month 8625 dTempDate = new Date(oDTP.oData.iCurrentYear, (oDTP.oData.iCurrentMonth + 1), oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8626 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8627 $(oDTP.element).find(".month .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8628 8629 // Increment Year 8630 dTempDate = new Date((oDTP.oData.iCurrentYear + 1), oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8631 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8632 $(oDTP.element).find(".year .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8633 8634 // Increment Hour 8635 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, (oDTP.oData.iCurrentHour + 1), oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8636 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8637 $(oDTP.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8638 8639 // Increment Minutes 8640 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, (oDTP.oData.iCurrentMinutes + 1), oDTP.oData.iCurrentSeconds, 0); 8641 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8642 $(oDTP.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8643 8644 // Increment Seconds 8645 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, (oDTP.oData.iCurrentSeconds + 1), 0); 8646 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8647 $(oDTP.element).find(".seconds .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8648 } 8649 } 8650 8651 if (oDTP.oData.dMinValue !== null) { 8652 if (oDTP.oData.bTimeMode) { 8653 // Decrement Hour 8654 if ((oDTP.oData.iCurrentHour - 1) < oDTP.oData.dMinValue.getHours() || ((oDTP.oData.iCurrentHour - 1) === oDTP.oData.dMinValue.getHours() && oDTP.oData.iCurrentMinutes < oDTP.oData.dMinValue.getMinutes())) 8655 $(oDTP.element).find(".hour .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8656 8657 // Decrement Minutes 8658 if (oDTP.oData.iCurrentHour <= oDTP.oData.dMinValue.getHours() && (oDTP.oData.iCurrentMinutes - 1) < oDTP.oData.dMinValue.getMinutes()) 8659 $(oDTP.element).find(".minutes .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8660 } 8661 else { 8662 // Decrement Day 8663 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, (oDTP.oData.iCurrentDay - 1), oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8664 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8665 $(oDTP.element).find(".day .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8666 8667 // Decrement Month 8668 dTempDate = new Date(oDTP.oData.iCurrentYear, (oDTP.oData.iCurrentMonth - 1), oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8669 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8670 $(oDTP.element).find(".month .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8671 8672 // Decrement Year 8673 dTempDate = new Date((oDTP.oData.iCurrentYear - 1), oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8674 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8675 $(oDTP.element).find(".year .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8676 8677 // Decrement Hour 8678 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, (oDTP.oData.iCurrentHour - 1), oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8679 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8680 $(oDTP.element).find(".hour .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8681 8682 // Decrement Minutes 8683 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, (oDTP.oData.iCurrentMinutes - 1), oDTP.oData.iCurrentSeconds, 0); 8684 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8685 $(oDTP.element).find(".minutes .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8686 8687 // Decrement Seconds 8688 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, oDTP.oData.iCurrentHour, oDTP.oData.iCurrentMinutes, (oDTP.oData.iCurrentSeconds - 1), 0); 8689 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8690 $(oDTP.element).find(".seconds .decrement").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8691 } 8692 } 8693 8694 if (oDTP.oData.bIs12Hour) { 8695 var iTempHour, iTempMinutes; 8696 if (oDTP.oData.dMaxValue !== null || oDTP.oData.dMinValue !== null) { 8697 iTempHour = oDTP.oData.iCurrentHour; 8698 if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "AM")) 8699 iTempHour += 12; 8700 else if ($.cf._compare(oDTP.oData.sCurrentMeridiem, "PM")) 8701 iTempHour -= 12; 8702 8703 dTempDate = new Date(oDTP.oData.iCurrentYear, oDTP.oData.iCurrentMonth, oDTP.oData.iCurrentDay, iTempHour, oDTP.oData.iCurrentMinutes, oDTP.oData.iCurrentSeconds, 0); 8704 8705 if (oDTP.oData.dMaxValue !== null) { 8706 if (oDTP.oData.bTimeMode) { 8707 iTempMinutes = oDTP.oData.iCurrentMinutes; 8708 if (iTempHour > oDTP.oData.dMaxValue.getHours() || (iTempHour === oDTP.oData.dMaxValue.getHours() && iTempMinutes > oDTP.oData.dMaxValue.getMinutes())) 8709 $(oDTP.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8710 } 8711 else { 8712 if (dTempDate.getTime() > oDTP.oData.dMaxValue.getTime()) 8713 $(oDTP.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8714 } 8715 } 8716 8717 if (oDTP.oData.dMinValue !== null) { 8718 if (oDTP.oData.bTimeMode) { 8719 iTempMinutes = oDTP.oData.iCurrentMinutes; 8720 if (iTempHour < oDTP.oData.dMinValue.getHours() || (iTempHour === oDTP.oData.dMinValue.getHours() && iTempMinutes < oDTP.oData.dMinValue.getMinutes())) 8721 $(oDTP.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8722 } 8723 else { 8724 if (dTempDate.getTime() < oDTP.oData.dMinValue.getTime()) 8725 $(oDTP.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"); 8726 } 8727 } 8728 } 8729 } 8730 }, 8731 // Public Method 8732 setIsPopup: function (bIsPopup) { 8733 var oDTP = this; 8734 oDTP.settings.isPopup = bIsPopup; 8735 8736 if ($(oDTP.element).css("display") !== "none") 8737 oDTP._hidePicker(0);
8738 8739 if (oDTP.settings.isPopup) { 8740 $(oDTP.element).addClass("dtpicker-mobile"); 8741 8742 $(oDTP.element).css({ position: "fixed", top: 0, left: 0, width: "100%", height: "100%" }); 8743 } 8744 else { 8745 $(oDTP.element).removeClass("dtpicker-mobile"); 8746 8747 if (oDTP.oData.oInputElement !== null) { 8748 var iElemTop = $(oDTP.oData.oInputElement).offset().top + $(oDTP.oData.oInputElement).outerHeight(), 8749 iElemLeft = $(oDTP.oData.oInputElement).offset().left, 8750 iElemWidth = $(oDTP.oData.oInputElement).outerWidth(); 8751 8752 $(oDTP.element).css({ position: "absolute", top: iElemTop, left: iElemLeft, width: iElemWidth, height: "auto" }); 8753 } 8754 } 8755 }, 8756 _compareDates: function (dDate1, dDate2) { 8757 dDate1 = new Date(dDate1.getDate(), dDate1.getMonth(), dDate1.getFullYear(), 0, 0, 0, 0); 8758 dDate1 = new Date(dDate1.getDate(), dDate1.getMonth(), dDate1.getFullYear(), 0, 0, 0, 0); 8759 var iDateDiff = (dDate1.getTime() - dDate2.getTime()) / 864E5; 8760 return (iDateDiff === 0) ? iDateDiff : (iDateDiff / Math.abs(iDateDiff)); 8761 }, 8762 _compareTime: function (dTime1, dTime2) { 8763 var iTimeMatch = 0; 8764 if ((dTime1.getHours() === dTime2.getHours()) && (dTime1.getMinutes() === dTime2.getMinutes())) 8765 iTimeMatch = 1; // 1 = Exact Match 8766 else { 8767 if (dTime1.getHours() < dTime2.getHours()) 8768 iTimeMatch = 2; // time1 < time2 8769 else if (dTime1.getHours() > dTime2.getHours()) 8770 iTimeMatch = 3; // time1 > time2 8771 else if (dTime1.getHours() === dTime2.getHours()) { 8772 if (dTime1.getMinutes() < dTime2.getMinutes()) 8773 iTimeMatch = 2; // time1 < time2 8774 else if (dTime1.getMinutes() > dTime2.getMinutes()) 8775 iTimeMatch = 3; // time1 > time2 8776 } 8777 } 8778 return iTimeMatch; 8779 }, 8780 _compareDateTime: function (dDate1, dDate2) { 8781 var iDateTimeDiff = (dDate1.getTime() - dDate2.getTime()) / 6E4; 8782 return (iDateTimeDiff === 0) ? iDateTimeDiff : (iDateTimeDiff / Math.abs(iDateTimeDiff)); 8783 }, 8784 _determineMeridiemFromHourAndMinutes: function (iHour, iMinutes) { 8785 if (iHour > 12) { 8786 return "PM"; 8787 } 8788 else if (iHour === 12 && iMinutes >= 0) { 8789 return "PM"; 8790 } 8791 else { 8792 return "AM"; 8793 } 8794 }, 8795 // Public Method 8796 setLanguage: function (sLanguage) { 8797 var oDTP = this; 8798 8799 oDTP.settings = $.extend({}, $.DateTimePicker.defaults, $.DateTimePicker.i18n[sLanguage], oDTP.options); 8800 8801 oDTP._setDateFormatArray(); // Set DateFormatArray 8802 oDTP._setTimeFormatArray(); // Set TimeFormatArray 8803 oDTP._setDateTimeFormatArray(); // Set DateTimeFormatArray 8804 8805 return oDTP; 8806 } 8807 8808 }; 8809 8810})); 8811 8812; 8813!function (i) { 8814 "function" == typeof define && define.amd ? define(["jquery"], i) : "object" == typeof exports ? module.exports = i(require("jquery")) : i(jQuery) 8815}(function ($) { 8816 "use strict"; 8817 function i(i, t) { 8818 var o = $('<div class="minicolors" />'), s = $.minicolors.defaults, a, n, r, c, l; 8819 if (!i.data("minicolors-initialized")) { 8820 if (t = $.extend(!0, {}, s, t), o.addClass("minicolors-theme-" + t.theme).toggleClass("minicolors-with-opacity", t.opacity).toggleClass("minicolors-no-data-uris", t.dataUris !== !0), void 0 !== t.position && $.each(t.position.split(" "), function () { 8821 o.addClass("minicolors-position-" + this) 8822 }), a = "rgb" === t.format ? t.opacity ? "25" : "20" : t.keywords ? "11" : "7", i.addClass("minicolors-input").data("minicolors-initialized", !1).data("minicolors-settings", t).prop("size", a).wrap(o).after('<div class="minicolors-panel minicolors-slider-' + t.control + '"><div class="minicolors-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-opacity-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-grid minicolors-sprite"><div class="minicolors-grid-inner"></div><div class="minicolors-picker"><div></div></div></div></div>'), t.inline || (i.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>'), i.next(".minicolors-input-swatch").on("click", function (t) { 8823 t.preventDefault(), i.focus() 8824 })), c = i.parent().find(".minicolors-panel"), c.on("selectstart", function () { 8825 return !1 8826 }).end(), t.swatches && 0 !== t.swatches.length) 8827 for (t.swatches.length > 7 && (t.swatches.length = 7), c.addClass("minicolors-with-swatches"), n = $('<ul class="minicolors-swatches"></ul>').appendTo(c), l = 0; l < t.swatches.length; ++l) 8828 r = t.swatches[l], r = f(r) ? u(r, !0) : x(p(r, !0)), $('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></li>').appendTo(n).data("swatch-color", t.swatches[l]).find(".minicolors-swatch-color").css({ backgroundColor: y(r), opacity: r.a }), t.swatches[l] = r; 8829 t.inline && i.parent().addClass("minicolors-inline"), e(i, !1), i.data("minicolors-initialized", !0) 8830 } 8831 } 8832 function t(i) { 8833 var t = i.parent(); 8834 i.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input"), t.before(i).remove() 8835 } 8836 function o(i) { 8837 var t = i.parent(), o = t.find(".minicolors-panel"), a = i.data("minicolors-settings"); 8838 !i.data("minicolors-initialized") || i.prop("disabled") || t.hasClass("minicolors-inline") || t.hasClass("minicolors-focus") || (s(), t.addClass("minicolors-focus"), o.stop(!0, !0).fadeIn(a.showSpeed, function () { 8839 a.show && a.show.call(i.get(0)) 8840 })) 8841 } 8842 function s() { 8843 $(".minicolors-focus").each(function () { 8844 var i = $(this), t = i.find(".minicolors-input"), o = i.find(".minicolors-panel"), s = t.data("minicolors-settings"); 8845 o.fadeOut(s.hideSpeed, function () { 8846 s.hide && s.hide.call(t.get(0)), i.removeClass("minicolors-focus") 8847 }) 8848 }) 8849 } 8850 function a(i, t, o) { 8851 var s = i.parents(".minicolors").find(".minicolors-input"), a = s.data("minicolors-settings"), r = i.find("[class$=-picker]"), e = i.offset().left, c = i.offset().top, l = Math.round(t.pageX - e), h = Math.round(t.pageY - c), d = o ? a.animationSpeed : 0, p, u, g, m; 8852 t.originalEvent.changedTouches && (l = t.originalEvent.changedTouches[0].pageX - e, h = t.originalEvent.changedTouches[0].pageY - c), 0 > l && (l = 0), 0 > h && (h = 0), l > i.width() && (l = i.width()), h > i.height() && (h = i.height()), i.parent().is(".minicolors-slider-wheel") && r.parent().is(".minicolors-grid") && (p = 75 - l, u = 75 - h, g = Math.sqrt(p * p + u * u), m = Math.atan2(u, p), 0 > m && (m += 2 * Math.PI), g >
8852 75 && (g = 75, l = 75 - 75 * Math.cos(m), h = 75 - 75 * Math.sin(m)), l = Math.round(l), h = Math.round(h)), i.is(".minicolors-grid") ? r.stop(!0).animate({ top: h + "px", left: l + "px" }, d, a.animationEasing, function () { 8853 n(s, i) 8854 }) : r.stop(!0).animate({ top: h + "px" }, d, a.animationEasing, function () { 8855 n(s, i) 8856 }) 8857 } 8858 function n(i, t) { 8859 function o(i, t) { 8860 var o, s; 8861 return i.length && t ? (o = i.offset().left, s = i.offset().top, { x: o - t.offset().left + i.outerWidth() / 2, y: s - t.offset().top + i.outerHeight() / 2 }) : null 8862 } 8863 var s, a, n, e, l, h, d, p = i.val(), u = i.attr("data-opacity"), g = i.parent(), f = i.data("minicolors-settings"), v = g.find(".minicolors-input-swatch"), b = g.find(".minicolors-grid"), w = g.find(".minicolors-slider"), y = g.find(".minicolors-opacity-slider"), k = b.find("[class$=-picker]"), M = w.find("[class$=-picker]"), x = y.find("[class$=-picker]"), I = o(k, b), S = o(M, w), z = o(x, y); 8864 if (t.is(".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider")) { 8865 switch (f.control) { 8866 case "wheel": 8867 e = b.width() / 2 - I.x, l = b.height() / 2 - I.y, h = Math.sqrt(e * e + l * l), d = Math.atan2(l, e), 0 > d && (d += 2 * Math.PI), h > 75 && (h = 75, I.x = 69 - 75 * Math.cos(d), I.y = 69 - 75 * Math.sin(d)), a = m(h / .75, 0, 100), s = m(180 * d / Math.PI, 0, 360), n = m(100 - Math.floor(S.y * (100 / w.height())), 0, 100), p = C({ h: s, s: a, b: n }), w.css("backgroundColor", C({ h: s, s: a, b: 100 })); 8868 break; 8869 case "saturation": 8870 s = m(parseInt(I.x * (360 / b.width()), 10), 0, 360), a = m(100 - Math.floor(S.y * (100 / w.height())), 0, 100), n = m(100 - Math.floor(I.y * (100 / b.height())), 0, 100), p = C({ h: s, s: a, b: n }), w.css("backgroundColor", C({ h: s, s: 100, b: n })), g.find(".minicolors-grid-inner").css("opacity", a / 100); 8871 break; 8872 case "brightness": 8873 s = m(parseInt(I.x * (360 / b.width()), 10), 0, 360), a = m(100 - Math.floor(I.y * (100 / b.height())), 0, 100), n = m(100 - Math.floor(S.y * (100 / w.height())), 0, 100), p = C({ h: s, s: a, b: n }), w.css("backgroundColor", C({ h: s, s: a, b: 100 })), g.find(".minicolors-grid-inner").css("opacity", 1 - n / 100); 8874 break; 8875 default: 8876 s = m(360 - parseInt(S.y * (360 / w.height()), 10), 0, 360), a = m(Math.floor(I.x * (100 / b.width())), 0, 100), n = m(100 - Math.floor(I.y * (100 / b.height())), 0, 100), p = C({ h: s, s: a, b: n }), b.css("backgroundColor", C({ h: s, s: 100, b: 100 })) 8877 } 8878 u = f.opacity ? parseFloat(1 - z.y / y.height()).toFixed(2) : 1, r(i, p, u) 8879 } else 8880 v.find("span").css({ backgroundColor: p, opacity: u }), c(i, p, u) 8881 } 8882 function r(i, t, o) { 8883 var s, a = i.parent(), n = i.data("minicolors-settings"), r = a.find(".minicolors-input-swatch"); 8884 n.opacity && i.attr("data-opacity", o), "rgb" === n.format ? (s = f(t) ? u(t, !0) : x(p(t, !0)), o = "" === i.attr("data-opacity") ? 1 : m(parseFloat(i.attr("data-opacity")).toFixed(2), 0, 1), (isNaN(o) || !n.opacity) && (o = 1), t = i.minicolors("rgbObject").a <= 1 && s && n.opacity ? "rgba(" + s.r + ", " + s.g + ", " + s.b + ", " + parseFloat(o) + ")" : "rgb(" + s.r + ", " + s.g + ", " + s.b + ")") : (f(t) && (t = w(t)), t = d(t, n.letterCase)), i.val(t), r.find("span").css({ backgroundColor: t, opacity: o }), c(i, t, o) 8885 } 8886 function e(i, t) { 8887 var o, s, a, n, r, e, l, h, b, y, M = i.parent(), x = i.data("minicolors-settings"), I = M.find(".minicolors-input-swatch"), S = M.find(".minicolors-grid"), z = M.find(".minicolors-slider"), F = M.find(".minicolors-opacity-slider"), D = S.find("[class$=-picker]"), T = z.find("[class$=-picker]"), j = F.find("[class$=-picker]"); 8888 switch (f(i.val()) ? (o = w(i.val()), r = m(parseFloat(v(i.val())).toFixed(2), 0, 1), r && i.attr("data-opacity", r)) : o = d(p(i.val(), !0), x.letterCase), o || (o = d(g(x.defaultValue, !0), x.letterCase)), s = k(o), n = x.keywords ? $.map(x.keywords.split(","), function (i) { 8889 return $.trim(i.toLowerCase()) 8890 }) : [], e = "" !== i.val() && $.inArray(i.val().toLowerCase(), n) > -1 ? d(i.val()) : f(i.val()) ? u(i.val()) : o, t || i.val(e), x.opacity && (a = "" === i.attr("data-opacity") ? 1 : m(parseFloat(i.attr("data-opacity")).toFixed(2), 0, 1), isNaN(a) && (a = 1), i.attr("data-opacity", a), I.find("span").css("opacity", a), h = m(F.height() - F.height() * a, 0, F.height()), j.css("top", h + "px")), "transparent" === i.val().toLowerCase() && I.find("span").css("opacity", 0), I.find("span").css("backgroundColor", o), x.control) { 8891 case "wheel": 8892 b = m(Math.ceil(.75 * s.s), 0, S.height() / 2), y = s.h * Math.PI / 180, l = m(75 - Math.cos(y) * b, 0, S.width()), h = m(75 - Math.sin(y) * b, 0, S.height()), D.css({ top: h + "px", left: l + "px" }), h = 150 - s.b / (100 / S.height()), "" === o && (h = 0), T.css("top", h + "px"), z.css("backgroundColor", C({ h: s.h, s: s.s, b: 100 })); 8893 break; 8894 case "saturation": 8895 l = m(5 * s.h / 12, 0, 150), h = m(S.height() - Math.ceil(s.b / (100 / S.height())), 0, S.height()), D.css({ top: h + "px", left: l + "px" }), h = m(z.height() - s.s * (z.height() / 100), 0, z.height()), T.css("top", h + "px"), z.css("backgroundColor", C({ h: s.h, s: 100, b: s.b })), M.find(".minicolors-grid-inner").css("opacity", s.s / 100); 8896 break; 8897 case "brightness": 8898 l = m(5 * s.h / 12, 0, 150), h = m(S.height() - Math.ceil(s.s / (100 / S.height())), 0, S.height()), D.css({ top: h + "px", left: l + "px" }), h = m(z.height() - s.b * (z.height() / 100), 0, z.height()), T.css("top", h + "px"), z.css("backgroundColor", C({ h: s.h, s: s.s, b: 100 })), M.find(".minicolors-grid-inner").css("opacity", 1 - s.b / 100); 8899 break; 8900 default: 8901 l = m(Math.ceil(s.s / (100 / S.width())), 0, S.width()), h = m(S.height() - Math.ceil(s.b / (100 / S.height())), 0, S.height()), D.css({ top: h + "px", left: l + "px" }), h = m(z.height() - s.h / (360 / z.height()), 0, z.height()), T.css("top", h + "px"), S.css("backgroundColor", C({ h: s.h, s: 100, b: 100 })) 8902 } 8903 i.data("minicolors-initialized") && c(i, e, a) 8904 } 8905 function c(i, t, o) { 8906 var s = i.data("minicolors-settings"), a = i.data("minicolors-lastChange"), n, r, e; 8907 if (!a || a.value !== t || a.opacity !== o) { 8908 if (i.data("minicolors-lastChange", { value: t, opacity: o }), s.swatches && 0 !== s.swatches.length) { 8909 for (n = f(t) ? u(t, !0) : x(t), r = - 1, e = 0; e < s.swatches.length; ++e) 8910 if (n.r === s.swatches[e].r && n.g === s.swatches[e].g && n.b === s.swatches[e].b && n.a === s.swatches[e].a) { 8911 r = e; 8912 break 8913 } 8914 i.parent().find(".minicolors-swatches .minicolors-swatch").removeClass("selected"), -1 !== e && i.parent().find(".minicolors-swatches .minicolors-swatch").eq(e).addClass("selected") 8915 } 8916 s.change && (s.changeDelay ? (clearTimeout(i.data("minicolors-changeTimeout")), i.data("minicolors-changeTimeout", setTimeout(function () { 8917 s.change.call(i.get(0), t, o) 8918 }, s.changeDelay))) : s.change.call(i.get(0), t, o)), i.trigger("change").trigger("input") 8919 } 8920 } 8921 function l(i) { 8922 var t = p($(i).val(), !0), o = x(t), s = $(i).attr("data-opacity"); 8923 return o ? (void 0 !== s && $.extend(o, { a: parseFloat(s) }), o) : null 8924 } 8925 function h(i, t) { 8926 var o = p($(i).val(), !0), s = x(o), a = $(i).attr("data-opacity"); 8927 return s ? (void 0 === a && (a = 1), t ? "rgba(" + s.r + ", " + s.g + ", " + s.b + ", " + parseFloat(a) + ")" : "rgb(" + s.r + ", " + s.g + ", " + s.b + ")") : null 8928 } 8929 function d(i, t) { 8930 return "uppercase" === t ? i.toUpperCase() : i.toLowerCase() 8931 } 8932 function p(i, t) { 8933 return i = i.replace(/^#/g, ""), i.match(/^[A-F0-9]{3,6}/gi) ? 3 !== i.length && 6 !== i.length ? "" : (3 === i.length && t && (i = i[0] + i[0] + i[1] + i[1] + i[2] + i[2]), "#" + i) : "" 8934 } 8935 function u(i, t) { 8936 var o = i.replace(/[^\d,.]/g, ""), s = o.split(","); 8937 return s[0] = m(parseInt(s[0], 10), 0, 255), s[1] = m(parseInt(s[1], 10), 0, 255), s[2] = m(parseInt(s[2], 10), 0, 255), s[3] && (s[3] = m(parseFloat(s[3], 10), 0, 1)), t ? { r: s[0], g: s[1], b: s[2], a: s[3] ? s[3] : null } : "undefined" != typeof s[3] && s[3] <= 1 ? "rgba(" + s[0] + ", " + s[1] + ", " + s[2] + ", " + s[3] + ")" : "rgb(" + s[0] + ", " + s[1] + ", " + s[2] + ")" 8938 } 8939 function g(i, t) { 8940 return f(i) ? u(i) : p(i, t) 8941 } 8942 function m(i, t, o) { 8943 return t > i && (i = t), i > o && (i = o), i 8944 } 8945 function f(i) { 8946 var t = i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); 8947 return t && 4 === t.length ? !0 : !1 8948 } 8949 function v(i) { 8950 return i = i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2})?|\.\d{1,2})[\s+]?/i), i && 6 === i.length ? i[4] : "1" 8951 } 8952 function b(i) { 8953 var t = {}, o = Math.round(i.h), s = Math.round(255 * i.s / 100), a = Math.round(255 * i.b / 100); 8954 if (0 === s) 8955 t.r = t.g = t.b = a; 8956 else { 8957 var n = a, r = (255 - s) * a / 255, e = (n - r) * (o % 60) / 60; 8958 360 === o && (o = 0), 60 > o ? (t.r = n, t.b = r, t.g = r + e) : 120 > o ? (t.g = n, t.b = r, t.r = n - e) : 180 > o ? (t.g = n, t.r = r, t.b = r + e) : 240 > o ? (t.b = n, t.r = r, t.g = n - e) : 300 > o ? (t.b = n, t.g = r, t.r = r + e) : 360 > o ? (t.r = n, t.g = r, t.b = n - e) : (t.r = 0, t.g = 0, t.b = 0) 8959 } 8960 return { r: Math.round(t.r), g: Math.round(t.g), b: Math.round(t.b) } 8961 } 8962 function w(i) { 8963 return i = i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i), i && 4 === i.length ? "#" + ("0" + parseInt(i[1], 10).toString(16)).slice(-2) + ("0" + parseInt(i[2], 10).toString(16)).slice(-2) + ("0" + parseInt(i[3], 10).toString(16)).slice(-2) : "" 8964 } 8965 function y(i) { 8966 var t = [i.r.toString(16), i.g.toString(16), i.b.toString(16)];
8967 return $.each(t, function (i, o) { 8968 1 === o.length && (t[i] = "0" + o) 8969 }), "#" + t.join("") 8970 } 8971 function C(i) { 8972 return y(b(i)) 8973 } 8974 function k(i) { 8975 var t = M(x(i)); 8976 return 0 === t.s && (t.h = 360), t 8977 } 8978 function M(i) { 8979 var t = { h: 0, s: 0, b: 0 }, o = Math.min(i.r, i.g, i.b), s = Math.max(i.r, i.g, i.b), a = s - o; 8980 return t.b = s, t.s = 0 !== s ? 255 * a / s : 0, 0 !== t.s ? i.r === s ? t.h = (i.g - i.b) / a : i.g === s ? t.h = 2 + (i.b - i.r) / a : t.h = 4 + (i.r - i.g) / a : t.h = -1, t.h *= 60, t.h < 0 && (t.h += 360), t.s *= 100 / 255, t.b *= 100 / 255, t 8981 } 8982 function x(i) { 8983 return i = parseInt(i.indexOf("#") > -1 ? i.substring(1) : i, 16), { r: i >> 16, g: (65280 & i) >> 8, b: 255 & i } 8984 } 8985 $.minicolors = { defaults: { animationSpeed: 50, animationEasing: "swing", change: null, changeDelay: 0, control: "hue", dataUris: !0, defaultValue: "", format: "hex", hide: null, hideSpeed: 100, inline: !1, keywords: "", letterCase: "lowercase", opacity: !1, position: "bottom left", show: null, showSpeed: 100, theme: "default", swatches: [] } }, $.extend($.fn, { 8986 minicolors: function (a, n) { 8987 switch (a) { 8988 case "destroy": 8989 return $(this).each(function () { 8990 t($(this)) 8991 }), $(this); 8992 case "hide": 8993 return s(), $(this); 8994 case "opacity": 8995 return void 0 === n ? $(this).attr("data-opacity") : ($(this).each(function () { 8996 e($(this).attr("data-opacity", n)) 8997 }), $(this)); 8998 case "rgbObject": 8999 return l($(this), "rgbaObject" === a); 9000 case "rgbString": 9001 case "rgbaString": 9002 return h($(this), "rgbaString" === a); 9003 case "settings": 9004 return void 0 === n ? $(this).data("minicolors-settings") : ($(this).each(function () { 9005 var i = $(this).data("minicolors-settings") || {}; 9006 t($(this)), $(this).minicolors($.extend(!0, i, n)) 9007 }), $(this)); 9008 case "show": 9009 return o($(this).eq(0)), $(this); 9010 case "value": 9011 return void 0 === n ? $(this).val() : ($(this).each(function () { 9012 "object" == typeof n ? (n.opacity && $(this).attr("data-opacity", m(n.opacity, 0, 1)), n.color && $(this).val(n.color)) : $(this).val(n), e($(this)) 9013 }), $(this)); 9014 default: 9015 return "create" !== a && (n = a), $(this).each(function () { 9016 i($(this), n) 9017 }), $(this) 9018 } 9019 } 9020 }), $(document).on("mousedown.minicolors touchstart.minicolors", function (i) { 9021 $(i.target).parents().add(i.target).hasClass("minicolors") || s() 9022 }).on("mousedown.minicolors touchstart.minicolors", ".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider", function (i) { 9023 var t = $(this); 9024 i.preventDefault(), $(document).data("minicolors-target", t), a(t, i, !0) 9025 }).on("mousemove.minicolors touchmove.minicolors", function (i) { 9026 var t = $(document).data("minicolors-target"); 9027 t && a(t, i) 9028 }).on("mouseup.minicolors touchend.minicolors", function () { 9029 $(this).removeData("minicolors-target") 9030 }).on("click.minicolors", ".minicolors-swatches li", function (i) { 9031 i.preventDefault(); 9032 var t = $(this), o = t.parents(".minicolors").find(".minicolors-input"), s = t.data("swatch-color"); 9033 r(o, s, v(s)), e(o) 9034 }).on("mousedown.minicolors touchstart.minicolors", ".minicolors-input-swatch", function (i) { 9035 var t = $(this).parent().find(".minicolors-input"); 9036 i.preventDefault(), o(t) 9037 }).on("focus.minicolors", ".minicolors-input", function () { 9038 var i = $(this); 9039 i.data("minicolors-initialized") && o(i) 9040 }).on("blur.minicolors", ".minicolors-input", function () { 9041 var i = $(this), t = i.data("minicolors-settings"), o, s, a, n, r; 9042 i.data("minicolors-initialized") && (o = t.keywords ? $.map(t.keywords.split(","), function (i) { 9043 return $.trim(i.toLowerCase()) 9044 }) : [], "" !== i.val() && $.inArray(i.val().toLowerCase(), o) > -1 ? r = i.val() : (f(i.val()) ? a = u(i.val(), !0) : (s = p(i.val(), !0), a = s ? x(s) : null), r = null === a ? t.defaultValue : "rgb" === t.format ? u(t.opacity ? "rgba(" + a.r + "," + a.g + "," + a.b + "," + i.attr("data-opacity") + ")" : "rgb(" + a.r + "," + a.g + "," + a.b + ")") : y(a)), n = t.opacity ? i.attr("data-opacity") : 1, "transparent" === r.toLowerCase() && (n = 0), i.closest(".minicolors").find(".minicolors-input-swatch > span").css("opacity", n), i.val(r), "" === i.val() && i.val(g(t.defaultValue, !0)), i.val(d(i.val(), t.letterCase))) 9045 }).on("keydown.minicolors", ".minicolors-input", function (i) { 9046 var t = $(this); 9047 if (t.data("minicolors-initialized")) 9048 switch (i.keyCode) { 9049 case 9: 9050 s(); 9051 break; 9052 case 13: 9053 case 27: 9054 s(), t.blur() 9055 } 9056 }).on("keyup.minicolors", ".minicolors-input", function () { 9057 var i = $(this); 9058 i.data("minicolors-initialized") && e(i, !0) 9059 }).on("paste.minicolors", ".minicolors-input", function () { 9060 var i = $(this); 9061 i.data("minicolors-initialized") && setTimeout(function () { 9062 e(i, !0) 9063 }, 1) 9064 }) 9065}); 9066; 9067$(function () { 9068 9069 /* 9070 * -------------------------- 9071 * Set up all our required plugins 9072 * -------------------------- 9073 */ 9074 9075 /* Datepicker */ 9076 $(document).ajaxComplete(function () { 9077 $('#DatePicker').remove(); 9078 var $div = $("<div>", { id: "DatePicker" }); 9079 $("body").append($div); 9080 $div.DateTimePicker({ 9081 dateTimeFormat: Attendize.DateTimeFormat 9082 }); 9083 9084 });
9085 9086 /* Responsive sidebar */ 9087 $(document.body).on('click', '.toggleSidebar', function (e) { 9088 $('html').toggleClass('sidebar-open-ltr'); 9089 e.preventDefault(); 9090 }); 9091 9092 /* Scroll to top */ 9093 $(window).scroll(function () { 9094 if ($(this).scrollTop() > 100) { 9095 $('.totop').fadeIn(); 9096 } else { 9097 $('.totop').fadeOut(); 9098 } 9099 }); 9100 9101 $(".totop").click(function () { 9102 $("html, body").animate({ 9103 scrollTop: 0 9104 }, 200); 9105 }); 9106 9107 9108 /* 9109 * -------------------- 9110 * Ajaxify those forms 9111 * -------------------- 9112 * 9113 * All forms with the 'ajax' class will automatically handle showing errors etc. 9114 * 9115 */ 9116 $('form.ajax').ajaxForm({ 9117 delegation: true, 9118 beforeSubmit: function (formData, jqForm, options) { 9119 9120 $(jqForm[0]) 9121 .find('.error.help-block') 9122 .remove(); 9123 $(jqForm[0]).find('.has-error') 9124 .removeClass('has-error'); 9125 9126 var $submitButton = $(jqForm[0]).find('input[type=submit]'); 9127 toggleSubmitDisabled($submitButton); 9128 9129 9130 }, 9131 uploadProgress: function (event, position, total, percentComplete) { 9132 $('.uploadProgress').show().html('Uploading Images - ' + percentComplete + '% Complete... '); 9133 }, 9134 error: function (data, statusText, xhr, $form) { 9135 9136 // Form validation error. 9137 if (422 == data.status) { 9138 processFormErrors($form, $.parseJSON(data.responseText)); 9139 return; 9140 } 9141 9142 showMessage('Whoops!, it looks like the server returned an error.'); 9143 9144 var $submitButton = $form.find('input[type=submit]'); 9145 toggleSubmitDisabled($submitButton); 9146 9147 $('.uploadProgress').hide(); 9148 }, 9149 success: function (data, statusText, xhr, $form) { 9150 9151 switch (data.status) { 9152 case 'success': 9153 9154 if ($form.hasClass('reset')) { 9155 $form.resetForm(); 9156 } 9157 9158 if ($form.hasClass('closeModalAfter')) { 9159 $('.modal, .modal-backdrop').fadeOut().remove(); 9160 } 9161 9162 var $submitButton = $form.find('input[type=submit]'); 9163 toggleSubmitDisabled($submitButton); 9164 9165 if (typeof data.message !== 'undefined') { 9166 showMessage(data.message); 9167 } 9168 9169 if (typeof data.runThis !== 'undefined') { 9170 eval(data.runThis); 9171 } 9172 9173 if (data.gd == 'gd') { 9174 $("#gdch").addClass("gdclo"); 9175 $(".gdjsbutton1").addClass("gddisplaynone"); 9176 $(".gdjsbutton2").addClass("gddisplaynone"); 9177 $(".gdjsbutton3").addClass("gddisplaynone"); 9178 $(".gdjsbutton4").addClass("gddisplaynone"); 9179 $("#gdcheckview").addClass("gddisplaynone"); 9180 $("#gdcheckmsg").removeClass("gddisplaynone"); 9181 $(".gdjsbutton5").removeClass("gddisplaynone"); 9182 if (data.gdok == 'File Failed') { 9183 document.getElementById("gdcheckmsg").innerHTML = " Excel format error file import failed"; 9184 } else { 9185 if (data.gdok == 'scheduled') { 9186 document.getElementById("gdcheckmsg").innerHTML = "Scheduled"; 9187 $(".scheduletoolbar").addClass("gddisplaynone"); 9188 } else { 9189 document.getElementById("gdcheckmsg").innerHTML = data.gdok + " Attendees Successfully Invited"; 9190 } 9191 } 9192 document.getElementById("gdjsbutton5").innerHTML = data.gdredirectUrl; 9193 } 9194 9195 if (typeof data.redirectUrl !== 'undefined') { 9196 window.location.href = data.redirectUrl; 9197 } 9198 9199 break; 9200 9201 case 'error': 9202 processFormErrors($form, data.messages); 9203 break; 9204 9205 default: 9206 break; 9207 } 9208 9209 $('.uploadProgress').hide(); 9210 }, 9211 dataType: 'json' 9212 });
9213 9214 9215 /* 9216 * -------------------- 9217 * Create a simple way to show remote dynamic modals from the frontend 9218 * -------------------- 9219 * 9220 * E.g : 9221 * <a href='/route/to/modal' class='loadModal'> 9222 * Click For Modal 9223 * </a> 9224 * 9225 */ 9226 $(document.body).on('click', '.gdjsbutton02', function () { 9227 $(".gdjsbutton0").addClass("gddisplaynone"); 9228 $(".gdjsbutton01").removeClass("gddisplaynone"); 9229 $(".gdjsbutton02").removeClass("gddisplaynone"); 9230 $(".gdjsbutton1").addClass("gddisplaynone"); 9231 $(".gdjsbutton2").addClass("gddisplaynone"); 9232 $("#gdbo").addClass("gddisplaynone"); 9233 $("#gdhistory").removeClass("gddisplaynone"); 9234 9235 $.ajax({ 9236 url: "/event/attendees/history/" + document.getElementById("gdjsbutton00").innerHTML, 9237 dataType: 'json', 9238 data: {}, 9239 success: function (dic) { 9240 var table = $('#gdhistorytable').dataTable({ 9241 order: [[0, 'desc']], 9242 "scrollX": true, 9243 destroy: true, 9244 "data": dic.gdrows, 9245 "columns": [ 9246 { data: "id", title: "id" }, 9247 { data: "file_name", title: "file name" }, 9248 // { data: "imported_count", title: "imported"}, 9249 // { data: "record_count", title: "record"}, 9250 { data: "created_at", title: "created" }, 9251 { data: "schedule_date", title: "schedule" }, 9252 { data: "status", title: "status" }, 9253 { data: "finish_at", title: "finish" }, 9254 { 9255 "render": function (data, type, row, meta) { 9256 return "<button class='btn btn-xs btn-primary' type='button' id='checkAttendeesImportLog' att_log_id='" + row.id + "'>log</button>"; 9257 } 9258 }, 9259 // { data: "schedule_log", title: "log"}, 9260 ] 9261 }); 9262 $("#gdhistorytable").addClass("display"); 9263 }, error: function (log) { 9264 console.log(log); 9265 } 9266 }); 9267 }); 9268 $(document.body).on('click', '.gdjsbutton0', function () { // history 9269 $(".gdjsbutton0").addClass("gddisplaynone"); 9270 $(".gdjsbutton01").removeClass("gddisplaynone"); 9271 $(".gdjsbutton02").removeClass("gddisplaynone"); 9272 $(".gdjsbutton1").addClass("gddisplaynone"); 9273 $(".gdjsbutton2").addClass("gddisplaynone"); 9274 $("#gdbo").addClass("gddisplaynone"); 9275 $("#gdhistory").removeClass("gddisplaynone"); 9276 $.ajax({
9277 url: "/event/attendees/history/" + document.getElementById("gdjsbutton00").innerHTML, 9278 dataType: 'json', 9279 data: {}, 9280 success: function (dic) { 9281 var table = $('#gdhistorytable').DataTable({ 9282 order: [[0, 'desc']], 9283 "scrollX": true, 9284 destroy: true, 9285 "data": dic.gdrows, 9286 "columns": [ 9287 { data: "id", title: "id" }, 9288 { data: "file_name", title: "file name" }, 9289 // { data: "imported_count", title: "imported"}, 9290 // { data: "record_count", title: "record"}, 9291 { data: "created_at", title: "created" }, 9292 { data: "schedule_date", title: "schedule" }, 9293 { data: "status", title: "status" }, 9294 { data: "finish_at", title: "finish" }, 9295 { 9296 "render": function (data, type, row, meta) { 9297 return "<button class='btn btn-xs btn-primary' type='button' id='checkAttendeesImportLog' att_log_id='" + row.id + "'>log</button>"; 9298 } 9299 }, 9300 // { data: "schedule_log", title: "log"}, 9301 ] 9302 }); 9303 $("#gdhistorytable").addClass("display"); 9304 }, error: function (log) { 9305 console.log(log); 9306 } 9307 }); 9308 }); 9309 9310 $(document.body).on('click', '#checkAttendeesImportLog', function () { 9311 $("#gdhistory").addClass("gddisplaynone"); 9312 $(".gdjsbutton02").addClass("gddisplaynone"); 9313 $("#gdlog").removeClass("gddisplaynone"); 9314 $(".gdjsbutton03").removeClass("gddisplaynone"); 9315 $(".gdjsbutton01").removeClass("gddisplaynone"); 9316 var att_log_id = $(this).attr("att_log_id"); 9317 $.ajax({
9318 url: "/event/attendees/showLogMsg/" + att_log_id, 9319 dataType: 'json', 9320 data: {}, 9321 success: function (obj) { 9322 var logs = obj.schedule_log; 9323 if (logs) { 9324 logs = logs.replace(/\n/g, "<br>"); 9325 var html = "<div id='logMsg'></div>"; 9326 $("#gdlog").html(html); 9327 $("#gdlog").find('#logMsg').html(logs); 9328 } else { 9329 $("#gdlog").html("<div id='logMsg'>No Logs</div>"); 9330 } 9331 }, error: function () { 9332 console.log("failed"); 9333 } 9334 }); 9335 }); 9336 $(document.body).on('click', ".gdjsbutton03", function () { 9337 $("#gdhistory").removeClass("gddisplaynone"); 9338 $(".gdjsbutton01").removeClass("gddisplaynone"); 9339 $(".gdjsbutton02").removeClass("gddisplaynone"); 9340 $(".gdjsbutton03").addClass("gddisplaynone"); 9341 $("#gdlog").addClass("gddisplaynone"); 9342 9343 var html = document.getElementById("gdlog").innerHTML; 9344 document.getElementById("logMsg").remove(); 9345 }); 9346 9347 $(document.body).on('click', '.gdjsbutton01', function () { 9348 $(".gdjsbutton0").removeClass("gddisplaynone"); 9349 $(".gdjsbutton01").addClass("gddisplaynone"); 9350 $(".gdjsbutton02").addClass("gddisplaynone"); 9351 $(".gdjsbutton1").removeClass("gddisplaynone"); 9352 $(".gdjsbutton2").removeClass("gddisplaynone"); 9353 $("#gdbo").removeClass("gddisplaynone"); 9354 $("#gdhistory").addClass("gddisplaynone"); 9355 $("#gdlog").addClass("gddisplaynone"); 9356 }); 9357 $(document.body).on('click', '.gdjsbutton5', function () { 9358 window.location.href = document.getElementById("gdjsbutton5").innerHTML; 9359 }); 9360 $(document.body).on('click', '.gdjsbutton2', function () { // check file 9361 $("#gdbo").addClass("gddisplaynone"); 9362 $("#gdcheckview").removeClass("gddisplaynone"); 9363 $(".gdjsbutton1").addClass("gddisplaynone"); 9364 $(".gdjsbutton2").addClass("gddisplaynone"); 9365 $(".gdjsbutton3").removeClass("gddisplaynone"); 9366 $(".gdjsbutton4").removeClass("gddisplaynone"); 9367 $(".gdjsbutton0").addClass("gddisplaynone"); 9368 $(".scheduletoolbar").removeClass("gddisplaynone"); 9369 }); 9370 $(document.body).on('click', '.gdjsbutton3', function () { // check fileéé¢çcancel button 9371 $("#gdbo").removeClass("gddisplaynone"); 9372 $("#gdcheckview").addClass("gddisplaynone"); 9373 $(".gdjsbutton1").removeClass("gddisplaynone"); 9374 $(".gdjsbutton2").removeClass("gddisplaynone"); 9375 $(".gdjsbutton3").addClass("gddisplaynone"); 9376 $(".gdjsbutton4").addClass("gddisplaynone"); 9377 $(".gdjsbutton0").removeClass("gddisplaynone"); 9378 $(".scheduletoolbar").addClass("gddisplaynone"); 9379 }); 9380 $(document.body).on('change', '.gdp :file', function () { 9381 document.getElementById("gdjsbutton2").innerHTML = 'Working...'; 9382 var fileObj = $(".gdinp")[0].files[0]; 9383 var formFile = new FormData(); 9384 formFile.append("file", fileObj); 9385 var data = formFile; 9386 $.ajax({
9387 url: "/event/attendees/check", 9388 data: data, 9389 type: "Post", 9390 dataType: "json", 9391 cache: false, 9392 processData: false, 9393 contentType: false, 9394 success: function (dic) { 9395 $(".gdjsbutton2").attr("disabled", false); 9396 $(".gdjsbutton2").removeClass("gdclo"); 9397 document.getElementById("gdjsbutton2").setAttribute("style", ""); 9398 document.getElementById("gdjsbutton2").innerHTML = 'Check .xlsx File'; 9399 var jsonColumns = JSON.parse(dic.result); 9400 var table = $('#gdtable').DataTable({ 9401 //"scrollX": true, 9402 destroy: true, 9403 "data": dic.the_file, 9404 "columns": jsonColumns 9405 // [ 9406 // { data: "first_name", title: "first_name"}, 9407 // { data: "last_name", title: "last_name"}, 9408 // { data: "phone_number", title: "phone_number"}, 9409 // { data: "email", title:"email"}, 9410 // ] 9411 }); 9412 $("#gdtable").addClass("display"); 9413 }, error: function (log) { 9414 console.log(log); 9415 } 9416 }) 9417 }); 9418 $(document.body).on('click', '.gdu, [data-invoke~=modal]', function (e) { 9419 $(".gdjsbutton3").attr("disabled", true); 9420 $(".gdjsbutton3").addClass("gdclo"); 9421 $("#gdprogress").removeClass("gdcssri"); 9422 if ($(".scheduleform").size() > 0) return; 9423 t1 = window.setInterval(function () { 9424 $.ajax({
9425 url: '/event/checkprogress/' + document.getElementById("gdbatchnum").innerHTML, 9426 dataType: 'json', 9427 data: {}, 9428 success: function (dic) { 9429 if (dic.total_record) { 9430 if (dic.num_added) { 9431 document.getElementById("gdprogress").innerHTML = dic.num_added + '/' + dic.total_record; 9432 } 9433 if (document.getElementById("gdcheckmsg").innerText) { 9434 clearInterval(t1); 9435 } 9436 } 9437 }, error: function (log) { 9438 console.log(log); 9439 clearInterval(t1); 9440 } 9441 }); 9442 }, 100); 9443 }); 9444 $(document.body).on('click', '.loadModal, [data-invoke~=modal]', function (e) { 9445 9446 var loadUrl = $(this).data('href'), 9447 cacheResult = $(this).data('cache') === 'on', 9448 $button = $(this); 9449 9450 $('.modal').remove(); 9451 $('html').addClass('working'); 9452 9453 $.ajax({
9454 url: loadUrl, 9455 data: {}, 9456 localCache: cacheResult, 9457 dataType: 'html', 9458 success: function (data) { 9459 hideMessage(); 9460 9461 $('body').append(data); 9462 9463 var $modal = $('.modal'); 9464 9465 $modal.modal({ 9466 'backdrop': 'static' 9467 }); 9468 9469 $modal.modal('show'); 9470 9471 $modal.on('hidden.bs.modal', function (e) { 9472 // window 9473 location.hash = ''; 9474 }); 9475 9476 $('html').removeClass('working'); 9477 9478 } 9479 }).done().fail(function (data) { 9480 $('html').removeClass('working'); 9481 showMessage('Whoops!, something has gone wrong.<br><br>' + data.status + ' ' + data.statusText); 9482 }); 9483 9484 e.preventDefault(); 9485 }); 9486 9487 /* 9488 * ------------------------------------------------------------ 9489 * A slightly hackish way to close modals on back button press. 9490 * ------------------------------------------------------------ 9491 */ 9492 $(window).on('hashchange', function (e) { 9493 $('.modal').modal('hide'); 9494 }); 9495 9496 9497 /* 9498 * ------------------------------------------------------------- 9499 * Simple way for any type of object to be deleted. 9500 * ------------------------------------------------------------- 9501 * 9502 * E.g markup: 9503 * <a data-route='/route/to/delete' data-id='123' data-type='objectType'> 9504 * Delete This Object 9505 * </a> 9506 * 9507 */ 9508 $('.deleteThis').on('click', function (e) { 9509 9510 /* 9511 * Confirm if the user wants to delete this object 9512 */ 9513 if ($(this).data('confirm-delete') !== 'yes') { 9514 $(this).data('original-text', $(this).html()).html('Click To Confirm?').data('confirm-delete', 'yes'); 9515 9516 var that = $(this); 9517 setTimeout(function () { 9518 that.data('confirm-delete', 'no').html(that.data('original-text')); 9519 }, 2000); 9520 9521 return; 9522 } 9523 9524 var deleteId = $(this).data('id'), 9525 deleteType = $(this).data('type'), 9526 route = $(this).data('route'); 9527 9528 $.post(route, deleteType + '_id=' + deleteId) 9529 .done(function (data) { 9530 9531 if (typeof data.message !== 'undefined') { 9532 showMessage(data.message); 9533 } 9534 9535 switch (data.status) { 9536 case 'success': 9537 $('#' + deleteType + '_' + deleteId).fadeOut(); 9538 if (typeof data.redirectUrl !== 'undefined') { 9539 window.location.href = data.redirectUrl; 9540 } 9541 break; 9542 case 'error': 9543 /* Error */ 9544 break; 9545 9546 default: 9547 break; 9548 } 9549 }).fail(function (data) { 9550 showMessage(Attendize.GenericErrorMessages); 9551 }); 9552 9553 e.preventDefault(); 9554 }); 9555 9556 9557 $(document.body).on('click', '.pauseTicketSales', function (e) { 9558 9559 var ticketId = $(this).data('id'), 9560 route = $(this).data('route'); 9561 9562 $.post(route, 'ticket_id=' + ticketId) 9563 .done(function (data) { 9564 9565 if (typeof data.message !== 'undefined') { 9566 showMessage(data.message); 9567 } 9568 9569 switch (data.status) { 9570 case 'success': 9571 setTimeout(function () { 9572 document.location.reload(); 9573 }, 300); 9574 break; 9575 case 'error': 9576 /* Error */ 9577 break; 9578 9579 default: 9580 break; 9581 } 9582 }).fail(function (data) { 9583 showMessage(Attendize.GenericErrorMessages); 9584 }); 9585 9586 9587 e.preventDefault(); 9588 });
9589 9590 /** 9591 * Toggle checkboxes 9592 */ 9593 $(document.body).on('click', '.check-all', function (e) { 9594 var toggleClass = $(this).data('check-class'); 9595 $('.' + toggleClass).each(function () { 9596 this.checked = $(this).checked; 9597 }); 9598 }); 9599 9600 9601 /* 9602 * ------------------------------------------------------------ 9603 * Toggle hidden content when a.show-more-content is clicked 9604 * ------------------------------------------------------------ 9605 */ 9606 $(document.body).on('click', '.show-more-options', function (e) { 9607 9608 var toggleClass = !$(this).data('toggle-class') 9609 ? '.more-options' 9610 : $(this).data('toggle-class'); 9611 9612 9613 if ($(this).hasClass('toggled')) { 9614 $(this).html($(this) 9615 .data('original-text')); 9616 9617 } else { 9618 9619 if (!$(this).data('original-text')) { 9620 $(this).data('original-text', $(this).html()); 9621 } 9622 $(this).html(!$(this).data('show-less-text') ? 'Show Less' : $(this).data('show-less-text')); 9623 } 9624 9625 $(this).toggleClass('toggled'); 9626 9627 /* 9628 * ? 9629 */ 9630 if ($(this).data('clear-field')) { 9631 $($(this).data('clear-field')).val(''); 9632 } 9633 9634 $(toggleClass).slideToggle(); 9635 e.preventDefault(); 9636 }); 9637 9638 9639 /* 9640 * Sort by trigger 9641 */ 9642 $('select[name=sort_by_select]').on('change', function () { 9643 $('input[name=sort_by]').val($(this).val()).closest('form').submit(); 9644 }); 9645 9646 /** 9647 * Custom file inputs 9648 */ 9649 $(document).on('change', '.btn-file :file', function () { 9650 var input = $(this), 9651 numFiles = input.get(0).files ? input.get(0).files.length : 1, 9652 label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); 9653 9654 input.trigger('fileselect', [ 9655 numFiles, 9656 label 9657 ]); 9658 }); 9659 9660 $(document.body).on('fileselect', '.btn-file :file', function (event, numFiles, label) { 9661 var input = $(this).parents('.input-group').find(':text'), 9662 log = numFiles > 1 ? numFiles + ' files selected' : label; 9663 if (input.length) { 9664 input.val(log); 9665 } else { 9666 if (log) { 9667 console.log(log); 9668 } 9669 9670 } 9671 }); 9672 9673 /** 9674 * Scale the preview iFrames when changing the design of organiser/event pages. 9675 */ 9676 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 9677 9678 var target = $(e.target).attr("href"); 9679 9680 if ($(target).hasClass('scale_iframe')) { 9681 9682 var $iframe = $('iframe', target); 9683 var iframeWidth = $('.iframe_wrap').innerWidth(); 9684 var iframeHeight = $('.iframe_wrap').height(); 9685 9686 $iframe.css({ 9687 width: 1200, 9688 height: 1400 9689 }); 9690 9691 var iframeScale = (iframeWidth / 1200); 9692 $iframe.css({ 9693 '-webkit-transform': 'scale(' + iframeScale + ')', 9694 '-ms-transform': 'scale(' + iframeScale + ')', 9695 'transform': 'scale(' + iframeScale + ')', 9696 '-webkit-transform-origin': '0 0', 9697 '-ms-transform-origin': '0 0', 9698 'transform-origin': '0 0', 9699 }); 9700 } 9701 }); 9702 9703 $(document.body).on('click', '.markPaymentReceived', function (e) { 9704 9705 var orderId = $(this).data('id'), 9706 route = $(this).data('route'); 9707 9708 $.post(route, 'order_id=' + orderId) 9709 .done(function (data) { 9710 9711 if (typeof data.message !== 'undefined') { 9712 showMessage(data.message); 9713 } 9714 9715 switch (data.status) { 9716 case 'success': 9717 setTimeout(function () { 9718 document.location.reload(); 9719 }, 300); 9720 break; 9721 case 'error': 9722 /* Error */ 9723 break; 9724 9725 default: 9726 break; 9727 } 9728 }).fail(function (data) { 9729 showMessage(Attendize.GenericErrorMessages); 9730 }); 9731 e.preventDefault(); 9732 });
9733 9734 $(document.body).on('click', '.btnSendZoomInvitation', function (e) { 9735 9736 var orderId = $(this).data('id'), 9737 route = $(this).data('route'); 9738 9739 $.post(route, 'order_id=' + orderId) 9740 .done(function (data) { 9741 if (data.status == 'success') { 9742 showMessage(data.message); 9743 } else { 9744 showErrorMessage(data.message); 9745 } 9746 }).fail(function (data) { 9747 showErrorMessage(Attendize.GenericErrorMessages); 9748 }); 9749 e.preventDefault(); 9750 }); 9751 9752}); 9753 9754function changeQuestionType(select) { 9755 var select = $(select); 9756 var selected = select.find(':selected'); 9757 if (selected.data('has-options') == '1') { 9758 $('#question-options').removeClass('hide'); 9759 } else { 9760 $('#question-options').addClass('hide'); 9761 } 9762 if (selected.val() === '1') { 9763 $("#is_show_div").removeClass('hide'); 9764 $("#is_display_div").removeClass('hide'); 9765 } else if (selected.val() === '2') { 9766 $("#is_show_div").removeClass('hide'); 9767 $("#is_display_div").addClass('hide'); 9768 } else { 9769 $("#is_display_div").addClass('hide'); 9770 $("#is_show_div").addClass('hide'); 9771 } 9772 9773 $('#add-question-option').removeAttr("onclick"); 9774 $('#add-question-option').unbind('click'); 9775 if (select.val() === '6' || select.val() === '3') { 9776 $("input[name='option_sel[]']").removeClass('hide'); 9777 $('#add-question-option').bind('click', addQuestionOption_checkbox); 9778 $('.class_option_sel').html(''); 9779 $('.class_option_sel').append('<input class="form-control" name="option_sel[]" type="checkbox" >'); 9780 $('.class_option_head').show(); 9781 $('.class_option_colspan').attr('colspan', 3); 9782 9783 $("input[name='option_sel[]']").on('click', function () { 9784 var _this = $(this); 9785 if (_this.is(':checked')) { 9786 $("input[name='option_sel[]']").each(function () { 9787 if (!$(this).is(':checked')) { 9788 $(this).prop('disabled', true); 9789 } 9790 }); 9791 } else { 9792 $("input[name='option_sel[]']").each(function () { 9793 $(this).prop('disabled', false); 9794 }); 9795 } 9796 }); 9797 } else { 9798 $("input[name='option_sel[]']").addClass('hide'); 9799 $('#add-question-option').bind('click', addQuestionOption); 9800 $('.class_option_sel').html(''); 9801 $('.class_option_head').hide(); 9802 $('.class_option_colspan').attr('colspan', 2); 9803 } 9804} 9805 9806function addQuestionOption_checkbox() { 9807 var tbody = $('#question-options tbody'); 9808 var questionOption = $('#question-option-template_checkbox').html(); 9809 9810 tbody.append(questionOption); 9811 9812 $("input[name='option[]']").on("change", function () { 9813 var _this = $(this); 9814 $("input[name='option[]']").each(function (k, v) { 9815 var _opt_this = $(this); 9816 $("input[name='option_sel[]']").each(function (key, value) { 9817 var _sel_this = $(this); 9818 if (k == key) { 9819 _sel_this.val(_opt_this.val()); 9820 } 9821 }); 9822 }); 9823 }); 9824 $("input[name='option_sel[]']").on('click', function () { 9825 var _this = $(this); 9826 if (_this.is(':checked')) { 9827 $("input[name='option_sel[]']").each(function () { 9828 if (!$(this).is(':checked')) { 9829 $(this).prop('disabled', true); 9830 } 9831 }); 9832 } else { 9833 $("input[name='option_sel[]']").each(function () { 9834 $(this).prop('disabled', false); 9835 }); 9836 } 9837 }); 9838} 9839 9840function addQuestionOption() { 9841 var tbody = $('#question-options tbody'); 9842 var questionOption = $('#question-option-template').html(); 9843 9844 tbody.append(questionOption); 9845} 9846 9847function removeQuestionOption(removeBtn) { 9848 var removeBtn = $(removeBtn); 9849 var tbody = removeBtn.parents('tbody'); 9850 9851 if (tbody.find('tr').length > 1) { 9852 removeBtn.parents('tr').remove(); 9853 } else { 9854 alert('You must have at least one option.'); 9855 } 9856} 9857
9858function processFormErrors($form, errors) { 9859 $.each(errors, function (index, error) { 9860 var $input = $(':input[name=' + index + ']', $form); 9861 9862 if ($input.prop('type') === 'file') { 9863 $('#input-' + $input.prop('name')).append('<div class="help-block error">' + error + '</div>') 9864 .parent() 9865 .addClass('has-error'); 9866 } else { 9867 $input.after('<div class="help-block error">' + error + '</div>') 9868 .parent() 9869 .addClass('has-error'); 9870 } 9871 9872 }); 9873 9874 var $submitButton = $form.find('input[type=submit]'); 9875 toggleSubmitDisabled($submitButton); 9876} 9877 9878 9879 9880/** 9881 * 9882 * @param elm $submitButton 9883 * @returns void 9884 */ 9885function toggleSubmitDisabled($submitButton) { 9886 9887 if ($submitButton.hasClass('disabled')) { 9888 $submitButton.attr('disabled', false) 9889 .removeClass('disabled') 9890 .val($submitButton.data('original-text')); 9891 return; 9892 } 9893 9894 $submitButton.data('original-text', $submitButton.val()) 9895 .attr('disabled', true) 9896 .addClass('disabled') 9897 .val('Working...'); 9898} 9899 9900/** 9901 * 9902 * @returns {{}} 9903 */ 9904$.fn.serializeObject = function () { 9905 var o = {}; 9906 var a = this.serializeArray(); 9907 $.each(a, function () { 9908 if (o[this.name] !== undefined) { 9909 if (!o[this.name].push) { 9910 o[this.name] = [o[this.name]]; 9911 } 9912 o[this.name].push(this.value || ''); 9913 } else { 9914 o[this.name] = this.value || ''; 9915 } 9916 }); 9917 return o; 9918}; 9919 9920/** 9921 * Replaces a parameter in a URL with a new parameter 9922 * 9923 * @param url 9924 * @param paramName 9925 * @param paramValue 9926 * @returns {*} 9927 */ 9928function replaceUrlParam(url, paramName, paramValue) { 9929 var pattern = new RegExp('\\b(' + paramName + '=).*?(&|$)') 9930 if (url.search(pattern) >= 0) { 9931 return url.replace(pattern, '$1' + paramValue + '$2'); 9932 } 9933 return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue 9934} 9935 9936/** 9937 * Shows users a message. 9938 * Currently uses humane.js 9939 * 9940 * @param string message 9941 * @returns void 9942 */ 9943function showMessage(message) { 9944 humane.log(message, { 9945 timeoutAfterMove: 3000, 9946 waitForMove: true 9947 }); 9948} 9949function showErrorMessage(message) { 9950 humane.log(message, { 9951 timeoutAfterMove: 10000, 9952 timeout: 10000, 9953 waitForMove: true, 9954 addnCls: 'error' 9955 }); 9956} 9957 9958function showHelp(message) { 9959 humane.log(message, { 9960 timeout: 12000 9961 }); 9962} 9963 9964function hideMessage() { 9965 humane.remove(); 9966} 9967 9968function markFpsManualReview(orderId, route) { 9969 $.post(route, 'order_id=' + orderId) 9970 .done(function (data) { 9971 if (typeof data.message !== 'undefined') { 9972 showMessage(data.message); 9973 } 9974 if (data.status === 'success') { 9975 setTimeout(function () { 9976 document.location.reload(); 9977 }, 300); 9978 } 9979 }).fail(function (data) { 9980 showMessage('Whoops!, something has gone wrong.'); 9981 }); 9982} 9983 9984function confirmFpsPayment(orderId, route) { 9985 $.post(route, 'order_id=' + orderId) 9986 .done(function (data) { 9987 if (typeof data.message !== 'undefined') { 9988 showMessage(data.message); 9989 } 9990 if (data.status === 'success') { 9991 setTimeout(function () { 9992 document.location.reload(); 9993 }, 300); 9994 } 9995 }).fail(function (data) { 9996 showMessage('Whoops!, something has gone wrong.'); 9997 }); 9998} 9999 10000
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.