ui-jqueryui.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. var UIJQueryUI = function () {
  2. var handleDatePickers = function () {
  3. $("#ui_date_picker").datepicker();
  4. $("#ui_date_picker_with_button_bar").datepicker({
  5. showButtonPanel: true
  6. });
  7. $("#ui_date_picker_inline").datepicker();
  8. $("#ui_date_picker_change_year_month" ).datepicker({
  9. changeMonth: true,
  10. changeYear: true
  11. });
  12. $("#ui_date_picker_multiple").datepicker({
  13. numberOfMonths: 2,
  14. showButtonPanel: true
  15. });
  16. $( "#ui_date_picker_range_from" ).datepicker({
  17. defaultDate: "+1w",
  18. changeMonth: true,
  19. numberOfMonths: 2,
  20. onClose: function( selectedDate ) {
  21. $( "#ui_date_picker_range_to" ).datepicker( "option", "minDate", selectedDate );
  22. }
  23. });
  24. $( "#ui_date_picker_range_to" ).datepicker({
  25. defaultDate: "+1w",
  26. changeMonth: true,
  27. numberOfMonths: 2,
  28. onClose: function( selectedDate ) {
  29. $( "#ui_date_picker_range_from" ).datepicker( "option", "maxDate", selectedDate );
  30. }
  31. });
  32. $("#ui_date_picker_week_year" ).datepicker({
  33. showWeek: true,
  34. firstDay: 1
  35. });
  36. $("#ui_date_picker_trigger input").datepicker();
  37. $("#ui_date_picker_trigger .add-on").click(function(){
  38. $("#ui_date_picker_trigger input").datepicker("show");
  39. });
  40. }
  41. var handleDialogs = function () {
  42. // basic dialog1
  43. $( "#dialog_basic1" ).dialog({
  44. autoOpen: false,
  45. dialogClass: 'ui-dialog-yellow',
  46. show: {
  47. effect: "blind",
  48. duration: 500
  49. },
  50. hide: {
  51. effect: "explode",
  52. duration: 500
  53. }
  54. });
  55. $( "#basic_opener1").click(function() {
  56. $( "#dialog_basic1" ).dialog( "open" );
  57. $('.ui-dialog button').blur();// avoid button autofocus
  58. });
  59. // basic dialog2
  60. $( "#dialog_basic2" ).dialog({
  61. autoOpen: false,
  62. dialogClass: 'ui-dialog-purple',
  63. show: {
  64. effect: "blind",
  65. duration: 500
  66. },
  67. hide: {
  68. effect: "explode",
  69. duration: 500
  70. }
  71. });
  72. $( "#basic_opener2").click(function() {
  73. $( "#dialog_basic2" ).dialog( "open" );
  74. $('.ui-dialog button').blur();// avoid button autofocus
  75. });
  76. // basic dialog3
  77. $( "#dialog_basic3" ).dialog({
  78. autoOpen: false,
  79. dialogClass: 'ui-dialog-grey',
  80. show: {
  81. effect: "blind",
  82. duration: 500
  83. },
  84. hide: {
  85. effect: "explode",
  86. duration: 500
  87. }
  88. });
  89. $( "#basic_opener3").click(function() {
  90. $( "#dialog_basic3" ).dialog( "open" );
  91. $('.ui-dialog button').blur();// avoid button autofocus
  92. });
  93. // basic dialog4
  94. $( "#dialog_basic4" ).dialog({
  95. autoOpen: false,
  96. dialogClass: 'ui-dialog-red',
  97. show: {
  98. effect: "blind",
  99. duration: 500
  100. },
  101. hide: {
  102. effect: "explode",
  103. duration: 500
  104. }
  105. });
  106. $( "#basic_opener4").click(function() {
  107. $( "#dialog_basic4" ).dialog( "open" );
  108. $('.ui-dialog button').blur();// avoid button autofocus
  109. });
  110. // info dialog
  111. $("#dialog_info").dialog({
  112. dialogClass: 'ui-dialog-blue',
  113. autoOpen: false,
  114. resizable: false,
  115. height: 250,
  116. modal: true,
  117. buttons: [
  118. {
  119. "text" : "OK",
  120. 'class' : 'btn green',
  121. click: function() {
  122. $(this).dialog( "close" );
  123. }
  124. }
  125. ]
  126. });
  127. $( "#info_opener").click(function() {
  128. $( "#dialog_info" ).dialog( "open" );
  129. $('.ui-dialog button').blur();// avoid button autofocus
  130. });
  131. //confirm dialog
  132. $("#dialog_confirm" ).dialog({
  133. dialogClass: 'ui-dialog-green',
  134. autoOpen: false,
  135. resizable: false,
  136. height: 210,
  137. modal: true,
  138. buttons: [
  139. {
  140. 'class' : 'btn red',
  141. "text" : "Delete",
  142. click: function() {
  143. $(this).dialog( "close" );
  144. }
  145. },
  146. {
  147. 'class' : 'btn',
  148. "text" : "Cancel",
  149. click: function() {
  150. $(this).dialog( "close" );
  151. }
  152. }
  153. ]
  154. });
  155. $( "#confirm_opener").click(function() {
  156. $( "#dialog_confirm" ).dialog( "open" );
  157. $('.ui-dialog button').blur();// avoid button autofocus
  158. });
  159. }
  160. return {
  161. //main function to initiate the module
  162. init: function () {
  163. handleDatePickers();
  164. handleDialogs();
  165. }
  166. };
  167. }();