/projekty/list/files/resources/lib/datepicker/jquery.ui.datepicker.mobile.js

https://bitbucket.org/baniol/mobilang · JavaScript · 61 lines · 25 code · 9 blank · 27 comment · 0 complexity · eb6da64b3ffd65ae89b52c4305d99b94 MD5 · raw file

  1. /*
  2. * jQuery Mobile Framework : temporary extension to port jQuery UI's datepicker for mobile
  3. * Copyright (c) jQuery Project
  4. * Dual licensed under the MIT or GPL Version 2 licenses.
  5. * http://jquery.org/license
  6. */
  7. (function($, undefined ) {
  8. //cache previous datepicker ui method
  9. var prevDp = $.fn.datepicker;
  10. //rewrite datepicker
  11. $.fn.datepicker = function( options ){
  12. var dp = this;
  13. //call cached datepicker plugin
  14. prevDp.call( this, options );
  15. //extend with some dom manipulation to update the markup for jQM
  16. //call immediately
  17. function updateDatepicker(){
  18. $( ".ui-datepicker-header", dp ).addClass("ui-body-c ui-corner-top").removeClass("ui-corner-all");
  19. $( ".ui-datepicker-prev, .ui-datepicker-next", dp ).attr("href", "#");
  20. $( ".ui-datepicker-prev", dp ).buttonMarkup({iconpos: "notext", icon: "arrow-l", shadow: true, corners: true});
  21. $( ".ui-datepicker-next", dp ).buttonMarkup({iconpos: "notext", icon: "arrow-r", shadow: true, corners: true});
  22. $( ".ui-datepicker-calendar th", dp ).addClass("ui-bar-c");
  23. $( ".ui-datepicker-calendar td", dp ).addClass("ui-body-c");
  24. $( ".ui-datepicker-calendar a", dp ).buttonMarkup({corners: false, shadow: false});
  25. $( ".ui-datepicker-calendar a.ui-state-active", dp ).addClass("ui-btn-active"); // selected date
  26. $( ".ui-datepicker-calendar a.ui-state-highlight", dp ).addClass("ui-btn-up-e"); // today"s date
  27. $( ".ui-datepicker-calendar .ui-btn", dp ).each(function(){
  28. var el = $(this);
  29. // remove extra button markup - necessary for date value to be interpreted correctly
  30. el.html( el.find( ".ui-btn-text" ).text() );
  31. });
  32. };
  33. //update now
  34. updateDatepicker();
  35. // and on click
  36. $( dp ).click( updateDatepicker );
  37. //return jqm obj
  38. return this;
  39. };
  40. //bind to pagecreate to automatically enhance date inputs
  41. /*
  42. $( ".ui-page" ).live( "pagecreate", function(){
  43. $( "input[type='date'], input:jqmData(type='date')", this ).each(function(){
  44. if($(this).attr("data-options")!=undefined){
  45. dataPickerOptions=$.parseJSON( $(this).attr("data-options") );
  46. $(this).after( $( "<div />" ).datepicker(dataPickerOptions) );
  47. }else{
  48. $(this).after( $( "<div />" ).datepicker({ altField: "#" + $(this).attr( "id" ), showOtherMonths: true }) );
  49. }
  50. });
  51. });*/
  52. })( jQuery );