vendor: 5,557 bytes, lines 1-146
1(function ($) { 2 var datepicker_instActive; 3 4 function timepicker_getZindex( elem ) { 5 var position, value; 6 while ( elem.length && elem[ 0 ] !== document ) { 7 position = elem.css( "position" ); 8 if ( position === "absolute" || position === " relative" || position === "fixed" ) { 9 value = parseInt( elem.css( "zIndex" ), 10 ); 10 if ( !isNaN( value ) && value !== 0 ) { 11 return value; 12 } 13 } 14 elem = elem.parent(); 15 } 16 17 return 0; 18 } 19 20 function Timepicker() { 21 this._curInst = null; 22 this._keyEvent = false; 23 this._disabledInputs = []; 24 this._timepickerShowing = false; 25 this._inDialog = false; 26 this._mainDivId = "ui-timepicker-div"; 27 this._inlineClass = "ui-timepicker-inline"; 28 this._appendClass = "ui-timepicker-append"; 29 this._triggerClass = "ui-timepicker-trigger"; 30 this._dialogClass = "ui-timepicker-dialog"; 31 this._disableClass = "ui-timepicker-disabled"; 32 this._unselectableClass = "ui-timepicker-unselectable"; 33 this.regional = []; 34 this.regional[ "" ] = { 35 36 }; 37 this._defaults = { 38 showOn: "focus", 39 showAnim: "fadeIn", 40 showOptions: {}, 41 appendText: "", 42 duration: "fast", 43 beforeShowDay: null, 44 beforeShow: null, 45 onSelect: null, 46 onClose: null, 47 constrainInputInput: true, 48 autoSzie: false, 49 disabled: false 50 }; 51 $.extend( this._defaults, this.regional[ "" ] ); 52 this.regional.en = $.extend( true, {}, this.regional[ "" ] ); 53 this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); 54 this.dpDiv = timepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-timepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ); 55 } 56 57 $.extend( Timepicker.prototype, { 58 markerClassName: "hasTimepicker", 59 60 setDefaults: function ( settings ) { 61 timepicker_extendRemove( this._defaults, settings || {} ); 62 return this; 63 }, 64 65 _attachTimepicker: function ( target, settings ) { 66 var nodeName, inline, inst; 67 nodeName = target.nodeName.toLowerCase(); 68 inline = ( nodeName === "div" || nodeName === "span" ); 69 if ( !target.id ) { 70 this.uuid += 1; 71 target.id = "tp" + this.uuid; 72 } 73 inst = this._newInst( $( target ), inline ); 74 inst.settings = $.extend( {}, settings || {} ); 75 if ( nodeName === "input" ) { 76 this._connectTimepicker( target, inst ); 77 } 78 }, 79 80 _newInst: function ( target, inline ) { 81 var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars 82 return { id: id, input: target, // associated target 83 selectedHour: 0, selectedMinute: 0, selectedAmPm: 0, // current selection 84 inline: inline, // is timepicker inline or not 85 dpDiv: ( !inline ? this.dpDiv : // presentation div 86 timepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-timepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) }; 87 }, 88 89 _connectTimepicker: function ( target, inst ) { 90 var input = $( target ); 91 inst.append = $( [] ); 92 inst.trigger = $( [] ); 93 if ( input.hasClass( this.markerClassName ) ) { 94 return; 95 } 96 this._attachments( input, inst ); 97 input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ). 98 on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp ); 99 this._autoSize( inst ); 100 $.data( target, "timepicker", inst ); 101 102 if ( inst.settings.disabled ) { 103 this._disabledTimepicker( target ); 104 } 105 }, 106 107 _attachments: function ( input, inst ) { 108 var showOn, buttonText, buttonImage, 109 appendText = this._get( inst, "appendText" ); 110 111 if ( inst.append ) { 112 inst.append.remove(); 113 } 114 if ( appendText ) { 115 inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>"); 116 input["after"]( inst.append ); 117 } 118 119 input.off( "focus", this._showTimepicker ); 120 121 if ( inst.trigger ) { 122 inst.trigger.remove(); 123 } 124 125 showOn = this._get( inst, "showOn" ); 126 if ( showOn === "focus" || showOn === "both" ) { 127 input.on( "focus", this._showTimepicker ); 128 } 129 }, 130 131 _autoSize: function ( inst ) { 132 133 }, 134 135 _destroyTimepicker: function ( target ) { 136 var nodeName, 137 $target = $( target ), 138 inst = $.data( target, "timepicker" ); 139 140 if ( !$target.hasClass( this.markerClassName ) ) { 141 return; 142 } 143 144 nodeName = target.nodeName.toLowerCase(); 145 $.removeData( target, "timepicker" ); 146 if ( nodeName === "input" ) {
vendor: 13,348 bytes, lines 147-465
147 inst.append.remove(); 148 inst.trigger.remove(); 149 $target.removeClass( this.markerClassName ). 150 off( "focus", this._showTimepicker ). 151 off( "keydown", this._doKeyDown ). 152 off( "keypress", this._doKeyPress ). 153 off( "keyup", this._doKeyUp ); 154 } else if ( nodeName === "div" || nodeName === "span" ) { 155 $target.removeClass( this.markerClassName ).empty(); 156 } 157 158 if ( timepicker_instActive === inst ) { 159 timepicker_instActive = null; 160 } 161 }, 162 163 _enableTimepicker: function ( target ) { 164 var nodeName, inline, 165 $target = $( target ), 166 inst = $.data( target, "timepicker" ); 167 168 if ( !$target.hasClass( this.markerClassName) ) { 169 return; 170 } 171 172 nodeName = target.nodeName.toLowerCase(); 173 if ( nodeName === "input" ) { 174 target.disabled = false; 175 inst.trigger.filter( "button" ). 176 each( function () { this.disabled = false; } ).end(). 177 filter( "img" ).css( { opacity: "1.0", cursor: "" } ); 178 } else if ( nodeName === "div" || nodeName === "span" ) { 179 inline = $target.children( "." + this._inlineClass ); 180 inline.children().removeClass( "ui-state-disabled" ); 181 } 182 this._disabledInputs = $.map( this._disabledInputs, 183 function( value ) { return ( value === target ? null : value ); } ); 184 }, 185 186 _disableTimepicker: function ( target ) { 187 var nodeName, inline, 188 $target = $( target ), 189 inst = $.data( target, "timepicker" ); 190 191 if ( !$target.hasClass( this.markerClassName ) ) { 192 return; 193 } 194 195 nodeName = target.nodeName.toLowerCase(); 196 if ( nodeName === "input" ) { 197 target.disabled = true; 198 inst.trigger.filter( "button" ). 199 each( function() { this.disabled = true; } ).end(). 200 filter( "img" ).css( { opacity: "0.5", cursor: "default" } ); 201 } else if ( nodeName === "div" || nodeName === "span" ) { 202 inline = $target.children( "." + this._inlineClass ); 203 inline.children().addClass( "ui-state-disabled" ); 204 } 205 this.disabledInputs = $.map( this._disabledInputs, 206 function ( value ) { return ( value === target ? null : value ); } ); 207 this._disabledInputs[ this._disabledInputs.length ] = target; 208 }, 209 210 _isDisabledTimepicker: function ( target ) { 211 if ( !target ) { 212 return false; 213 } 214 for ( var i = 0; i < this._disabledInputs.length; i++ ) { 215 if ( this._disabledInputs[ i ] === target ) { 216 return true; 217 } 218 } 219 return false; 220 }, 221 222 _getInst: function ( target ) { 223 try { 224 return $.data( target, "timepicker" ); 225 } catch ( err ) { 226 throw "Missing instance data for this timepicker"; 227 } 228 }, 229 230 _doKeyDown: function ( event ) { 231 var onSelect, dateStr, sel, 232 inst = $.timepicker._getInst( event.target ), 233 handled = true; 234 235 inst._keyEvent = true; 236 if ( $.timepicker._timepickerShowing ) { 237 switch ( event.keyCode ) { 238 239 } 240 } else if ( event.keyCode === 36 && event.ctrlKey ) { 241 $.timepicker._showTimepicker( this ); 242 } else { 243 handled = false; 244 } 245 246 if ( handled ) { 247 event.preventDefault(); 248 event.stopPropagation(); 249 } 250 }, 251 252 _doKeyPress: function ( event ) { 253 var chars, chr, 254 inst = $.timepicker._getInst( event.target ); 255 256 if ( $.timepicker._get( inst, "constrainInput" ) ) { 257 chars = $.timepicker._possibleChars( $.timepicker._get( inst, "timeFormat" ) ); 258 chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode ); 259 return event.ctrlKey || event.metaKey || ( chr < " " || ! chars || chars.indexOf( chr ) > -1 ); 260 } 261 }, 262 263 _doKeyUp: function ( event ) { 264 265 }, 266 267 _showTimepicker: function ( input ) { 268 input = input.target || input; 269 if ( input.nodeName.toLowerCase() !== "input" ) { 270 input = $( "input", input.parentNode )[ 0 ]; 271 } 272 273 if ( $.timepicker._isDisabledTimepicker( input ) || $.timepicker._lastInput === input ) { 274 return; 275 } 276 277 var inst, beforeShow, beforeShowSettings, isFixed, 278 offset, showAnim, duration; 279 280 inst = $.timepicker._getInst( input ); 281 if ( $.timepicker._curInst && $.timepicker._curInst !== inst ) { 282 $.timepicker._curInst.dpDiv.stop( true, true ); 283 if ( inst && $.timepicker._timepickerShowing ) { 284 $.timepicker._hideTimepicker( $.timepicker._curInst.input[ 0 ] ); 285 } 286 } 287 288 beforeShow = $.timepicker._get( inst, "beforeShow" ); 289 beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {}; 290 if ( beforeShowSettings === false ) { 291 return; 292 } 293 timepicker_extendRemove( inst.settings, beforeShowSettings ); 294 295 inst.lastVal = null; 296 $.timepicker._lastInput = input; 297 // $.timepicker._setTimeFromField( inst ); 298 299 if ( $.timepicker._inDialog ) { 300 input.value = ""; 301 } 302 if ( !$.timepicker._pos ) { 303 $.timepicker._pos = $.timepicker._findPos( input ); 304 $.timepicker._pos[ 1 ] += input.offsetHeight; 305 } 306 307 isFixed = false; 308 $( input ).parents().each( function () { 309 isFixed |= $( this ).css( "position" ) === "fixed"; 310 return !isFixed; 311 } ); 312 313 offset = { left: $.timepicker._pos[ 0 ], top: $.timepicker._pos[ 1 ] }; 314 $.timepicker._pos = null; 315 316 inst.dpDiv.empty(); 317 318 inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } ); 319 $.timepicker._updateTimepicker( inst ); 320 321 offset = $.timepicker._checkOffset( inst, offset, isFixed ); 322 inst.dpDiv.css( { position: ( $.timepicker._inDialog && $.blockUI ? 323 "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none", 324 left: offset.left + "px", top: offset.top + "px" } ); 325 326 if ( !inst.inline ) { 327 showAnim = $.timepicker._get( inst, "showAnim" ); 328 duration = $.timepicker._get( inst, "duration" ); 329 inst.dpDiv.css( "z-index", timepicker_getZindex( $( input ) ) + 1 ); 330 $.timepicker._timepickerShowing = true; 331 332 if ( $.effects && $.effects.effect[ showAnim ] ) { 333 inst.dpDiv.show( showAnim, $.timepicker._get( inst, "showOptions" ), duration ); 334 } else { 335 inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null ); 336 } 337 338 if ( $.timepicker._shouldFocusInput( inst ) ) { 339 inst.input.trigger( "focus" ); 340 } 341 342 $.timepicker._curInst = inst; 343 } 344 }, 345 346 _updateTimepicker: function ( inst ) { 347 this.maxRows = 4; 348 timepicker_instActive = inst; 349 inst.dpDiv.empty().append( this._generateHTML( inst ) ); 350 this._attachHandlers ( inst ); 351 352 353 }, 354 355 _shouldFocusInput: function( inst ) { 356 return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); 357 }, 358 359 _checkOffset: function ( inst, offset, isFixed ) { 360 var dpWidth = inst.dpDiv.outerWidth(), 361 dpHeight = inst.dpDiv.outerHeight(), 362 inputWidth = inst.input ? inst.input.outerWidth() : 0, 363 inputHeight = inst.input ? inst.input.outerHeight() : 0, 364 viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ), 365 viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() ); 366 367 offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 ); 368 offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0; 369 offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0; 370 371 offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ? 372 Math.abs( offset.left + dpWidth - viewWidth ) : 0 ); 373 offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewWidth && viewWidth > dpWidth ) ? 374 Math.abs( dpHeight + inputHeight ) : 0 ); 375 376 return offset; 377 }, 378 379 _findPos: function ( obj ) { 380 var position, 381 inst = this._getInst( obj ), 382 isRTL = this._get( inst, "isRTL" ); 383 384 while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) { 385 obj = obj[ isRTL ? "previousSibling" : "nextSibling" ]; 386 } 387 388 position = $( obj ).offset(); 389 return [ position.left, position.top ]; 390 }, 391 392 _hideTimepicker: function ( input ) { 393 var showAnim, duration, postProcess, onClose, 394 inst = this._curInst; 395 396 if ( !inst || ( input && inst !== $.data( input, "timepicker" ) ) ) { 397 return; 398 } 399 400 if ( this._timepickerShowing ) { 401 showAnim = this._get( inst, "showAnim" ); 402 duration = this._get( inst, "duration" ); 403 postProcess = function () { 404 $.timepicker._tidyDialog( inst ); 405 }; 406 407 if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) { 408 inst.dpDiv.hide( showAnim, $.timepicker._get( inst, "showOptions" ), duration, postProcess ); 409 } else { 410 inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" : 411 ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess ); 412 } 413 414 if ( !showAnim ) { 415 postProcess(); 416 } 417 this._timepickerShowing = false; 418 419 onClose = this._get( inst, "onClose" ); 420 if ( onClose ) { 421 onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] ); 422 } 423 424 this._lastInput = null; 425 if ( this._inDialog ) { 426 this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } ); 427 if( $.blockUI ) { 428 $.unblockUI(); 429 $( "body" ).append( this.dpDiv ); 430 } 431 } 432 this._inDialog = false; 433 } 434 }, 435 436 _tidyDialog: function ( inst ) { 437 // inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-timepicker-calendar" ); 438 }, 439 440 _checkExternalClick: function ( event ) { 441 if ( !$.timepicker._curInst ) { 442 return; 443 } 444 445 var $target = $( event.target ), 446 inst = $.timepicker._getInst( $target[ 0 ] ); 447 448 if ( ( ( $target[ 0 ].id !== $.timepicker._mainDivId && 449 $target.parents( "#" + $.timepicker._mainDivId ).length === 0 && 450 !$target.hasClass( $.timepicker.markerClassName ) && 451 !$target.closest( '.' + $.timepicker._triggerClass ).length && 452 $.timepicker._timepickerShowing && !( $.timepicker._inDialog && $.blockUI ) ) ) || 453 ( $target.hasClass( $.timepicker.markerClassName ) && $.timepicker._curInst !== inst ) ) { 454 $.timepicker._hideTimepicker(); 455 } 456 }, 457 458 _get: function ( inst, name ) { 459 return inst.settings[ name ] !== undefined ? 460 inst.settings[ name ] : this._defaults[ name ]; 461 }, 462 463 _attachHandlers: function ( inst ) { 464 var stepMonths = this._get( inst, "stepMonths" ), 465 id = "#" + inst.id.replace( /\\\\/g, "\\" );
466 inst.dpDiv.find( "[data-handler]" ).map( function () { 467 var handler = { 468 prev: function() { 469 470 }, 471 next: function () { 472 473 }, 474 hide: function() { 475 $.timepicker._hideTimepicker(); 476 } 477 }; 478 $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] ); 479 }) 480 }, 481 482 _generateHTML: function ( inst ) { 483 var html, hours, minutes, am_pm; 484 485 html = '<div class="display-flex padding-vert-sml">'; 486 487 spacer = ':'; 488 hours = '<div class="display-flex flex-direction-column padding-horz-sml">' + 489 '<a href="#">UP</a>' + 490 '<input type="text" value="1" size="2" />' + 491 '<a href="#">DN</a>' + 492 '</div>'; 493 minutes = '<div class="display-flex flex-direction-column padding-horz-sml">' + 494 '<a href="#">UP</a>' + 495 '<input type="text" value="1" size="2" />' + 496 '<a href="#">DN</a>' + 497 '</div>'; 498 am_pm = '<div class="display-flex flex-direction-column padding-horz-sml">' + 499 '<a href="#">UP</a>' + 500 '<input type="text" value="1" size="2" />' + 501 '<a href="#">DN</a>' + 502 '</div>'; 503 504 html += hours; 505 html += minutes; 506 html += am_pm; 507 508 html += '</div>'; 509 inst._keyEvent = false; 510 return html; 511 } 512 }); 513 514 function timepicker_bindHover ( dpDiv ) { 515 var selector = "button"; 516 return dpDiv.on( "mouseout", selector, function () { 517 $( this ).removeClass( "ui-state-hover" ); 518 } ) 519 .on( "mouseover", selector, timepicker_handleMouseover ); 520 } 521 522 function timepicker_handleMouseover() { 523 if ( !$timepicker._isDisabledTimepicker( timepicker_instActive.inline ? timepicker_instActive.dpDiv.parent()[ 0 ] : timepicker_instActive.input[ 0 ] ) ) { 524 $( this ).addClass( "ui-state-hover" ); 525 } 526 } 527 528 function timepicker_extendRemove ( target, props ) { 529 $.extend( target, props ); 530 for ( var name in props ) { 531 if ( props[ name ] == null ) { 532 target[ name ] = props[ name ]; 533 } 534 } 535 return target; 536 } 537 538 $.fn.timepicker = function ( options ) { 539 540 if ( !this.length ) { 541 return this; 542 } 543 544 if ( !$.timepicker.initialized ) { 545 $( document ).on( "mousedown", $.timepicker._checkExternalClick ); 546 $.timepicker.initialized = true; 547 } 548 549 if ( $( "#" + $.timepicker._mainDivId ).length === 0 ) { 550 $( "body" ).append( $.timepicker.dpDiv ); 551 } 552 553 var otherArgs = Array.prototype.slice.call( arguments, 1 ); 554 if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) { 555 return $.timepicker[ "_" + options + "Datepicker" ]. 556 apply( $.timepicker, [ this[ 0 ] ].concat( otherArgs ) ); 557 } 558 if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) { 559 return $.timepicker[ "_" + options + "Datepicker" ]. 560 apply( $.timepicker, [ this[ 0 ] ].concat( otherArgs ) ); 561 } 562 return this.each( function() { 563 typeof options === "string" ? 564 $.timepicker[ "_" + options + "Datepicker" ]. 565 apply( $.timepicker, [ this ].concat( otherArgs ) ) : 566 $.timepicker._attachTimepicker( this, options ); 567 } ); 568 } 569 $.timepicker = new Timepicker(); 570 $.timepicker.initialized = false; 571 $.timepicker.uuid = new Date().getTime(); 572 $.timepicker.version = "1.0.0"; 573 574})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.