vendor: 5,491 bytes, lines 1-239
1/* ----------------------------------------------------------------------------- 2 3 AnyPicker - Customizable Picker for Mobile OS 4 Version 2.0.9 5 Copyright (c)2017 Lajpat Shah 6 Contributors : https://github.com/nehakadam/AnyPicker/contributors 7 Repository : https://github.com/nehakadam/AnyPicker 8 Homepage : https://nehakadam.github.io/AnyPicker 9 10 ----------------------------------------------------------------------------- */ 11 12(function () { 13 14 "use strict"; 15 16// --------------------------------- Global Variables : AnyPicker.Core Start -------------------------------------- 17 18//"use strict"; 19 20$.CF = { 21 22 setPropertiesStyle: function(sProp, sArrProps) 23 { 24 var oTest = window.getComputedStyle(document.documentElement, ''); 25 for(var iProp in sArrProps) 26 { 27 if(oTest[sArrProps[iProp]] !== undefined) 28 { 29 var sPrefix = ""; 30 31 if(sArrProps[iProp].search("Webkit") !== -1) 32 sPrefix = "-webkit-"; 33 else if(sArrProps[iProp].search("Moz") !== -1) 34 sPrefix = "-moz-"; 35 else if(sArrProps[iProp].search("O") !== -1) 36 sPrefix = "-o-"; 37 else if(sArrProps[iProp].search("ms") !== -1) 38 sPrefix = "-ms-"; 39 40 return sPrefix + sProp; 41 } 42 } 43 }, 44 45 testProperties: function(sProp, sArrProps, bReturnProp) 46 { 47 var oTest = window.getComputedStyle(document.documentElement, ''); 48 for(var iProp in sArrProps) 49 { 50 if(oTest[sArrProps[iProp]] !== undefined) 51 { 52 if(bReturnProp) 53 { 54 return sArrProps[iProp]; 55 } 56 else 57 return true; 58 } 59 } 60 if(bReturnProp) 61 return ""; 62 else 63 return false; 64 }, 65 66 compareDataType: function(oVariable, sDataType) 67 { 68 if(typeof oVariable === sDataType.toLocaleLowerCase()) 69 return true; 70 return false; 71 }, 72 73 compareStrings: function(sString1, sString2) 74 { 75 var to = this; 76 if(sString1 !== null && sString1 !== undefined && sString2 !== null && sString2 !== undefined) 77 { 78 if(typeof sString1 === "string" && typeof sString2 === "string") 79 { 80 if(sString1.toLocaleLowerCase() === sString2.toLocaleLowerCase()) 81 return true; 82 } 83 return false; 84 } 85 else 86 { 87 if((sString1 === null && sString2 === null) || (sString1 === undefined && sString2 === undefined)) 88 return true; 89 else 90 return false; 91 } 92 }, 93 94 isValid: function(oValue) 95 { 96 if(oValue !== undefined && oValue !== null && oValue !== "") 97 return true; 98 else 99 return false; 100 } 101 102}; 103 104$.AnyPicker = $.AnyPicker || { 105 106 name: "AnyPicker", // Plugin Name 107 108 version: "2.0.3", // Plugin Version 109 110 i18n: // Internationalization Strings 111 { 112 113 }, 114 115 defaults: // Defaults Settings 116 { 117 mode: "datetime", 118 119 parent: "body", 120 layout: "popup", 121 hAlign: "left", 122 vAlign: "bottom", 123 relativeTo: null, 124 inputElement: null, 125 inputChangeEvent: "onSet", 126 127 lang: "", 128 rtl: false, 129 animationDuration: 500, 130 131 // View Section Components Start 132 133 setButton: 134 { 135 markup: "<a id='ap-button-set' class='ap-button'>Set</a>", 136 markupContentWindows: "<span class='ap-button-icon ap-icon-set'></span><span class='ap-button-text'>set</span>", 137 type: "Button" 138 // action: function(){} 139 }, 140 141 clearButton: 142 { 143 markup: "<a id='ap-button-clear' class='ap-button'>Clear</a>", 144 markupContentWindows: "<span class='ap-button-icon ap-icon-clear'></span><span class='ap-button-text'>clear</span>", 145 type: "Button" 146 // action: function(){} 147 }, 148 149 nowButton: 150 { 151 markup: "<a id='ap-button-now' class='ap-button'>Now</a>", 152 markupContentWindows: "<span class='ap-button-icon ap-icon-now'></span><span class='ap-button-text'>now</span>", 153 type: "Button" 154 // action: function(){} 155 }, 156 157 cancelButton: 158 { 159 markup: "<a id='ap-button-cancel' class='ap-button'>Cancel</a>", 160 markupContentWindows: "<span class='ap-button-icon ap-icon-cancel'></span><span class='ap-button-text'>cancel</span>", 161 type: "Button" 162 // action: function(){} 163 }, 164 165 headerTitle: 166 { 167 markup: "<span class='ap-header__title'>Select</span>", 168 type: "Text", 169 contentBehaviour: "Static", // Static or Dynamic 170 format: "" // DateTime Format 171 }, 172 173 // View Section Components End 174 175 viewSections: 176 { 177 header: ["headerTitle"], 178 contentTop: [], 179 contentBottom: [], 180 footer: ["cancelButton", "setButton"] 181 }, 182 183 i18n: 184 { 185 headerTitle: "Select", 186 setButton: "Set", 187 clearButton: "Clear", 188 nowButton: "Now", 189 cancelButton: "Cancel", 190 dateSwitch: "Date", 191 timeSwitch: "Time" 192 }, 193 194 theme: "Default", 195 196 //------------------ Callback Functions Start -------------------------- 197 198 onInit: null, // () 199 200 onBeforeShowPicker: null, // () 201 onShowPicker: null, // () 202 203 onBeforeHidePicker: null, // () 204 onHidePicker: null, // () 205 206 parseInput: null, // () 207 formatOutput: null, // () 208 209 setOutput: null, 210 onSetOutput: null, 211 212 buttonClicked: null 213 214 //------------------ Callback Functions End -------------------------- 215 }, 216 217 tempDefaults: // Plugin-level Variables required to maintain state across methods 218 { 219 sOrientation: "portrait", 220 overlayClass: "", 221 overlaySelector: "", 222 iExt: 2, 223 dir: "ltr", 224 sElemTag: "", 225 oElemValid: { 226 bIsInput: false, 227 bIsListItem: false, 228 bIsSelect: false 229 }, 230 sInputElemTag: "", 231 oInputElemValid: { 232 bIsInput: false, 233 bIsListItem: false, 234 bIsSelect: false 235 }, 236 prevActive: null, 237 bFirst: true, 238 sDateTimeTab: "date", 239 iCompDragStart: 0,
vendor: 40,549 bytes, lines 240-1473
240 headerTitleDefined: false, 241 bIsiPad: false, 242 bModified: { 243 set: false, 244 cancel: false, 245 clear: false, 246 now: false 247 }, 248 tabKey: false 249 }, 250 251 extra: // Common Temporary Variables 252 { 253 sArrModes: ["select", "datetime"], // Modes of AnyPicker 254 sArrLayout: ["popup", "relative", "fixed", "inline"], // Type of AnyPicker Layout 255 sArrHAlign: ["left", "center", "right"], // Horizontal Alignment of View 256 sArrVAlign: ["top", "middle", "bottom"], // Vertical Alignment of View 257 sArrViewSections: ["header", "contentTop", "contentBottom", "footer"], 258 oArrInputChangeEvent: ["onChange", "onSet"], 259 sArrThemes: ["Default", "iOS", "Android", "Windows"], 260 261 bIsTouchDevice: "ontouchstart" in document.documentElement, 262 sClickHandler: ("ontouchstart" in document.documentElement ? "click" : "click"), 263 sClickHandlerButtons: ("ontouchstart" in document.documentElement ? "touchstart" : "click"), 264 265 bHasCSS3D : $.CF.testProperties("perspective", ["WebkitPerspective", "MozPerspective", "OPerspective", "msPerspective", "perspective", "perspectiveProperty"], false), 266 sCSSTransform: $.CF.testProperties("transform", ["WebkitTransform", "MozTransform", "OTransform", "msTransform", "transform"], true), 267 sCSSTransformStyle: $.CF.setPropertiesStyle("transform", ["WebkitTransform", "MozTransform", "OTransform", "msTransform", "transform"]), 268 sCSSTransition: $.CF.testProperties("transition", ["WebkitTransition", "MozTransition", "OTransition", "msTransition", "transition"], true), 269 bHasCSSAnimation: $.CF.testProperties("animation", ["WebkitAnimation", "MozAnimation", "OAnimation", "msAnimation", "animation"], false), 270 sMouseWheel: ('onwheel' in document || document.documentMode >= 9 ) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], //"MozMousePixelScroll DOMMouseScroll mousewheel wheel" 271 bHasIE10Pointer: window.navigator.msPointerEnabled && !window.navigator.pointerEnabled, 272 bHasPointer: window.navigator.pointerEnabled || window.navigator.msPointerEnabled, 273 bIsiPad: navigator.userAgent.match(/iPad/i) !== null 274 } 275 276}; 277 278// --------------------------------- Global Variables : AnyPicker.Core End -------------------------------------- 279 280(function (factory) 281{ 282 if (typeof define === 'function' && define.amd) // AMD. Register as an anonymous module. 283 { 284 define(['jquery'], factory); 285 } 286 else if (typeof exports === 'object') // Node/CommonJS 287 { 288 module.exports = factory(require('jquery')); 289 } 290 else // Browser globals 291 { 292 factory(jQuery); 293 } 294} 295(function ($) 296{ 297 $.fn.AnyPicker = function(options) 298 { 299 var oAnyPicker = $(this).data(); 300 301 var sArrDataKeys = Object.keys(oAnyPicker), 302 iKey, sKey; 303 if(options === null || options === undefined) // return AnyPicker object 304 { 305 if(sArrDataKeys.length > 0) 306 { 307 for(iKey in sArrDataKeys) 308 { 309 sKey = sArrDataKeys[iKey]; 310 if(sKey.search("plugin_AnyPicker_") !== -1) 311 { 312 return oAnyPicker[sKey]; 313 } 314 } 315 } 316 else 317 console.log("No AnyPicker Object Defined For This Element"); 318 } 319 else if(typeof options === "string") // call methods using AnyPicker object 320 { 321 if(oAnyPicker !== null || oAnyPicker !== undefined) 322 { 323 if(sArrDataKeys.length > 0) 324 { 325 if(options === "destroy") 326 { 327 if(sArrDataKeys.length > 0) 328 { 329 for(iKey in sArrDataKeys) 330 { 331 sKey = sArrDataKeys[iKey]; 332 if(sKey.search("plugin_AnyPicker_") !== -1) 333 { 334 oAnyPicker = oAnyPicker[sKey]; 335 $(window).off("blur." + oAnyPicker.setting.timestamp); 336 var oInput = $(oAnyPicker.setting.inputElement); 337 $(oInput).off("focus." + oAnyPicker.setting.timestamp); 338 $(oInput).off("blur." + oAnyPicker.setting.timestamp); 339 340 $(".ap-overlay-" + sKey.replace("plugin_AnyPicker_", "")).remove(); // Remove AnyPicker DOM appended for a particular AnyPicker object 341 $(this).removeData(sKey); 342 343 //console.log("Destroyed AnyPicker Object"); 344 //console.log(oAnyPicker); 345 346 break; 347 } 348 } 349 } 350 else 351 console.log("No AnyPicker Object Defined For This Element"); 352 353 // ** Destoy AnyPicker Object ** 354 // unbind events 355 // remove data attached to Element 356 // remove AnyPicker Object from the $.AnyPicker.extra.oArrAnyPicker 357 } 358 } 359 else 360 console.log("No AnyPicker Object Defined For This Element"); 361 } 362 } 363 else // create a new AnyPicker object 364 { 365 return this.each(function() 366 { 367 var iTimeStamp = (new Date()).getTime(); 368 if(!$.data(this, "plugin_AnyPicker_" + iTimeStamp)) 369 { 370 options.timestamp = iTimeStamp; 371 oAnyPicker = new AnyPicker(this, options); 372 $.data(this, "plugin_AnyPicker_" + iTimeStamp, oAnyPicker); 373 oAnyPicker.init(); 374 375 //console.log("Created AnyPicker Object "); 376 //console.log(oAnyPicker); 377 } 378 else 379 { 380 if(sArrDataKeys.length > 0) 381 { 382 for(iKey in sArrDataKeys) 383 { 384 sKey = sArrDataKeys[iKey]; 385 if(sKey.search("plugin_AnyPicker_") !== -1) 386 { 387 return oAnyPicker[sKey]; 388 } 389 } 390 } 391 else 392 console.log("No AnyPicker Object Defined For This Element"); 393 } 394 }); 395 } 396 }; 397})); 398 399// AnyPicker Constructor 400function AnyPicker(element, options) 401{ 402 var apo = this; 403 404 apo.elem = element; 405 var sLang = (options.lang !== undefined || options.lang !== null) ? options.lang : $.CalenStyle.defaults.lang, 406 io18n = $.extend(true, {}, $.AnyPicker.defaults.i18n, $.AnyPicker.i18n[sLang], options.i18n), 407 oDefaults = $.extend(true, {}, $.AnyPicker.defaults); 408 409 io18n = { 410 i18n: io18n 411 }; 412 oDefaults.i18n = {}; 413 options.i18n = {}; 414 415 apo.setting = $.extend({}, oDefaults, options, io18n); 416 apo.tmp = $.extend({}, $.AnyPicker.tempDefaults); 417 418 apo.tmp.overlayClass = "ap-overlay-" + apo.setting.timestamp; 419 apo.tmp.overlaySelector = "." + apo.tmp.overlayClass; 420 apo.tmp.sOrientation = apo._getDeviceOrientation(); 421 422 //----------- Theme-wise Changes In Settings ------------------- 423 424 if($.CF.isValid(options.headerTitle)) 425 apo.tmp.headerTitleDefined = true; 426 427 if($.CF.compareStrings(apo.setting.theme, "Android")) 428 { 429 if(!$.CF.isValid(options.rowHeight)) 430 apo.setting.rowHeight = 50; 431 432 if(!$.CF.isValid(options.visibleRows)) 433 apo.setting.visibleRows = 3; 434 } 435 else if($.CF.compareStrings(apo.setting.theme, "iOS")) 436 { 437 if(!$.CF.isValid(options.rowHeight)) 438 apo.setting.rowHeight = 36; 439 440 if(!$.CF.isValid(options.visibleRows)) 441 apo.setting.visibleRows = 5; 442 443 if(!$.CF.isValid(options.viewSections)) 444 { 445 if($.CF.compareStrings(apo.setting.layout, "fixed")) 446 { 447 apo.setting.viewSections = { 448 header: [], 449 contentTop: [], 450 contentBottom: [], 451 footer: ["cancelButton", "headerTitle", "setButton"] 452 }; 453 } 454 else 455 { 456 apo.setting.viewSections = { 457 header: ["cancelButton", "headerTitle", "setButton"], 458 contentTop: [], 459 contentBottom: [], 460 footer: [] 461 }; 462 } 463 } 464 465 if($.AnyPicker.extra.bIsiPad) 466 apo.tmp.bIsiPad = true; 467 if(apo.tmp.bIsiPad && $.CF.compareStrings(apo.setting.layout, "popup")) 468 apo.setting.layout = "popover"; 469 } 470 else if($.CF.compareStrings(apo.setting.theme, "Windows")) 471 { 472 apo.setting.layout = "popup"; 473 apo.setting.visibleRows = 5; 474 apo.setting.rowHeight = 100; 475 476 if(!$.CF.isValid(options.viewSections)) 477 { 478 apo.setting.viewSections = { 479 header: ["headerTitle"], 480 contentTop: [], 481 contentBottom: [], 482 footer: ["setButton", "cancelButton"] 483 }; 484 } 485 486 if($.CF.isValid(options.setButton)) 487 apo.tmp.bModified.set = true; 488 if($.CF.isValid(options.cancelButton)) 489 apo.tmp.bModified.cancel = true; 490 if($.CF.isValid(options.nowButton)) 491 apo.tmp.bModified.now = true; 492 if($.CF.isValid(options.clearButton)) 493 apo.tmp.bModified.clear = true; 494 } 495 496 //-------------------------------------------------------------- 497 498 apo.tmp.iExt = Math.floor(apo.setting.visibleRows / 2); 499 apo.tmp.sDir = apo.setting.rtl ? "rtl" : "ltr"; 500 501 $.AnyPicker.extra.dToday = apo._getCurrentDate(); 502 if(apo.tmp.selectedDate === null) 503 apo.tmp.selectedDate = $.AnyPicker.extra.dToday; 504 if(apo.setting.maxYear === 0) 505 apo.setting.maxYear = $.AnyPicker.extra.dToday.getFullYear(); 506 if($.CF.isValid(apo.setting.components) && apo.tmp.numOfComp === 0) 507 apo.tmp.numOfComp = apo.setting.components.length; 508 509 $.AnyPicker.extra.sStartEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerDown' : 'pointerdown') : ($.AnyPicker.extra.bIsTouchDevice ? 'touchstart' : 'mousedown touchstart')); 510 $.AnyPicker.extra.sMoveEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerMove' : 'pointermove') : ($.AnyPicker.extra.bIsTouchDevice ? 'touchmove' : 'mousemove touchmove')); 511 $.AnyPicker.extra.sEndEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerUp' : 'pointerup') : ($.AnyPicker.extra.bIsTouchDevice ? 'touchend' : 'mouseup touchend')); 512 $.AnyPicker.extra.sLeaveEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerLeave' : 'pointerleave') : ($.AnyPicker.extra.bIsTouchDevice ? null : 'mouseleave')); 513 $.AnyPicker.extra.sCancelEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerCancel' : 'pointercancel') : null); 514 $.AnyPicker.extra.sOutEv = ($.AnyPicker.extra.bHasPointer ? ($.AnyPicker.extra.bHasIE10Pointer ? 'MSPointerOut' : 'pointerout') : null); 515 516 //alert("Events : " + $.AnyPicker.extra.sStartEv + " " + $.AnyPicker.extra.sMoveEv + " " + $.AnyPicker.extra.sEndEv + " " + $.AnyPicker.extra.sLeaveEv + " " + $.AnyPicker.extra.sCancelEv + " " + $.AnyPicker.extra.sOutEv); 517} 518 519// --------------------------------- Functions : AnyPicker.Core Start -------------------------------------- 520 521AnyPicker.prototype = { 522 523 // Public Method 524 init: function() 525 { 526 var apo = this; 527 528 if($.CF.isValid(apo.elem)) 529 { 530 apo.tmp.sElemTag = $(apo.elem).prop("tagName").toLowerCase() ; 531 if(apo.tmp.sElemTag === "input") 532 apo.tmp.oElemValid.bIsInput = true; 533 else if(apo.tmp.sElemTag === "ul" || apo.tmp.sElemTag === "ol" || apo.tmp.sElemTag === "dl") 534 apo.tmp.oElemValid.bIsListItem = true; 535 else if(apo.tmp.sElemTag === "select") 536 apo.tmp.oElemValid.bIsSelect = true; 537 } 538 539 if($.CF.isValid(apo.setting.inputElement)) 540 { 541 apo.tmp.sInputElemTag = $(apo.setting.inputElement).prop("tagName").toLowerCase(); 542 if(apo.tmp.sInputElemTag === "input") 543 apo.tmp.oInputElemValid.bIsInput = true; 544 else if(apo.tmp.sInputElemTag === "ul" || apo.tmp.sInputElemTag === "ol" || apo.tmp.sInputElemTag === "dl") 545 apo.tmp.oInputElemValid.bIsListItem = true; 546 else if(apo.tmp.sInputElemTag === "select") 547 apo.tmp.oInputElemValid.bIsSelect = true; 548 } 549 else if($.CF.isValid(apo.elem)) 550 { 551 apo.setting.inputElement = apo.elem; 552 apo.tmp.sInputElemTag = apo.tmp.sElemTag; 553 apo.tmp.oInputElemValid = apo.tmp.oElemValid; 554 } 555 556 if($.CF.compareStrings(apo.setting.mode, "select")) 557 { 558 apo.__setComponentsOfSelect(); 559 } 560 else if($.CF.compareStrings(apo.setting.mode, "datetime")) 561 { 562 apo.__setComponentsOfDateTimePicker(); 563 } 564 565 if(apo.tmp.sInputElemTag !== "" && !(apo.tmp.oInputElemValid.bIsListItem || apo.tmp.oInputElemValid.bIsSelect)) 566 { 567 var $oInput = $(apo.setting.inputElement); 568 if(apo.tmp.oInputElemValid.bIsInput) 569 { 570 $oInput.off("focus." + apo.setting.timestamp); 571 $oInput.on("focus." + apo.setting.timestamp, {"apo": apo}, apo._inputElementClicked); 572 $oInput.on("blur." + apo.setting.timestamp, function(e) 573 { 574 if($.AnyPicker.tempDefaults.tabKey) 575 apo.showOrHidePicker(); 576 apo.tmp.prevActive = null; 577 }); 578 579 $oInput.on("keydown." + apo.setting.timestamp, function(e) 580 { 581 if((e.keyCode ? e.keyCode : e.which) === "9") 582 $.AnyPicker.tempDefaults.tabKey = true; 583 }); 584 } 585 else 586 { 587 $oInput.off("click." + apo.setting.timestamp); 588 $oInput.on("click." + apo.setting.timestamp, {"apo": apo}, apo._inputElementClicked); 589 } 590 } 591 592 if($.CF.isValid(apo.setting.onInit)) 593 apo.setting.onInit.call(apo); 594 }, 595 596 _inputElementClicked: function(e) 597 { 598 e.stopPropagation(); 599 e.preventDefault(); 600 601 var apo = e.data.apo; 602 603 if(document.activeElement === apo.tmp.prevActive && document.activeElement === apo.setting.inputElement) 604 return; 605 apo.tmp.prevActive = document.activeElement; 606 607 // Get Selected Values (Value in the text field or Value set in the inputElement) 608 if(apo.tmp.sInputElemTag !== "" && !(apo.tmp.oInputElemValid.bIsListItem || apo.tmp.oInputElemValid.bIsSelect)) 609 { 610 var $oInput = $(apo.setting.inputElement), sElemValue; 611 612 if(apo.tmp.oInputElemValid.bIsInput) 613 sElemValue = $oInput.val(); 614 else 615 { 616 var sDataVal = $oInput.attr("data-val"); 617 if($.CF.isValid(sDataVal)) 618 sElemValue = sDataVal; 619 else 620 sElemValue = $oInput.text(); 621 } 622 623 if(!$.AnyPicker.tempDefaults.tabKey) 624 { 625 apo.showOrHidePicker(sElemValue); 626 } 627 else 628 { 629 $.AnyPicker.tempDefaults.tabKey = false; 630 setTimeout(function() 631 { 632 apo.showOrHidePicker(sElemValue); 633 }, 500); 634 } 635 } 636 else 637 console.log("No InputElement Specified"); 638 }, 639 640 // Public Method 641 showOrHidePicker: function(sElemValue) 642 { 643 var apo = this; 644 645 var iTempIndex, sLabel, sValue, 646 sArrValues = [], oArrSelectedValues = []; 647 648 if(sElemValue !== undefined && sElemValue !== null) 649 { 650 if($.CF.isValid(apo.setting.parseInput)) 651 { 652 if($.CF.compareStrings(apo.setting.mode, "datetime")) 653 { 654 apo.setting.selectedDate = apo.setting.parseInput.call(apo, sElemValue); 655 } 656 else if($.CF.compareStrings(apo.setting.mode, "select")) 657 { 658 sArrValues = apo.setting.parseInput.call(apo, sElemValue); 659 660 for(iTempIndex = 0; iTempIndex < sArrValues.length; iTempIndex++) 661 { 662 sLabel = sArrValues[iTempIndex]; 663 sValue = apo.__getDataSourceValueFromLabel(sLabel, iTempIndex, true); 664 oArrSelectedValues.push( 665 { 666 component: iTempIndex, 667 val: sValue, 668 label: sLabel 669 }); 670 } 671 apo.tmp.selectedValues.values = oArrSelectedValues; 672 } 673 } 674 else 675 { 676 if($.CF.compareStrings(apo.setting.mode, "datetime")) 677 { 678 apo.setting.selectedDate = sElemValue; 679 } 680 else if($.CF.compareStrings(apo.setting.mode, "select")) 681 { 682 if(sElemValue !== "") 683 { 684 sArrValues = []; oArrSelectedValues = []; 685 if(apo.tmp.numOfComp > 1) 686 sArrValues = sElemValue.split(" "); 687 else 688 sArrValues.push(sElemValue); 689 690 for(iTempIndex = 0; iTempIndex < sArrValues.length; iTempIndex++) 691 { 692 sLabel = sArrValues[iTempIndex]; 693 sValue = apo.__getDataSourceValueFromLabel(sLabel, iTempIndex, true); 694 oArrSelectedValues.push( 695 { 696 component: iTempIndex, 697 val: sValue, 698 label: sLabel 699 }); 700 } 701 } 702 else 703 { 704 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 705 { 706 var oCompData = apo.setting.dataSource[iTempIndex].data; 707 sLabel = oCompData[0].label; 708 sValue = oCompData[0].val; 709 oArrSelectedValues.push( 710 { 711 component: iTempIndex, 712 val: sValue, 713 label: sLabel 714 }); 715 } 716 } 717 718 apo.tmp.selectedValues.values = oArrSelectedValues; 719 } 720 } 721 } 722 723 if($(apo.tmp.overlaySelector).length > 0) 724 apo._hidePicker(); 725 else 726 { 727 if(!$.CF.isValid(apo.setting.onBeforeShowPicker)) 728 apo._showPicker(); 729 else 730 { 731 if(apo.setting.onBeforeShowPicker.call(apo)) 732 apo._showPicker(); 733 } 734 } 735 }, 736 737 _showPicker: function() 738 { 739 var apo = this; 740 741 // if($.CF.isValid(apo.setting.onBeforeShowPicker)) 742 // apo.setting.onBeforeShowPicker.call(apo); 743 744 apo.tmp.sOrientation = apo._getDeviceOrientation(); 745 746 var sTemp = "", 747 bAddSectionHeader = (($.CF.compareStrings(apo.setting.layout, "popup") || $.CF.compareStrings(apo.setting.layout, "popover")) && apo.setting.viewSections.header.length > 0), 748 bAddSectionFooter = (($.CF.compareStrings(apo.setting.layout, "popup") || $.CF.compareStrings(apo.setting.layout, "popover")) && apo.setting.viewSections.footer.length > 0), 749 bAddSectionFooterFixedTop = ($.CF.compareStrings(apo.setting.layout, "fixed") && $.CF.compareStrings(apo.setting.vAlign, "bottom") && apo.setting.viewSections.footer.length > 0), 750 bAddSectionFooterFixedBottom = ($.CF.compareStrings(apo.setting.layout, "fixed") && $.CF.compareStrings(apo.setting.vAlign, "top") && apo.setting.viewSections.footer.length > 0), 751 bIsDateTimeField = ($.CF.compareStrings(apo.setting.mode, "datetime") && apo.tmp.sDateTimeMode === "datetime"), 752 sLayout = "ap-layout-" + apo.setting.layout, 753 sTheme = "ap-theme-" + apo.setting.theme.toLowerCase(), 754 sDir = "ap-dir-" + apo.tmp.sDir; 755 756 if($.CF.compareStrings(apo.setting.layout, "popover")) 757 { 758 var iBodyScrollTop = $("body").scrollTop(), 759 iWinHeight = $(window).height(), 760 iMinTop = iBodyScrollTop, 761 iMaxTop = iBodyScrollTop + iWinHeight, 762 iPopupHeight = $.CF.compareStrings(apo.setting.rowsNavigation, "scroller") ? 300 : 350, 763 iTooltipTop = $(apo.setting.inputElement).offset().top - iPopupHeight, 764 bTooltipTop = (iTooltipTop < iMinTop) ? false : true, 765 iTooltipBottom = $(apo.setting.inputElement).offset().top + $(apo.setting.inputElement).height() + iPopupHeight, 766 bTooltipBottom = (iTooltipBottom > iMaxTop) ? false : true; 767 apo.tmp.sTooltip = bTooltipBottom ? "bottom" : bTooltipTop ? "top" : apo.setting.rtl ? "right" : "left"; 768 } 769 770 sTemp += "<div class='ap-overlay " + sLayout + " " + apo.tmp.overlayClass + " " + sTheme + " " + sDir + "'>"; 771 772 sTemp += "<div class='ap-bg'>"; 773 774 sTemp += "<div class='ap-cont' dir='" + apo.tmp.sDir + "'>"; 775 776 if($.CF.isValid(apo.tmp.sTooltip)) 777 sTemp += "<span class='ap-tooltip ap-tooltip-" + apo.tmp.sTooltip + "'></span>"; 778 779 if(bAddSectionHeader) 780 { 781 sTemp += "<div class='ap-header'>"; 782 783 if(bIsDateTimeField && $.CF.compareStrings(apo.setting.theme, "Windows")) 784 { 785 sTemp += "<div class='ap-content-switch'>"; 786 if(apo.setting.rtl) 787 { 788 sTemp += "<span class='ap-content-switch-tab ap-content-switch-time'>" + apo.setting.i18n.timeSwitch + "</span>"; 789 sTemp += "<span class='ap-content-switch-tab ap-content-switch-date ap-content-switch-selected'>" + apo.setting.i18n.dateSwitch + "</span>"; 790 } 791 else 792 { 793 sTemp += "<span class='ap-content-switch-tab ap-content-switch-date ap-content-switch-selected'>" + apo.setting.i18n.dateSwitch + "</span>"; 794 sTemp += "<span class='ap-content-switch-tab ap-content-switch-time'>" + apo.setting.i18n.timeSwitch + "</span>"; 795 } 796 sTemp += "</div>"; 797 798 apo.tmp.sDateTimeTab = "time"; 799 } 800 801 sTemp += "</div>"; 802 } 803 804 if(bAddSectionFooterFixedTop) 805 { 806 sTemp += "<div class='ap-footer ap-footer-top'>"; 807 if($.CF.compareStrings(apo.setting.theme, "Default")) 808 sTemp += "<div class='ap-button-cont'></div>"; 809 sTemp += "</div>"; 810 } 811 812 sTemp += "<div class='ap-content'>"; 813 814 if(apo.setting.viewSections.contentTop.length > 0) 815 sTemp += "<div class='ap-content-top'></div>"; 816 817 if(bIsDateTimeField && !$.CF.compareStrings(apo.setting.theme, "Windows")) 818 { 819 sTemp += "<div class='ap-content-switch'>"; 820 if(apo.setting.rtl) 821 { 822 sTemp += "<span class='ap-content-switch-tab ap-content-switch-time'>" + apo.setting.i18n.timeSwitch + "</span>"; 823 sTemp += "<span class='ap-content-switch-tab ap-content-switch-date ap-content-switch-selected'>" + apo.setting.i18n.dateSwitch + "</span>"; 824 } 825 else 826 { 827 sTemp += "<span class='ap-content-switch-tab ap-content-switch-date ap-content-switch-selected'>" + apo.setting.i18n.dateSwitch + "</span>"; 828 sTemp += "<span class='ap-content-switch-tab ap-content-switch-time'>" + apo.setting.i18n.timeSwitch + "</span>"; 829 } 830 sTemp += "</div>"; 831 832 apo.tmp.sDateTimeTab = "date"; 833 } 834 835 sTemp += "<div class='ap-content-middle'>"; 836 837 sTemp += "<div class='ap-component-section'></div>"; 838 839 sTemp += "</div>"; // Close .ap-content-middle 840 841 if(apo.setting.viewSections.contentBottom.length > 0) 842 sTemp += "<div class='ap-content-bottom'></div>"; 843 844 sTemp += "</div>"; // Close .ap-content 845 846 if(bAddSectionFooter || bAddSectionFooterFixedBottom) 847 { 848 sTemp += "<div class='ap-footer ap-footer-bottom'>"; 849 if($.CF.compareStrings(apo.setting.theme, "Default")) 850 sTemp += "<div class='ap-button-cont'></div>"; 851 sTemp += "</div>"; 852 } 853 854 sTemp += "</div>"; // Close .ap-cont 855 856 sTemp += "</div>"; // Close .ap-bg 857 858 sTemp += "</div>"; // Close .ap-overlay 859 860 $(apo.setting.parent).append(sTemp); 861 862 if(apo.setting.layout === "popover") 863 $("body").addClass("noscroll"); 864 865 if($.AnyPicker.extra.bHasCSSAnimation) 866 { 867 $(apo.tmp.overlaySelector).addClass("ap-show"); 868 $(apo.tmp.overlaySelector).css({"display": "block"}); 869 if($.CF.compareStrings(apo.setting.layout, "fixed")) 870 { 871 if($.CF.compareStrings(apo.setting.vAlign, "top")) 872 $(apo.tmp.overlaySelector).find(".ap-cont").addClass("ap-top-slide-down"); 873 else if($.CF.compareStrings(apo.setting.vAlign, "bottom")) 874 $(apo.tmp.overlaySelector).find(".ap-cont").addClass("ap-bottom-slide-up"); 875 } 876 877 setTimeout(function() 878 { 879 $(apo.tmp.overlaySelector).css({"opacity": 1}); 880 $(apo.tmp.overlaySelector).removeClass("ap-show"); 881 if($.CF.compareStrings(apo.setting.layout, "fixed")) 882 { 883 if($.CF.compareStrings(apo.setting.vAlign, "top")) 884 { 885 $(apo.tmp.overlaySelector).find(".ap-cont").removeClass("ap-top-slide-down"); 886 $(apo.tmp.overlaySelector + " .ap-cont").css({"top": 0}); 887 } 888 else if($.CF.compareStrings(apo.setting.vAlign, "bottom")) 889 { 890 $(apo.tmp.overlaySelector).find(".ap-cont").removeClass("ap-bottom-slide-up"); 891 $(apo.tmp.overlaySelector + " .ap-cont").css({"bottom": 0}); 892 } 893 } 894 }, apo.setting.animationDuration); 895 } 896 else 897 { 898 $(apo.tmp.overlaySelector).show(0); 899 } 900 901 if($.CF.isValid(apo.setting.onShowPicker)) 902 apo.setting.onShowPicker.call(apo); 903 904 apo._adjustPicker(); 905 apo._addViewSectionComponents(); 906 apo.__initComponents(); 907 apo._adjustPicker(); 908 909 apo.tmp.bIsManualDraggingAfterShow = false; 910 911 if($.CF.compareStrings(apo.setting.mode, "datetime") && apo.tmp.sDateTimeMode === "datetime") 912 apo._setDateTimeTabs(apo.tmp.sDateTimeTab); 913 }, 914 915 _hidePicker: function() 916 { 917 var apo = this; 918 919 if($(apo.tmp.overlaySelector).length > 0) 920 { 921 if($.CF.isValid(apo.setting.onBeforeHidePicker)) 922 apo.setting.onBeforeHidePicker.call(apo); 923 924 if($.AnyPicker.extra.bHasCSSAnimation) 925 { 926 $(apo.tmp.overlaySelector).addClass("ap-hide"); 927 if($.CF.compareStrings(apo.setting.layout, "fixed")) 928 { 929 if($.CF.compareStrings(apo.setting.vAlign, "top")) 930 $(apo.tmp.overlaySelector).find(".ap-cont").addClass("ap-top-slide-up"); 931 else if($.CF.compareStrings(apo.setting.vAlign, "bottom")) 932 $(apo.tmp.overlaySelector).find(".ap-cont").addClass("ap-bottom-slide-down"); 933 } 934 setTimeout(function() 935 { 936 $(apo.tmp.overlaySelector).remove(); 937 }, apo.setting.animationDuration); 938 } 939 else 940 { 941 $(apo.tmp.overlaySelector).hide(0); 942 setTimeout(function() 943 { 944 $(apo.tmp.overlaySelector).remove(); 945 }, apo.setting.animationDuration); 946 } 947 948 if(apo.setting.layout === "popover") 949 $("body").removeClass("noscroll"); 950 951 apo.tmp.prevActive = null; 952 953 if($.CF.isValid(apo.setting.onHidePicker)) 954 apo.setting.onHidePicker.call(apo); 955 } 956 }, 957 958 _adjustPicker: function(iNumOfComp) 959 { 960 var apo = this; 961 962 if($.CF.compareStrings(apo.setting.theme, "Windows")) 963 { 964 iNumOfComp = $.CF.isValid(iNumOfComp) ? parseInt(iNumOfComp) : apo.tmp.numOfComp; 965 966 var iAvailableHeight = $(window).height(), 967 iAvailableWidth = $(window).width(), 968 bIsPortrait = apo._getDeviceOrientation() === "portrait", 969 iPadding = 10, iMaxWidth; 970 971 if(bIsPortrait) 972 apo.setting.visibleRows = 5; 973 else 974 apo.setting.visibleRows = 3; 975 976 if(!apo.setting.componentsCoverFullWidth) 977 { 978 if(!bIsPortrait) 979 { 980 iRowWidth = Math.floor(iAvailableHeight / 3); 981 iMaxWidth = iRowWidth * iNumOfComp; 982 iMaxWidth = (iAvailableHeight > iMaxWidth) ? iMaxWidth : iAvailableHeight; 983 iPadding = (iAvailableWidth - iMaxWidth) / 2; 984 iAvailableWidth = iAvailableHeight; 985 } 986 else 987 { 988 iRowWidth = Math.floor(iAvailableWidth / 3); 989 iMaxWidth = iRowWidth * iNumOfComp; 990 iPadding = (iAvailableWidth - iMaxWidth) / 2; 991 } 992 $(apo.tmp.overlaySelector).find(".ap-content-middle").css({"padding-left": iPadding, "padding-right": iPadding}); 993 } 994 995 iAvailableWidth -= 16; 996 var iRowHeight = Math.floor(iAvailableHeight / apo.setting.visibleRows), 997 iRowWidth = Math.floor(iAvailableWidth / 3); 998 999 if(!apo.setting.componentsCoverFullWidth) 1000 apo.setting.rowHeight = iRowWidth; 1001 else 1002 { 1003 iRowHeight = Math.floor(iAvailableHeight / apo.setting.visibleRows); 1004 apo.setting.rowHeight = iRowHeight; 1005 } 1006 1007 var iCalculatedHeight = apo.setting.rowHeight * apo.setting.visibleRows, 1008 iContTop = (iAvailableHeight - iCalculatedHeight) / 2, 1009 iContentTop, iContentBottom; 1010 $(apo.tmp.overlaySelector).find(".ap-content").css({"top": iContTop}); 1011 1012 iContTop += 2; 1013 iContentTop = $(apo.tmp.overlaySelector).find(".ap-header").height() - iContTop; 1014 $(apo.tmp.overlaySelector).find(".ap-content-top").css({"top": iContentTop}); 1015 iContTop -= 2; 1016 iContentBottom = $(apo.tmp.overlaySelector).find(".ap-footer").height() + iContTop; 1017 $(apo.tmp.overlaySelector).find(".ap-content-bottom").css({"bottom": iContentBottom}); 1018 1019 apo.tmp.iExt = Math.floor(apo.setting.visibleRows / 2); 1020 } 1021 1022 var $oRelativeTo = $((apo.setting.relativeTo === null) ? apo.setting.inputElement : apo.setting.relativeTo), 1023 iTop = $oRelativeTo.offset().top, 1024 iLeft = $oRelativeTo.offset().left, 1025 iWidth = $oRelativeTo.outerWidth(); 1026 if($.CF.compareStrings(apo.setting.layout, "popover")) 1027 { 1028 var iBodyScrollTop = $("body").scrollTop(), 1029 iWinWidth = $(window).outerWidth(), 1030 iWinHeight = $(window).outerHeight(), 1031 iMinTop = iBodyScrollTop, 1032 iMaxTop = iBodyScrollTop + iWinHeight, 1033 iInputTop = $(apo.setting.inputElement).offset().top - iBodyScrollTop, 1034 iInputHeight = $(apo.setting.inputElement).outerHeight(), 1035 iInputBottom = iInputTop + iInputHeight, 1036 iInputLeft = $(apo.setting.inputElement).offset().left, 1037 iInputWidth = $(apo.setting.inputElement).outerWidth(), 1038 iInputRight = iInputLeft + iInputWidth, 1039 iPopupWidth = $(apo.tmp.overlaySelector).find(".ap-cont").outerWidth(), 1040 iPopupHeight = $(apo.tmp.overlaySelector).find(".ap-cont").outerHeight(), 1041 iPopupTop, iPopupLeft, iPopupBottom, 1042 iTooltipHeight = 10, 1043 iTooltipWidth = 10; 1044 1045 if(apo.tmp.sTooltip === "top") 1046 { 1047 iPopupTop = iInputTop - iPopupHeight - iTooltipHeight; 1048 iPopupBottom = (iPopupTop < 0) ? 5 : iPopupTop; 1049 iPopupLeft = iInputLeft + 5; 1050 } 1051 else if(apo.tmp.sTooltip === "bottom") 1052 { 1053 iPopupTop = iInputBottom + iTooltipHeight; 1054 iPopupLeft = iInputLeft + 5; 1055 if(apo.tmp.sDir === "rtl") 1056 iPopupLeft = iInputRight - iPopupWidth; 1057 } 1058 else if(apo.tmp.sTooltip === "left") 1059 { 1060 iPopupTop = iInputTop - ((iPopupHeight / 2) - (iInputHeight / 2)); 1061 iPopupTop = (iPopupTop < iMinTop) ? 5 : iPopupTop; 1062 iPopupLeft = iInputLeft + iInputWidth + 5; 1063 } 1064 else if(apo.tmp.sTooltip === "right") 1065 { 1066 iPopupTop = iInputTop - ((iPopupHeight / 2) - (iInputHeight / 2)); 1067 iPopupTop = (iPopupTop < iMinTop) ? 5 : iPopupTop; 1068 iPopupLeft = iInputLeft - (iPopupWidth + iTooltipWidth); 1069 } 1070 $(apo.tmp.overlaySelector).find(".ap-cont").css({"position": "absolute", "left": iPopupLeft, "top": iPopupTop}); 1071 } 1072 else if($.CF.compareStrings(apo.setting.layout, "inline")) 1073 { 1074 $(apo.tmp.overlaySelector).find(".ap-cont").css({"position": "absolute", "width": iWidth, "left": iLeft, "top": iTop}); 1075 } 1076 else if($.CF.compareStrings(apo.setting.layout, "relative")) 1077 { 1078 $oRelativeTo = $((apo.setting.relativeTo === null) ? apo.setting.inputElement : apo.setting.relativeTo); 1079 var iDocLeft = 0, 1080 iDocRight = $(document).outerWidth(), 1081 iContWidth = $(".ap-cont").outerWidth(), 1082 iRelElemWidth = iWidth; 1083 1084 iWidth = (iRelElemWidth > iContWidth) ? iContWidth : iRelElemWidth; 1085 iTop = iTop + $oRelativeTo.outerHeight(); 1086 1087 if($.CF.compareStrings(apo.setting.hAlign, "center")) 1088 iLeft = (iRelElemWidth > iWidth) ? (iLeft + (iWidth/2)) : ((iRelElemWidth === iWidth) ? iLeft : (iLeft - (iWidth/2))); 1089 else if($.CF.compareStrings(apo.setting.hAlign, "right")) 1090 iLeft = iLeft - iWidth; 1091 1092 iLeft = (iLeft < iDocLeft) ? (iDocLeft + 5) : iLeft; 1093 var iRight = iLeft + iWidth; 1094 1095 if(iRight > iDocRight) 1096 { 1097 if(iLeft > (iDocLeft + 5)) 1098 { 1099 iLeft = iLeft - (iRight - (iDocRight + 5)); 1100 iLeft = (iLeft < iDocLeft) ? (iDocLeft + 5) : iLeft; 1101 iRight = iLeft + iWidth; 1102 iWidth = (iRight > iDocRight) ? (iDocRight - 10) : iWidth; 1103 } 1104 else 1105 { 1106 iWidth = iDocRight - 10; 1107 } 1108 } 1109 1110 $(apo.tmp.overlaySelector).find(".ap-cont").css({"position": "absolute", "min-width": iWidth, "left": iLeft, "top": iTop}); 1111 } 1112 else if($.CF.compareStrings(apo.setting.layout, "fixed")) 1113 { 1114 if($.CF.compareStrings(apo.setting.vAlign, "top")) 1115 $(apo.tmp.overlaySelector + " .ap-cont").css({"top": -1000}); 1116 else if($.CF.compareStrings(apo.setting.vAlign, "bottom")) 1117 $(apo.tmp.overlaySelector + " .ap-cont").css({"bottom": -1000}); 1118 } 1119 }, 1120 1121 _addViewSectionComponents: function() 1122 { 1123 var apo = this; 1124 var iTempIndex1, iTempIndex2, 1125 bWindowsTheme = $.CF.compareStrings(apo.setting.theme, "Windows"); 1126 1127 for(iTempIndex1 = 0; iTempIndex1 < $.AnyPicker.extra.sArrViewSections.length; iTempIndex1++) 1128 { 1129 var sViewSection = $.AnyPicker.extra.sArrViewSections[iTempIndex1]; 1130 var sArrComponents = apo.setting.viewSections[sViewSection]; 1131 if(sArrComponents.length > 0) 1132 { 1133 for(iTempIndex2 = 0; iTempIndex2 < sArrComponents.length; iTempIndex2++) 1134 { 1135 var sComp = sArrComponents[iTempIndex2], 1136 oComp = apo.setting[sComp] || null, 1137 $oCompElem = $(oComp.markup); 1138 if(bWindowsTheme && $.CF.isValid(oComp.markupContentWindows)) 1139 $oCompElem.html(oComp.markupContentWindows); 1140 1141 if(oComp !== undefined && oComp !== null && oComp !== "") 1142 { 1143 if($.CF.compareStrings(sViewSection, "header")) 1144 { 1145 $(apo.tmp.overlaySelector).find(".ap-header").append($oCompElem); // Append Component 1146 if($.CF.compareStrings(oComp.type, "Button") && $.CF.compareDataType(oComp.action, "function")) 1147 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, oComp.action); // Bind Action 1148 } 1149 else if($.CF.compareStrings(sViewSection, "contentTop")) 1150 { 1151 $(apo.tmp.overlaySelector).find(".ap-content-top").append($oCompElem); // Append Component 1152 if($.CF.compareStrings(oComp.type, "Button") && $.CF.compareDataType(oComp.action, "function")) 1153 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, oComp.action); // Bind Action 1154 } 1155 else if($.CF.compareStrings(sViewSection, "contentBottom")) 1156 { 1157 $(apo.tmp.overlaySelector).find(".ap-content-bottom").append($oCompElem); // Append Component 1158 if($.CF.compareStrings(oComp.type, "Button") && $.CF.compareDataType(oComp.action, "function")) 1159 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, oComp.action); // Bind Action 1160 } 1161 else if($.CF.compareStrings(sViewSection, "footer")) 1162 { 1163 var $oeButtonCont = $(apo.tmp.overlaySelector).find(".ap-button-cont"); 1164 if($oeButtonCont.length > 0) 1165 $oeButtonCont.append($oCompElem); 1166 else 1167 $(apo.tmp.overlaySelector).find(".ap-footer").append($oCompElem); // Append Component 1168 if($.CF.compareStrings(oComp.type, "Button") && $.CF.compareDataType(oComp.action, "function")) 1169 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, oComp.action); // Bind Action 1170 } 1171 1172 if($.CF.compareStrings(sComp, "headerTitle") && $.CF.compareStrings(oComp.contentBehaviour, "Static")) 1173 $(apo.tmp.overlaySelector).find(".ap-header__title").text(apo.setting.i18n.headerTitle); 1174 1175 if($.CF.compareStrings(sComp, "setButton")) 1176 { 1177 if(!bWindowsTheme || (bWindowsTheme && apo.tmp.bModified.set)) 1178 $oCompElem.text(apo.setting.i18n.setButton); 1179 else if(bWindowsTheme && !apo.tmp.bModified.set) 1180 $oCompElem.find(".ap-button-text").text(apo.setting.i18n.setButton); 1181 } 1182 else if($.CF.compareStrings(sComp, "clearButton")) 1183 { 1184 if(!bWindowsTheme || (bWindowsTheme && apo.tmp.bModified.clear)) 1185 $oCompElem.text(apo.setting.i18n.clearButton); 1186 else if(bWindowsTheme && !apo.tmp.bModified.clear) 1187 $oCompElem.find(".ap-button-text").text(apo.setting.i18n.clearButton); 1188 } 1189 else if($.CF.compareStrings(sComp, "nowButton")) 1190 { 1191 if(!bWindowsTheme || (bWindowsTheme && apo.tmp.bModified.now)) 1192 $oCompElem.text(apo.setting.i18n.nowButton); 1193 else if(bWindowsTheme && !apo.tmp.bModified.now) 1194 $oCompElem.find(".ap-button-text").text(apo.setting.i18n.nowButton); 1195 } 1196 else if($.CF.compareStrings(sComp, "cancelButton")) 1197 { 1198 if(!bWindowsTheme || (bWindowsTheme && apo.tmp.bModified.cancel)) 1199 $oCompElem.text(apo.setting.i18n.cancelButton); 1200 else if(bWindowsTheme && !apo.tmp.bModified.cancel) 1201 $oCompElem.find(".ap-button-text").text(apo.setting.i18n.cancelButton); 1202 } 1203 1204 if($.CF.compareStrings(oComp.type, "Button")) 1205 { 1206 if(!$.CF.compareDataType(oComp.action, "function")) 1207 { 1208 if($.CF.compareStrings(sComp, "setButton")) 1209 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, apo._setButtonAction); 1210 else if($.CF.compareStrings(sComp, "clearButton")) 1211 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, apo._clearButtonAction); 1212 else if($.CF.compareStrings(sComp, "nowButton")) 1213 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, apo._nowButtonAction); 1214 else if($.CF.compareStrings(sComp, "cancelButton")) 1215 $oCompElem.on("click." + apo.setting.timestamp, {"apo": apo}, apo._cancelButtonAction); 1216 } 1217 } 1218 } 1219 } 1220 } 1221 } 1222 1223 if(bWindowsTheme) 1224 { 1225 $(".ap-button-icon, .ap-button-text").click(function(e) 1226 { 1227 $(this).closest(".ap-button").trigger("click"); 1228 }); 1229 } 1230 1231 $(apo.tmp.overlaySelector).find(".ap-button") 1232 .on("mousedown touchstart", function(e) 1233 { 1234 //e.stopPropagation(); 1235 //e.preventDefault(); 1236 $(this).addClass("ap-button-active"); 1237 }) 1238 .on("mouseup touchend", function(e) 1239 { 1240 //e.stopPropagation(); 1241 //e.preventDefault(); 1242 $(this).removeClass("ap-button-active"); 1243 }); 1244 1245 $(window).on("blur." + apo.setting.timestamp, function(e) 1246 { 1247 apo.tmp.prevActive = document.activeElement; 1248 }); 1249 1250 $(apo.tmp.overlaySelector).off("click." + apo.setting.timestamp); 1251 1252 setTimeout(function() 1253 { 1254 $(apo.tmp.overlaySelector).on("click." + apo.setting.timestamp, function(e) 1255 { 1256 var iDTDiff = Date.now() - apo.tmp.iCompDragStart; 1257 if(!apo.setting.bIsTouched && iDTDiff > 1000) 1258 apo._hidePicker(); 1259 }); 1260 }, 300); 1261 1262 $(apo.tmp.overlaySelector).find(".ap-cont, .ap-cont *").on("click." + apo.setting.timestamp, function(e) 1263 { 1264 e.stopPropagation(); 1265 }); 1266 1267 $(apo.tmp.overlaySelector).find(".ap-content-switch-date").click(function(e) 1268 { 1269 e.stopPropagation(); 1270 apo._setDateTimeTabs("date"); 1271 }); 1272 1273 $(apo.tmp.overlaySelector).find(".ap-content-switch-time").click(function(e) 1274 { 1275 e.stopPropagation(); 1276 apo._setDateTimeTabs("time"); 1277 }); 1278 1279 $(window).resize(function() 1280 { 1281 apo._adjustOnOrientationChange(); 1282 }); 1283 }, 1284 1285 _setDateTimeTabs: function(sSelectedTab) 1286 { 1287 var apo = this; 1288 var sDisabledTab = (sSelectedTab === "date") ? "time" : "date"; 1289 apo.tmp.sDateTimeTab = sSelectedTab; 1290 1291 $(apo.tmp.overlaySelector).find(".ap-content-switch-tab").removeClass("ap-content-switch-selected"); 1292 $(apo.tmp.overlaySelector).find(".ap-content-switch-" + sSelectedTab).addClass("ap-content-switch-selected"); 1293 var $oeDisabledTabs = $(apo.tmp.overlaySelector).find("[data-type='" + sDisabledTab + "']"), 1294 $oeSelectedTabs = $(apo.tmp.overlaySelector).find("[data-type='" + sSelectedTab + "']"); 1295 $oeDisabledTabs.css("display", "none"); 1296 $oeSelectedTabs.css("display", "table-cell"); 1297 1298 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1299 apo._adjustPicker($oeSelectedTabs.length); 1300 }, 1301 1302 _setOutput: function() 1303 { 1304 var apo = this; 1305 var sOutput = ""; 1306 1307 if($.CF.isValid(apo.setting.formatOutput)) 1308 { 1309 sOutput = apo.setting.formatOutput.call(apo, apo.tmp.selectedValues, apo.tmp.bIsManualDraggingAfterShow); 1310 } 1311 else 1312 { 1313 if($.CF.compareStrings(apo.setting.mode, "select")) 1314 { 1315 for(var iCompIndex = 0; iCompIndex < apo.tmp.numOfComp; iCompIndex++) 1316 { 1317 if(iCompIndex !== 0) 1318 sOutput += " "; 1319 sOutput += apo.tmp.selectedValues.values[iCompIndex].label; 1320 } 1321 } 1322 else if($.CF.compareStrings(apo.setting.mode, "datetime")) 1323 { 1324 sOutput = apo.formatOutputDates(apo.tmp.selectedValues.date, apo.tmp.bIsManualDraggingAfterShow); 1325 } 1326 } 1327 1328 if(apo.tmp.oElemValid.bIsListItem || apo.tmp.oElemValid.bIsSelect) 1329 { 1330 var sChild, $oChildElem; 1331 if(apo.tmp.oElemValid.bIsListItem) 1332 sChild = "li"; 1333 else if(apo.tmp.oElemValid.bIsSelect) 1334 sChild = "option"; 1335 $(apo.elem).find(sChild).each(function() 1336 { 1337 $oChildElem = $(this); 1338 1339 var sValue = $oChildElem.attr("value") || $oChildElem.data("value") || $oChildElem.text(); 1340 1341 if(apo.tmp.selectedValues.values[0].val === sValue) 1342 { 1343 if(apo.tmp.oElemValid.bIsSelect) 1344 $oChildElem.attr("selected", true); 1345 else if(apo.tmp.oElemValid.bIsListItem) 1346 $oChildElem.attr("data-selected", true); 1347 } 1348 else 1349 { 1350 if(apo.tmp.oElemValid.bIsSelect) 1351 $oChildElem.attr("selected", false); 1352 else if(apo.tmp.oElemValid.bIsListItem) 1353 $oChildElem.attr("data-selected", false); 1354 } 1355 }); 1356 } 1357 1358 if($.CF.isValid(apo.setting.setOutput)) 1359 apo.setting.setOutput.call(apo, sOutput, apo.tmp.selectedValues, apo.tmp.bIsManualDraggingAfterShow); 1360 else 1361 { 1362 if(apo.setting.inputElement !== null) 1363 { 1364 var $oInput = $(apo.setting.inputElement); 1365 if(apo.tmp.oInputElemValid.bIsInput) 1366 { 1367 $oInput.val(sOutput); 1368 } 1369 else 1370 { 1371 $oInput.text(sOutput); 1372 } 1373 } 1374 1375 if($.CF.isValid(apo.setting.onSetOutput)) 1376 apo.setting.onSetOutput.call(apo, sOutput, apo.tmp.selectedValues, apo.tmp.bIsManualDraggingAfterShow); 1377 } 1378 }, 1379 1380 _clearOutput: function() 1381 { 1382 var apo = this; 1383 1384 var $oInput = $(apo.setting.inputElement); 1385 if(apo.tmp.oInputElemValid.bIsInput) 1386 $oInput.val(""); 1387 else 1388 $oInput.text(""); 1389 }, 1390 1391 _setButtonAction: function(e) 1392 { 1393 var apo = e.data.apo; 1394 1395 apo._setOutput(); 1396 apo.showOrHidePicker(); 1397 1398 if($.CF.isValid(apo.setting.buttonClicked)) 1399 apo.setting.buttonClicked.call(apo, "set"); 1400 }, 1401 1402 _clearButtonAction: function(e) 1403 { 1404 var apo = e.data.apo; 1405 1406 apo.tmp.selectedDate = $.AnyPicker.extra.dToday; 1407 if(apo.tmp.sInputElemTag !== "" && !(apo.tmp.oInputElemValid.bIsListItem || apo.tmp.oInputElemValid.bIsSelect)) 1408 { 1409 var $oInput = $(apo.setting.inputElement); 1410 1411 if(apo.tmp.oInputElemValid.bIsInput) 1412 $oInput.val(""); 1413 else 1414 $oInput.text(""); 1415 } 1416 apo.showOrHidePicker(); 1417 1418 if($.CF.isValid(apo.setting.buttonClicked)) 1419 apo.setting.buttonClicked.call(apo, "clear"); 1420 }, 1421 1422 _nowButtonAction: function(e) 1423 { 1424 var apo = e.data.apo; 1425 1426 if($.CF.compareStrings(apo.setting.mode, "datetime")) 1427 { 1428 apo.tmp.selectedDate = apo._getCurrentDate(); 1429 apo._setSelectedAndInvalidValuesForRows(); 1430 } 1431 1432 if($.CF.isValid(apo.setting.buttonClicked)) 1433 apo.setting.buttonClicked.call(apo, "now"); 1434 }, 1435 1436 _cancelButtonAction: function(e) 1437 { 1438 var apo = e.data.apo; 1439 apo.showOrHidePicker(); 1440 1441 if($.CF.isValid(apo.setting.buttonClicked)) 1442 apo.setting.buttonClicked.call(apo, "cancel"); 1443 }, 1444 1445 _getDeviceOrientation: function() 1446 { 1447 var $window = $(window); 1448 if($window.width() > $window.height()) 1449 return "landscape"; 1450 else 1451 return "portrait"; 1452 }, 1453 1454 _adjustOnOrientationChange: function() 1455 { 1456 var apo = this; 1457 1458 var sCurrentOrientation = apo._getDeviceOrientation(); 1459 if(sCurrentOrientation !== apo.tmp.sOrientation) 1460 { 1461 $("body").prepend("<div class='ap-loading'>Loading</div>"); 1462 apo.tmp.sOrientation = sCurrentOrientation; 1463 apo._adjustPicker(); 1464 apo.reloadAllComponents(); 1465 } 1466 } 1467 1468}; 1469 1470// --------------------------------- Functions : AnyPicker.Core End -------------------------------------- 1471 1472 1473
vendor: 6,840 bytes, lines 1474-1699
1474 1475// --------------------------------- Global Variables : AnyPicker.PickerComponent Start ----------------------------------- 1476 1477//"use strict"; 1478 1479$.AnyPicker = $.extend(true, $.AnyPicker, { 1480 1481 defaults: // Defaults Settings 1482 { 1483 components: null, 1484 dataSource: null, 1485 1486 showComponentLabel: false, 1487 componentsCoverFullWidth: false, 1488 visibleRows: 3, 1489 maxRows: 0, 1490 rowHeight: 50, 1491 1492 rowsNavigation: "scroller", 1493 1494 //------------------ Callback Functions Start -------------------------- 1495 1496 rowView: null, // (componentNumber, rowNumber, dataSourceRecord) 1497 onChange: null // (componentNumber, rowNumber, selectedValues) 1498 1499 //------------------ Callback Functions End ---------------------------- 1500 }, 1501 1502 tempDefaults: // Plugin-level Variables required to maintain state across methods 1503 { 1504 numOfComp: 0, 1505 selectedValues: {}, 1506 1507 bIsManualDraggingAfterShow: true, 1508 bIsManualDragging: false, 1509 bIsTouched: false, 1510 iTS: 0, 1511 1512 iPos: 0, 1513 iPosPrev: 0, 1514 iPosStop: 0, 1515 1516 iOffset: 0, 1517 iOffsetPrev: 0, 1518 1519 iVelocity: 0, 1520 iAmplitude: 0, 1521 1522 oVelocityTicker: null, 1523 oScrollTicker: null, 1524 1525 iMinTopPos: 0, 1526 iMaxTopPos: 0, 1527 oScrollingComp: null, 1528 iScrollingComp: -1, 1529 1530 iTmConst: 100, 1531 bEnd: false 1532 }, 1533 1534 extra: // Common Temporary Variables 1535 { 1536 sArrRowsNavigation: ["scroller+buttons", "scroller", "buttons"] 1537 } 1538 1539}); 1540 1541// --------------------------------- Global Variables : AnyPicker.PickerComponent End -------------------------------------- 1542 1543// --------------------------------- Functions : AnyPicker.PickerComponent Start ------------------------------------ 1544 1545AnyPicker.prototype = $.extend(AnyPicker.prototype, { 1546 1547 __initComponents: function() 1548 { 1549 var apo = this; 1550 1551 if(!apo.tmp.bFirst) 1552 { 1553 if($.CF.compareStrings(apo.setting.mode, "select")) 1554 apo.__setComponentsOfSelect(); 1555 else if($.CF.compareStrings(apo.setting.mode, "datetime")) 1556 apo.__setComponentsOfDateTimePicker(); 1557 } 1558 else 1559 apo.tmp.bFirst = false; 1560 1561 var iNumOfComponents = apo.tmp.numOfComp || apo.setting.components.length; 1562 1563 if(iNumOfComponents > 0) 1564 { 1565 if(apo.setting.components.length > 0) // Length of actual components array 1566 apo.reloadAllComponents(); 1567 else 1568 console.log("For apo.setting.mode \n 1. Select - \n Please set apo.setting.components 2. DateTime - \n Please enter a valid outputDateTimeFormat "); 1569 } 1570 }, 1571 1572 // Public Method 1573 reloadAllComponents: function() 1574 { 1575 var apo = this; 1576 var iTempIndex; 1577 1578 $(apo.setting.parent).find(".ap-component-section").html(""); 1579 1580 $("body").prepend("<div class='ap-loading'></div>"); 1581 1582 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 1583 { 1584 apo.reloadComponent(iTempIndex, false); 1585 } 1586 1587 apo.adjustComponents(); 1588 apo.setSelectedAndInvalidValuesForRows(true); 1589 }, 1590 1591 // Public Method 1592 reloadComponent: function(iComp, bSingleLoad) 1593 { 1594 var apo = this; 1595 var sTemp = ""; 1596 1597 var iNumRows, iRowIndex, 1598 oSData = apo.setting.dataSource[iComp].data, 1599 bIsSelected = false, sClassSelectedRow, 1600 sCompId = "ap-component-" + iComp, 1601 $oeComp = $(apo.setting.parent).find("#" + sCompId), 1602 oComp = apo.setting.components[iComp], 1603 sType = $.CF.isValid(oComp.type) ? oComp.type : oComp.label, 1604 sWidth = $.CF.isValid(oComp.width) ? ("width: " + oComp.width) : "", 1605 sAlign = apo.setting.rtl ? ($.CF.compareStrings(oComp.textAlign, "left") ? "right" : $.CF.compareStrings(oComp.textAlign, "right") ? "left" : "") : oComp.textAlign, 1606 sTextAlign = $.CF.isValid(sAlign) ? ("text-align: " + sAlign) : ""; 1607 1608 if($oeComp.length === 0) 1609 sTemp += "<div class='ap-component' id='" + sCompId + "' data-type='" + sType + "' " + (sWidth !== "" ? ("style='" + sWidth + ";'") : "") + ">"; 1610 1611 if(!$.CF.compareStrings(apo.setting.theme, "Windows")) 1612 { 1613 if(apo.setting.showComponentLabel) 1614 sTemp += "<div class='ap-component-label' " + (sTextAlign !== "" ? ("style='" + sTextAlign + ";'") : "") + ">" + oComp.label + "</div>"; 1615 } 1616 1617 if($.CF.compareStrings(apo.setting.rowsNavigation, "scroller+buttons") || $.CF.compareStrings(apo.setting.rowsNavigation, "buttons")) 1618 sTemp += "<div class='ap-component-plus ap-icon-arrow-up-filled' " + (sTextAlign !== "" ? ("style='" + sTextAlign + ";'") : "") + "></div>"; 1619 1620 sTemp += "<div class='ap-component-cont' tabindex='0'>"; 1621 1622 sTemp += "<div class='ap-component-data' role='listbox' aria-label='" + oComp.label + "'>"; 1623 1624 for(iRowIndex = 0; iRowIndex < apo.tmp.iExt; iRowIndex++) 1625 { 1626 sTemp += "<div class='ap-row ap-row-ext'></div>"; 1627 } 1628 1629 for(iRowIndex = 0; iRowIndex < oSData.length; iRowIndex++) 1630 { 1631 bIsSelected = ($.CF.isValid(oSData[iRowIndex].selected) ? oSData[iRowIndex].selected : false); 1632 sClassSelectedRow = bIsSelected ? "ap-row-selected" : ""; 1633 sTemp += "<div class='ap-row " + sClassSelectedRow + "' id='ap-row-" + iComp + "-" + iRowIndex+ "' data-value='" + oSData[iRowIndex].val + "' data-label='" + oSData[iRowIndex].label + "' role='option' aria-selected='" + bIsSelected + "' " + (sTextAlign !== "" ? ("style='" + sTextAlign + ";'") : "") + ">"; 1634 1635 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1636 { 1637 sTemp += "<div class='ap-row-bg'>"; 1638 if(!$.CF.isValid(apo.setting.rowView)) 1639 sTemp += "<div class='ap-row-content'>"; 1640 } 1641 1642 if($.CF.isValid(apo.setting.rowView)) 1643 sTemp += apo.setting.rowView.call(apo, iComp, iRowIndex, oSData[iRowIndex]); 1644 else 1645 sTemp += oSData[iRowIndex].label; 1646 1647 if($.CF.compareStrings(apo.setting.theme, "Windows") && !$.CF.isValid(apo.setting.rowView)) 1648 { 1649 sTemp += "</div>"; 1650 sTemp += "<div class='ap-row-label'>"; 1651 if(apo.setting.showComponentLabel) 1652 sTemp += oComp.label; 1653 sTemp += "</div>"; 1654 } 1655 1656 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1657 sTemp += "</div>"; 1658 1659 sTemp += "</div>"; 1660 } 1661 1662 for(iRowIndex = 0; iRowIndex < apo.tmp.iExt; iRowIndex++) 1663 { 1664 sTemp += "<div class='ap-row ap-row-ext'></div>"; 1665 } 1666 1667 sTemp += "</div>"; 1668 1669 sTemp += "<div class='ap-component-gradient'></div>"; 1670 sTemp += "<div class='ap-component-selector' id='ap-component-selector-" + iComp + "'></div>"; 1671 1672 sTemp += "</div>"; 1673 1674 if($.CF.compareStrings(apo.setting.rowsNavigation, "scroller+buttons") || $.CF.compareStrings(apo.setting.rowsNavigation, "buttons")) 1675 sTemp += "<div class='ap-component-minus ap-icon-arrow-down-filled' " + (sTextAlign !== "" ? ("style='" + sTextAlign + ";'") : "") + "></div>"; 1676 1677 if($oeComp.length === 0) 1678 sTemp += "</div>"; 1679 1680 if($oeComp.length > 0) 1681 $oeComp.html(sTemp); 1682 else 1683 $(apo.setting.parent).find(".ap-component-section").append(sTemp); 1684 1685 apo._bindEventsToComponent(iComp); 1686 1687 if($oeComp.length > 0 || bSingleLoad) 1688 apo.adjustComponents(); 1689 if(bSingleLoad) 1690 apo.setSelectedAndInvalidValuesForRows(true); 1691 }, 1692 1693 _bindEventsToComponent: function(iComp) 1694 { 1695 var apo = this; 1696 var $oParent = $("#ap-component-" + iComp), 1697 $oCompCont = $oParent.find(".ap-component-cont"), 1698 oData = 1699 {
vendor: 30,368 bytes, lines 1700-2744
1700 component: iComp, 1701 apo: apo 1702 }; 1703 1704 if($.CF.compareStrings(apo.setting.rowsNavigation, "scroller+buttons") || $.CF.compareStrings(apo.setting.rowsNavigation, "scroller")) 1705 { 1706 $oCompCont.on($.AnyPicker.extra.sStartEv + "." + apo.setting.timestamp, oData, apo._onStartDrag); 1707 $oCompCont.on($.AnyPicker.extra.sMoveEv + "." + apo.setting.timestamp, oData, apo._onDrag); 1708 if($.CF.isValid($.AnyPicker.extra.sEndEv)) 1709 $oCompCont.on($.AnyPicker.extra.sEndEv + "." + apo.setting.timestamp, oData, apo._onEndDrag); 1710 if($.CF.isValid($.AnyPicker.extra.sOutEv)) 1711 $oCompCont.on($.AnyPicker.extra.sOutEv + "." + apo.setting.timestamp, oData, apo._onEndDrag); 1712 1713 if($.AnyPicker.extra.sMouseWheel.length > 0) 1714 { 1715 for(var iEventIndex = 0; iEventIndex < $.AnyPicker.extra.sMouseWheel.length; iEventIndex++) 1716 $oCompCont.on($.AnyPicker.extra.sMouseWheel[iEventIndex] + "." + apo.setting.timestamp, oData, apo._onMouseWheelScroll); 1717 } 1718 } 1719 1720 if($.CF.compareStrings(apo.setting.rowsNavigation, "scroller+buttons") || $.CF.compareStrings(apo.setting.rowsNavigation, "buttons")) 1721 { 1722 $oParent.find(".ap-component-plus").on("click." + apo.setting.timestamp, oData, apo._onClickButtonMinus); 1723 $oParent.find(".ap-component-minus").on("click." + apo.setting.timestamp, oData, apo._onClickButtonPlus); 1724 } 1725 1726 $oCompCont.on("keydown." + apo.setting.timestamp, oData, apo._onKeyDown); 1727 $oCompCont.on("keyup." + apo.setting.timestamp, oData, apo._onKeyUp); 1728 }, 1729 1730 // Public Method 1731 adjustComponents: function() 1732 { 1733 var apo = this; 1734 var $overlaySelector = $(apo.tmp.overlaySelector); 1735 $overlaySelector.find(".ap-component-cont").css({"height": (apo.setting.rowHeight * apo.setting.visibleRows)}); 1736 $overlaySelector.find(".ap-row, .ap-component-selector").css({"height": apo.setting.rowHeight, "line-height": apo.setting.rowHeight + "px"}); 1737 $overlaySelector.find(".ap-row-bg").css({"height": apo.setting.rowHeight - 8}); 1738 1739 if(!$.CF.compareStrings(apo.setting.theme, "Windows")) 1740 { 1741 var iContWidth = $(".ap-cont").width(), 1742 iContHeight = $(".ap-cont").height(), 1743 iWinWidth = $(window).width(), 1744 iWinHeight = $(window).height(), 1745 iWidth = iWinWidth, 1746 iHeight = iWinHeight, 1747 bWidthChanged = false, bHeightChanged = false; 1748 1749 if(iContWidth > iWinWidth) 1750 { 1751 bWidthChanged = true; 1752 iWidth = iContWidth + 20; 1753 } 1754 if(iContHeight > iWinHeight) 1755 { 1756 bHeightChanged = true; 1757 iHeight = iContHeight + 20; 1758 } 1759 1760 if(bWidthChanged || bHeightChanged) 1761 { 1762 $overlaySelector.css({"position": "absolute", "height": iHeight, "width": iWidth}); 1763 1764 if($.CF.compareStrings(apo.setting.layout, "fixed")) 1765 $(".ap-cont").css({"position": "absolute"}); 1766 } 1767 1768 if($.CF.compareStrings(apo.setting.layout, "relative")) 1769 { 1770 var $oRelativeTo = $((apo.setting.relativeTo === null) ? apo.setting.inputElement : apo.setting.relativeTo), 1771 $oAPCont = $overlaySelector.find(".ap-cont"), 1772 iTop = $oRelativeTo.offset().top + $oAPCont.height(); 1773 if($.CF.compareStrings(apo.setting.vAlign, "top")) 1774 $oAPCont.css({"top": iTop}); 1775 } 1776 } 1777 1778 setTimeout(function() 1779 { 1780 $(".ap-loading").remove(); 1781 }, 0); 1782 }, 1783 1784 _onStartDrag: function(e) 1785 { 1786 var apo = e.data.apo; 1787 1788 if(!apo.tmp.bIsManualDragging) 1789 { 1790 apo.tmp.bIsManualDraggingAfterShow = true; 1791 apo.tmp.bIsManualDragging = true; 1792 } 1793 apo.tmp.bIsTouched = true; 1794 apo.tmp.bEnd = false; 1795 apo.tmp.iPos = apo._getTouchPosition(e); 1796 apo.tmp.bFromTouchStart = true; 1797 apo._setScrollingData(e); 1798 1799 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1800 { 1801 var $oComp = $(apo.tmp.overlaySelector).find("#ap-component-" + apo.tmp.iScrollingComp); 1802 1803 if(apo.tmp.bIsManualDragging) 1804 { 1805 $(apo.tmp.overlaySelector).find(".ap-component").removeClass("ap-component-modifying"); 1806 $oComp.addClass("ap-component-modifying"); 1807 } 1808 } 1809 1810 if(e.type === "mousedown") 1811 { 1812 $(document).on("mousemove." + apo.setting.timestamp, e.data, apo._onDrag); 1813 $(document).on("mouseup." + apo.setting.timestamp, e.data, apo._onEndDrag); 1814 } 1815 1816 e.preventDefault(); 1817 e.stopPropagation(); 1818 return false; 1819 }, 1820 1821 _onDrag: function(e) 1822 { 1823 var apo = e.data.apo; 1824 var iPosNew, iDSDelta, iTSDelta, iTSNDelta, iDSTS, iDir, iDSTSDiff, 1825 iTSNew = Date.now(); 1826 1827 apo._clearScrollTicker(); 1828 1829 if(apo.tmp.bIsTouched && (!$.AnyPicker.extra.bHasPointer || $.AnyPicker.extra.bHasPointer && (apo.tmp.bFromTouchStart || (!apo.tmp.bFromTouchStart && (iTSNew - apo.tmp.iTS > 1000))))) 1830 { 1831 iPosNew = apo._getTouchPosition(e); 1832 iTSNew = Date.now(); 1833 iDSDelta = (apo.tmp.iPos - iPosNew); 1834 iDir = iDSDelta / Math.abs(iDSDelta); 1835 1836 if(iDSDelta > 2 || iDSDelta < -2) 1837 { 1838 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1839 { 1840 var $oComp = $(apo.tmp.overlaySelector).find("#ap-component-" + apo.tmp.iScrollingComp), 1841 $oAllRows = $oComp.find(".ap-row"); 1842 $oAllRows.attr("aria-selected", "false"); 1843 $oAllRows.removeClass("ap-row-selected"); 1844 } 1845 1846 apo.tmp.iPosPrev = apo.tmp.iPos; 1847 apo.tmp.iPos = iPosNew; 1848 iTSDelta = iTSNew - apo.tmp.iTS; 1849 apo.tmp.iTS = iTSNew; 1850 iDSTS = (iDSDelta / iTSDelta); 1851 apo.tmp.iTotalDS += iDSDelta; 1852 iDSTSDiff = apo.tmp.iPrevDSTS - iDSTS; 1853 1854 if($.AnyPicker.extra.bHasPointer) 1855 { 1856 if($.AnyPicker.extra.bIsTouchDevice) 1857 { 1858 if(iDSDelta > 10 || iDSDelta < -10) 1859 { 1860 if($.CF.compareStrings(apo.setting.theme, "iOS")) 1861 iDSDelta = apo.setting.visibleRows * 4 * iDSTS; 1862 else 1863 { 1864 if(Math.abs(apo.tmp.iTotalDS) > 100) 1865 { 1866 if(iDSTS > 0.05) 1867 { 1868 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1869 iDSDelta = iDSDelta * iTSDelta * 5; 1870 else 1871 iDSDelta = iDSDelta * iTSDelta * 2; 1872 } 1873 else 1874 { 1875 if(iDir === 1) 1876 iDSDelta = (iDir * apo.setting.rowHeight/2); 1877 else 1878 iDSDelta = (iDir * apo.setting.rowHeight/1.2); 1879 } 1880 } 1881 else if(iDSTS > 0.06 && Math.abs(iDSTSDiff) > 0.08) 1882 { 1883 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1884 iDSDelta = iDSDelta * iTSDelta * 5; 1885 else 1886 iDSDelta = iDSDelta * iTSDelta * 2; 1887 } 1888 else 1889 { 1890 if(iDSDelta > 50 || iDSDelta < -50) 1891 { 1892 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1893 iDSDelta = iDSDelta * iTSDelta * 5; 1894 else 1895 iDSDelta = iDSDelta * iTSDelta * 2; 1896 } 1897 } 1898 } 1899 } 1900 else 1901 { 1902 if(Math.abs(iDSTS) > 0.06 && Math.abs(iDSTSDiff) > 0.08) 1903 { 1904 if($.CF.compareStrings(apo.setting.theme, "Windows")) 1905 iDSDelta = iDSDelta * iTSDelta * 5; 1906 else 1907 iDSDelta = iDSDelta * iTSDelta * 2; 1908 } 1909 else 1910 { 1911 if(iDir === 1) 1912 iDSDelta = (iDir * apo.setting.rowHeight/2); 1913 else 1914 iDSDelta = (iDir * apo.setting.rowHeight/1.2); 1915 } 1916 } 1917 } 1918 else 1919 { 1920 if(iDSDelta < 2 && iDSDelta > -2 && iDSDelta !== 0) 1921 iDSDelta = (iDir * 5); 1922 1923 if(iDSDelta > 5 || iDSDelta < -5) 1924 iDSDelta = (apo.setting.visibleRows / 10) * 320 * iDSTS; 1925 else 1926 iDSDelta = iDir * apo.setting.rowHeight; 1927 } 1928 } 1929 else 1930 { 1931 if(iDSDelta > 10 || iDSDelta < -10) // 10 1932 iDSDelta = iDSDelta + apo.setting.visibleRows * 16 * iDSTS; // 80 | 160 1933 } 1934 apo.tmp.iPrevDSTS = iDSTS; 1935 1936 apo._scrollToPosition("drag", (apo.tmp.iOffset + iDSDelta), false, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 1937 apo.tmp.bFromTouchStart = false; 1938 } 1939 } 1940 1941 e.preventDefault(); 1942 e.stopPropagation(); 1943 return false; 1944 }, 1945 1946 _onEndDrag: function(e) 1947 { 1948 var apo = e.data.apo; 1949 1950 if(!apo.tmp.bEnd) 1951 { 1952 apo.tmp.bEnd = true; 1953 apo.tmp.bIsTouched = false; 1954 1955 apo._scrollToPosition("drag", apo.tmp.iOffset, true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 1956 1957 if(e.type === "mouseup") 1958 { 1959 $(document).off("mousemove." + apo.setting.timestamp, apo._onDrag); 1960 $(document).off("mouseup." + apo.setting.timestamp, apo._onEndDrag); 1961 } 1962 } 1963 1964 e.preventDefault(); 1965 e.stopPropagation(); 1966 return false; 1967 }, 1968 1969 _onMouseWheelScroll: function(e) 1970 { 1971 var apo = e.data.apo; 1972 var oData = e.data, 1973 iDelta; 1974 e = e || window.event; // old IE support 1975 1976 if(oData.component !== apo.tmp.iScrollingComp) 1977 apo._setScrollingData(e); 1978 apo._clearScrollTicker(); 1979 1980 iDelta = e.wheelDelta ? (e.wheelDelta / 3) : (e.originalEvent.wheelDelta ? (e.originalEvent.wheelDelta / 3) : (e.detail ? (-e.detail / 3) : 0)); 1981 apo._scrollToPosition("mouseWheel", (apo.tmp.iOffset - (iDelta)), true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 1982 1983 e.preventDefault(); 1984 e.stopPropagation(); 1985 return false; 1986 }, 1987 1988 _onClickButtonPlus: function(e) 1989 { 1990 var apo = e.data.apo; 1991 1992 e.preventDefault(); 1993 e.stopPropagation(); 1994 1995 apo._setScrollingData(e); 1996 apo._clearScrollTicker(); 1997 1998 apo._scrollToPosition("button", (apo.tmp.iOffset + apo.setting.rowHeight), true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 1999 }, 2000 2001 _onClickButtonMinus: function(e) 2002 { 2003 var apo = e.data.apo; 2004 2005 e.preventDefault(); 2006 e.stopPropagation(); 2007 2008 apo._setScrollingData(e); 2009 apo._clearScrollTicker(); 2010 2011 apo._scrollToPosition("button", (apo.tmp.iOffset - apo.setting.rowHeight), true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 2012 }, 2013 2014 _onKeyDown: function(e) 2015 { 2016 var apo = e.data.apo; 2017 2018 e.preventDefault(); 2019 e.stopPropagation(); 2020 2021 apo._setScrollingData(e); 2022 apo._clearScrollTicker(); 2023 2024 if(e.keyCode === 38) // Up Arrow Key 2025 { 2026 apo._scrollToPosition("key", (apo.tmp.iOffset - apo.setting.rowHeight), true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 2027 } 2028 else if(e.keyCode === 40) // Down Arrow Key 2029 { 2030 apo._scrollToPosition("key", (apo.tmp.iOffset + apo.setting.rowHeight), true, "#ap-component-" + apo.tmp.iScrollingComp + " .ap-component-data"); 2031 } 2032 }, 2033 2034 _onKeyUp: function(e) 2035 { 2036 var apo = e.data.apo; 2037 2038 e.preventDefault(); 2039 e.stopPropagation(); 2040 2041 apo._unsetScrollingData(); 2042 }, 2043 2044 _getTouchPosition: function(e) 2045 { 2046 var apo = e.data.apo; 2047 2048 e = e.originalEvent || e; 2049 return e.changedTouches ? e.changedTouches[0].pageY : e.pageY; 2050 }, 2051 2052 _setScrollingData: function(e) 2053 { 2054 var apo = e.data.apo; 2055 2056 apo.tmp.iScrollingComp = parseInt(e.data.component); 2057 apo.tmp.oScrollingComp = $("#ap-component-"+e.data.component).find(".ap-component-data"); 2058 apo.tmp.iMinTopPos = 0; 2059 apo.tmp.iMaxTopPos = ($(apo.tmp.oScrollingComp).find(".ap-row").length * apo.setting.rowHeight) - $(apo.tmp.oScrollingComp).parent().innerHeight(); 2060 apo.tmp.iTS = Date.now(); 2061 apo.tmp.iCompDragStart = apo.tmp.iTS; 2062 apo.tmp.iOffsetStart = Math.abs($(apo.tmp.oScrollingComp).position().top); 2063 apo.tmp.iOffset = apo.tmp.iOffsetStart; 2064 apo.tmp.iOffsetPrev = apo.tmp.iOffsetStart; 2065 apo.tmp.iTimeout = 0; 2066 apo.tmp.iDir = 1; 2067 apo.tmp.iTotalDS = 0; 2068 apo.tmp.iPrevDSTS = 0; 2069 2070 apo._clearScrollTicker(); 2071 }, 2072 2073 _unsetScrollingData: function() 2074 { 2075 var apo = this; 2076 2077 apo.tmp.bIsTouched = false; 2078 apo.tmp.iPos = 0; 2079 apo.tmp.iTS = 0; 2080 2081 apo.tmp.iOffset = 0; 2082 apo.tmp.iTimeout = 0; 2083 2084 apo.tmp.iMinTopPos = 0; 2085 apo.tmp.iMaxTopPos = 0; 2086 apo.tmp.oScrollingComp = null; 2087 apo.tmp.iScrollingComp = -1; 2088 apo.tmp.iDir = 0; 2089 2090 apo._clearScrollTicker(); 2091 2092 $(document).off("mousemove." + apo.setting.timestamp); 2093 $(document).off("mouseup." + apo.setting.timestamp); 2094 $(document).off("touchend." + apo.setting.timestamp); 2095 }, 2096 2097 _getScrollingData: function() 2098 { 2099 var apo = this; 2100 var oScrollingData = {}; 2101 2102 oScrollingData.iScrollingComp = apo.tmp.iScrollingComp; 2103 oScrollingData.oScrollingComp = apo.tmp.oScrollingComp; 2104 oScrollingData.iMinTopPos = apo.tmp.iMinTopPos; 2105 oScrollingData.iMaxTopPos = apo.tmp.iMaxTopPos; 2106 oScrollingData.iTS = apo.tmp.iTS; 2107 oScrollingData.iCompDragStart = apo.tmp.iCompDragStart; 2108 oScrollingData.iOffsetStart = apo.tmp.iOffsetStart; 2109 oScrollingData.iOffset = apo.tmp.iOffset; 2110 oScrollingData.iOffsetPrev = apo.tmp.iOffsetPrev; 2111 oScrollingData.iTimeout = apo.tmp.iTimeout; 2112 oScrollingData.iDir = apo.tmp.iDir; 2113 2114 return oScrollingData; 2115 }, 2116 2117 _clearScrollTicker: function() 2118 { 2119 var apo = this; 2120 2121 clearTimeout(apo.tmp.oScrollTicker); 2122 apo.tmp.oScrollTicker = null; 2123 }, 2124 2125 /* 2126 2127 sSource values can be - 2128 2129 1. auto 2130 2. drag 2131 3. mousewheel 2132 4. button 2133 5. key 2134 2135 */ 2136 _scrollToPosition: function(sSource, iOffsetNew, bStop, sComp) 2137 { 2138 var apo = this; 2139 2140 var iComp = apo.tmp.iScrollingComp, 2141 iDir = (iOffsetNew < apo.tmp.iOffset) ? 1 : (iOffsetNew === apo.tmp.iOffset) ? apo.tmp.iDir : -1, // Bottom Up : Top Down 2142 iPosMod = iOffsetNew % apo.setting.rowHeight, 2143 iHalfRowHeight = apo.setting.rowHeight / 4, 2144 iPrevOffset = apo.tmp.iOffset, 2145 iTime = 0.1; 2146 2147 apo.tmp.iDir = iDir; 2148 2149 if(bStop) 2150 iOffsetNew = (iPosMod !== 0) ? ((iPosMod < iHalfRowHeight) ? (iOffsetNew - iPosMod) : (iOffsetNew + (apo.setting.rowHeight - iPosMod))) : iOffsetNew; 2151 2152 var iMinPosBounce = apo.tmp.iMinTopPos - apo.setting.rowHeight, 2153 iMaxPosBounce = apo.tmp.iMaxTopPos + apo.setting.rowHeight; 2154 2155 apo.tmp.iOffset = (iOffsetNew > apo.tmp.iMaxTopPos) ? iMaxPosBounce : (iOffsetNew < apo.tmp.iMinTopPos) ? iMinPosBounce : iOffsetNew; 2156 2157 if($.AnyPicker.extra.bHasCSS3D) 2158 { 2159 var iDiffOffset = Math.abs(iPrevOffset - apo.tmp.iOffset); 2160 2161 if(sSource === "drag") 2162 { 2163 if(iDiffOffset < (apo.setting.rowHeight * 6)) 2164 iTime = (iDiffOffset / (apo.setting.rowHeight * 10)); // Increase Divisor value to increase speed 2165 else 2166 { 2167 iTime = (iDiffOffset / (apo.setting.rowHeight * 10)); // Increase Divisor value to increase speed 2168 iTime = (iTime <= 0.2) ? 0.2 : iTime; 2169 } 2170 } 2171 else 2172 iTime = 0.1; 2173 2174 apo._performTransition(iComp, sComp, apo.tmp.iOffset, (apo.tmp.iTimeout/1000), apo.tmp.iMinTopPos, apo.tmp.iMaxTopPos, iDir, iMinPosBounce, iMaxPosBounce, sSource, bStop); 2175 apo.tmp.iTimeout = (apo.tmp.iTimeout - (Date.now() - apo.tmp.iTS)) + (iTime * 1000); 2176 } 2177 else 2178 apo._performTransition(iComp, sComp, apo.tmp.iOffset, iTime, apo.tmp.iMinTopPos, apo.tmp.iMaxTopPos, iDir, iMinPosBounce, iMaxPosBounce, sSource, bStop); 2179 }, 2180 2181 _performTransition: function(iComp, sComp, iOffset, iTime, iMinTopPos, iMaxTopPos, iDir, iMinPosBounce, iMaxPosBounce, sSource, bStop) 2182 { 2183 var apo = this; 2184 var oElem = $(apo.tmp.overlaySelector).find(sComp).get(0), 2185 iOffsetNew = apo._getOffset(oElem, true), 2186 iDiffOffset = Math.abs(iOffsetNew - iOffset), 2187 iExpTime = iDiffOffset / (apo.setting.rowHeight * 10); // Increase Divisor value to increase speed 2188 2189 iTime = (iTime > iExpTime) ? iExpTime : iTime; 2190 iTime = (iTime < 0.1) ? 0.1 : iTime; 2191 iTime = ($.AnyPicker.extra.bHasPointer && apo.tmp.bIsTouched && sSource === "auto") ? 0 : iTime; 2192 2193 if($.AnyPicker.extra.bHasCSS3D) 2194 { 2195 oElem.style[$.AnyPicker.extra.sCSSTransition] = $.AnyPicker.extra.sCSSTransformStyle + " " + iTime + "s ease-out"; 2196 oElem.style[$.AnyPicker.extra.sCSSTransform] = "translate3d(0px, "+ -iOffset +"px, 0px)"; 2197 } 2198 else 2199 $(oElem).animate({"top": -iOffset}, 100); 2200 2201 apo.tmp.iOffset = iOffset; 2202 2203 // --------------------------------------------------------------- 2204 2205 var oScrollingData = apo._getScrollingData(); 2206 apo._performTransitionAfter(oScrollingData, iMaxPosBounce, iMinPosBounce, sSource, iTime, bStop); 2207 apo._clearScrollTicker(); 2208 }, 2209 2210 _performTransitionAfter: function(oScrollingData, iMaxPosBounce, iMinPosBounce, sSource, iTime, bStop) 2211 { 2212 var apo = this; 2213 2214 setTimeout(function() 2215 { 2216 if(bStop && (sSource === "drag" || sSource === "mouseWheel")) 2217 { 2218 apo.tmp.oScrollTicker = 1; 2219 apo._scrollToRow(oScrollingData.iDir, iMaxPosBounce, iMinPosBounce, oScrollingData.iMinTopPos, oScrollingData.iMaxTopPos, sSource); 2220 } 2221 2222 var oElem = $(oScrollingData.oScrollingComp).get(0), 2223 iOffset = (sSource === "auto") ? oScrollingData.iOffset : -apo._getOffset(oElem, false), 2224 2225 bLTMin = (iOffset < oScrollingData.iMinTopPos), 2226 bGTMax = (iOffset > oScrollingData.iMaxTopPos), 2227 2228 iOffsetNew = Math.abs(iOffset); 2229 2230 if(bLTMin) 2231 iOffset = oScrollingData.iMinTopPos; 2232 else if(bGTMax) 2233 iOffset = oScrollingData.iMaxTopPos; 2234 2235 if(bLTMin || bGTMax) 2236 { 2237 iTime = Math.abs(iOffsetNew - iOffset) / (apo.setting.rowHeight * 10); 2238 if($.AnyPicker.extra.bHasCSS3D) 2239 { 2240 oElem.style[$.AnyPicker.extra.sCSSTransition] = $.AnyPicker.extra.sCSSTransformStyle + " " + iTime + "s ease-out"; 2241 oElem.style[$.AnyPicker.extra.sCSSTransform] = "translate3d(0px, "+ -Math.abs(iOffset) +"px, 0px)"; 2242 } 2243 else 2244 $(oElem).animate({"top": -Math.abs(iOffset)}, 100); 2245 2246 oScrollingData.iOffset = iOffset; 2247 iOffsetNew = iOffset; 2248 2249 apo._skipDisabledRowAfter(oScrollingData, iOffsetNew, sSource, iTime, bStop); 2250 } 2251 else 2252 { 2253 if(bStop || (iOffsetNew === oScrollingData.iMinTopPos || iOffsetNew === oScrollingData.iMaxTopPos)) 2254 apo._skipDisabledRow(sSource, oScrollingData.iScrollingComp, iOffsetNew, oScrollingData.iDir); 2255 } 2256 }, (iTime * 1000)); 2257 }, 2258 2259 _skipDisabledRowAfter: function(oScrollingData, iOffsetNew, sSource, iTime, bStop) 2260 { 2261 var apo = this; 2262 2263 setTimeout(function() 2264 { 2265 var iOffsetVal = (sSource === "auto") ? iOffsetNew : oScrollingData.iOffset; 2266 if(bStop || (iOffsetVal === oScrollingData.iMinTopPos || iOffsetVal === oScrollingData.iMaxTopPos)) 2267 apo._skipDisabledRow(sSource, oScrollingData.iScrollingComp, iOffsetVal, oScrollingData.iDir); 2268 }, (iTime * 1000)); 2269 }, 2270 2271 _getOffset: function(oElem, bAbs) 2272 { 2273 var sMatrix = $(oElem).hasClass("ap-component-data") ? $(oElem).css("transform") : $(oElem).find(".ap-component-data").css("transform"), 2274 iOffset = 0; 2275 2276 if($.CF.isValid(sMatrix)) 2277 { 2278 if(sMatrix === "none") 2279 iOffset = 0; 2280 else 2281 { 2282 sMatrix = sMatrix.replace("matrix(", ""); 2283 sMatrix = sMatrix.replace(")", ""); 2284 var iArrMatrix = sMatrix.split(", "); 2285 iOffset = (iArrMatrix.length > 6) ? parseInt(iArrMatrix[13]) : parseInt(iArrMatrix[5]); 2286 } 2287 } 2288 2289 if(bAbs) 2290 return Math.abs(iOffset); 2291 else 2292 return iOffset; 2293 }, 2294 2295 _scrollToRow: function(iDir, iMaxPosBounce, iMinPosBounce, iMinTopPos, iMaxTopPos, sSource) 2296 { 2297 var apo = this; 2298 2299 var iPosMod, iOffset, iTime; 2300 if(apo.tmp.oScrollTicker !== null) 2301 { 2302 var oElem = $(apo.tmp.oScrollingComp).get(0); 2303 iOffset = apo._getOffset(oElem, false); 2304 iPosMod = iOffset % apo.setting.rowHeight; 2305 2306 if(iPosMod !== 0 || (iPosMod === 0 && (iOffset > iMinTopPos || iOffset < -iMaxTopPos))) 2307 { 2308 iOffset = Math.abs(iOffset); 2309 iOffset = (iDir === -1) ? (iOffset + (apo.setting.rowHeight - Math.abs(iPosMod))) : (iOffset + iPosMod); 2310 iOffset = (iOffset > iMaxTopPos) ? iMaxTopPos : (iOffset < iMinTopPos) ? iMinTopPos : iOffset; 2311 2312 iTime = 0.4; 2313 if($.AnyPicker.extra.bHasCSS3D) 2314 { 2315 oElem.style[$.AnyPicker.extra.sCSSTransition] = $.AnyPicker.extra.sCSSTransformStyle + " " + iTime + "s ease-out"; 2316 oElem.style[$.AnyPicker.extra.sCSSTransform] = "translate3d(0px, "+ -Math.abs(iOffset) +"px, 0px)"; 2317 } 2318 else 2319 $(oElem).animate({"top": -Math.abs(iOffset)}, 100); 2320 apo.tmp.iOffset = iOffset; 2321 } 2322 } 2323 }, 2324 2325 __scrollToSelectedRow: function() 2326 { 2327 var apo = this; 2328 var iTempIndex; 2329 var e = {}, iTimeout = 0; 2330 2331 if($.CF.compareStrings(apo.setting.mode, "datetime")) 2332 apo.__setSelectedDateTimeInComponent(); 2333 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 2334 { 2335 var oArrSelected = $(apo.tmp.overlaySelector).find("#ap-component-" + iTempIndex + " .ap-row-selected"), 2336 oElemSelected = (oArrSelected.length > 0) ? oArrSelected[0] : null; 2337 if(oElemSelected !== null) 2338 { 2339 var iPosTop = $(oElemSelected).position().top, 2340 iExtraHeight = (apo.tmp.iExt * apo.setting.rowHeight); 2341 iPosTop = (iPosTop === 0) ? iPosTop : (iPosTop - iExtraHeight); 2342 2343 apo.callScrollToPosition(iTempIndex, apo, iPosTop, iTimeout); 2344 iTimeout += 200; 2345 } 2346 } 2347 }, 2348 2349 callScrollToPosition: function(iComp, oAPO, iPosTop, iTimeout) 2350 { 2351 var apo = this; 2352 var e = {}; 2353 //setTimeout(function() 2354 //{ 2355 e.data = { component: iComp, apo: oAPO }; 2356 apo._setScrollingData(e); 2357 apo._scrollToPosition("auto", iPosTop, true, "#ap-component-" + iComp + " .ap-component-data"); 2358 //}, iTimeout); 2359 }, 2360 2361 // Public Method 2362 setSelectedAndInvalidValuesForRows: function(bSetSelected) 2363 { 2364 var apo = this; 2365 2366 if($.CF.compareStrings(apo.setting.mode, "select")) 2367 apo.__disableInvalidRowsOfSelect(); 2368 else if($.CF.compareStrings(apo.setting.mode, "datetime")) 2369 { 2370 if(bSetSelected) 2371 apo.__setSelectedDateTimeInComponent(); 2372 2373 $(apo.tmp.overlaySelector).find(".ap-row").removeClass("ap-row-disabled ap-row-invalid ap-row-hidden"); 2374 apo.__disableInvalidRowsOfDateTimePicker(); 2375 apo.__setDaysOfMonthInDatePicker(); 2376 } 2377 2378 if(bSetSelected) 2379 apo.__scrollToSelectedRow(); 2380 }, 2381 2382 /* 2383 2384 After the component stops scrolling, 2385 2386 Unset the values of the non-selected components in - 2387 2388 1. apo.setting.dataSource 2389 2. Set aria-selected attribute as false 2390 2391 set the value of the selected component in - 2392 2393 1. apo.setting.dataSource 2394 2. aria-selected attribute of the selected DOM element 2395 2396 */ 2397 __changeComponentValue: function(iComp, sNewValue) 2398 { 2399 var apo = this; 2400 var oComp = apo.setting.components[iComp], 2401 oDataSource = apo.setting.dataSource[iComp].data, 2402 iTempIndex, sElemId, $oElem; 2403 2404 for(iTempIndex = 0; iTempIndex < oDataSource.length; iTempIndex++) 2405 { 2406 sElemId = "#ap-row-" + iComp + "-" + iTempIndex; 2407 $oElem = $(apo.tmp.overlaySelector).find(sElemId); 2408 2409 if(oDataSource[iTempIndex].val === sNewValue) 2410 { 2411 oDataSource[iTempIndex].selected = true; 2412 $oElem.attr("aria-selected", "true"); 2413 $oElem.addClass("ap-row-selected"); 2414 } 2415 else 2416 { 2417 oDataSource[iTempIndex].selected = false; 2418 $oElem.attr("aria-selected", "false"); 2419 $oElem.removeClass("ap-row-selected"); 2420 } 2421 } 2422 }, 2423 2424 /* 2425 2426 If picker component rests on the disabled row after scrolling, 2427 2428 1. Find the next enabled row to be selected in direction of scrolling. 2429 2. If enabled row cannot be found then search for enabled row in the opposite direction 2430 2431 Once row is found call _scrollToPosition() 2432 2433 */ 2434 _skipDisabledRow: function(sSource, iComp, iOffset, iDir) 2435 { 2436 var apo = this; 2437 var sElemSel = "#ap-component-" + iComp + " .ap-component-data", 2438 oElem = $(apo.tmp.overlaySelector).find(sElemSel).get(0), 2439 iRow = Math.floor(iOffset / apo.setting.rowHeight), 2440 sPartialId = "#ap-row-" + iComp + "-", 2441 sRowId = sPartialId + iRow, 2442 iTotalRows = $(oElem).find(".ap-row").length - (2 * apo.tmp.iExt), 2443 bIsRowDisabled = $(oElem).find(sRowId).hasClass("ap-row-disabled"), 2444 iEnabledRow = -1, 2445 iDirPrev = 0, e = {}, 2446 bSkippedRow = false; 2447 2448 if($.CF.isValid(oElem) && bIsRowDisabled) 2449 { 2450 if(iDir === 1) 2451 { 2452 iEnabledRow = apo._findRows(iComp, iRow, iTotalRows, oElem, iDir); 2453 if(iEnabledRow === -1) 2454 { 2455 iDir = -1; 2456 iDirPrev = 1; 2457 } 2458 } 2459 2460 if(iDir === -1) 2461 { 2462 iEnabledRow = apo._findRows(iComp, iRow, iTotalRows, oElem, iDir); 2463 if(iEnabledRow === -1 && iDirPrev === 0) 2464 { 2465 iDir = 1; 2466 iEnabledRow = apo._findRows(iComp, iRow, iTotalRows, oElem, iDir); 2467 } 2468 } 2469 2470 var iNewOffset = (iEnabledRow !== -1) ? ($(oElem).find(sPartialId + iEnabledRow).position().top - (apo.tmp.iExt * apo.setting.rowHeight)) : -1; 2471 if(iEnabledRow !== -1 && iOffset !== iNewOffset) 2472 { 2473 bSkippedRow = true; 2474 e.data = { component: iComp, apo: apo }; 2475 apo._setScrollingData(e); 2476 apo._scrollToPosition("auto", iNewOffset, true, sElemSel); 2477 } 2478 else 2479 { 2480 setTimeout(function() 2481 { 2482 apo._actionsOnComponentStop(sSource, iComp, iRow, iOffset, iDir); 2483 }, 200); 2484 } 2485 } 2486 else 2487 { 2488 setTimeout(function() 2489 { 2490 apo._actionsOnComponentStop(sSource, iComp, iRow, iOffset, iDir); 2491 }, 200); 2492 } 2493 }, 2494 2495 _actionsOnComponentStop: function(sSource, iComp, iRow, iOffset, iDir) 2496 { 2497 var apo = this; 2498 var iTempIndex, bReloaded = false, sHeaderTitle = ""; 2499 2500 apo.__setAriaSelectedForRowElement(iComp, iOffset, iDir); 2501 apo._getSelectedValueInComponent(null); 2502 2503 if($.CF.compareStrings(apo.setting.inputChangeEvent, "onChange")) 2504 apo._setOutput(); 2505 2506 if(apo.tmp.sHeaderTitleType === "DynamicFunction") 2507 { 2508 sHeaderTitle = apo.setting.headerTitle.format.call(apo.tmp.selectedValues); 2509 $(apo.tmp.overlaySelector).find(".ap-header__title").text(sHeaderTitle); 2510 } 2511 else if(apo.tmp.sHeaderTitleType === "DynamicString") 2512 { 2513 if($.CF.compareStrings(apo.setting.mode, "select")) 2514 { 2515 for(var iCompIndex = 0; iCompIndex < apo.tmp.numOfComp; iCompIndex++) 2516 { 2517 if(iCompIndex !== 0) 2518 sHeaderTitle += " "; 2519 sHeaderTitle += apo.tmp.selectedValues.values[iCompIndex].label; 2520 } 2521 } 2522 else if($.CF.compareStrings(apo.setting.mode, "datetime")) 2523 { 2524 sHeaderTitle = apo.formatOutputDates(apo.tmp.selectedValues.date, apo.tmp.sArrHeaderTitleFormat); 2525 } 2526 2527 var bSetHeaderTitle = true; 2528 if(!apo.tmp.bIsManualDragging) // !$.CF.compareStrings(apo.setting.theme, "iOS") && 2529 bSetHeaderTitle = false; 2530 if(bSetHeaderTitle) 2531 $(apo.tmp.overlaySelector).find(".ap-header__title").text(sHeaderTitle); 2532 } 2533 2534 if(sSource !== "auto" && $.CF.isValid(apo.setting.onChange)) 2535 apo.setting.onChange.call(apo, iComp, iRow, apo.tmp.selectedValues, sSource); 2536 2537 if(!bReloaded) 2538 apo.setSelectedAndInvalidValuesForRows(false); 2539 }, 2540 2541 /* 2542 2543 Find rows in the scrolling component before/after a specified Row in a specified direction. 2544 2545 */ 2546 _findRows: function(iComp, iRow, iTotalRows, oElem, iDir) 2547 { 2548 var apo = this; 2549 var iTempIndex; 2550 2551 if(iDir === -1) 2552 { 2553 for(iTempIndex = (iRow + 1); iTempIndex < iTotalRows; iTempIndex++) 2554 { 2555 if(! $(oElem).find("#ap-row-" + iComp + "-" + iTempIndex).hasClass("ap-row-disabled")) 2556 return iTempIndex; 2557 } 2558 } 2559 else if(iDir === 1) 2560 { 2561 for(iTempIndex = (iRow - 1); iTempIndex > 0; iTempIndex--) 2562 { 2563 if(! $(oElem).find("#ap-row-" + iComp + "-" + iTempIndex).hasClass("ap-row-disabled")) 2564 return iTempIndex; 2565 } 2566 } 2567 2568 return -1; 2569 }, 2570 2571 /* 2572 2573 Validate selected values to ensure that the values are not specified as disabled values or they do not fall in the disabled values range. 2574 2575 */ 2576 _validateSelectedValues: function() 2577 { 2578 var apo = this; 2579 2580 if($.CF.compareStrings(apo.setting.mode, "datetime")) 2581 { 2582 var dNewSelectedDate = apo.__getSelectedDate(false); 2583 apo.__validateSelectedDate(dNewSelectedDate, false); 2584 } 2585 }, 2586 2587 __setAriaSelectedForRowElement: function(iComp, iOffset, iDir) 2588 { 2589 var apo = this; 2590 var $oElemComp = $(apo.tmp.overlaySelector).find("#ap-component-" + iComp), 2591 iElementIndex; 2592 2593 if(iOffset === 0) 2594 iOffset = apo._getOffset($oElemComp, true); 2595 2596 if(iDir === 1) 2597 iElementIndex = Math.floor(iOffset / apo.setting.rowHeight); 2598 else if(iDir === -1) 2599 iElementIndex = Math.ceil(iOffset / apo.setting.rowHeight); 2600 2601 var $oAllRows = $oElemComp.find(".ap-row"), 2602 $oThisRow = $oElemComp.find("#ap-row-" + iComp + "-" + iElementIndex); 2603 2604 $oAllRows.attr("aria-selected", "false"); 2605 $oAllRows.removeClass("ap-row-selected"); 2606 2607 $oThisRow.attr("aria-selected", "true"); 2608 $oThisRow.addClass("ap-row-selected"); 2609 }, 2610 2611 _getSelectedValueInComponent: function(iComp) 2612 { 2613 var apo = this; 2614 var iTempIndex, 2615 $oSelectedElem, sSelectedValue, sSelectedDisplayValue, 2616 oArrSelectedValues = []; 2617 2618 apo.tmp.selectedValues = {}; 2619 2620 if($.CF.isValid(iComp)) 2621 { 2622 $oSelectedElem = $(apo.tmp.overlaySelector).find("#ap-component-" + iComp + " .ap-row-selected"); 2623 2624 oArrSelectedValues.push( 2625 { 2626 component: iComp, 2627 val: $oSelectedElem.data("value"), 2628 label: $oSelectedElem.data("label") 2629 }); 2630 } 2631 else 2632 { 2633 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 2634 { 2635 $oSelectedElem = $(apo.tmp.overlaySelector).find("#ap-component-" + iTempIndex + " .ap-row-selected"); 2636 2637 oArrSelectedValues.push( 2638 { 2639 component: iTempIndex, 2640 val: $oSelectedElem.data("value"), 2641 label: $oSelectedElem.data("label") 2642 }); 2643 } 2644 } 2645 2646 apo.tmp.selectedValues.values = oArrSelectedValues; 2647 2648 if($.CF.compareStrings(apo.setting.mode, "datetime")) 2649 { 2650 apo.tmp.selectedValues.date = apo.__getSelectedDate(false); 2651 apo.tmp.selectedDate = apo.tmp.selectedValues.date; 2652 } 2653 }, 2654 2655 __getDataSourceValueFromLabel: function(sLabel, iInCompIndex, bSetSelected) 2656 { 2657 var apo = this; 2658 var iCompIndex, iTempIndex, 2659 oCompData, oData, sValue = ""; 2660 2661 if($.CF.isValid(iInCompIndex)) 2662 { 2663 oCompData = apo.setting.dataSource[iInCompIndex].data; 2664 for(iTempIndex = 0; iTempIndex < oCompData.length; iTempIndex++) 2665 { 2666 oData = oCompData[iTempIndex]; 2667 if($.CF.compareStrings(oData.label, sLabel)) 2668 { 2669 sValue = oData.val; 2670 if(bSetSelected) 2671 oData.selected = true; 2672 } 2673 else 2674 { 2675 if(bSetSelected) 2676 oData.selected = false; 2677 } 2678 apo.setting.dataSource[iInCompIndex].data[iTempIndex] = oData; 2679 } 2680 } 2681 else 2682 { 2683 for(iCompIndex = 0; iCompIndex < apo.tmp.numOfComp; iCompIndex++) 2684 { 2685 oCompData = apo.setting.dataSource[iCompIndex].data; 2686 for(iTempIndex = 0; iTempIndex < oCompData.length; iTempIndex++) 2687 { 2688 oData = oCompData[iTempIndex]; 2689 if($.CF.compareStrings(oData.label, sLabel)) 2690 { 2691 if(bSetSelected) 2692 oData.selected = true; 2693 sValue = oData.val; 2694 } 2695 else 2696 { 2697 if(bSetSelected) 2698 oData.selected = false; 2699 } 2700 } 2701 } 2702 } 2703 2704 return sValue; 2705 }, 2706 2707 __getValuesOfComponent: function(sValueOf, iComp) 2708 { 2709 var apo = this; 2710 var oValue = null, iCompIndex; 2711 2712 if(sValueOf === "component") 2713 { 2714 if(apo.setting.components[iComp].component === iComp) 2715 oValue = apo.setting.components[iComp]; 2716 else 2717 { 2718 for(iCompIndex = 0; iCompIndex < apo.tmp.numOfComp; iCompIndex++) 2719 { 2720 if(apo.setting.components[iCompIndex].component === iComp) 2721 oValue = apo.setting.components[iCompIndex]; 2722 } 2723 } 2724 } 2725 else if(sValueOf === "datasource") 2726 { 2727 if(apo.setting.dataSource[iComp].component === iComp) 2728 oValue = apo.setting.dataSource[iComp]; 2729 else 2730 { 2731 for(iCompIndex = 0; iCompIndex < apo.tmp.numOfComp; iCompIndex++) 2732 { 2733 if(apo.setting.dataSource[iCompIndex].component === iComp) 2734 oValue = apo.setting.dataSource[iCompIndex]; 2735 } 2736 } 2737 } 2738 2739 return oValue; 2740 } 2741 2742}); 2743 2744// --------------------------------- Functions : AnyPicker.PickerComponent End --------------------------------------
vendor: 3,002 bytes, lines 2745-2862
2745 2746 2747 2748 2749// --------------------------------- Functions : AnyPicker.Select Start ------------------------------------ 2750 2751//"use strict"; 2752 2753AnyPicker.prototype = $.extend(AnyPicker.prototype, { 2754 2755 __setComponentsOfSelect: function() 2756 { 2757 var apo = this; 2758 2759 if(apo.setting.dataSource === null) 2760 { 2761 if(apo.tmp.oElemValid.bIsListItem || apo.tmp.oElemValid.bIsSelect) 2762 { 2763 var sChild, $oChildElem; 2764 apo.setting.components = []; 2765 2766 var oComponent = {}; 2767 oComponent.component = 1; 2768 oComponent.name = $(apo.elem).data("name"); 2769 oComponent.label = $(apo.elem).data("label"); 2770 apo.setting.components.push(oComponent); 2771 2772 var oArrData = []; 2773 2774 if(apo.tmp.oElemValid.bIsListItem) 2775 sChild = "li"; 2776 else if(apo.tmp.oElemValid.bIsSelect) 2777 sChild = "option"; 2778 2779 $(apo.elem).find(sChild).each(function() 2780 { 2781 $oChildElem = $(this); 2782 2783 var oSelectData = { 2784 2785 val: $oChildElem.attr("value") || $oChildElem.data("value") || $oChildElem.text(), 2786 label: $oChildElem.text(), 2787 selected: function() 2788 { 2789 if($oChildElem.attr("selected") || $oChildElem.attr("data-selected") !== undefined && $oChildElem.attr("data-selected") === "true") 2790 return true; 2791 else 2792 return false; 2793 }, 2794 disabled: function() 2795 { 2796 if($oChildElem.attr("disabled") || $oChildElem.data("disabled") !== undefined && $oChildElem.data("disabled") === "true") 2797 return true; 2798 else 2799 return false; 2800 } 2801 }; 2802 2803 if(oSelectData.disabled) 2804 { 2805 oSelectData.selected = false; 2806 } 2807 else if(oSelectData.selected) 2808 { 2809 apo.tmp.selected = { 2810 val: oSelectData.val, 2811 displayVal: oSelectData.displayVal 2812 }; 2813 } 2814 2815 oArrData.push(oSelectData); 2816 }); 2817 2818 apo.setting.dataSource = []; 2819 var oData = {}; 2820 oData.component = 1; 2821 oData.data = oArrData; 2822 apo.setting.dataSource.push(oData); 2823 2824 apo.tmp.numOfComp = 1; 2825 2826 if($.CF.compareStrings(apo.setting.headerTitle.contentBehaviour, "Dynamic") && $.CF.isValid(apo.setting.headerTitle.format)) 2827 { 2828 if(typeof apo.setting.headerTitle.format === "function") 2829 apo.tmp.sHeaderTitleType = "DynamicFunction"; 2830 else if(typeof apo.setting.headerTitle.format === "string") 2831 { 2832 apo.tmp.sHeaderTitleType = "DynamicString"; 2833 } 2834 } 2835 } 2836 else 2837 console.log("You will have to specify dataSource either as a JSON object or as <ul>, <ol>, <dl> or <select>"); 2838 } 2839 }, 2840 2841 __disableInvalidRowsOfSelect: function() 2842 { 2843 var apo = this; 2844 var iTempIndex1, bIsInvalidRow, 2845 oData = apo.setting.dataSource[0].data; 2846 2847 for(iTempIndex1 = 0; iTempIndex1 < oData.length; iTempIndex1++) 2848 { 2849 bIsInvalidRow = $.CF.isValid(oData[iTempIndex1].disabled); 2850 2851 if(bIsInvalidRow && oData[iTempIndex1].disabled === true) 2852 { 2853 $(apo.elem).find("#ap-row-0-" + iTempIndex1).addClass("ap-row-disabled"); 2854 } 2855 } 2856 } 2857 2858}); 2859 2860// --------------------------------- Functions : AnyPicker.Select End -------------------------------------- 2861 2862
vendor: 76,436 bytes, lines 2863-5573
2863 2864 2865// --------------------------------- Global Variables : AnyPicker.DateTime Start ----------------------------------- 2866 2867//"use strict"; 2868 2869$.AnyPicker = $.extend(true, $.AnyPicker, { 2870 2871 defaults: // Defaults Settings 2872 { 2873 2874 selectedDate: null, 2875 2876 i18n: 2877 { 2878 veryShortDays: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 2879 shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 2880 fullDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 2881 shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 2882 fullMonths: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], 2883 numbers: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], 2884 meridiem: 2885 { 2886 a: ["a", "p"], 2887 aa: ["am", "pm"], 2888 A: ["A", "P"], 2889 AA: ["AM", "PM"] 2890 }, 2891 2892 componentLabels: { 2893 date: "Date", 2894 day: "Day", 2895 month: "Month", 2896 year: "Year", 2897 hours: "Hours", 2898 minutes: "Minutes", 2899 seconds: "Seconds", 2900 meridiem: "Meridiem" 2901 } 2902 }, 2903 2904 inputDateTimeFormat: "", 2905 dateTimeFormat: "dd-MM-yyyy hh:mm AA", 2906 2907 tzOffset: "", 2908 2909 maxValue: null, 2910 minValue: null, 2911 maxYear: 0, 2912 disableValues: {}, 2913 2914 intervals: 2915 { 2916 h: 1, 2917 m: 1, 2918 s: 1 2919 }, 2920 roundOff: true 2921 2922 //------------------ Callback Functions Start -------------------------- 2923 2924 //------------------ Callback Functions End ---------------------------- 2925 }, 2926 2927 tempDefaults: // Plugin-level Variables required to maintain state across methods 2928 { 2929 oMinMax: {}, 2930 oArrPDisable: {}, 2931 sDateTimeMode: "", 2932 sArrDateTimeFormat: [], 2933 sDateTimeRegex: "", 2934 diffDateTimeFormats: false, 2935 sArrInputDateTimeFormat: [], 2936 sInputDateTimeRegex: "", 2937 sHeaderTitleType: "Static", 2938 sArrHeaderTitleFormat: [], 2939 dPrevDate: null 2940 }, 2941 2942 extra: // Common Temporary Variables 2943 { 2944 dToday: new Date(), 2945 2946 iMS: 2947 { 2948 m: 6E4, 2949 h: 36E5, 2950 d: 864E5, 2951 w: 6048E5 2952 }, 2953 2954 sFormatRegex: /(\[[^\[]*\])|(\\)?(MMMM|MMM|MM?|DDDD|DDD|DD|D|dd?|yyyy|YYYY|yy|YY|y|Y|aa?|AA?|hh?|HH?|mm?|ss?|x|X|zz?|ZZ?|.)/g, 2955 2956 en: 2957 { 2958 veryShortDays: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 2959 shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 2960 fullDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 2961 shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 2962 fullMonths: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], 2963 numbers: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], 2964 meridiem: 2965 { 2966 a: ["a", "p"], 2967 aa: ["am", "pm"], 2968 A: ["A", "P"], 2969 AA: ["PM", "PM"] 2970 } 2971 }, 2972 2973 sArrDateComponents: 2974 [ 2975 "d", "dd", "DD", "DDD", "DDDD", 2976 "M", "MM", "MMM", "MMMM", 2977 "y", "yy", "yyyy", "Y", "YY", "YYYY", 2978 "h", "hh", "H", "HH", 2979 "m", "mm", 2980 "s", "ss", 2981 "AA", "A", "aa", "a" 2982 ], 2983 2984 sArrDateTimeModes: 2985 [ 2986 "date", 2987 "time", 2988 "datetime" 2989 ] 2990 } 2991 2992}); 2993 2994// --------------------------------- Global Variables : AnyPicker.DateTime End -------------------------------------- 2995 2996// --------------------------------- Functions : AnyPicker.DateTime Start ------------------------------------ 2997 2998AnyPicker.prototype = $.extend(AnyPicker.prototype, { 2999 3000 _isSupportedFormat: function(sFormat) 3001 { 3002 var apo = this; 3003 return (sFormat.search($.AnyPicker.extra.sFormatRegex, "") !== -1); 3004 }, 3005 3006 /* 3007 3008 A function to set components data of picker for a particular datetime format. 3009 3010 */ 3011 __setComponentsOfDateTimePicker: function() 3012 { 3013 var apo = this; 3014 3015 var iTempIndex, sFormat; 3016 3017 apo.setting.components = []; 3018 apo.tmp.numOfComp = 0; 3019 apo.setting.dataSource = []; 3020 3021 var bHasDateComponent = (apo.setting.dateTimeFormat.search(/D|d|M|y|Y/, "") !== -1), 3022 bHasTimeComponent = (apo.setting.dateTimeFormat.search(/H|h|m|s|A|a/, "") !== -1); 3023 3024 apo.tmp.sDateTimeMode = (bHasDateComponent && bHasTimeComponent) ? "datetime" : (bHasDateComponent ? "date" : (bHasTimeComponent ? "time" : "")); 3025 3026 if($.CF.isValid(apo.setting.dateTimeFormat)) 3027 { 3028 if($.CF.isValid(apo.setting.inputDateTimeFormat)) 3029 { 3030 apo.tmp.diffDateTimeFormats = (apo.setting.dateTimeFormat !== apo.setting.inputDateTimeFormat); 3031 } 3032 else 3033 { 3034 apo.setting.inputDateTimeFormat = apo.setting.dateTimeFormat; 3035 apo.tmp.diffDateTimeFormats = false; 3036 } 3037 } 3038 else 3039 { 3040 console.log("Invalid DateTimeFormat"); 3041 } 3042 3043 apo.tmp.sArrDateTimeFormat = apo._setDateTimeFormatComponentsArray(apo.setting.dateTimeFormat); 3044 if(apo.tmp.diffDateTimeFormats) 3045 apo.tmp.sArrInputDateTimeFormat = apo._setDateTimeFormatComponentsArray(apo.setting.inputDateTimeFormat); 3046 3047 //----------------- Code to concatenate separators End ------------- 3048 3049 apo.tmp.sDateTimeRegex = apo._createDateTimeRegex(apo.tmp.sArrDateTimeFormat); 3050 if(apo.tmp.diffDateTimeFormats) 3051 apo.tmp.sInputDateTimeRegex = apo._createDateTimeRegex(apo.tmp.sArrInputDateTimeFormat); 3052 3053 apo.setSelectedDate(apo.setting.selectedDate); 3054 apo.parseDisableValues(); 3055 3056 var bMMMMddYYYY = apo.setting.dateTimeFormat.match(/(MMMM).*(dd|d).*(yyyy|YYYY)/); 3057 if(apo.tmp.sArrDateTimeFormat.length > 0) 3058 { 3059 for(iTempIndex = 0; iTempIndex < apo.tmp.sArrDateTimeFormat.length; iTempIndex++) 3060 { 3061 sFormat = apo.tmp.sArrDateTimeFormat[iTempIndex]; 3062 if(sFormat.search(/D|d|M|y|Y|H|h|m|s|A|a/, "g") !== -1) 3063 { 3064 apo._setComponentAndDataSourceForFormat(sFormat, {"MMMMddYYYY": bMMMMddYYYY}); 3065 } 3066 } 3067 } 3068 3069 if(!apo.tmp.headerTitleDefined && $.CF.compareStrings(apo.setting.mode, "datetime") && !$.CF.compareStrings(apo.setting.theme, "iOS")) 3070 { 3071 apo.setting.headerTitle.contentBehaviour = "Dynamic"; 3072 if(apo.tmp.sDateTimeMode === "datetime") 3073 { 3074 if(apo._formatContains(apo.tmp.sArrDateTimeFormat, ["d", "M", "y|Y", "h", "m"], "and") && apo._formatContains(apo.tmp.sArrDateTimeFormat, ["a", "A"], "or")) 3075 apo.setting.headerTitle.format = "dd.MM.yyyy, hh:mm " + apo._getFormatForComponent("meridiem"); 3076 else if(apo._formatContains(apo.tmp.sArrDateTimeFormat, ["d", "M", "y|Y", "H", "m"], "and")) 3077 apo.setting.headerTitle.format = "dd.MM.yyyy, HH:mm"; 3078 else 3079 apo.setting.headerTitle.format = apo.setting.dateTimeFormat; 3080 } 3081 else if(apo.tmp.sDateTimeMode === "date") 3082 { 3083 if(apo._formatContains(apo.tmp.sArrDateTimeFormat, ["d", "M", "y|Y"], "and")) 3084 apo.setting.headerTitle.format = "DDD, MMM dd, yyyy"; 3085 else 3086 apo.setting.headerTitle.format = apo.setting.dateTimeFormat; 3087 } 3088 else if(apo.tmp.sDateTimeMode === "time") 3089 { 3090 if(apo._formatContains(apo.tmp.sArrDateTimeFormat, ["h", "m"], "and") && apo._formatContains(apo.tmp.sArrDateTimeFormat, ["a", "A"], "or")) 3091 apo.setting.headerTitle.format = "hh:mm " + apo._getFormatForComponent("meridiem"); 3092 else if(apo._formatContains(apo.tmp.sArrDateTimeFormat, ["H", "m"], "and")) 3093 apo.setting.headerTitle.format = "HH:mm"; 3094 else 3095 apo.setting.headerTitle.format = apo.setting.dateTimeFormat; 3096 } 3097 } 3098 3099 if($.CF.compareStrings(apo.setting.headerTitle.contentBehaviour, "Dynamic") && $.CF.isValid(apo.setting.headerTitle.format)) 3100 { 3101 if(typeof apo.setting.headerTitle.format === "function") 3102 apo.tmp.sHeaderTitleType = "DynamicFunction"; 3103 else if(typeof apo.setting.headerTitle.format === "string") 3104 { 3105 apo.tmp.sHeaderTitleType = "DynamicString"; 3106 apo.tmp.sArrHeaderTitleFormat = apo._matchRegex($.AnyPicker.extra.sFormatRegex, apo.setting.headerTitle.format); 3107 } 3108 } 3109 }, 3110 3111 // Public Method 3112 setSelectedDate: function(oDate) 3113 { 3114 var apo = this; 3115 3116 if($.CF.isValid(oDate)) 3117 { 3118 if(typeof oDate === "string") 3119 { 3120 apo.tmp.selectedDate = apo._parseInputDateTime(oDate); 3121 } 3122 else if(Object.prototype.toString.call(oDate) === "[object Date]") 3123 { 3124 apo.setting.selectedDate = apo.formatOutputDates(oDate); 3125 apo.tmp.selectedDate = new Date(oDate); 3126 } 3127 3128 if(apo.setting.inputElement !== null) 3129 { 3130 var $oInput = $(apo.setting.inputElement); 3131 if(apo.tmp.oInputElemValid.bIsInput) 3132 { 3133 $oInput.val(apo.setting.selectedDate); 3134 } 3135 else 3136 { 3137 $oInput.text(apo.setting.selectedDate); 3138 } 3139 } 3140 } 3141 else 3142 { 3143 apo.tmp.selectedDate = new Date($.AnyPicker.extra.dToday); 3144 } 3145 }, 3146 3147 // Public Method 3148 setMinimumDate: function(oDate) 3149 { 3150 var apo = this; 3151 3152 apo.setting.minValue = oDate; 3153 apo.parseDisableValues(); 3154 }, 3155 3156 // Public Method 3157 setMaximumDate: function(oDate) 3158 { 3159 var apo = this; 3160 3161 apo.setting.maxValue = oDate; 3162 apo.parseDisableValues(); 3163 }, 3164 3165 _getFormatForComponent: function(sCompName) 3166 { 3167 var apo = this; 3168 for(var iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 3169 { 3170 var oComp = apo.setting.components[iTempIndex]; 3171 if(oComp.name === sCompName) 3172 return oComp.format; 3173 } 3174 }, 3175 3176 _formatContains: function(sArrFormat, sArrComp, bLogic) 3177 { 3178 var apo = this; 3179 var iTempIndex1, iTempIndex2, 3180 bArrComp = [], bContains; 3181 3182 for(iTempIndex1 = 0; iTempIndex1 < sArrComp.length; iTempIndex1++) 3183 { 3184 var sComp = sArrComp[iTempIndex1], 3185 bComp = false; 3186 for(iTempIndex2 = 0; iTempIndex2 < sArrFormat.length; iTempIndex2++) 3187 { 3188 var sFormat = sArrFormat[iTempIndex2]; 3189 if($.CF.isValid(sFormat) && $.CF.isValid(sComp)) 3190 { 3191 if(sFormat.search(new RegExp(sComp), "") !== -1) 3192 { 3193 bComp = true; 3194 break; 3195 } 3196 } 3197 } 3198 bArrComp.push(bComp); 3199 } 3200 3201 if(bLogic === "and") 3202 { 3203 bContains = true; 3204 for(iTempIndex1 = 0; iTempIndex1 < bArrComp.length; iTempIndex1++) 3205 { 3206 if(bArrComp[iTempIndex1] !== true) 3207 { 3208 bContains = false; 3209 break; 3210 } 3211 } 3212 } 3213 else if(bLogic === "or") 3214 { 3215 bContains = false; 3216 for(iTempIndex1 = 0; iTempIndex1 < bArrComp.length; iTempIndex1++) 3217 { 3218 if(bArrComp[iTempIndex1] === true) 3219 { 3220 bContains = true; 3221 break; 3222 } 3223 } 3224 } 3225 3226 return bContains; 3227 }, 3228 3229 _setComponentAndDataSourceForFormat: function(sCompFormat, sArrSpecial) 3230 { 3231 var apo = this; 3232 3233 var oComp = {}, oData = {}, 3234 bIsSupportedFormat = apo._isSupportedFormat(sCompFormat); 3235 3236 if(bIsSupportedFormat) 3237 { 3238 if(sCompFormat === "d" || sCompFormat === "dd") 3239 { 3240 oComp.name = "date"; 3241 oComp.label = apo.setting.i18n.componentLabels.date; 3242 oComp.type = "date"; 3243 3244 if($.CF.compareStrings(apo.setting.theme, "iOS")) 3245 { 3246 if(sArrSpecial.MMMMddYYYY) 3247 { 3248 oComp.width = "24%"; 3249 oComp.textAlign = "right"; 3250 } 3251 } 3252 } 3253 else if(sCompFormat === "DD" || sCompFormat === "DDD" || sCompFormat === "DDDD") 3254 { 3255 oComp.name = "day"; 3256 oComp.label = apo.setting.i18n.componentLabels.day; 3257 oComp.type = "date"; 3258 } 3259 else if(sCompFormat === "M" || sCompFormat === "MM" || sCompFormat === "MMM" || sCompFormat === "MMMM") 3260 { 3261 oComp.name = "month"; 3262 oComp.label = apo.setting.i18n.componentLabels.month; 3263 oComp.type = "date"; 3264 3265 if($.CF.compareStrings(apo.setting.theme, "iOS")) 3266 { 3267 if(sArrSpecial.MMMMddYYYY) 3268 { 3269 oComp.width = "46%"; 3270 oComp.textAlign = "left"; 3271 } 3272 } 3273 } 3274 else if(sCompFormat === "y" || sCompFormat === "Y" || sCompFormat === "yyyy" || sCompFormat === "Y" || sCompFormat === "YYYY") 3275 { 3276 oComp.name = "year"; 3277 oComp.label = apo.setting.i18n.componentLabels.year; 3278 oComp.type = "date"; 3279 3280 if($.CF.compareStrings(apo.setting.theme, "iOS")) 3281 { 3282 if(sArrSpecial.MMMMddYYYY) 3283 { 3284 oComp.width = "30%"; 3285 oComp.textAlign = "right"; 3286 } 3287 } 3288 } 3289 else if(sCompFormat === "H" || sCompFormat === "HH" || sCompFormat === "h" || sCompFormat === "hh") 3290 { 3291 oComp.name = "hours"; 3292 oComp.label = apo.setting.i18n.componentLabels.hours; 3293 oComp.type = "time"; 3294 } 3295 else if(sCompFormat === "m" || sCompFormat === "mm") 3296 { 3297 oComp.name = "minutes"; 3298 oComp.label = apo.setting.i18n.componentLabels.minutes; 3299 oComp.type = "time"; 3300 } 3301 else if(sCompFormat === "s" || sCompFormat === "ss") 3302 { 3303 oComp.name = "seconds"; 3304 oComp.label = apo.setting.i18n.componentLabels.seconds; 3305 oComp.type = "time"; 3306 } 3307 else if(sCompFormat === "aa" || sCompFormat === "a" || sCompFormat === "AA" || sCompFormat === "A") 3308 { 3309 oComp.name = "meridiem"; 3310 oComp.label = apo.setting.i18n.componentLabels.meridiem; 3311 oComp.type = "time"; 3312 } 3313 else 3314 console.log("Picker Component for " + sCompFormat + " can noot be added because the format you specified as " + sCompFormat + " cannot be parsed using this function. If you want to parse it, please add the condition in the _setComponentAndDataSourceForFormat function."); 3315 3316 oComp.format = sCompFormat; 3317 oComp.component = apo.tmp.numOfComp; 3318 apo.setting.components.push(oComp); 3319 3320 oData.component = oComp.component; 3321 oData.data = apo.__setDataSourceArrayForComponent(oComp.name, sCompFormat); 3322 apo.setting.dataSource.push(oData); 3323 3324 apo.tmp.numOfComp++; 3325 } 3326 }, 3327 3328 __setDataSourceArrayForComponent: function(sCompName, sCompFormat) 3329 { 3330 var apo = this; 3331 3332 var iChars, iTempIndex, 3333 iDaysOfMonth, iStartValue, iEndValue, 3334 iTotalYears, iStepYears, 3335 oArrData = [], 3336 oSelectedDate = apo.getDateObject(apo.tmp.selectedDate), 3337 oMin = null, oMax = null; 3338 3339 if($.CF.isValid(apo.tmp.oMinMax.min)) 3340 { 3341 oMin = apo.getDateObject(apo.tmp.oMinMax.min); 3342 } 3343 if($.CF.isValid(apo.tmp.oMinMax.max)) 3344 { 3345 oMax = apo.getDateObject(apo.tmp.oMinMax.max); 3346 } 3347 3348 if(sCompName === "day") 3349 { 3350 if(sCompFormat === "DD") 3351 { 3352 for(iTempIndex = 0; iTempIndex < $.AnyPicker.extra.en.veryShortDays.length; iTempIndex++) 3353 { 3354 oArrData.push( 3355 { 3356 val: iTempIndex, 3357 label: apo.setting.i18n.veryShortDays[iTempIndex] 3358 }); 3359 } 3360 } 3361 else if(sCompFormat === "DDD") 3362 { 3363 for(iTempIndex = 0; iTempIndex < $.AnyPicker.extra.en.shortDays.length; iTempIndex++) 3364 { 3365 oArrData.push( 3366 { 3367 val: iTempIndex, 3368 label: apo.setting.i18n.shortDays[iTempIndex] 3369 }); 3370 } 3371 } 3372 else if(sCompFormat === "DDDD") 3373 { 3374 for(iTempIndex = 0; iTempIndex < $.AnyPicker.extra.en.fullDays.length; iTempIndex++) 3375 { 3376 oArrData.push( 3377 { 3378 val: iTempIndex, 3379 label: apo.setting.i18n.fullDays[iTempIndex] 3380 }); 3381 } 3382 } 3383 } 3384 else if(sCompName === "date") 3385 { 3386 iDaysOfMonth = 31; 3387 3388 iStartValue = 1; 3389 iEndValue = iDaysOfMonth; 3390 if($.CF.isValid(oMin) && $.CF.isValid(oMax)) 3391 { 3392 if((oMin.y === oMax.y) && (oMin.M === oMax.M)) 3393 { 3394 iStartValue = oMin.d; 3395 iEndValue = oMax.d; 3396 } 3397 } 3398 3399 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex++) 3400 { 3401 if(sCompFormat === "d") 3402 iChars = 0; 3403 else if(sCompFormat === "dd") 3404 iChars = 2; 3405 3406 oArrData.push( 3407 { 3408 val: iTempIndex, 3409 label: apo.getNumberStringInFormat(iTempIndex, iChars, true) 3410 }); 3411 } 3412 } 3413 else if(sCompName === "month") 3414 { 3415 iStartValue = 1; 3416 iEndValue = 12; 3417 if($.CF.isValid(oMin) && $.CF.isValid(oMax)) 3418 { 3419 if(oMin.y === oMax.y) 3420 { 3421 iStartValue = oMin.M; 3422 iEndValue = oMax.M; 3423 3424 if(sCompFormat === "M" || sCompFormat === "MM") 3425 { 3426 iStartValue++; 3427 iEndValue++; 3428 } 3429 } 3430 } 3431 3432 if(sCompFormat === "M" || sCompFormat === "MM") 3433 { 3434 if(sCompFormat === "M") 3435 iChars = 0; 3436 else if(sCompFormat === "MM") 3437 iChars = 2; 3438 3439 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex++) 3440 { 3441 oArrData.push( 3442 { 3443 val: (iTempIndex - 1), 3444 label: apo.getNumberStringInFormat(iTempIndex, iChars, true) 3445 }); 3446 } 3447 } 3448 else if(sCompFormat === "MMM") 3449 { 3450 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex++) 3451 { 3452 oArrData.push( 3453 { 3454 val: (iTempIndex - 1), 3455 label: apo.setting.i18n.shortMonths[iTempIndex - 1] 3456 }); 3457 } 3458 } 3459 else if(sCompFormat === "MMMM") 3460 { 3461 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex++) 3462 { 3463 oArrData.push( 3464 { 3465 val: (iTempIndex - 1), 3466 label: apo.setting.i18n.fullMonths[iTempIndex - 1] 3467 }); 3468 } 3469 } 3470 } 3471 else if(sCompName === "year") 3472 { 3473 iTotalYears = (apo.setting.maxRows === 0) ? 50 : apo.setting.maxRows; 3474 iStepYears = Math.floor(iTotalYears / 2); 3475 3476 if($.CF.isValid(oMin)) 3477 iStartValue = oMin.y; 3478 else 3479 iStartValue = (iTotalYears % 2 === 0) ? (oSelectedDate.y - iStepYears - 1) : (oSelectedDate.y - iStepYears); 3480 3481 if($.CF.isValid(oMax)) 3482 iEndValue = oMax.y; 3483 else 3484 iEndValue = (oSelectedDate.y + iStepYears); 3485 3486 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex++) 3487 { 3488 oArrData.push( 3489 { 3490 val: iTempIndex, 3491 label: apo.getNumberStringInFormat(iTempIndex, 0, true) 3492 }); 3493 } 3494 } 3495 else if(sCompName === "hours") 3496 { 3497 var iArrHourValues = [], 3498 iStartHour = 0; 3499 3500 if(!apo.setting.roundOff) 3501 { 3502 iStartHour = oSelectedDate.H; 3503 while((iStartHour - apo.setting.intervals.h) >= 0) 3504 iStartHour -= apo.setting.intervals.h; 3505 } 3506 3507 if(sCompFormat === "h" || sCompFormat === "hh") 3508 { 3509 iArrHourValues = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; 3510 3511 iStartHour = iStartHour % 12; 3512 iStartHour = (iStartHour === 0) ? 12 : iStartHour; 3513 iStartValue = iArrHourValues.indexOf(iStartHour); 3514 iEndValue = 11; 3515 } 3516 else if(sCompFormat === "H" || sCompFormat === "HH") 3517 { 3518 iStartValue = iStartHour; 3519 iEndValue = 23; 3520 } 3521 3522 if(sCompFormat === "h" || sCompFormat === "H") 3523 iChars = 0; 3524 else if(sCompFormat === "hh" || sCompFormat === "HH") 3525 iChars = 2; 3526 3527 for(iTempIndex = iStartValue; iTempIndex <= iEndValue; iTempIndex = (iTempIndex + apo.setting.intervals.h)) 3528 { 3529 if(sCompFormat === "h" || sCompFormat === "hh") 3530 { 3531 oArrData.push( 3532 { 3533 val: iArrHourValues[iTempIndex], 3534 label: apo.getNumberStringInFormat(iArrHourValues[iTempIndex], iChars, true) 3535 }); 3536 } 3537 else if(sCompFormat === "H" || sCompFormat === "HH") 3538 { 3539 oArrData.push( 3540 { 3541 val: iTempIndex, 3542 label: apo.getNumberStringInFormat(iTempIndex, iChars, true) 3543 }); 3544 } 3545 } 3546 } 3547 else if(sCompName === "minutes") 3548 { 3549 var iStartMinute = 0; 3550 if(!apo.setting.roundOff) 3551 { 3552 iStartMinute = oSelectedDate.m; 3553 while((iStartMinute - apo.setting.intervals.m) >= 0) 3554 iStartMinute -= apo.setting.intervals.m; 3555 } 3556 3557 if(sCompFormat === "m") 3558 iChars = 0; 3559 else if(sCompFormat === "mm") 3560 iChars = 2; 3561 3562 for(iTempIndex = iStartMinute; iTempIndex < 60; iTempIndex = (iTempIndex + apo.setting.intervals.m)) 3563 { 3564 oArrData.push( 3565 { 3566 val: iTempIndex, 3567 label: apo.getNumberStringInFormat(iTempIndex, iChars, true) 3568 }); 3569 } 3570 } 3571 else if(sCompName === "seconds") 3572 { 3573 var iStartSeconds = 0; 3574 if(!apo.setting.roundOff) 3575 { 3576 iStartSeconds = oSelectedDate.s; 3577 while((iStartSeconds - apo.setting.intervals.s) >= 0) 3578 iStartSeconds -= apo.setting.intervals.s; 3579 } 3580 3581 if(sCompFormat === "s") 3582 iChars = 0; 3583 else if(sCompFormat === "ss") 3584 iChars = 2; 3585 3586 for(iTempIndex = iStartSeconds; iTempIndex < 60; iTempIndex = (iTempIndex + apo.setting.intervals.s)) 3587 { 3588 oArrData.push( 3589 { 3590 val: iTempIndex, 3591 label: apo.getNumberStringInFormat(iTempIndex, iChars, true) 3592 }); 3593 } 3594 } 3595 else if(sCompName === "meridiem") 3596 { 3597 for(iTempIndex = 0; iTempIndex < 2; iTempIndex++) 3598 { 3599 oArrData.push( 3600 { 3601 val: iTempIndex, 3602 label: apo.setting.i18n.meridiem[sCompFormat][iTempIndex] 3603 }); 3604 } 3605 } 3606 3607 return oArrData; 3608 }, 3609 3610 _setDateTimeFormatComponentsArray: function(sDateTimeFormat) 3611 { 3612 var apo = this; 3613 var sArrDateTimeFormat = apo._matchRegex($.AnyPicker.extra.sFormatRegex, sDateTimeFormat); 3614 3615 //----------------- Code to concatenate separators Start ------------------- 3616 var iTempIndex, sPrevFormat = "", sArrTempFormat = []; 3617 for(iTempIndex = 0; iTempIndex < sArrDateTimeFormat.length; iTempIndex++) 3618 { 3619 var sTempFormat = sArrDateTimeFormat[iTempIndex]; 3620 if(sTempFormat.match(/[a-zA-Z0-9]/)) 3621 { 3622 if(sPrevFormat !== "") 3623 { 3624 sArrTempFormat.push(sPrevFormat); 3625 sPrevFormat = ""; 3626 } 3627 sArrTempFormat.push(sTempFormat); 3628 } 3629 else 3630 sPrevFormat += sTempFormat; 3631 } 3632 if(sPrevFormat !== "") 3633 { 3634 sArrTempFormat.push(sPrevFormat); 3635 sPrevFormat = ""; 3636 } 3637 return sArrTempFormat; 3638 }, 3639 3640 _createDateTimeRegex: function(sArrDateTimeFormat) 3641 { 3642 var apo = this; 3643 var iTempIndex, sFormat, 3644 sInRegex = "", sOutRegex = "", 3645 sRegexStart = "(\\[[^\\[]*\\])|(\\\\)?", 3646 sRegexEnd = "|.", 3647 sDateTimeRegex; 3648 3649 sInRegex += sRegexStart; 3650 for(iTempIndex = 0; iTempIndex < sArrDateTimeFormat.length; iTempIndex++) 3651 { 3652 sFormat = sArrDateTimeFormat[iTempIndex]; 3653 sInRegex = apo._getRegexComponentForFormat(sInRegex, sFormat); 3654 } 3655 sInRegex += sRegexEnd; 3656 sDateTimeRegex = new RegExp(sInRegex, "g"); 3657 return sDateTimeRegex; 3658 }, 3659 3660 _getRegexComponentForFormat: function(sInRegex, sFormat) 3661 { 3662 var apo = this; 3663 3664 //removed code with \b, because it was causing RegExp matching to break while using Unicode Characters. as \b and \w enforce restriction on characters be a subset of [A-Z,a-z,0-9] 3665 3666 if(sFormat === "d" || sFormat === "dd") 3667 { 3668 sInRegex += "(\\d{1,2})"; 3669 } 3670 else if(sFormat === "DD") 3671 { 3672 /* 3673 sInRegex += "(\\b"; 3674 sInRegex += apo.setting.i18n.veryShortDays.join("\\b|\\b"); 3675 sInRegex += "\\b)"; 3676 */ 3677 sInRegex += "("; 3678 sInRegex += apo.setting.i18n.veryShortDays.join("|"); 3679 sInRegex += ")"; 3680 } 3681 else if(sFormat === "DDD") 3682 { 3683 sInRegex += "("; 3684 sInRegex += apo.setting.i18n.shortDays.join("|"); 3685 sInRegex += ")"; 3686 } 3687 else if(sFormat === "DDDD") 3688 { 3689 sInRegex += "("; 3690 sInRegex += apo.setting.i18n.fullDays.join("|"); 3691 sInRegex += ")"; 3692 } 3693 else if(sFormat === "M" || sFormat === "MM") 3694 { 3695 sInRegex += "(\\d{1,2})"; 3696 } 3697 else if(sFormat === "MMM") 3698 { 3699 sInRegex += "("; 3700 sInRegex += apo.setting.i18n.shortMonths.join("|"); 3701 sInRegex += ")"; 3702 } 3703 else if(sFormat === "MMMM") 3704 { 3705 /* 3706 sInRegex += "(\\b"; 3707 sInRegex += apo.setting.i18n.fullMonths.join("\\b|\\b"); 3708 sInRegex += "\\b)"; 3709 */ 3710 sInRegex += "("; 3711 sInRegex += apo.setting.i18n.fullMonths.join("|"); 3712 sInRegex += ")"; 3713 } 3714 else if($.CF.compareStrings(sFormat, "y") || $.CF.compareStrings(sFormat, "yyyy")) 3715 { 3716 sInRegex += "(\\d{1,4})"; 3717 } 3718 else if($.CF.compareStrings(sFormat, "yy")) 3719 { 3720 sInRegex += "(\\d{2})"; 3721 } 3722 else if($.CF.compareStrings(sFormat, "h") || $.CF.compareStrings(sFormat, "hh")) 3723 { 3724 sInRegex += "(\\d{1,2})"; 3725 } 3726 else if(sFormat === "m" || sFormat === "mm") 3727 { 3728 sInRegex += "(\\d{1,2})"; 3729 } 3730 else if(sFormat === "s" || sFormat === "ss") 3731 { 3732 sInRegex += "(\\d{1,2})"; 3733 } 3734 else if(sFormat === "a" || sFormat === "aa" || sFormat === "A" || sFormat === "AA") 3735 { 3736 sInRegex += "("; 3737 3738 if(sFormat === "a") 3739 sInRegex += apo.setting.i18n.meridiem.a.join("|"); 3740 else if(sFormat === "aa") 3741 sInRegex += apo.setting.i18n.meridiem.aa.join("|"); 3742 else if(sFormat === "A") 3743 sInRegex += apo.setting.i18n.meridiem.A.join("|"); 3744 else if(sFormat === "AA") 3745 sInRegex += apo.setting.i18n.meridiem.AA.join("|"); 3746 3747 sInRegex += ")"; 3748 } 3749 else if(sFormat === "/" || sFormat === "-" || sFormat === "." || sFormat === " " || sFormat === ":" || sFormat === ",") 3750 { 3751 //sInRegex += "(\\b" +sFormat + "\\b)"; 3752 sInRegex += "(/|-|.| |:|,)"; 3753 } 3754 else 3755 { 3756 //sInRegex += "(\\b" +sFormat + "\\b)"; 3757 sInRegex += "(" + sFormat + ")"; 3758 } 3759 3760 return sInRegex; 3761 }, 3762 3763 _matchRegex: function(sRegex, sString) 3764 { 3765 var apo = this; 3766 var sArrOut = [], sArrString = []; 3767 3768 while((sArrString = sRegex.exec(sString)) !== null) 3769 { 3770 for(var iTempIndex = 3; iTempIndex < sArrString.length; iTempIndex++) 3771 { 3772 sArrOut.push(sArrString[iTempIndex]); 3773 } 3774 if(sArrString.index === sRegex.lastIndex) 3775 { 3776 sRegex.lastIndex++; 3777 } 3778 } 3779 3780 return sArrOut; 3781 }, 3782 3783 _parseInputDateTime: function(sDate) 3784 { 3785 var apo = this; 3786 var oThisDate = null, oDate = {}, 3787 iTempIndex, sFormat, sDTComp, 3788 iArrDateTimeComps, sDateTimeRegex, iArrDateTimeFormatComps; 3789 3790 if(typeof sDate === "string") 3791 { 3792 iArrDateTimeFormatComps = apo.tmp.diffDateTimeFormats ? apo.tmp.sArrInputDateTimeFormat : apo.tmp.sArrDateTimeFormat; 3793 sDateTimeRegex = apo.tmp.diffDateTimeFormats ? apo.tmp.sInputDateTimeRegex : apo.tmp.sDateTimeRegex; 3794 iArrDateTimeComps = apo._matchRegex(sDateTimeRegex, sDate); 3795 3796 for(iTempIndex = 0; iTempIndex < iArrDateTimeFormatComps.length; iTempIndex++) 3797 { 3798 sFormat = iArrDateTimeFormatComps[iTempIndex]; 3799 sDTComp = iArrDateTimeComps[iTempIndex]; 3800 3801 if(sFormat.search(/D|d|M|y|Y|H|h|m|s|A|a/, "") !== -1) 3802 oDate = apo._setInputDateTimeValue(sFormat, sDTComp, oDate); 3803 } 3804 3805 if($.CF.isValid(oDate.h)) 3806 { 3807 if(($.CF.compareStrings(oDate.me, "AM") || $.CF.compareStrings(oDate.sm, "A")) && oDate.h === 12) 3808 oDate.H = 0; 3809 else if(($.CF.compareStrings(oDate.me, "PM") || $.CF.compareStrings(oDate.sm, "P")) && oDate.h < 12) 3810 oDate.H = oDate.h + 12; 3811 else 3812 oDate.H = oDate.h; 3813 } 3814 3815 oThisDate = apo.setDateInFormat({"iDate": oDate}, ""); 3816 } 3817 else if(Object.prototype.toString.call(sDate) === "[object Date]") 3818 { 3819 oThisDate = new Date(sDate); 3820 } 3821 3822 return oThisDate; 3823 }, 3824 3825 _setInputDateTimeValue: function(sDateTimeFormat, sDateTimeValue, oThisDate) 3826 { 3827 var apo = this; 3828 3829 if(apo._isSupportedFormat(sDateTimeFormat)) 3830 { 3831 if(sDateTimeFormat === "d" || sDateTimeFormat === "dd") 3832 { 3833 oThisDate.d = parseInt(sDateTimeValue); 3834 } 3835 else if(sDateTimeFormat === "M" || sDateTimeFormat === "MM") 3836 { 3837 oThisDate.M = parseInt(sDateTimeValue) - 1; 3838 } 3839 else if(sDateTimeFormat === "MMM") 3840 { 3841 oThisDate.M = apo.setting.i18n.shortMonths.indexOf(sDateTimeValue); 3842 } 3843 else if(sDateTimeFormat === "MMMM") 3844 { 3845 oThisDate.M = apo.setting.i18n.fullMonths.indexOf(sDateTimeValue); 3846 } 3847 else if($.CF.compareStrings(sDateTimeFormat, "yy")) 3848 { 3849 oThisDate.y = parseInt(sDateTimeValue); 3850 3851 var iMaxPrefix = (apo.setting.maxYear / 100), // first two digits of the year 3852 iMaxSuffix = (apo.setting.maxYear % 100); // last two digits of the year 3853 3854 if(oThisDate.y > iMaxSuffix) 3855 oThisDate.y = ((iMaxPrefix - 1) * 100) + oThisDate.y; 3856 else 3857 oThisDate.y = (iMaxPrefix * 100) + oThisDate.y; 3858 } 3859 else if($.CF.compareStrings(sDateTimeFormat, "y") || $.CF.compareStrings(sDateTimeFormat, "yyyy")) 3860 { 3861 oThisDate.y = parseInt(sDateTimeValue); 3862 } 3863 else if(sDateTimeFormat === "H" || sDateTimeFormat === "HH") 3864 { 3865 oThisDate.H = parseInt(sDateTimeValue); 3866 } 3867 else if(sDateTimeFormat === "h" || sDateTimeFormat === "hh") 3868 { 3869 oThisDate.h = parseInt(sDateTimeValue); 3870 } 3871 else if(sDateTimeFormat === "m" || sDateTimeFormat === "mm") 3872 { 3873 oThisDate.m = parseInt(sDateTimeValue); 3874 } 3875 else if(sDateTimeFormat === "s" || sDateTimeFormat === "ss") 3876 { 3877 oThisDate.s = parseInt(sDateTimeValue); 3878 } 3879 else if(sDateTimeFormat === "a" || sDateTimeFormat === "A") 3880 { 3881 if($.CF.isValid(sDateTimeValue)) 3882 { 3883 if(sDateTimeValue.search(/A/gi, "") !== -1) 3884 oThisDate.me = "A"; 3885 else if(sDateTimeValue.search(/P/gi, "") !== -1) 3886 oThisDate.me = "P"; 3887 } 3888 } 3889 else if(sDateTimeFormat === "aa" || sDateTimeFormat === "AA") 3890 { 3891 if($.CF.isValid(sDateTimeValue)) 3892 { 3893 if(sDateTimeValue.search(/AM/gi, "") !== -1) 3894 oThisDate.me = "AM"; 3895 else if(sDateTimeValue.search(/PM/gi, "") !== -1) 3896 oThisDate.me = "PM"; 3897 } 3898 } 3899 } 3900 3901 return oThisDate; 3902 }, 3903 3904 // Public Method 3905 formatOutputDates: function(dDate, oFormat) 3906 { 3907 var apo = this; 3908 var sOutput = "", sFormat, iTempIndex, 3909 sArrFormat, oDate; 3910 3911 if($.CF.isValid(oFormat)) 3912 { 3913 if(typeof oFormat === "string") 3914 sArrFormat = apo._setDateTimeFormatComponentsArray(oFormat); 3915 else if(typeof oFormat === "object") 3916 sArrFormat = oFormat; 3917 else 3918 sArrFormat = (apo.tmp.diffDateTimeFormats ? apo.tmp.sArrInputDateTimeFormat : apo.tmp.sArrDateTimeFormat); 3919 } 3920 else 3921 sArrFormat = (apo.tmp.diffDateTimeFormats ? apo.tmp.sArrInputDateTimeFormat : apo.tmp.sArrDateTimeFormat); 3922 3923 oDate = apo.getDateObject(dDate); 3924 3925 for(iTempIndex = 0; iTempIndex < sArrFormat.length; iTempIndex++) 3926 { 3927 sFormat = sArrFormat[iTempIndex]; 3928 3929 if(sFormat === "dd") 3930 { 3931 sOutput += apo.getNumberStringInFormat(oDate.d, 2, true); 3932 } 3933 else if(sFormat === "d") 3934 { 3935 sOutput += apo.getNumberStringInFormat(oDate.d, 0, true); 3936 } 3937 else if(sFormat === "DDDD") 3938 { 3939 sOutput += apo.setting.i18n.fullDays[oDate.D]; 3940 } 3941 else if(sFormat === "DDD") 3942 { 3943 sOutput += apo.setting.i18n.shortDays[oDate.D]; 3944 } 3945 else if(sFormat === "DD") 3946 { 3947 sOutput += apo.setting.i18n.veryShortDays[oDate.D]; 3948 } 3949 else if(sFormat === "MMMM") 3950 { 3951 sOutput += apo.setting.i18n.fullMonths[oDate.M]; 3952 } 3953 else if(sFormat === "MMM") 3954 { 3955 sOutput += apo.setting.i18n.shortMonths[oDate.M]; 3956 } 3957 else if(sFormat === "MM") 3958 { 3959 sOutput += apo.getNumberStringInFormat((oDate.M + 1), 2, true); 3960 } 3961 else if(sFormat === "M") 3962 { 3963 sOutput += apo.getNumberStringInFormat((oDate.M + 1), 0, true); 3964 } 3965 else if($.CF.compareStrings(sFormat, "yyyy")) 3966 { 3967 sOutput += apo.getNumberStringInFormat(oDate.y, 4, true); 3968 } 3969 else if($.CF.compareStrings(sFormat, "yy")) 3970 { 3971 var iYear = ((Math.floor(oDate.y / 10) % 10) * 10) + (oDate.y % 10); 3972 sOutput += apo.getNumberStringInFormat(iYear, 2, true); 3973 } 3974 else if($.CF.compareStrings(sFormat, "y")) 3975 { 3976 sOutput += apo.getNumberStringInFormat(oDate.y, 4, true); 3977 } 3978 else if(sFormat === "hh") 3979 { 3980 sOutput += apo.getNumberStringInFormat(oDate.h, 2, true); 3981 } 3982 else if(sFormat === "h") 3983 { 3984 sOutput += apo.getNumberStringInFormat(oDate.h, 0, true); 3985 } 3986 else if(sFormat === "HH") 3987 { 3988 sOutput += apo.getNumberStringInFormat(oDate.H, 2, true); 3989 } 3990 else if(sFormat === "H") 3991 { 3992 sOutput += apo.getNumberStringInFormat(oDate.H, 0, true); 3993 } 3994 else if(sFormat === "mm") 3995 { 3996 sOutput += apo.getNumberStringInFormat(oDate.m, 2, true); 3997 } 3998 else if(sFormat === "m") 3999 { 4000 sOutput += apo.getNumberStringInFormat(oDate.m, 0, true); 4001 } 4002 else if(sFormat === "ss") 4003 { 4004 sOutput += apo.getNumberStringInFormat(oDate.s, 2, true); 4005 } 4006 else if(sFormat === "s") 4007 { 4008 sOutput += apo.getNumberStringInFormat(oDate.s, 0, true); 4009 } 4010 else if(sFormat === "aa") 4011 { 4012 sOutput += oDate.me; 4013 } 4014 else if(sFormat === "a") 4015 { 4016 sOutput += oDate.sm; 4017 } 4018 else if(sFormat === "AA") 4019 { 4020 sOutput += oDate.me.toUpperCase(); 4021 } 4022 else if(sFormat === "A") 4023 { 4024 sOutput += oDate.sm.toUpperCase(); 4025 } 4026 else 4027 { 4028 sOutput += sFormat; 4029 } 4030 } 4031 4032 return sOutput; 4033 }, 4034 4035 // Public Method 4036 parseDisableValues: function() 4037 { 4038 var apo = this; 4039 apo.tmp.oMinMax = 4040 { 4041 min: null, 4042 max: null 4043 }; 4044 apo.tmp.oArrPDisable = 4045 { 4046 day: [], 4047 date: [], 4048 time: [], 4049 datetime: [] 4050 }; 4051 var iTempIndex, iTempIndex1, iTempIndex2; 4052 4053 if($.CF.isValid(apo.setting.minValue)) 4054 { 4055 var dMin = apo._parseInputDateTime(apo.setting.minValue); 4056 if($.CF.isValid(dMin)) 4057 apo.tmp.oMinMax.min = dMin; 4058 } 4059 if($.CF.isValid(apo.setting.maxValue)) 4060 { 4061 var dMax = apo._parseInputDateTime(apo.setting.maxValue); 4062 if($.CF.isValid(dMax)) 4063 apo.tmp.oMinMax.max = dMax; 4064 } 4065 4066 4067 var bIsOutOfBounds = false; 4068 if($.CF.isValid(apo.tmp.oMinMax.min) && $.CF.isValid(apo.tmp.oMinMax.max)) 4069 { 4070 if(apo.tmp.sDateTimeMode === "date") 4071 { 4072 if(!(apo.compareDates(apo.tmp.selectedDate, apo.tmp.oMinMax.min) >= 1 && apo.compareDates(apo.tmp.selectedDate, apo.tmp.oMinMax.max) <= -1)) 4073 bIsOutOfBounds = true; 4074 } 4075 else if(apo.tmp.sDateTimeMode === "time") 4076 { 4077 if(!(apo.compareTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.min) >= 1 && apo.compareTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.max) <= -1)) 4078 bIsOutOfBounds = true; 4079 } 4080 else if(apo.tmp.sDateTimeMode === "datetime") 4081 { 4082 if(!(apo.compareDateTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.min) >= 1 && apo.compareDateTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.max) <= -1)) 4083 bIsOutOfBounds = true; 4084 } 4085 4086 if(bIsOutOfBounds) 4087 { 4088 apo.setting.selectedDate = new Date(apo.tmp.oMinMax.min); 4089 apo.tmp.selectedDate = new Date(apo.tmp.oMinMax.min); 4090 } 4091 } 4092 else if($.CF.isValid(apo.tmp.oMinMax.min)) 4093 { 4094 if(apo.tmp.sDateTimeMode === "date") 4095 { 4096 if(apo.compareDates(apo.tmp.selectedDate, apo.tmp.oMinMax.min) < -1) 4097 bIsOutOfBounds = true; 4098 } 4099 else if(apo.tmp.sDateTimeMode === "time") 4100 { 4101 if(apo.compareTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.min) < -1) 4102 bIsOutOfBounds = true; 4103 } 4104 else if(apo.tmp.sDateTimeMode === "datetime") 4105 { 4106 if(apo.compareDateTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.min) < -1) 4107 bIsOutOfBounds = true; 4108 } 4109 4110 if(bIsOutOfBounds) 4111 { 4112 apo.setting.selectedDate = new Date(apo.tmp.oMinMax.min); 4113 apo.tmp.selectedDate = new Date(apo.tmp.oMinMax.min); 4114 } 4115 } 4116 else if($.CF.isValid(apo.tmp.oMinMax.max)) 4117 { 4118 if(apo.tmp.sDateTimeMode === "date") 4119 { 4120 if(apo.compareDates(apo.tmp.selectedDate, apo.tmp.oMinMax.max) > 1) 4121 bIsOutOfBounds = true; 4122 } 4123 else if(apo.tmp.sDateTimeMode === "time") 4124 { 4125 if(apo.compareTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.max) > 1) 4126 bIsOutOfBounds = true; 4127 } 4128 else if(apo.tmp.sDateTimeMode === "datetime") 4129 { 4130 if(apo.compareDateTimes(apo.tmp.selectedDate, apo.tmp.oMinMax.max) > 1) 4131 bIsOutOfBounds = true; 4132 } 4133 4134 if(bIsOutOfBounds) 4135 { 4136 apo.setting.selectedDate = new Date(apo.tmp.oMinMax.max); 4137 apo.tmp.selectedDate = new Date(apo.tmp.oMinMax.max); 4138 } 4139 } 4140 4141 if(apo.tmp.sDateTimeMode === "date") 4142 apo.tmp.oArrPDisable.date.push(apo.tmp.oMinMax); 4143 else if(apo.tmp.sDateTimeMode === "time") 4144 apo.tmp.oArrPDisable.time.push({day: [], val: [apo.tmp.oMinMax]}); 4145 else if(apo.tmp.sDateTimeMode === "datetime") 4146 apo.tmp.oArrPDisable.datetime.push(apo.tmp.oMinMax); 4147 4148 if($.CF.isValid(apo.setting.disableValues)) 4149 { 4150 // Parse Days 4151 if($.CF.isValid(apo.setting.disableValues.day) && apo.setting.disableValues.day.length > 0) 4152 { 4153 for(iTempIndex = 0; iTempIndex < apo.setting.disableValues.day.length; iTempIndex++) 4154 { 4155 if(apo.setting.disableValues.day[iTempIndex] >= 0 && apo.setting.disableValues.day[iTempIndex] <= 6) 4156 { 4157 apo.tmp.oArrPDisable.day.push(apo.setting.disableValues.day[iTempIndex]); 4158 } 4159 } 4160 } 4161 4162 // Parse Dates 4163 if($.CF.isValid(apo.setting.disableValues.date) && apo.setting.disableValues.date.length > 0) 4164 { 4165 for(iTempIndex = 0; iTempIndex < apo.setting.disableValues.date.length; iTempIndex++) 4166 { 4167 var oDate = apo.setting.disableValues.date[iTempIndex], 4168 oOutDate = null; 4169 4170 if($.CF.isValid(oDate.val)) 4171 { 4172 var oDateVal = apo._parseInputDateTime(oDate.val); 4173 if($.CF.isValid(oDateVal)) 4174 { 4175 if(oOutDate === null) 4176 oOutDate = {}; 4177 oOutDate.val = oDateVal; 4178 } 4179 } 4180 if($.CF.isValid(oDate.start)) 4181 { 4182 var oDateStart = apo._parseInputDateTime(oDate.start); 4183 if($.CF.isValid(oDateStart)) 4184 { 4185 if(oOutDate === null) 4186 oOutDate = {}; 4187 oOutDate.start = oDateStart; 4188 } 4189 } 4190 if($.CF.isValid(oDate.end)) 4191 { 4192 var oDateEnd = apo._parseInputDateTime(oDate.end); 4193 if($.CF.isValid(oDateEnd)) 4194 { 4195 if(oOutDate === null) 4196 oOutDate = {}; 4197 oOutDate.end = oDateEnd; 4198 } 4199 } 4200 4201 if($.CF.isValid(oOutDate)) 4202 apo.tmp.oArrPDisable.date.push(oOutDate); 4203 } 4204 } 4205 4206 // Parse Times 4207 if($.CF.isValid(apo.setting.disableValues.time) && apo.setting.disableValues.time.length > 0) 4208 { 4209 for(iTempIndex1 = 0; iTempIndex1 < apo.setting.disableValues.time.length; iTempIndex1++) 4210 { 4211 var oDayTime = apo.setting.disableValues.time[iTempIndex1], 4212 bIsValidDay = $.CF.isValid(oDayTime.day) && (oDayTime.day.length > 0), 4213 bIsValidVal = $.CF.isValid(oDayTime.val) && (oDayTime.val.length > 0); 4214 4215 if(bIsValidVal) 4216 { 4217 var oArrTimes = []; 4218 for(iTempIndex2 = 0; iTempIndex2 < oDayTime.val.length; iTempIndex2++) 4219 { 4220 var oTime = oDayTime.val[iTempIndex2], 4221 oOutTime = null; 4222 4223 if($.CF.isValid(oTime.val)) 4224 { 4225 var oTimeVal = apo._parseInputDateTime(oTime.val); 4226 if($.CF.isValid(oTimeVal)) 4227 { 4228 if(oOutTime === null) 4229 oOutTime = {}; 4230 oOutTime.val = oTime; 4231 } 4232 } 4233 if($.CF.isValid(oTime.start)) 4234 { 4235 var oTimeStart = apo._parseInputDateTime(oTime.start); 4236 if($.CF.isValid(oTimeStart)) 4237 { 4238 if(oOutTime === null) 4239 oOutTime = {}; 4240 oOutTime.start = oTimeStart; 4241 } 4242 } 4243 if($.CF.isValid(oTime.end)) 4244 { 4245 var oTimeEnd = apo._parseInputDateTime(oTime.end); 4246 if($.CF.isValid(oTimeEnd)) 4247 { 4248 if(oOutTime === null) 4249 oOutTime = {}; 4250 oOutTime.end = oTimeEnd; 4251 } 4252 } 4253 4254 if($.CF.isValid(oOutTime)) 4255 oArrTimes.push(oOutTime); 4256 } 4257 4258 if(oArrTimes.length > 0) 4259 { 4260 apo.tmp.oArrPDisable.time.push( 4261 { 4262 day: (bIsValidDay ? oDayTime.day : []), 4263 val: oArrTimes 4264 }); 4265 } 4266 } 4267 } 4268 } 4269 4270 // Parse DateTimes 4271 if($.CF.isValid(apo.setting.disableValues.datetime) && apo.setting.disableValues.datetime.length > 0) 4272 { 4273 for(iTempIndex1 = 0; iTempIndex1 < apo.setting.disableValues.datetime.length; iTempIndex1++) 4274 { 4275 var oDateTime = apo.setting.disableValues.datetime[iTempIndex1], 4276 oOutDateTime = null; 4277 4278 if($.CF.isValid(oDateTime.val)) 4279 { 4280 var oDateTimeVal = apo._parseInputDateTime(oDateTime.val); 4281 if($.CF.isValid(oDateTimeVal)) 4282 { 4283 if(oOutDateTime === null) 4284 oOutDateTime = {}; 4285 oOutDateTime.val = oDateTimeVal; 4286 } 4287 } 4288 if($.CF.isValid(oDateTime.start)) 4289 { 4290 var oDateTimeStart = apo._parseInputDateTime(oDateTime.start); 4291 if($.CF.isValid(oDateTimeStart)) 4292 { 4293 if(oOutDateTime === null) 4294 oOutDateTime = {}; 4295 oOutDateTime.start = oDateTimeStart; 4296 } 4297 } 4298 if($.CF.isValid(oDateTime.end)) 4299 { 4300 var oDateTimeEnd = apo._parseInputDateTime(oDateTime.end); 4301 if($.CF.isValid(oDateTimeEnd)) 4302 { 4303 if(oOutDateTime === null) 4304 oOutDateTime = {}; 4305 oOutDateTime.end = oDateTimeEnd; 4306 } 4307 } 4308 4309 if($.CF.isValid(oOutDateTime)) 4310 apo.tmp.oArrPDisable.datetime.push(oOutDateTime); 4311 } 4312 } 4313 } 4314 else 4315 console.log("Invalid value for AnyPicker plugin option disableValues"); 4316 }, 4317 4318 __setSelectedDateTimeInComponent: function() 4319 { 4320 var apo = this; 4321 var iTempIndex, oComp, sValue = "", iChars, 4322 oSelectedDate = apo.getDateObject(apo.tmp.selectedDate); 4323 4324 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 4325 { 4326 oComp = apo.setting.components[iTempIndex]; 4327 4328 if(oComp.name === "date") 4329 { 4330 sValue = oSelectedDate.d; 4331 } 4332 else if(oComp.name === "day") 4333 { 4334 sValue = oSelectedDate.D; 4335 } 4336 else if(oComp.name === "month") 4337 { 4338 sValue = oSelectedDate.M; 4339 } 4340 else if(oComp.name === "year") 4341 { 4342 sValue = oSelectedDate.y; 4343 } 4344 else if(oComp.name === "hours") 4345 { 4346 if(oComp.format === "h" || oComp.format === "hh") 4347 sValue = oSelectedDate.h; 4348 else if(oComp.format === "H" || oComp.format === "HH") 4349 sValue = oSelectedDate.H; 4350 } 4351 else if(oComp.name === "minutes") 4352 { 4353 sValue = oSelectedDate.m; 4354 } 4355 else if(oComp.name === "seconds") 4356 { 4357 sValue = oSelectedDate.s; 4358 } 4359 else if(oComp.name === "meridiem") 4360 { 4361 if(oSelectedDate.sm === "a") 4362 sValue = 0; 4363 else if(oSelectedDate.sm === "p") 4364 sValue = 1; 4365 } 4366 4367 apo.__changeComponentValue(iTempIndex, sValue); 4368 } 4369 }, 4370 4371 __disableInvalidRowsOfDateTimePicker: function() 4372 { 4373 var apo = this; 4374 var iTempIndex1, iTempIndex2, iTempIndex3, iTempIndex4, 4375 oArrValues = [], sValue, oArrSelectedValues, 4376 oComp, sCompName, sCompFormat, oData; 4377 4378 if(apo.tmp.numOfComp === 1) 4379 { 4380 oComp = apo.setting.components[0]; 4381 sCompName = oComp.name; 4382 sCompFormat = oComp.format; 4383 oData = apo.setting.dataSource[0].data; 4384 4385 if(sCompName === "day") 4386 { 4387 for(iTempIndex1 = 0; iTempIndex1 < oData.length; iTempIndex1++) 4388 { 4389 for(iTempIndex2 = 0; iTempIndex2 < apo.tmp.oArrPDisable.day.length; iTempIndex2++) 4390 { 4391 if(apo.tmp.oArrPDisable.day[iTempIndex2] === oData[iTempIndex2].val) 4392 { 4393 $(apo.elem).find("#ap-row-0-" + iTempIndex1).addClass("ap-row-disabled ap-row-invalid"); 4394 } 4395 } 4396 } 4397 } 4398 } 4399 else 4400 { 4401 oArrSelectedValues = apo.__getSelectedDate(true)[1]; 4402 4403 for(iTempIndex1 = 0; iTempIndex1 < apo.setting.dataSource.length; iTempIndex1++) // change values of one component (dataSource) 4404 { 4405 var oData1 = apo.setting.dataSource[iTempIndex1]; 4406 4407 for(iTempIndex2 = 0; iTempIndex2 < oData1.data.length; iTempIndex2++) // dataSource.data values 4408 { 4409 var oDateToValidate = { 4410 d: 1, 4411 M: 0, 4412 y: 0, 4413 H: 0, 4414 h: 0, 4415 m: 0, 4416 s: 0, 4417 sm: 0 4418 }; 4419 4420 for(iTempIndex3 = 0; iTempIndex3 < apo.tmp.numOfComp; iTempIndex3++) // set selected values 4421 { 4422 if(iTempIndex3 === iTempIndex1) 4423 { 4424 sValue = oData1.data[iTempIndex2].val; 4425 4426 oComp = apo.setting.components[iTempIndex3]; 4427 sCompName = oComp.name; 4428 sCompFormat = oComp.format; 4429 } 4430 else 4431 { 4432 sValue = oArrSelectedValues[iTempIndex3]; 4433 4434 oComp = apo.setting.components[iTempIndex3]; 4435 sCompName = oComp.name; 4436 sCompFormat = oComp.format; 4437 } 4438 4439 if(sCompName === "date") 4440 { 4441 oDateToValidate.d = parseInt(sValue); 4442 } 4443 else if(sCompName === "month") 4444 { 4445 oDateToValidate.M = parseInt(sValue); // parseInt(sValue) - 1 4446 } 4447 else if(sCompName === "year") 4448 { 4449 oDateToValidate.y = parseInt(sValue); 4450 } 4451 else if(sCompName === "hours") 4452 { 4453 if(sCompFormat === "h" || sCompFormat === "hh") 4454 { 4455 oDateToValidate.h = parseInt(sValue); 4456 oDateToValidate.H = -1; 4457 } 4458 else if(sCompFormat === "H" || sCompFormat === "HH") 4459 { 4460 oDateToValidate.H = parseInt(sValue); 4461 } 4462 } 4463 else if(sCompName === "minutes") 4464 { 4465 oDateToValidate.m = parseInt(sValue); 4466 } 4467 else if(sCompName === "seconds") 4468 { 4469 oDateToValidate.s = parseInt(sValue); 4470 } 4471 else if(sCompName === "meridiem") 4472 { 4473 oDateToValidate.sm = parseInt(sValue); 4474 } 4475 } 4476 4477 if(oDateToValidate.H === -1) 4478 { 4479 oDateToValidate.H = (oDateToValidate.sm === 1) ? ((oDateToValidate.h === 12) ? 12 : (oDateToValidate.h + 12)) : ((oDateToValidate.h === 12) ? 0 : oDateToValidate.h); 4480 } 4481 4482 var dNewSelectedDate = apo.setDateInFormat({"iDate": oDateToValidate}, ""); 4483 var bValidDate = apo.__validateSelectedDate(dNewSelectedDate, true, false); 4484 if(!bValidDate) 4485 { 4486 $("#ap-component-" + iTempIndex1).find("#ap-row-" + iTempIndex1 + "-" + iTempIndex2).addClass("ap-row-disabled ap-row-invalid"); 4487 } 4488 } 4489 } 4490 } 4491 }, 4492 4493 __getSelectedDate: function(bGetObject) 4494 { 4495 var apo = this; 4496 4497 var iTempIndex, oComp, oArrSelected, oElemSelected, iValue, 4498 oNewSelectedDate = apo.getDateObject(apo.tmp.selectedDate), 4499 dNewSelectedDate = {}, iMeridiem = 0, oArrSelectedValues = []; 4500 4501 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 4502 { 4503 oComp = apo.setting.components[iTempIndex]; 4504 oArrSelected = $(apo.tmp.overlaySelector).find("#ap-component-" + iTempIndex + " .ap-row-selected"); 4505 oElemSelected = (oArrSelected.length > 0) ? oArrSelected[0] : null; 4506 4507 iValue = parseInt($(oElemSelected).data('value')); 4508 oArrSelectedValues.push(iValue); 4509 if(oComp.name === "date") 4510 { 4511 oNewSelectedDate.d = isNaN(iValue) ? oNewSelectedDate.d : iValue; 4512 } 4513 else if(oComp.name === "day") 4514 { 4515 oNewSelectedDate.D = isNaN(iValue) ? oNewSelectedDate.D : iValue; 4516 } 4517 else if(oComp.name === "month") 4518 { 4519 oNewSelectedDate.M = isNaN(iValue) ? oNewSelectedDate.M : iValue; 4520 } 4521 else if(oComp.name === "year") 4522 { 4523 oNewSelectedDate.y = isNaN(iValue) ? oNewSelectedDate.y : iValue; 4524 } 4525 else if(oComp.name === "hours") 4526 { 4527 if(oComp.format === "h" || oComp.format === "hh") 4528 { 4529 oNewSelectedDate.h = isNaN(iValue) ? oNewSelectedDate.h : iValue; 4530 oNewSelectedDate.H = -1; 4531 } 4532 else 4533 oNewSelectedDate.H = isNaN(iValue) ? oNewSelectedDate.H : iValue; 4534 } 4535 else if(oComp.name === "minutes") 4536 { 4537 oNewSelectedDate.m = isNaN(iValue) ? oNewSelectedDate.m : iValue; 4538 } 4539 else if(oComp.name === "seconds") 4540 { 4541 oNewSelectedDate.s = isNaN(iValue) ? oNewSelectedDate.s : iValue; 4542 } 4543 else if(oComp.name === "meridiem") 4544 { 4545 iMeridiem = isNaN(iValue) ? (oNewSelectedDate.sm === "a" ? 0 : 1) : iValue; 4546 } 4547 } 4548 4549 if(oNewSelectedDate.H === -1) 4550 { 4551 oNewSelectedDate.H = (iMeridiem === 1) ? ((oNewSelectedDate.h === 12) ? 12 : (oNewSelectedDate.h + 12)) : ((oNewSelectedDate.h === 12) ? 0 : oNewSelectedDate.h); 4552 } 4553 4554 var iNoOfDays = apo._getNumberOfDaysOfMonth(oNewSelectedDate.M, oNewSelectedDate.y); 4555 if(oNewSelectedDate.d > iNoOfDays) 4556 oNewSelectedDate.d = iNoOfDays; 4557 4558 dNewSelectedDate = apo.setDateInFormat({"iDate": oNewSelectedDate}, ""); 4559 if(bGetObject) 4560 return [dNewSelectedDate, oArrSelectedValues]; 4561 else 4562 return dNewSelectedDate; 4563 }, 4564 4565 /* 4566 4567 1. Get New selectedDate based on the selected values in the Picker Components. 4568 2. Check whether new selectedDate is equal to or is in the range of disable date/time/datetimes 4569 3. If selectedDate matches disableDates then select previous value of selectedDate 4570 4571 */ 4572 __validateSelectedDate: function(dNewSelectedDate, bReturnResult, bIsBefore) 4573 { 4574 var apo = this; 4575 4576 var oNewSelectedDate = apo.getDateObject(dNewSelectedDate); 4577 4578 if($.CF.isValid(apo.tmp.oArrPDisable)) 4579 { 4580 var iTempIndex1, iTempIndex2, 4581 bHasDateComponent = (apo.tmp.sDateTimeMode === "datetime" || apo.tmp.sDateTimeMode === "date"), 4582 bHasTimeComponent = (apo.tmp.sDateTimeMode === "datetime" || apo.tmp.sDateTimeMode === "time"), 4583 bInvalidSelected = false, 4584 bResult = true, 4585 bLTMin, bGTMax, bDirIsBefore, oDateRecord, oTimeRecord; 4586 4587 // ----------------------------------------------------------------- 4588 4589 // Validate Day 4590 4591 if(!bInvalidSelected && bHasDateComponent && apo.tmp.oArrPDisable.day.length > 0) 4592 { 4593 for(iTempIndex1 = 0; iTempIndex1 < apo.tmp.oArrPDisable.day.length; iTempIndex1++) 4594 { 4595 if(apo.tmp.oArrPDisable.day[iTempIndex1] === oNewSelectedDate.D) 4596 { 4597 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4598 { 4599 bInvalidSelected = true; 4600 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, dNewSelectedDate, "day"); 4601 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4602 apo.__scrollToSelectedRow(); 4603 } 4604 else 4605 { 4606 if(bReturnResult) 4607 bResult = false; 4608 else 4609 apo.__scrollToSelectedRow(); 4610 } 4611 break; 4612 } 4613 } 4614 } 4615 else 4616 { 4617 //console.log("No Disable Day Specified"); 4618 } 4619 4620 // ----------------------------------------------------------------- 4621 4622 // Validate Date 4623 if(!bInvalidSelected && bHasDateComponent && apo.tmp.oArrPDisable.date.length > 0) 4624 { 4625 for(iTempIndex1 = 0; iTempIndex1 < apo.tmp.oArrPDisable.date.length; iTempIndex1++) 4626 { 4627 oDateRecord = apo.tmp.oArrPDisable.date[iTempIndex1]; 4628 4629 if($.CF.isValid(oDateRecord.val)) 4630 { 4631 if(apo.compareDates(dNewSelectedDate, oDateRecord.val) === 0) 4632 { 4633 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4634 { 4635 bInvalidSelected = true; 4636 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, dNewSelectedDate, "date"); 4637 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4638 apo.__scrollToSelectedRow(); 4639 } 4640 else 4641 { 4642 if(bReturnResult) 4643 bResult = false; 4644 else 4645 apo.__scrollToSelectedRow(); 4646 } 4647 break; 4648 } 4649 } 4650 else if($.CF.isValid(oDateRecord.start) && $.CF.isValid(oDateRecord.end)) 4651 { 4652 if(apo.compareDates(dNewSelectedDate, oDateRecord.start) >= 0 && apo.compareDates(dNewSelectedDate, oDateRecord.end) <= 0) 4653 { 4654 4655 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4656 { 4657 bInvalidSelected = true; 4658 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, oDateRecord.start, "date"); 4659 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4660 apo.__scrollToSelectedRow(); 4661 } 4662 else 4663 { 4664 if(bReturnResult) 4665 bResult = false; 4666 else 4667 apo.__scrollToSelectedRow(); 4668 } 4669 break; 4670 } 4671 } 4672 else if($.CF.isValid(oDateRecord.start)) 4673 { 4674 if(apo.compareDates(dNewSelectedDate, oDateRecord.start) >= 0) 4675 { 4676 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4677 { 4678 bInvalidSelected = true; 4679 dNewSelectedDate = apo._findValidSelectedDate(true, oDateRecord.start, "date"); 4680 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4681 apo.__scrollToSelectedRow(); 4682 } 4683 else 4684 { 4685 if(bReturnResult) 4686 bResult = false; 4687 else 4688 apo.__scrollToSelectedRow(); 4689 } 4690 break; 4691 } 4692 } 4693 else if($.CF.isValid(oDateRecord.end)) 4694 { 4695 if(apo.compareDates(dNewSelectedDate, oDateRecord.end) <= 0) 4696 { 4697 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4698 { 4699 bInvalidSelected = true; 4700 dNewSelectedDate = apo._findValidSelectedDate(false, oDateRecord.end, "date"); 4701 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4702 apo.__scrollToSelectedRow(); 4703 } 4704 else 4705 { 4706 if(bReturnResult) 4707 bResult = false; 4708 else 4709 apo.__scrollToSelectedRow(); 4710 } 4711 break; 4712 } 4713 } 4714 else if($.CF.isValid(oDateRecord.min) && $.CF.isValid(oDateRecord.max)) 4715 { 4716 bLTMin = apo.compareDates(dNewSelectedDate, oDateRecord.min) < 0; 4717 bGTMax = apo.compareDates(dNewSelectedDate, oDateRecord.max) > 0; 4718 bDirIsBefore = bLTMin ? true : bGTMax ? false : true; 4719 if(bLTMin || bGTMax) 4720 { 4721 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4722 { 4723 bInvalidSelected = true; 4724 dNewSelectedDate = apo._findValidSelectedDate(bDirIsBefore, oDateRecord.min, "date"); 4725 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4726 apo.__scrollToSelectedRow(); 4727 } 4728 else 4729 { 4730 if(bReturnResult) 4731 bResult = false; 4732 else 4733 apo.__scrollToSelectedRow(); 4734 } 4735 break; 4736 } 4737 } 4738 else if($.CF.isValid(oDateRecord.min)) 4739 { 4740 if(apo.compareDates(dNewSelectedDate, oDateRecord.min) < 0) 4741 { 4742 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4743 { 4744 bInvalidSelected = true; 4745 dNewSelectedDate = apo._findValidSelectedDate(false, oDateRecord.min, "date"); 4746 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4747 apo.__scrollToSelectedRow(); 4748 } 4749 else 4750 { 4751 if(bReturnResult) 4752 bResult = false; 4753 else 4754 apo.__scrollToSelectedRow(); 4755 } 4756 break; 4757 } 4758 } 4759 else if($.CF.isValid(oDateRecord.max)) 4760 { 4761 if(apo.compareDates(dNewSelectedDate, oDateRecord.max) > 0) 4762 { 4763 if(apo.compareDates(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4764 { 4765 bInvalidSelected = true; 4766 dNewSelectedDate = apo._findValidSelectedDate(true, oDateRecord.max, "date"); 4767 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4768 apo.__scrollToSelectedRow(); 4769 } 4770 else 4771 { 4772 if(bReturnResult) 4773 bResult = false; 4774 else 4775 apo.__scrollToSelectedRow(); 4776 } 4777 break; 4778 } 4779 } 4780 } 4781 } 4782 else 4783 { 4784 //console.log("No Disable Date Specified"); 4785 } 4786 4787 // ----------------------------------------------------------------- 4788 4789 // Validate Time 4790 4791 if(!bInvalidSelected && bHasTimeComponent && apo.tmp.oArrPDisable.time.length > 0) 4792 { 4793 for(iTempIndex1 = 0; iTempIndex1 < apo.tmp.oArrPDisable.time.length; iTempIndex1++) 4794 { 4795 var oDayRecord = apo.tmp.oArrPDisable.time[iTempIndex1], 4796 bIsValidDay = false; 4797 4798 if($.CF.isValid(oDayRecord.day) && oDayRecord.day.length > 0) 4799 { 4800 for(iTempIndex2 = 0; iTempIndex2 < oDayRecord.day.length; iTempIndex2++) 4801 { 4802 bIsValidDay = (oDayRecord.day[iTempIndex2] === oNewSelectedDate.D); 4803 if(bIsValidDay) 4804 break; 4805 } 4806 } 4807 else 4808 bIsValidDay = true; 4809 4810 if(bIsValidDay) 4811 { 4812 for(iTempIndex2 = 0; iTempIndex2 < oDayRecord.val.length; iTempIndex2++) 4813 { 4814 oTimeRecord = oDayRecord.val[iTempIndex2]; 4815 4816 if($.CF.isValid(oTimeRecord.val)) 4817 { 4818 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.val) === 0) 4819 { 4820 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4821 { 4822 bInvalidSelected = true; 4823 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, dNewSelectedDate, "time"); 4824 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4825 apo.__scrollToSelectedRow(); 4826 } 4827 else 4828 { 4829 if(bReturnResult) 4830 bResult = false; 4831 else 4832 apo.__scrollToSelectedRow(); 4833 } 4834 break; 4835 } 4836 } 4837 else if($.CF.isValid(oTimeRecord.start) && $.CF.isValid(oTimeRecord.end)) 4838 { 4839 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.start) >= 0 && apo.compareTimes(dNewSelectedDate, oTimeRecord.end) <= 0) 4840 { 4841 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4842 { 4843 bInvalidSelected = true; 4844 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, oTimeRecord.start, "time"); 4845 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4846 apo.__scrollToSelectedRow(); 4847 } 4848 else 4849 { 4850 if(bReturnResult) 4851 bResult = false; 4852 else 4853 apo.__scrollToSelectedRow(); 4854 } 4855 break; 4856 } 4857 } 4858 else if($.CF.isValid(oTimeRecord.start)) 4859 { 4860 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.start) >= 0) 4861 { 4862 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4863 { 4864 bInvalidSelected = true; 4865 dNewSelectedDate = apo._findValidSelectedDate(true, oTimeRecord.start, "time"); 4866 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4867 apo.__scrollToSelectedRow(); 4868 } 4869 else 4870 { 4871 if(bReturnResult) 4872 bResult = false; 4873 else 4874 apo.__scrollToSelectedRow(); 4875 } 4876 break; 4877 } 4878 } 4879 else if($.CF.isValid(oTimeRecord.end)) 4880 { 4881 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.end) <= 0) 4882 { 4883 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4884 { 4885 bInvalidSelected = true; 4886 dNewSelectedDate = apo._findValidSelectedDate(false, oTimeRecord.end, "time"); 4887 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4888 apo.__scrollToSelectedRow(); 4889 } 4890 else 4891 { 4892 if(bReturnResult) 4893 bResult = false; 4894 else 4895 apo.__scrollToSelectedRow(); 4896 } 4897 break; 4898 } 4899 } 4900 else if($.CF.isValid(oTimeRecord.min) && $.CF.isValid(oTimeRecord.max)) 4901 { 4902 bLTMin = apo.compareTimes(dNewSelectedDate, oTimeRecord.min) < 0; 4903 bGTMax = apo.compareTimes(dNewSelectedDate, oTimeRecord.max) > 0; 4904 bDirIsBefore = bLTMin ? true : bGTMax ? false : true; 4905 4906 if(bLTMin || bGTMax) 4907 { 4908 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4909 { 4910 bInvalidSelected = true; 4911 dNewSelectedDate = apo._findValidSelectedDate(bDirIsBefore, oTimeRecord.min, "time"); 4912 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4913 apo.__scrollToSelectedRow(); 4914 } 4915 else 4916 { 4917 if(bReturnResult) 4918 bResult = false; 4919 else 4920 apo.__scrollToSelectedRow(); 4921 } 4922 break; 4923 } 4924 } 4925 else if($.CF.isValid(oTimeRecord.min)) 4926 { 4927 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.min) < 0) 4928 { 4929 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4930 { 4931 bInvalidSelected = true; 4932 dNewSelectedDate = apo._findValidSelectedDate(false, oTimeRecord.min, "time"); 4933 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4934 apo.__scrollToSelectedRow(); 4935 } 4936 else 4937 { 4938 if(bReturnResult) 4939 bResult = false; 4940 else 4941 apo.__scrollToSelectedRow(); 4942 } 4943 break; 4944 } 4945 } 4946 else if($.CF.isValid(oTimeRecord.max)) 4947 { 4948 if(apo.compareTimes(dNewSelectedDate, oTimeRecord.max) > 0) 4949 { 4950 if(apo.compareTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4951 { 4952 bInvalidSelected = true; 4953 dNewSelectedDate = apo._findValidSelectedDate(true, oTimeRecord.max, "time"); 4954 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4955 apo.__scrollToSelectedRow(); 4956 } 4957 else 4958 { 4959 if(bReturnResult) 4960 bResult = false; 4961 else 4962 apo.__scrollToSelectedRow(); 4963 } 4964 break; 4965 } 4966 } 4967 } 4968 } 4969 } 4970 } 4971 else 4972 { 4973 //console.log("No Disable Time Specified"); 4974 } 4975 4976 // ----------------------------------------------------------------- 4977 4978 // Validate DateTime 4979 4980 if(!bInvalidSelected && bHasTimeComponent && apo.tmp.oArrPDisable.datetime.length > 0) 4981 { 4982 for(iTempIndex1 = 0; iTempIndex1 < apo.tmp.oArrPDisable.datetime.length; iTempIndex1++) 4983 { 4984 oDateRecord = apo.tmp.oArrPDisable.datetime[iTempIndex1]; 4985 4986 if($.CF.isValid(oDateRecord.val)) 4987 { 4988 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.val) === 0) 4989 { 4990 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 4991 { 4992 bInvalidSelected = true; 4993 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, dNewSelectedDate, "datetime"); 4994 apo.tmp.selectedDate = new Date(dNewSelectedDate); 4995 apo.__scrollToSelectedRow(); 4996 } 4997 else 4998 { 4999 if(bReturnResult) 5000 bResult = false; 5001 else 5002 apo.__scrollToSelectedRow(); 5003 } 5004 break; 5005 } 5006 } 5007 else if($.CF.isValid(oDateRecord.start) && $.CF.isValid(oDateRecord.end)) 5008 { 5009 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.start) >= 0 && apo.compareDateTimes(dNewSelectedDate, oDateRecord.end) <= 0) 5010 { 5011 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5012 { 5013 bInvalidSelected = true; 5014 dNewSelectedDate = apo._findValidSelectedDate(bIsBefore, oDateRecord.start, "datetime"); 5015 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5016 apo.__scrollToSelectedRow(); 5017 } 5018 else 5019 { 5020 if(bReturnResult) 5021 bResult = false; 5022 else 5023 apo.__scrollToSelectedRow(); 5024 } 5025 break; 5026 } 5027 } 5028 else if($.CF.isValid(oDateRecord.start)) 5029 { 5030 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.start) >= 0) 5031 { 5032 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5033 { 5034 bInvalidSelected = true; 5035 dNewSelectedDate = apo._findValidSelectedDate(true, oDateRecord.start, "datetime"); 5036 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5037 apo.__scrollToSelectedRow(); 5038 } 5039 else 5040 { 5041 if(bReturnResult) 5042 bResult = false; 5043 else 5044 apo.__scrollToSelectedRow(); 5045 } 5046 break; 5047 } 5048 } 5049 else if($.CF.isValid(oDateRecord.end)) 5050 { 5051 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.end) <= 0) 5052 { 5053 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5054 { 5055 bInvalidSelected = true; 5056 dNewSelectedDate = apo._findValidSelectedDate(false, oDateRecord.end, "datetime"); 5057 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5058 apo.__scrollToSelectedRow(); 5059 } 5060 else 5061 { 5062 if(bReturnResult) 5063 bResult = false; 5064 else 5065 apo.__scrollToSelectedRow(); 5066 } 5067 break; 5068 } 5069 } 5070 else if($.CF.isValid(oDateRecord.min) && $.CF.isValid(oDateRecord.max)) 5071 { 5072 bLTMin = apo.compareDateTimes(dNewSelectedDate, oDateRecord.min) < 0; 5073 bGTMax = apo.compareDateTimes(dNewSelectedDate, oDateRecord.max) > 0; 5074 bDirIsBefore = bLTMin ? true : bGTMax ? false : true; 5075 if(bLTMin || bGTMax) 5076 { 5077 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5078 { 5079 bInvalidSelected = true; 5080 dNewSelectedDate = apo._findValidSelectedDate(bDirIsBefore, oDateRecord.min, "datetime"); 5081 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5082 apo.__scrollToSelectedRow(); 5083 } 5084 else 5085 { 5086 if(bReturnResult) 5087 bResult = false; 5088 else 5089 apo.__scrollToSelectedRow(); 5090 } 5091 break; 5092 } 5093 } 5094 else if($.CF.isValid(oDateRecord.min)) 5095 { 5096 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.min) < 0) 5097 { 5098 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5099 { 5100 bInvalidSelected = true; 5101 dNewSelectedDate = apo._findValidSelectedDate(false, oDateRecord.min, "datetime"); 5102 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5103 apo.__scrollToSelectedRow(); 5104 } 5105 else 5106 { 5107 if(bReturnResult) 5108 bResult = false; 5109 else 5110 apo.__scrollToSelectedRow(); 5111 } 5112 break; 5113 } 5114 } 5115 else if($.CF.isValid(oDateRecord.max)) 5116 { 5117 if(apo.compareDateTimes(dNewSelectedDate, oDateRecord.max) > 0) 5118 { 5119 if(apo.compareDateTimes(dNewSelectedDate, apo.tmp.selectedDate) === 0) 5120 { 5121 bInvalidSelected = true; 5122 dNewSelectedDate = apo._findValidSelectedDate(true, oDateRecord.max, "datetime"); 5123 apo.tmp.selectedDate = new Date(dNewSelectedDate); 5124 apo.__scrollToSelectedRow(); 5125 } 5126 else 5127 { 5128 if(bReturnResult) 5129 bResult = false; 5130 else 5131 apo.__scrollToSelectedRow(); 5132 } 5133 break; 5134 } 5135 } 5136 } 5137 } 5138 else 5139 { 5140 //console.log("No Disable DateTime Specified"); 5141 } 5142 5143 // ----------------------------------------------------------------- 5144 5145 if(bReturnResult) 5146 return bResult; 5147 } 5148 else 5149 { 5150 if(bReturnResult) 5151 return true; 5152 } 5153 }, 5154 5155 _findValidSelectedDate: function(bIsBefore, dDate, sType) 5156 { 5157 var apo = this; 5158 5159 if(sType === "day" || sType === "date") 5160 { 5161 if($.CF.isValid(apo.setting.minValue) && apo.compareDates(apo.setting.minValue, dDate) >= 0) 5162 { 5163 dDate = new Date(apo.setting.minValue); 5164 bIsBefore = false; 5165 } 5166 5167 if($.CF.isValid(apo.setting.maxValue) && apo.compareDates(apo.setting.maxValue, dDate) <= 0) 5168 { 5169 dDate = new Date(apo.setting.maxValue); 5170 bIsBefore = true; 5171 } 5172 5173 do 5174 { 5175 if(bIsBefore) 5176 dDate = new Date(dDate.getTime() - $.AnyPicker.extra.iMS.d); 5177 else 5178 dDate = new Date(dDate.getTime() + $.AnyPicker.extra.iMS.d); 5179 if(apo.__validateSelectedDate(dDate, true, false)) 5180 { 5181 if((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareDates(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareDates(apo.setting.maxValue, dDate) >= 0))) 5182 { 5183 return dDate; 5184 } 5185 } 5186 5187 }while((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareDates(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareDates(apo.setting.maxValue, dDate) >= 0))); 5188 } 5189 else if(sType === "time") 5190 { 5191 if($.CF.isValid(apo.setting.minValue) && apo.compareTimes(apo.setting.minValue, dDate) >= 0) 5192 { 5193 dDate = new Date(apo.setting.minValue); 5194 bIsBefore = false; 5195 } 5196 5197 if($.CF.isValid(apo.setting.maxValue) && apo.compareTimes(apo.setting.maxValue, dDate) <= 0) 5198 { 5199 dDate = new Date(apo.setting.maxValue); 5200 bIsBefore = true; 5201 } 5202 5203 do 5204 { 5205 if(bIsBefore) 5206 dDate = new Date(dDate.getTime() - ($.AnyPicker.extra.iMS.m * apo.setting.intervals.m)); 5207 else 5208 dDate = new Date(dDate.getTime() + ($.AnyPicker.extra.iMS.m * apo.setting.intervals.m)); 5209 if(apo.__validateSelectedDate(dDate, true, false)) 5210 { 5211 if((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareTimes(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareTimes(apo.setting.maxValue, dDate) >= 0))) 5212 { 5213 return dDate; 5214 } 5215 } 5216 }while((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareTimes(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareTimes(apo.setting.maxValue, dDate) >= 0))); 5217 } 5218 else if(sType === "datetime") 5219 { 5220 if($.CF.isValid(apo.setting.minValue) && apo.compareDateTimes(apo.setting.minValue, dDate) >= 0) 5221 { 5222 dDate = new Date(apo.setting.minValue); 5223 bIsBefore = false; 5224 } 5225 5226 if($.CF.isValid(apo.setting.maxValue) && apo.compareDateTimes(apo.setting.maxValue, dDate) <= 0) 5227 { 5228 dDate = new Date(apo.setting.maxValue); 5229 bIsBefore = true; 5230 } 5231 5232 do 5233 { 5234 if(bIsBefore) 5235 dDate = new Date(dDate.getTime() - ($.AnyPicker.extra.iMS.m * apo.setting.intervals.m)); 5236 else 5237 dDate = new Date(dDate.getTime() + ($.AnyPicker.extra.iMS.m * apo.setting.intervals.m)); 5238 5239 if(apo.__validateSelectedDate(dDate, true, false)) 5240 { 5241 if((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareDateTimes(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareDateTimes(apo.setting.maxValue, dDate) >= 0))) 5242 { 5243 return dDate; 5244 } 5245 } 5246 }while((!$.CF.isValid(apo.setting.minValue) || ($.CF.isValid(apo.setting.minValue) && apo.compareDateTimes(apo.setting.minValue, dDate) <= 0)) && (!$.CF.isValid(apo.setting.maxValue) || ($.CF.isValid(apo.setting.maxValue) && apo.compareDateTimes(apo.setting.maxValue, dDate) >= 0))); 5247 } 5248 5249 if($.CF.isValid(apo.setting.minValue)) 5250 { 5251 return apo.setting.minValue; 5252 } 5253 }, 5254 5255 __setDaysOfMonthInDatePicker: function() 5256 { 5257 var apo = this; 5258 5259 var iTempIndex, oComp, iDateComp = null, sDateCompFormat = null; 5260 for(iTempIndex = 0; iTempIndex < apo.tmp.numOfComp; iTempIndex++) 5261 { 5262 oComp = apo.setting.components[iTempIndex]; 5263 if(oComp.name === "date") 5264 { 5265 iDateComp = oComp.component; 5266 sDateCompFormat = oComp.format; 5267 } 5268 } 5269 5270 if(iDateComp !== null) 5271 { 5272 var oSelectedDate = apo.getDateObject(apo.tmp.selectedDate), 5273 iNoOfDays = apo._getNumberOfDaysOfMonth(oSelectedDate.M, oSelectedDate.y), 5274 bHasAria = false; 5275 5276 for(iTempIndex = (iNoOfDays + 1); iTempIndex <= 31; iTempIndex++) 5277 { 5278 var $oHiddenElem = $("#ap-component-" + iDateComp).find("#ap-row-" + iDateComp + "-" + (iTempIndex - 1)); 5279 $oHiddenElem.addClass("ap-row-disabled ap-row-hidden"); 5280 if(!bHasAria) 5281 bHasAria = ($oHiddenElem.attr("aria-selected") === "true") ? true : false; 5282 } 5283 5284 if(bHasAria) 5285 { 5286 var dTemp = new Date(oSelectedDate.y, oSelectedDate.M, iNoOfDays, oSelectedDate.H, oSelectedDate.m, oSelectedDate.s, oSelectedDate.ms); 5287 5288 apo.__validateSelectedDate(dTemp, false, true); 5289 apo.__scrollToSelectedRow(); 5290 } 5291 } 5292 }, 5293 5294 //------------------------------- Date Manipulation Functions Start ------------------------------- 5295 5296 // Public Method 5297 setDateInFormat: function(oInput, sType) 5298 { 5299 var apo = this; 5300 5301 if(oInput.date === undefined && oInput.iDate === undefined) 5302 oInput.date = apo._getCurrentDate(); 5303 if(oInput.iDate === undefined) 5304 { 5305 oInput.iDate = { 5306 d: oInput.date.getDate(), 5307 M: oInput.date.getMonth(), 5308 y: oInput.date.getFullYear(), 5309 H: oInput.date.getHours(), 5310 m: oInput.date.getMinutes(), 5311 s: oInput.date.getSeconds(), 5312 ms: oInput.date.getMilliseconds() 5313 }; 5314 } 5315 else 5316 { 5317 oInput.iDate = { 5318 d: (oInput.iDate.d !== undefined) ? oInput.iDate.d : 1, 5319 M: (oInput.iDate.M !== undefined) ? oInput.iDate.M : $.AnyPicker.extra.dToday.getMonth(), 5320 y: (oInput.iDate.y !== undefined) ? oInput.iDate.y : $.AnyPicker.extra.dToday.getFullYear(), 5321 H: (oInput.iDate.H !== undefined) ? oInput.iDate.H : 0, 5322 m: (oInput.iDate.m !== undefined) ? oInput.iDate.m : 0, 5323 s: (oInput.iDate.s !== undefined) ? oInput.iDate.s : 0, 5324 ms: (oInput.iDate.ms !== undefined) ? oInput.iDate.ms : 0 5325 }; 5326 } 5327 5328 var dDate; 5329 if(!$.CF.isValid(sType)) 5330 dDate = new Date(oInput.iDate.y, oInput.iDate.M, oInput.iDate.d, oInput.iDate.H, oInput.iDate.m, oInput.iDate.s, oInput.iDate.ms); 5331 else if(sType === "START") 5332 dDate = new Date(oInput.iDate.y, oInput.iDate.M, oInput.iDate.d, 0, 0, 0, 0); 5333 else if(sType === "END") 5334 dDate = new Date(oInput.iDate.y, oInput.iDate.M, oInput.iDate.d, 23, 59, 59, 999); 5335 5336 return dDate; 5337 }, 5338 5339 _getCurrentDate: function() 5340 { 5341 var apo = this; 5342 var dToday = apo.getDateByAddingOutputTZOffset(apo.convertToUTC(new Date()), apo.setting.tzOffset); 5343 return dToday; 5344 }, 5345 5346 // Public Method 5347 convertToUTC: function(dIpDate, sIpTZOffset) 5348 { 5349 var apo = this; 5350 return new Date(dIpDate.getTime() - ((sIpTZOffset === undefined || sIpTZOffset === "" || sIpTZOffset === null) ? -(dIpDate.getTimezoneOffset() * $.AnyPicker.extra.iMS.m) : apo._getTZOffsetInMS(sIpTZOffset))); 5351 }, 5352 5353 _getTZOffsetInMS: function(sTZOffset) 5354 { 5355 var apo = this; 5356 var iOffsetMS = 0; 5357 if(sTZOffset === undefined || sTZOffset === "" || sTZOffset === null) 5358 iOffsetMS = -($.AnyPicker.extra.dToday.getTimezoneOffset() * $.AnyPicker.extra.iMS.m); 5359 else 5360 { 5361 var sArrTZOffset = apo._matchRegex(/^([+|-]{1})([0-1]{0,1}[0-9]{1}):([0-6]{0,1}[0-9]{1})$/, sTZOffset); 5362 iOffsetMS = parseInt(sArrTZOffset[2]) * $.AnyPicker.extra.iMS.h + parseInt(sArrTZOffset[3]) * $.AnyPicker.extra.iMS.m; 5363 iOffsetMS = (sArrTZOffset[1]==="+") ? iOffsetMS : -iOffsetMS; 5364 } 5365 return iOffsetMS; 5366 }, 5367 5368 // Public Method 5369 getDateByAddingOutputTZOffset: function(dIpDate, sOpTZOffset) 5370 { 5371 var apo = this; 5372 return new Date(dIpDate.getTime() + apo._getTZOffsetInMS(sOpTZOffset)); 5373 }, 5374 5375 // Public Method 5376 normalizeDateTimeWithOffset: function(dIpDate, sIpTZOffset, sOpTZOffset) 5377 { 5378 var apo = this; 5379 return apo.getDateByAddingOutputTZOffset(apo.convertToUTC(dIpDate, sIpTZOffset), sOpTZOffset); 5380 }, 5381 5382 _getNumberOfDaysOfMonth: function(iMonth, iYear) 5383 { 5384 var apo = this; 5385 var iArrMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], 5386 iArrLeapYearMonthDays = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 5387 if(iYear % 4 === 0) 5388 return iArrLeapYearMonthDays[iMonth]; 5389 else 5390 return iArrMonthDays[iMonth]; 5391 }, 5392 5393 _normalizeDateTime: function(dInputDate, sFunction, sUnit) 5394 { 5395 var apo = this; 5396 // sFunction = "START" | "END" 5397 // sUnit = "s" | "m" | "h" | "T" | "d" | "M" | 5398 5399 var dOutputDate, 5400 iArrInput = 5401 { 5402 d: dInputDate.getDate(), 5403 M: dInputDate.getMonth(), 5404 y: dInputDate.getFullYear(), 5405 H: dInputDate.getHours(), 5406 m: dInputDate.getMinutes(), 5407 s: dInputDate.getSeconds() 5408 }; 5409 5410 switch(sUnit) 5411 { 5412 case "s": 5413 { 5414 if(sFunction === "START") 5415 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, iArrInput.H, iArrInput.m, 0, 0); 5416 else if(sFunction === "END") 5417 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, iArrInput.H, iArrInput.m, 59, 999); 5418 } 5419 break; 5420 case "m": 5421 { 5422 if(sFunction === "START") 5423 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, iArrInput.H, 0, 0, 0); 5424 else if(sFunction === "END") 5425 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, iArrInput.H, 59, 59, 999); 5426 } 5427 break; 5428 case "h": 5429 case "T": 5430 { 5431 if(sFunction === "START") 5432 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, 0, 0, 0, 0); 5433 else if(sFunction === "END") 5434 dOutputDate = new Date(iArrInput.y, iArrInput.M, iArrInput.d, 23, 59, 59, 999); 5435 } 5436 break; 5437 case "d": 5438 case "dE": 5439 { 5440 if(sFunction === "START") 5441 dOutputDate = new Date(iArrInput.y, iArrInput.M, 1, 0, 0, 0, 0); 5442 else if(sFunction === "END") 5443 dOutputDate = new Date(iArrInput.y, iArrInput.M, apo._getNumberOfDaysOfMonth(iArrInput.M, iArrInput.y), 0, 0, 0, 0); 5444 } 5445 break; 5446 case "M": 5447 case "ME": 5448 case "y": 5449 case "yE": 5450 { 5451 if(sFunction === "START") 5452 dOutputDate = new Date(iArrInput.y, 0, 1, 0, 0, 0, 0); 5453 else if(sFunction === "END") 5454 dOutputDate = new Date(iArrInput.y, 11, apo._getNumberOfDaysOfMonth(11, iArrInput.y), 0, 0, 0, 0); 5455 } 5456 break; 5457 } 5458 5459 if(sUnit === "dE" || sUnit === "ME" || sUnit === "yE") 5460 dOutputDate = apo._normalizeDateTime(dOutputDate, "END", "T"); 5461 5462 return dOutputDate; 5463 }, 5464 5465 _getDifference: function(sUnit, dDate1, dDate2) 5466 { 5467 var apo = this; 5468 // sUnit = "ms | "s" | "m" | "h" | "T" | "d" | "M"| "y" 5469 5470 var iUnitDiff, iMSDiff = dDate1.getTime() - dDate2.getTime(); 5471 5472 if(sUnit === "ms") 5473 iUnitDiff = iMSDiff; 5474 else if(sUnit === "s") 5475 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.s); 5476 else if(sUnit === "m") 5477 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.m); 5478 else if(sUnit === "h") 5479 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.h); 5480 else if(sUnit === "d") 5481 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.d); 5482 else if(sUnit === "M") 5483 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.m); 5484 else if(sUnit === "y") 5485 iUnitDiff = (iMSDiff / $.AnyPicker.extra.iMS.y); 5486 5487 return iUnitDiff; 5488 }, 5489 5490 // Public Method 5491 compareDates: function(dDate1, dDate2) 5492 { 5493 var apo = this; 5494 dDate1 = apo._normalizeDateTime(dDate1, "START", "T"); 5495 dDate2 = apo._normalizeDateTime(dDate2, "START", "T"); 5496 var iDateDiff = apo._getDifference("d", dDate1, dDate2); 5497 return (iDateDiff === 0) ? iDateDiff: (iDateDiff/Math.abs(iDateDiff)); 5498 }, 5499 5500 // Public Method 5501 compareDateTimes: function(dDate1, dDate2) 5502 { 5503 var apo = this; 5504 var iDateTimeDiff = apo._getDifference("m", dDate1, dDate2); 5505 return (iDateTimeDiff === 0) ? iDateTimeDiff: (iDateTimeDiff/Math.abs(iDateTimeDiff)); 5506 }, 5507 5508 // Public Method 5509 compareTimes: function(dDate1, dDate2) 5510 { 5511 var apo = this; 5512 var dDateTime1 = new Date($.AnyPicker.extra.dToday), 5513 dDateTime2 = new Date($.AnyPicker.extra.dToday); 5514 5515 dDateTime1.setHours(dDate1.getHours()); 5516 dDateTime1.setMinutes(dDate1.getMinutes()); 5517 dDateTime1.setSeconds(dDate1.getSeconds()); 5518 5519 dDateTime2.setHours(dDate2.getHours()); 5520 dDateTime2.setMinutes(dDate2.getMinutes()); 5521 dDateTime2.setSeconds(dDate2.getSeconds()); 5522 5523 return apo.compareDateTimes(dDateTime1, dDateTime2); 5524 }, 5525 5526 // Public Method 5527 getNumberStringInFormat: function(iNumber, iChars, bIsLocalized) 5528 { 5529 var apo = this; 5530 var iTempIndex, sFormattedString = "", sNumber = iNumber.toString(), iNumberLength = sNumber.length; 5531 if(iChars !== 0) 5532 { 5533 for(iTempIndex = 0; iTempIndex < (iChars - iNumberLength); iTempIndex++) 5534 sFormattedString += (bIsLocalized ? apo.setting.i18n.numbers[0] : "0"); 5535 } 5536 if(!bIsLocalized) 5537 sFormattedString += sNumber; 5538 else 5539 { 5540 for(iTempIndex = 0; iTempIndex < iNumberLength; iTempIndex++) 5541 sFormattedString += apo.setting.i18n.numbers[parseInt(sNumber.charAt(iTempIndex))]; 5542 } 5543 return sFormattedString; 5544 }, 5545 5546 // Public Method 5547 getDateObject: function(dInput) 5548 { 5549 var apo = this; 5550 5551 var oInput = { 5552 D: dInput.getDay(), 5553 d: dInput.getDate(), 5554 M: dInput.getMonth(), 5555 y: dInput.getFullYear(), 5556 H: dInput.getHours(), 5557 m: dInput.getMinutes(), 5558 s: dInput.getSeconds(), 5559 ms: dInput.getMilliseconds() 5560 }; 5561 5562 oInput.h = (oInput.H > 12) ? (oInput.H - 12) : ((oInput.H === 0) ? 12 : oInput.H); 5563 oInput.me = (oInput.H < 12) ? "am" : "pm"; 5564 oInput.sm = (oInput.H < 12) ? "a" : "p"; 5565 5566 return oInput; 5567 } 5568 5569 //------------------------------- Date Manipulation Functions End ------------------------------- 5570 5571}); 5572 5573// --------------------------------- Functions : AnyPicker.DateTime End --------------------------------------
5574 5575 5576}()); 5577
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.