spiderfw 0.6.27 → 0.6.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/CHANGELOG +4 -0
  2. data/VERSION +1 -1
  3. data/apps/core/admin/admin.rb +6 -2
  4. data/apps/core/admin/controllers/admin_controller.rb +10 -3
  5. data/apps/core/admin/controllers/app_admin_controller.rb +15 -0
  6. data/apps/core/admin/public/css/sass/admin.css +29 -33
  7. data/apps/core/admin/public/css/sass/grid.css +14 -0
  8. data/apps/core/admin/public/sass/admin.scss +3 -2
  9. data/apps/core/admin/views/admin.layout.shtml +1 -0
  10. data/apps/core/auth/controllers/mixins/auth_helper.rb +15 -5
  11. data/apps/core/components/assets.rb +60 -41
  12. data/apps/core/components/public/js/jquery/jquery-1.8.3.js +9472 -0
  13. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/jquery.ui.core.js +1 -1
  14. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/button_bg.png +0 -0
  15. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/datepicker.gif +0 -0
  16. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/icon_sprite.png +0 -0
  17. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/progress_bar.gif +0 -0
  18. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/slider_h_bg.gif +0 -0
  19. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/slider_handles.png +0 -0
  20. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/slider_v_bg.gif +0 -0
  21. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/tab_bg.gif +0 -0
  22. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/the_gradient.gif +0 -0
  23. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-anim_basic_16x16.gif +0 -0
  24. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  25. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  26. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_flat_10_000000_40x100.png +0 -0
  27. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  28. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  29. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  30. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  31. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  32. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  33. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-icons_222222_256x240.png +0 -0
  34. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-icons_228ef1_256x240.png +0 -0
  35. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-icons_ef8c08_256x240.png +0 -0
  36. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-icons_ffd27a_256x240.png +0 -0
  37. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/images/ui-icons_ffffff_256x240.png +0 -0
  38. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/css/Aristo/jquery-ui.custom.css +528 -0
  39. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-af.js +23 -0
  40. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ar-DZ.js +23 -0
  41. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ar.js +23 -0
  42. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-az.js +23 -0
  43. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-be.js +23 -0
  44. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-bg.js +24 -0
  45. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-bs.js +23 -0
  46. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ca.js +23 -0
  47. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-cs.js +23 -0
  48. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-cy-GB.js +23 -0
  49. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-da.js +23 -0
  50. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-de.js +23 -0
  51. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-el.js +23 -0
  52. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-en-AU.js +23 -0
  53. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-en-GB.js +23 -0
  54. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-en-NZ.js +23 -0
  55. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-eo.js +23 -0
  56. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-es.js +23 -0
  57. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-et.js +23 -0
  58. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-eu.js +23 -0
  59. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fa.js +59 -0
  60. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fi.js +23 -0
  61. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fo.js +23 -0
  62. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fr-CA.js +23 -0
  63. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fr-CH.js +23 -0
  64. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-fr.js +25 -0
  65. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-gl.js +23 -0
  66. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-he.js +23 -0
  67. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-hi.js +23 -0
  68. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-hr.js +23 -0
  69. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-hu.js +23 -0
  70. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-hy.js +23 -0
  71. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-id.js +23 -0
  72. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-is.js +23 -0
  73. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-it.js +23 -0
  74. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ja.js +23 -0
  75. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ka.js +21 -0
  76. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-kk.js +23 -0
  77. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-km.js +23 -0
  78. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ko.js +23 -0
  79. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ky.js +24 -0
  80. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-lb.js +23 -0
  81. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-lt.js +23 -0
  82. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-lv.js +23 -0
  83. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-mk.js +23 -0
  84. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ml.js +23 -0
  85. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ms.js +23 -0
  86. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-nb.js +22 -0
  87. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-nl-BE.js +23 -0
  88. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-nl.js +23 -0
  89. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-nn.js +22 -0
  90. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-no.js +23 -0
  91. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-pl.js +23 -0
  92. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-pt-BR.js +23 -0
  93. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-pt.js +22 -0
  94. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-rm.js +21 -0
  95. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ro.js +26 -0
  96. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ru.js +23 -0
  97. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sk.js +23 -0
  98. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sl.js +24 -0
  99. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sq.js +23 -0
  100. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sr-SR.js +23 -0
  101. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sr.js +23 -0
  102. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-sv.js +23 -0
  103. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-ta.js +23 -0
  104. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-th.js +23 -0
  105. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-tj.js +23 -0
  106. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-tr.js +23 -0
  107. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-uk.js +24 -0
  108. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-vi.js +23 -0
  109. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-zh-CN.js +23 -0
  110. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-zh-HK.js +23 -0
  111. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/i18n/jquery.ui.datepicker-zh-TW.js +23 -0
  112. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.accordion.js +571 -0
  113. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.autocomplete.js +614 -0
  114. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.button.js +419 -0
  115. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.core.js +324 -0
  116. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.datepicker.js +2044 -0
  117. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.dialog.js +767 -0
  118. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.draggable.js +941 -0
  119. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.droppable.js +364 -0
  120. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-blind.js +82 -0
  121. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-bounce.js +113 -0
  122. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-clip.js +67 -0
  123. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-drop.js +65 -0
  124. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-explode.js +97 -0
  125. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-fade.js +30 -0
  126. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-fold.js +76 -0
  127. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-highlight.js +50 -0
  128. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-pulsate.js +63 -0
  129. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-scale.js +318 -0
  130. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-shake.js +74 -0
  131. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-slide.js +64 -0
  132. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect-transfer.js +47 -0
  133. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.effect.js +1259 -0
  134. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.menu.js +621 -0
  135. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.mouse.js +169 -0
  136. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.position.js +497 -0
  137. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.progressbar.js +145 -0
  138. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.resizable.js +963 -0
  139. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.selectable.js +269 -0
  140. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.slider.js +641 -0
  141. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.sortable.js +1236 -0
  142. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.spinner.js +492 -0
  143. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.tabs.js +846 -0
  144. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.tooltip.js +400 -0
  145. data/apps/core/components/public/js/jquery/jquery-ui-1.9.2/ui/jquery.ui.widget.js +521 -0
  146. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.js +3 -1
  147. data/apps/core/components/public/js/plugins/sortable.js +5 -5
  148. data/apps/core/components/widgets/month_calendar/month_calendar.shtml +1 -1
  149. data/apps/core/components/widgets/table/table.rb +18 -5
  150. data/apps/core/forms/public/date_time.js +3 -0
  151. data/apps/core/forms/widgets/form/form.rb +1 -1
  152. data/apps/core/forms/widgets/inputs/date_time/date_time.rb +5 -0
  153. data/apps/core/forms/widgets/inputs/file_input/file_input.rb +1 -1
  154. data/apps/core/forms/widgets/inputs/select/select.rb +11 -16
  155. data/apps/messenger/config/options.rb +5 -5
  156. data/apps/messenger/controllers/messenger_admin_controller.rb +1 -1
  157. data/apps/messenger/controllers/messenger_controller.rb +1 -1
  158. data/apps/messenger/lib/backends/mobyt.rb +1 -1
  159. data/apps/messenger/messenger.rb +4 -2
  160. data/apps/messenger/views/admin/index.shtml +1 -1
  161. data/lib/spiderfw/controller/dispatcher.rb +5 -5
  162. data/lib/spiderfw/controller/mixins/visual.rb +10 -8
  163. data/lib/spiderfw/http/http.rb +1 -1
  164. data/lib/spiderfw/model/base_model.rb +2 -2
  165. data/lib/spiderfw/model/mappers/db_mapper.rb +4 -2
  166. data/lib/spiderfw/model/mixins/tree.rb +4 -5
  167. data/lib/spiderfw/model/model.rb +2 -1
  168. data/lib/spiderfw/model/storage/db/adapters/mysql.rb +18 -20
  169. data/lib/spiderfw/model/storage/db/adapters/oracle.rb +1 -1
  170. data/lib/spiderfw/spider.rb +5 -1
  171. data/lib/spiderfw/templates/blocks/layout_assets.rb +5 -2
  172. data/lib/spiderfw/templates/layout.rb +7 -3
  173. data/lib/spiderfw/templates/template.rb +8 -1
  174. data/lib/spiderfw/utils/monkey/date_time.rb +7 -5
  175. data/lib/spiderfw/utils/monkey/module.rb +12 -0
  176. metadata +373 -157
  177. data/lib/spiderfw/model/storage/db/connectors/mysql.rb +0 -16
  178. data/lib/spiderfw/model/storage/db/connectors/mysql2.rb +0 -9
  179. /data/apps/core/admin/public/img/{icons-s845a69dd9f.png → icons-s8b18557db6.png} +0 -0
@@ -0,0 +1,621 @@
1
+ /*!
2
+ * jQuery UI Menu @VERSION
3
+ * http://jqueryui.com
4
+ *
5
+ * Copyright 2012 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
7
+ * http://jquery.org/license
8
+ *
9
+ * http://api.jqueryui.com/menu/
10
+ *
11
+ * Depends:
12
+ * jquery.ui.core.js
13
+ * jquery.ui.widget.js
14
+ * jquery.ui.position.js
15
+ */
16
+ (function( $, undefined ) {
17
+
18
+ $.widget( "ui.menu", {
19
+ version: "@VERSION",
20
+ defaultElement: "<ul>",
21
+ delay: 300,
22
+ options: {
23
+ icons: {
24
+ submenu: "ui-icon-carat-1-e"
25
+ },
26
+ menus: "ul",
27
+ position: {
28
+ my: "left top",
29
+ at: "right top"
30
+ },
31
+ role: "menu",
32
+
33
+ // callbacks
34
+ blur: null,
35
+ focus: null,
36
+ select: null
37
+ },
38
+
39
+ _create: function() {
40
+ this.activeMenu = this.element;
41
+ // flag used to prevent firing of the click handler
42
+ // as the event bubbles up through nested menus
43
+ this.mouseHandled = false;
44
+ this.element
45
+ .uniqueId()
46
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
47
+ .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
48
+ .attr({
49
+ role: this.options.role,
50
+ tabIndex: 0
51
+ })
52
+ // need to catch all clicks on disabled menu
53
+ // not possible through _on
54
+ .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
55
+ if ( this.options.disabled ) {
56
+ event.preventDefault();
57
+ }
58
+ }, this ));
59
+
60
+ if ( this.options.disabled ) {
61
+ this.element
62
+ .addClass( "ui-state-disabled" )
63
+ .attr( "aria-disabled", "true" );
64
+ }
65
+
66
+ this._on({
67
+ // Prevent focus from sticking to links inside menu after clicking
68
+ // them (focus should always stay on UL during navigation).
69
+ "mousedown .ui-menu-item > a": function( event ) {
70
+ event.preventDefault();
71
+ },
72
+ "click .ui-state-disabled > a": function( event ) {
73
+ event.preventDefault();
74
+ },
75
+ "click .ui-menu-item:has(a)": function( event ) {
76
+ var target = $( event.target ).closest( ".ui-menu-item" );
77
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
78
+ this.mouseHandled = true;
79
+
80
+ this.select( event );
81
+ // Open submenu on click
82
+ if ( target.has( ".ui-menu" ).length ) {
83
+ this.expand( event );
84
+ } else if ( !this.element.is( ":focus" ) ) {
85
+ // Redirect focus to the menu
86
+ this.element.trigger( "focus", [ true ] );
87
+
88
+ // If the active item is on the top level, let it stay active.
89
+ // Otherwise, blur the active item since it is no longer visible.
90
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
91
+ clearTimeout( this.timer );
92
+ }
93
+ }
94
+ }
95
+ },
96
+ "mouseenter .ui-menu-item": function( event ) {
97
+ var target = $( event.currentTarget );
98
+ // Remove ui-state-active class from siblings of the newly focused menu item
99
+ // to avoid a jump caused by adjacent elements both having a class with a border
100
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
101
+ this.focus( event, target );
102
+ },
103
+ mouseleave: "collapseAll",
104
+ "mouseleave .ui-menu": "collapseAll",
105
+ focus: function( event, keepActiveItem ) {
106
+ // If there's already an active item, keep it active
107
+ // If not, activate the first item
108
+ var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
109
+
110
+ if ( !keepActiveItem ) {
111
+ this.focus( event, item );
112
+ }
113
+ },
114
+ blur: function( event ) {
115
+ this._delay(function() {
116
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
117
+ this.collapseAll( event );
118
+ }
119
+ });
120
+ },
121
+ keydown: "_keydown"
122
+ });
123
+
124
+ this.refresh();
125
+
126
+ // Clicks outside of a menu collapse any open menus
127
+ this._on( this.document, {
128
+ click: function( event ) {
129
+ if ( !$( event.target ).closest( ".ui-menu" ).length ) {
130
+ this.collapseAll( event );
131
+ }
132
+
133
+ // Reset the mouseHandled flag
134
+ this.mouseHandled = false;
135
+ }
136
+ });
137
+ },
138
+
139
+ _destroy: function() {
140
+ // Destroy (sub)menus
141
+ this.element
142
+ .removeAttr( "aria-activedescendant" )
143
+ .find( ".ui-menu" ).addBack()
144
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
145
+ .removeAttr( "role" )
146
+ .removeAttr( "tabIndex" )
147
+ .removeAttr( "aria-labelledby" )
148
+ .removeAttr( "aria-expanded" )
149
+ .removeAttr( "aria-hidden" )
150
+ .removeAttr( "aria-disabled" )
151
+ .removeUniqueId()
152
+ .show();
153
+
154
+ // Destroy menu items
155
+ this.element.find( ".ui-menu-item" )
156
+ .removeClass( "ui-menu-item" )
157
+ .removeAttr( "role" )
158
+ .removeAttr( "aria-disabled" )
159
+ .children( "a" )
160
+ .removeUniqueId()
161
+ .removeClass( "ui-corner-all ui-state-hover" )
162
+ .removeAttr( "tabIndex" )
163
+ .removeAttr( "role" )
164
+ .removeAttr( "aria-haspopup" )
165
+ .children().each( function() {
166
+ var elem = $( this );
167
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
168
+ elem.remove();
169
+ }
170
+ });
171
+
172
+ // Destroy menu dividers
173
+ this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
174
+ },
175
+
176
+ _keydown: function( event ) {
177
+ /*jshint maxcomplexity:20*/
178
+ var match, prev, character, skip, regex,
179
+ preventDefault = true;
180
+
181
+ function escape( value ) {
182
+ return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
183
+ }
184
+
185
+ switch ( event.keyCode ) {
186
+ case $.ui.keyCode.PAGE_UP:
187
+ this.previousPage( event );
188
+ break;
189
+ case $.ui.keyCode.PAGE_DOWN:
190
+ this.nextPage( event );
191
+ break;
192
+ case $.ui.keyCode.HOME:
193
+ this._move( "first", "first", event );
194
+ break;
195
+ case $.ui.keyCode.END:
196
+ this._move( "last", "last", event );
197
+ break;
198
+ case $.ui.keyCode.UP:
199
+ this.previous( event );
200
+ break;
201
+ case $.ui.keyCode.DOWN:
202
+ this.next( event );
203
+ break;
204
+ case $.ui.keyCode.LEFT:
205
+ this.collapse( event );
206
+ break;
207
+ case $.ui.keyCode.RIGHT:
208
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
209
+ this.expand( event );
210
+ }
211
+ break;
212
+ case $.ui.keyCode.ENTER:
213
+ case $.ui.keyCode.SPACE:
214
+ this._activate( event );
215
+ break;
216
+ case $.ui.keyCode.ESCAPE:
217
+ this.collapse( event );
218
+ break;
219
+ default:
220
+ preventDefault = false;
221
+ prev = this.previousFilter || "";
222
+ character = String.fromCharCode( event.keyCode );
223
+ skip = false;
224
+
225
+ clearTimeout( this.filterTimer );
226
+
227
+ if ( character === prev ) {
228
+ skip = true;
229
+ } else {
230
+ character = prev + character;
231
+ }
232
+
233
+ regex = new RegExp( "^" + escape( character ), "i" );
234
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
235
+ return regex.test( $( this ).children( "a" ).text() );
236
+ });
237
+ match = skip && match.index( this.active.next() ) !== -1 ?
238
+ this.active.nextAll( ".ui-menu-item" ) :
239
+ match;
240
+
241
+ // If no matches on the current filter, reset to the last character pressed
242
+ // to move down the menu to the first item that starts with that character
243
+ if ( !match.length ) {
244
+ character = String.fromCharCode( event.keyCode );
245
+ regex = new RegExp( "^" + escape( character ), "i" );
246
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
247
+ return regex.test( $( this ).children( "a" ).text() );
248
+ });
249
+ }
250
+
251
+ if ( match.length ) {
252
+ this.focus( event, match );
253
+ if ( match.length > 1 ) {
254
+ this.previousFilter = character;
255
+ this.filterTimer = this._delay(function() {
256
+ delete this.previousFilter;
257
+ }, 1000 );
258
+ } else {
259
+ delete this.previousFilter;
260
+ }
261
+ } else {
262
+ delete this.previousFilter;
263
+ }
264
+ }
265
+
266
+ if ( preventDefault ) {
267
+ event.preventDefault();
268
+ }
269
+ },
270
+
271
+ _activate: function( event ) {
272
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
273
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
274
+ this.expand( event );
275
+ } else {
276
+ this.select( event );
277
+ }
278
+ }
279
+ },
280
+
281
+ refresh: function() {
282
+ var menus,
283
+ icon = this.options.icons.submenu,
284
+ submenus = this.element.find( this.options.menus );
285
+
286
+ // Initialize nested menus
287
+ submenus.filter( ":not(.ui-menu)" )
288
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
289
+ .hide()
290
+ .attr({
291
+ role: this.options.role,
292
+ "aria-hidden": "true",
293
+ "aria-expanded": "false"
294
+ })
295
+ .each(function() {
296
+ var menu = $( this ),
297
+ item = menu.prev( "a" ),
298
+ submenuCarat = $( "<span>" )
299
+ .addClass( "ui-menu-icon ui-icon " + icon )
300
+ .data( "ui-menu-submenu-carat", true );
301
+
302
+ item
303
+ .attr( "aria-haspopup", "true" )
304
+ .prepend( submenuCarat );
305
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
306
+ });
307
+
308
+ menus = submenus.add( this.element );
309
+
310
+ // Don't refresh list items that are already adapted
311
+ menus.children( ":not(.ui-menu-item):has(a)" )
312
+ .addClass( "ui-menu-item" )
313
+ .attr( "role", "presentation" )
314
+ .children( "a" )
315
+ .uniqueId()
316
+ .addClass( "ui-corner-all" )
317
+ .attr({
318
+ tabIndex: -1,
319
+ role: this._itemRole()
320
+ });
321
+
322
+ // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
323
+ menus.children( ":not(.ui-menu-item)" ).each(function() {
324
+ var item = $( this );
325
+ // hyphen, em dash, en dash
326
+ if ( !/[^\-—–\s]/.test( item.text() ) ) {
327
+ item.addClass( "ui-widget-content ui-menu-divider" );
328
+ }
329
+ });
330
+
331
+ // Add aria-disabled attribute to any disabled menu item
332
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
333
+
334
+ // If the active item has been removed, blur the menu
335
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
336
+ this.blur();
337
+ }
338
+ },
339
+
340
+ _itemRole: function() {
341
+ return {
342
+ menu: "menuitem",
343
+ listbox: "option"
344
+ }[ this.options.role ];
345
+ },
346
+
347
+ _setOption: function( key, value ) {
348
+ if ( key === "icons" ) {
349
+ this.element.find( ".ui-menu-icon" )
350
+ .removeClass( this.options.icons.submenu )
351
+ .addClass( value.submenu );
352
+ }
353
+ this._super( key, value );
354
+ },
355
+
356
+ focus: function( event, item ) {
357
+ var nested, focused;
358
+ this.blur( event, event && event.type === "focus" );
359
+
360
+ this._scrollIntoView( item );
361
+
362
+ this.active = item.first();
363
+ focused = this.active.children( "a" ).addClass( "ui-state-focus" );
364
+ // Only update aria-activedescendant if there's a role
365
+ // otherwise we assume focus is managed elsewhere
366
+ if ( this.options.role ) {
367
+ this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
368
+ }
369
+
370
+ // Highlight active parent menu item, if any
371
+ this.active
372
+ .parent()
373
+ .closest( ".ui-menu-item" )
374
+ .children( "a:first" )
375
+ .addClass( "ui-state-active" );
376
+
377
+ if ( event && event.type === "keydown" ) {
378
+ this._close();
379
+ } else {
380
+ this.timer = this._delay(function() {
381
+ this._close();
382
+ }, this.delay );
383
+ }
384
+
385
+ nested = item.children( ".ui-menu" );
386
+ if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
387
+ this._startOpening(nested);
388
+ }
389
+ this.activeMenu = item.parent();
390
+
391
+ this._trigger( "focus", event, { item: item } );
392
+ },
393
+
394
+ _scrollIntoView: function( item ) {
395
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
396
+ if ( this._hasScroll() ) {
397
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
398
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
399
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
400
+ scroll = this.activeMenu.scrollTop();
401
+ elementHeight = this.activeMenu.height();
402
+ itemHeight = item.height();
403
+
404
+ if ( offset < 0 ) {
405
+ this.activeMenu.scrollTop( scroll + offset );
406
+ } else if ( offset + itemHeight > elementHeight ) {
407
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
408
+ }
409
+ }
410
+ },
411
+
412
+ blur: function( event, fromFocus ) {
413
+ if ( !fromFocus ) {
414
+ clearTimeout( this.timer );
415
+ }
416
+
417
+ if ( !this.active ) {
418
+ return;
419
+ }
420
+
421
+ this.active.children( "a" ).removeClass( "ui-state-focus" );
422
+ this.active = null;
423
+
424
+ this._trigger( "blur", event, { item: this.active } );
425
+ },
426
+
427
+ _startOpening: function( submenu ) {
428
+ clearTimeout( this.timer );
429
+
430
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
431
+ // shift in the submenu position when mousing over the carat icon
432
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
433
+ return;
434
+ }
435
+
436
+ this.timer = this._delay(function() {
437
+ this._close();
438
+ this._open( submenu );
439
+ }, this.delay );
440
+ },
441
+
442
+ _open: function( submenu ) {
443
+ var position = $.extend({
444
+ of: this.active
445
+ }, this.options.position );
446
+
447
+ clearTimeout( this.timer );
448
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
449
+ .hide()
450
+ .attr( "aria-hidden", "true" );
451
+
452
+ submenu
453
+ .show()
454
+ .removeAttr( "aria-hidden" )
455
+ .attr( "aria-expanded", "true" )
456
+ .position( position );
457
+ },
458
+
459
+ collapseAll: function( event, all ) {
460
+ clearTimeout( this.timer );
461
+ this.timer = this._delay(function() {
462
+ // If we were passed an event, look for the submenu that contains the event
463
+ var currentMenu = all ? this.element :
464
+ $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
465
+
466
+ // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
467
+ if ( !currentMenu.length ) {
468
+ currentMenu = this.element;
469
+ }
470
+
471
+ this._close( currentMenu );
472
+
473
+ this.blur( event );
474
+ this.activeMenu = currentMenu;
475
+ }, this.delay );
476
+ },
477
+
478
+ // With no arguments, closes the currently active menu - if nothing is active
479
+ // it closes all menus. If passed an argument, it will search for menus BELOW
480
+ _close: function( startMenu ) {
481
+ if ( !startMenu ) {
482
+ startMenu = this.active ? this.active.parent() : this.element;
483
+ }
484
+
485
+ startMenu
486
+ .find( ".ui-menu" )
487
+ .hide()
488
+ .attr( "aria-hidden", "true" )
489
+ .attr( "aria-expanded", "false" )
490
+ .end()
491
+ .find( "a.ui-state-active" )
492
+ .removeClass( "ui-state-active" );
493
+ },
494
+
495
+ collapse: function( event ) {
496
+ var newItem = this.active &&
497
+ this.active.parent().closest( ".ui-menu-item", this.element );
498
+ if ( newItem && newItem.length ) {
499
+ this._close();
500
+ this.focus( event, newItem );
501
+ }
502
+ },
503
+
504
+ expand: function( event ) {
505
+ var newItem = this.active &&
506
+ this.active
507
+ .children( ".ui-menu " )
508
+ .children( ".ui-menu-item" )
509
+ .first();
510
+
511
+ if ( newItem && newItem.length ) {
512
+ this._open( newItem.parent() );
513
+
514
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
515
+ this._delay(function() {
516
+ this.focus( event, newItem );
517
+ });
518
+ }
519
+ },
520
+
521
+ next: function( event ) {
522
+ this._move( "next", "first", event );
523
+ },
524
+
525
+ previous: function( event ) {
526
+ this._move( "prev", "last", event );
527
+ },
528
+
529
+ isFirstItem: function() {
530
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
531
+ },
532
+
533
+ isLastItem: function() {
534
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
535
+ },
536
+
537
+ _move: function( direction, filter, event ) {
538
+ var next;
539
+ if ( this.active ) {
540
+ if ( direction === "first" || direction === "last" ) {
541
+ next = this.active
542
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
543
+ .eq( -1 );
544
+ } else {
545
+ next = this.active
546
+ [ direction + "All" ]( ".ui-menu-item" )
547
+ .eq( 0 );
548
+ }
549
+ }
550
+ if ( !next || !next.length || !this.active ) {
551
+ next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
552
+ }
553
+
554
+ this.focus( event, next );
555
+ },
556
+
557
+ nextPage: function( event ) {
558
+ var item, base, height;
559
+
560
+ if ( !this.active ) {
561
+ this.next( event );
562
+ return;
563
+ }
564
+ if ( this.isLastItem() ) {
565
+ return;
566
+ }
567
+ if ( this._hasScroll() ) {
568
+ base = this.active.offset().top;
569
+ height = this.element.height();
570
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
571
+ item = $( this );
572
+ return item.offset().top - base - height < 0;
573
+ });
574
+
575
+ this.focus( event, item );
576
+ } else {
577
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
578
+ [ !this.active ? "first" : "last" ]() );
579
+ }
580
+ },
581
+
582
+ previousPage: function( event ) {
583
+ var item, base, height;
584
+ if ( !this.active ) {
585
+ this.next( event );
586
+ return;
587
+ }
588
+ if ( this.isFirstItem() ) {
589
+ return;
590
+ }
591
+ if ( this._hasScroll() ) {
592
+ base = this.active.offset().top;
593
+ height = this.element.height();
594
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
595
+ item = $( this );
596
+ return item.offset().top - base + height > 0;
597
+ });
598
+
599
+ this.focus( event, item );
600
+ } else {
601
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
602
+ }
603
+ },
604
+
605
+ _hasScroll: function() {
606
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
607
+ },
608
+
609
+ select: function( event ) {
610
+ // TODO: It should never be possible to not have an active item at this
611
+ // point, but the tests don't trigger mouseenter before click.
612
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
613
+ var ui = { item: this.active };
614
+ if ( !this.active.has( ".ui-menu" ).length ) {
615
+ this.collapseAll( event, true );
616
+ }
617
+ this._trigger( "select", event, ui );
618
+ }
619
+ });
620
+
621
+ }( jQuery ));