bookyt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) hide show
  1. data/app/assets/images/16x16/add.png +0 -0
  2. data/app/assets/images/16x16/alert.png +0 -0
  3. data/app/assets/images/16x16/combolink.png +0 -0
  4. data/app/assets/images/16x16/copy.png +0 -0
  5. data/app/assets/images/16x16/delete.png +0 -0
  6. data/app/assets/images/16x16/edit.png +0 -0
  7. data/app/assets/images/16x16/filter.png +0 -0
  8. data/app/assets/images/16x16/index.png +0 -0
  9. data/app/assets/images/16x16/notice.png +0 -0
  10. data/app/assets/images/16x16/pdf.png +0 -0
  11. data/app/assets/images/16x16/print.png +0 -0
  12. data/app/assets/images/16x16/show.png +0 -0
  13. data/app/assets/images/22x22/arrow-right.png +0 -0
  14. data/app/assets/images/22x22/edit.png +0 -0
  15. data/app/assets/images/22x22/insert_booking.png +0 -0
  16. data/app/assets/images/22x22/remove.png +0 -0
  17. data/app/assets/images/32x32/edit.png +0 -0
  18. data/app/assets/images/32x32/remove.png +0 -0
  19. data/app/assets/images/48x48/accounting.png +0 -0
  20. data/app/assets/images/48x48/basic_claims_data.png +0 -0
  21. data/app/assets/images/48x48/contacts.png +0 -0
  22. data/app/assets/images/48x48/invoicing.png +0 -0
  23. data/app/assets/images/48x48/nav_users.png +0 -0
  24. data/app/assets/images/48x48/settings.png +0 -0
  25. data/app/assets/images/48x48/store.png +0 -0
  26. data/app/assets/images/button_bg.png +0 -0
  27. data/app/assets/images/crystal-icons/16x16/filter.png +0 -0
  28. data/app/assets/images/down.png +0 -0
  29. data/app/assets/images/favicon.ico +0 -0
  30. data/app/assets/images/flavour-extended/48x48/invoice.png +0 -0
  31. data/app/assets/images/free-business-desktop-icons/48x48/business.png +0 -0
  32. data/app/assets/images/gnome-web-icons/48x48/Gnome-X-Office-Address-Book-48.png +0 -0
  33. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  34. data/app/assets/images/jquery-ui/ui-bg_flat_55_fbec88_40x100.png +0 -0
  35. data/app/assets/images/jquery-ui/ui-bg_glass_75_759fcf_1x400.png +0 -0
  36. data/app/assets/images/jquery-ui/ui-bg_glass_85_aeb9cf_1x400.png +0 -0
  37. data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  38. data/app/assets/images/jquery-ui/ui-bg_gloss-wave_55_aeb9cf_500x100.png +0 -0
  39. data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_759fcf_1x100.png +0 -0
  40. data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_f6f6f6_1x100.png +0 -0
  41. data/app/assets/images/jquery-ui/ui-icons_217bc0_256x240.png +0 -0
  42. data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  43. data/app/assets/images/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
  44. data/app/assets/images/jquery-ui/ui-icons_6da8d5_256x240.png +0 -0
  45. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  46. data/app/assets/images/jquery-ui/ui-icons_d8e7f3_256x240.png +0 -0
  47. data/app/assets/images/jquery-ui/ui-icons_f9bd01_256x240.png +0 -0
  48. data/app/assets/images/jquery/tooltip/black_arrow.png +0 -0
  49. data/app/assets/images/letter-logo.alpha.png +0 -0
  50. data/app/assets/images/letter-logo.big.png +0 -0
  51. data/app/assets/images/letter-logo.orig.png +0 -0
  52. data/app/assets/images/letter-logo.png +0 -0
  53. data/app/assets/images/loading.gif +0 -0
  54. data/app/assets/images/logo.png +0 -0
  55. data/app/assets/images/oxygen-icons/16x16/application-pdf.png +0 -0
  56. data/app/assets/images/oxygen-icons/16x16/document-preview.png +0 -0
  57. data/app/assets/images/oxygen-icons/16x16/document-print.png +0 -0
  58. data/app/assets/images/oxygen-icons/16x16/edit-copy.png +0 -0
  59. data/app/assets/images/oxygen-icons/16x16/go-next.png +0 -0
  60. data/app/assets/images/oxygen-icons/16x16/mail-mark-notjunk.png +0 -0
  61. data/app/assets/images/oxygen-icons/16x16/status_unknown.png +0 -0
  62. data/app/assets/images/oxygen-icons/48x48/system-users.png +0 -0
  63. data/app/assets/images/rails.png +0 -0
  64. data/app/assets/images/up.png +0 -0
  65. data/app/assets/javascripts/application.js +49 -0
  66. data/app/assets/javascripts/cyt.js +86 -0
  67. data/app/assets/javascripts/jquery-ui.js +11437 -0
  68. data/app/assets/javascripts/jquery.dirtyform.js +242 -0
  69. data/app/assets/javascripts/jquery.form.js +785 -0
  70. data/app/assets/javascripts/jquery.js +8936 -0
  71. data/app/assets/javascripts/jquery.meio.mask.js +683 -0
  72. data/app/assets/javascripts/jquery.remotipart.js +46 -0
  73. data/app/assets/javascripts/jquery.ui.combobox.js +77 -0
  74. data/app/assets/javascripts/jquery_ujs.js +316 -0
  75. data/app/assets/javascripts/nested_form.js +51 -0
  76. data/app/assets/javascripts/tooltip.js +343 -0
  77. data/app/assets/stylesheets/.gitkeep +0 -0
  78. data/app/assets/stylesheets/ie.scss +16 -0
  79. data/app/assets/stylesheets/ie6.scss +4 -0
  80. data/app/assets/stylesheets/partials/_base.sass +39 -0
  81. data/app/assets/stylesheets/partials/_content.sass +60 -0
  82. data/app/assets/stylesheets/partials/_jquery.sass +2 -0
  83. data/app/assets/stylesheets/partials/_layout.sass +21 -0
  84. data/app/assets/stylesheets/partials/_sidebar.sass +5 -0
  85. data/app/assets/stylesheets/partials/content/_accounting.sass +41 -0
  86. data/app/assets/stylesheets/partials/content/_ajax_indicator.sass +28 -0
  87. data/app/assets/stylesheets/partials/content/_app.sass +43 -0
  88. data/app/assets/stylesheets/partials/content/_combobox.sass +8 -0
  89. data/app/assets/stylesheets/partials/content/_cyt.sass +200 -0
  90. data/app/assets/stylesheets/partials/content/_fancy_buttons.sass +10 -0
  91. data/app/assets/stylesheets/partials/content/_flash_errors.sass +46 -0
  92. data/app/assets/stylesheets/partials/content/_form_view.sass +20 -0
  93. data/app/assets/stylesheets/partials/content/_icons.sass +35 -0
  94. data/app/assets/stylesheets/partials/content/_invoice.sass +6 -0
  95. data/app/assets/stylesheets/partials/content/_overview.sass +40 -0
  96. data/app/assets/stylesheets/partials/content/_pagination.sass +61 -0
  97. data/app/assets/stylesheets/partials/content/_person.sass +5 -0
  98. data/app/assets/stylesheets/partials/content/_scaffold.sass +67 -0
  99. data/app/assets/stylesheets/partials/content/_table_list.sass +26 -0
  100. data/app/assets/stylesheets/partials/content/formtastic/_formtastic.sass +201 -0
  101. data/app/assets/stylesheets/partials/content/formtastic/_formtastic_cyt.sass +90 -0
  102. data/app/assets/stylesheets/partials/formtastic/_custom_fields.sass +2 -0
  103. data/app/assets/stylesheets/partials/formtastic/_formtastic_base.sass +652 -0
  104. data/app/assets/stylesheets/partials/jquery/_jquery_ui.sass +1461 -0
  105. data/app/assets/stylesheets/partials/jquery/_tooltip.sass +21 -0
  106. data/app/assets/stylesheets/partials/layout/_header.sass +29 -0
  107. data/app/assets/stylesheets/partials/layout/_navigation.sass +2 -0
  108. data/app/assets/stylesheets/partials/layout/navigation/_main.sass +34 -0
  109. data/app/assets/stylesheets/partials/layout/navigation/_sidebar.sass +18 -0
  110. data/app/assets/stylesheets/partials/print/_app.sass +21 -0
  111. data/app/assets/stylesheets/partials/print/_layout.sass +24 -0
  112. data/app/assets/stylesheets/print.scss +5 -0
  113. data/app/assets/stylesheets/screen.scss +12 -0
  114. data/app/controllers/account_types_controller.rb +2 -0
  115. data/app/controllers/accounts_controller.rb +30 -0
  116. data/app/controllers/application_controller.rb +12 -0
  117. data/app/controllers/attachments_controller.rb +15 -0
  118. data/app/controllers/authorized_controller.rb +24 -0
  119. data/app/controllers/bank_accounts_controller.rb +2 -0
  120. data/app/controllers/booking_imports_controller.rb +2 -0
  121. data/app/controllers/booking_templates_controller.rb +8 -0
  122. data/app/controllers/bookings_controller.rb +64 -0
  123. data/app/controllers/charge_booking_templates_controller.rb +2 -0
  124. data/app/controllers/charge_rates_controller.rb +2 -0
  125. data/app/controllers/companies_controller.rb +8 -0
  126. data/app/controllers/credit_invoices_controller.rb +29 -0
  127. data/app/controllers/customers_controller.rb +12 -0
  128. data/app/controllers/debit_invoices_controller.rb +43 -0
  129. data/app/controllers/direct_bookings_controller.rb +17 -0
  130. data/app/controllers/employees_controller.rb +3 -0
  131. data/app/controllers/employments_controller.rb +2 -0
  132. data/app/controllers/invoices_controller.rb +21 -0
  133. data/app/controllers/notes_controller.rb +34 -0
  134. data/app/controllers/overview_controller.rb +6 -0
  135. data/app/controllers/people_controller.rb +13 -0
  136. data/app/controllers/salaries_controller.rb +46 -0
  137. data/app/controllers/tenants_controller.rb +39 -0
  138. data/app/controllers/users_controller.rb +26 -0
  139. data/app/helpers/application_helper.rb +52 -0
  140. data/app/helpers/booking_helper.rb +10 -0
  141. data/app/helpers/booking_template_helper.rb +17 -0
  142. data/app/helpers/charge_rate_helper.rb +5 -0
  143. data/app/helpers/invoice_helper.rb +9 -0
  144. data/app/helpers/vat_rate_helper.rb +10 -0
  145. data/app/inputs/combobox_input.rb +23 -0
  146. data/app/inputs/date_field_input.rb +5 -0
  147. data/app/inputs/hour_field_input.rb +5 -0
  148. data/app/models/ability.rb +34 -0
  149. data/app/models/attachment.rb +13 -0
  150. data/app/models/booking_import.rb +8 -0
  151. data/app/models/booking_import_observer.rb +7 -0
  152. data/app/models/booking_reference.rb +4 -0
  153. data/app/models/booking_template.rb +92 -0
  154. data/app/models/charge_booking_template.rb +57 -0
  155. data/app/models/charge_rate.rb +30 -0
  156. data/app/models/civil_status.rb +5 -0
  157. data/app/models/company.rb +5 -0
  158. data/app/models/credit_invoice.rb +32 -0
  159. data/app/models/customer.rb +4 -0
  160. data/app/models/debit_invoice.rb +24 -0
  161. data/app/models/employee.rb +6 -0
  162. data/app/models/employment.rb +28 -0
  163. data/app/models/invoice.rb +145 -0
  164. data/app/models/line_item.rb +22 -0
  165. data/app/models/note.rb +8 -0
  166. data/app/models/person.rb +65 -0
  167. data/app/models/product.rb +2 -0
  168. data/app/models/profit.rb +9 -0
  169. data/app/models/religion.rb +5 -0
  170. data/app/models/role.rb +9 -0
  171. data/app/models/salary.rb +93 -0
  172. data/app/models/tenant.rb +43 -0
  173. data/app/models/user.rb +44 -0
  174. data/app/models/vat_rate.rb +11 -0
  175. data/app/uploaders/attachment_uploader.rb +12 -0
  176. data/app/views/account_types/_account_type.html.haml +6 -0
  177. data/app/views/account_types/_form.html.haml +7 -0
  178. data/app/views/account_types/_list.html.haml +7 -0
  179. data/app/views/account_types/index.html.haml +6 -0
  180. data/app/views/account_types/show.html.haml +6 -0
  181. data/app/views/accounts/_account.html.haml +12 -0
  182. data/app/views/accounts/_booking_item.html.haml +15 -0
  183. data/app/views/accounts/_booking_list.html.haml +19 -0
  184. data/app/views/accounts/_booking_list_footer.html.haml +2 -0
  185. data/app/views/accounts/_booking_list_header.html.haml +8 -0
  186. data/app/views/accounts/_booking_list_paginate.html.haml +5 -0
  187. data/app/views/accounts/_booking_list_saldo.html.haml +8 -0
  188. data/app/views/accounts/_booking_list_turnover.html.haml +9 -0
  189. data/app/views/accounts/_carry_booking.html.haml +9 -0
  190. data/app/views/accounts/_form.html.haml +10 -0
  191. data/app/views/accounts/_list_footer.html.haml +2 -0
  192. data/app/views/accounts/_list_header.html.haml +5 -0
  193. data/app/views/accounts/index.html.haml +8 -0
  194. data/app/views/accounts/show.html.haml +10 -0
  195. data/app/views/application/_form.html.haml +7 -0
  196. data/app/views/application/_list.html.haml +15 -0
  197. data/app/views/application/_search_form.html.haml +5 -0
  198. data/app/views/application/_show.html.haml +2 -0
  199. data/app/views/application/create.js.erb +3 -0
  200. data/app/views/application/destroy.js.erb +2 -0
  201. data/app/views/application/edit.html.haml +5 -0
  202. data/app/views/application/edit.js.erb +3 -0
  203. data/app/views/application/index.html.haml +7 -0
  204. data/app/views/application/new.html.haml +5 -0
  205. data/app/views/application/new.js.erb +3 -0
  206. data/app/views/application/show.html.haml +5 -0
  207. data/app/views/application/update.js.erb +3 -0
  208. data/app/views/attachments/_attachment.html.haml +5 -0
  209. data/app/views/attachments/_form.html.haml +15 -0
  210. data/app/views/attachments/_list.html.haml +6 -0
  211. data/app/views/bank_accounts/_bank_account.html.haml +1 -0
  212. data/app/views/booking_imports/_booking_import.html.haml +5 -0
  213. data/app/views/booking_imports/_form.html.haml +6 -0
  214. data/app/views/booking_imports/_list.html.haml +7 -0
  215. data/app/views/booking_imports/create.js.erb +4 -0
  216. data/app/views/booking_imports/index.html.haml +6 -0
  217. data/app/views/booking_imports/show.html.haml +6 -0
  218. data/app/views/booking_templates/_booking_template.html.haml +16 -0
  219. data/app/views/booking_templates/_form.html.haml +12 -0
  220. data/app/views/booking_templates/_list.html.haml +10 -0
  221. data/app/views/booking_templates/index.html.haml +6 -0
  222. data/app/views/bookings/_booking.html.haml +17 -0
  223. data/app/views/bookings/_form.html.haml +14 -0
  224. data/app/views/bookings/_list.html.haml +11 -0
  225. data/app/views/bookings/_new_form.html.haml +8 -0
  226. data/app/views/bookings/_sidebar.html.haml +7 -0
  227. data/app/views/bookings/_simple_form.html.haml +12 -0
  228. data/app/views/bookings/index.html.haml +9 -0
  229. data/app/views/bookings/new.html.haml +8 -0
  230. data/app/views/bookings/select.html.haml +11 -0
  231. data/app/views/bookings/show.html.haml +27 -0
  232. data/app/views/bookings/simple_edit.html.haml +4 -0
  233. data/app/views/charge_booking_templates/_charge_booking_template.html.haml +15 -0
  234. data/app/views/charge_booking_templates/_form.html.haml +12 -0
  235. data/app/views/charge_booking_templates/_list.html.haml +10 -0
  236. data/app/views/charge_rates/_form.html.haml +14 -0
  237. data/app/views/companies/_company.html.haml +5 -0
  238. data/app/views/companies/_form.html.haml +8 -0
  239. data/app/views/companies/_list.html.haml +6 -0
  240. data/app/views/companies/index.html.haml +6 -0
  241. data/app/views/companies/show.html.haml +27 -0
  242. data/app/views/credit_invoices/_credit_invoice.html.haml +9 -0
  243. data/app/views/credit_invoices/_form.html.haml +41 -0
  244. data/app/views/credit_invoices/_list.html.haml +20 -0
  245. data/app/views/credit_invoices/index.html.haml +7 -0
  246. data/app/views/credit_invoices/show.html.haml +56 -0
  247. data/app/views/customers/_customer.html.haml +5 -0
  248. data/app/views/customers/_form.html.haml +8 -0
  249. data/app/views/customers/_list.html.haml +6 -0
  250. data/app/views/customers/index.html.haml +6 -0
  251. data/app/views/customers/show.html.haml +22 -0
  252. data/app/views/debit_invoices/_debit_invoice.html.haml +9 -0
  253. data/app/views/debit_invoices/_form.html.haml +38 -0
  254. data/app/views/debit_invoices/_invoice_body.html.haml +8 -0
  255. data/app/views/debit_invoices/_invoice_info.html.haml +10 -0
  256. data/app/views/debit_invoices/_invoice_parties.html.haml +9 -0
  257. data/app/views/debit_invoices/_list.html.haml +21 -0
  258. data/app/views/debit_invoices/index.html.haml +7 -0
  259. data/app/views/debit_invoices/letter.html.haml +9 -0
  260. data/app/views/debit_invoices/letter.pdf.prawn +57 -0
  261. data/app/views/debit_invoices/show.html.haml +56 -0
  262. data/app/views/devise/confirmations/new.html.haml +10 -0
  263. data/app/views/devise/mailer/confirmation_instructions.html.haml +6 -0
  264. data/app/views/devise/mailer/reset_password_instructions.html.haml +10 -0
  265. data/app/views/devise/mailer/unlock_instructions.html.haml +8 -0
  266. data/app/views/devise/passwords/edit.html.haml +15 -0
  267. data/app/views/devise/passwords/new.html.haml +11 -0
  268. data/app/views/devise/sessions/new.html.haml +13 -0
  269. data/app/views/devise/shared/_links.haml +15 -0
  270. data/app/views/devise/unlocks/new.html.haml +11 -0
  271. data/app/views/direct_bookings/_form.html.haml +12 -0
  272. data/app/views/direct_bookings/_item.html.haml +17 -0
  273. data/app/views/direct_bookings/_list.html.haml +10 -0
  274. data/app/views/direct_bookings/_list_footer.html.haml +6 -0
  275. data/app/views/direct_bookings/_show.html.haml +3 -0
  276. data/app/views/direct_bookings/_show_all.html.haml +8 -0
  277. data/app/views/direct_bookings/list.js.erb +2 -0
  278. data/app/views/direct_bookings/new.js.erb +2 -0
  279. data/app/views/employees/_employee.html.haml +5 -0
  280. data/app/views/employees/_form.html.haml +19 -0
  281. data/app/views/employees/_list.html.haml +6 -0
  282. data/app/views/employees/index.html.haml +6 -0
  283. data/app/views/employees/show.html.haml +31 -0
  284. data/app/views/employments/_employment.html.haml +10 -0
  285. data/app/views/employments/_form.html.haml +24 -0
  286. data/app/views/employments/_list.html.haml +11 -0
  287. data/app/views/employments/_show.html.haml +9 -0
  288. data/app/views/employments/index.html.haml +5 -0
  289. data/app/views/invoices/_form.html.haml +13 -0
  290. data/app/views/invoices/_invoice.html.haml +7 -0
  291. data/app/views/invoices/_list.html.haml +20 -0
  292. data/app/views/invoices/_sidebar.html.haml +11 -0
  293. data/app/views/invoices/index.html.haml +17 -0
  294. data/app/views/invoices/show.html.haml +56 -0
  295. data/app/views/layouts/_flash_new.html.haml +1 -0
  296. data/app/views/layouts/_list_item_actions_for.html.haml +3 -0
  297. data/app/views/layouts/application.html.haml +46 -0
  298. data/app/views/line_items/_form.html.haml +6 -0
  299. data/app/views/line_items/_line_item.html.haml +7 -0
  300. data/app/views/line_items/_list_footer.html.haml +7 -0
  301. data/app/views/notes/_form.html.haml +10 -0
  302. data/app/views/notes/_list.html.haml +15 -0
  303. data/app/views/notes/index.html.haml +9 -0
  304. data/app/views/notes/show.html.haml +12 -0
  305. data/app/views/overview/index.html.haml +14 -0
  306. data/app/views/people/_form.html.haml +8 -0
  307. data/app/views/people/_list.html.haml +7 -0
  308. data/app/views/people/_person.html.haml +6 -0
  309. data/app/views/people/_show.html.haml +6 -0
  310. data/app/views/people/show.html.haml +21 -0
  311. data/app/views/persons/_civil.html.haml +5 -0
  312. data/app/views/persons/_show.html.haml +6 -0
  313. data/app/views/salaries/_form.html.haml +14 -0
  314. data/app/views/salaries/_list.html.haml +12 -0
  315. data/app/views/salaries/_salary.html.haml +10 -0
  316. data/app/views/salaries/_salary_certificate.html.haml +25 -0
  317. data/app/views/salaries/payslip.html.haml +40 -0
  318. data/app/views/salaries/show.html.haml +30 -0
  319. data/app/views/salaries/statistics.html.haml +6 -0
  320. data/app/views/tenants/_account.html.haml +7 -0
  321. data/app/views/tenants/_account_group_sheet.html.haml +8 -0
  322. data/app/views/tenants/_form.html.haml +17 -0
  323. data/app/views/tenants/_list.html.haml +7 -0
  324. data/app/views/tenants/_tenant.html.haml +7 -0
  325. data/app/views/tenants/balance_sheet.html.haml +43 -0
  326. data/app/views/tenants/index.html.haml +6 -0
  327. data/app/views/tenants/new.js.erb +1 -0
  328. data/app/views/tenants/profit_sheet.html.haml +26 -0
  329. data/app/views/tenants/show.html.haml +18 -0
  330. data/app/views/users/_demo.de-CH.html.haml +7 -0
  331. data/app/views/users/_demo.de.html.haml +7 -0
  332. data/app/views/users/_demo.html.haml +7 -0
  333. data/app/views/users/_form.html.haml +17 -0
  334. data/app/views/users/_list.html.haml +9 -0
  335. data/app/views/users/_show.html.haml +13 -0
  336. data/app/views/users/_user.html.haml +7 -0
  337. data/app/views/users/index.html.haml +6 -0
  338. data/app/views/users/new.js.erb +1 -0
  339. data/app/views/users/show.html.haml +14 -0
  340. data/lib/acts_as_csv.rb +113 -0
  341. data/lib/bookyt/engine.rb +18 -0
  342. data/lib/bookyt/version.rb +3 -0
  343. data/lib/float.rb +17 -0
  344. data/lib/pagination_list_link_renderer.rb +63 -0
  345. data/lib/parse_date.rb +27 -0
  346. data/lib/prawn/letter_document.rb +136 -0
  347. data/lib/raiffeisen_importer.rb +15 -0
  348. data/lib/recipes/bookyt.rb +15 -0
  349. data/lib/simple_navigation/renderer/list.rb +20 -0
  350. data/lib/simple_navigation/renderer/overview.rb +46 -0
  351. data/lib/sqlite3_extensions.rb +45 -0
  352. data/lib/tasks/.gitkeep +0 -0
  353. data/lib/tasks/bookyt.rake +15 -0
  354. data/lib/tasks/cucumber.rake +53 -0
  355. data/lib/tasks/environment_seeds.rake +7 -0
  356. data/lib/tasks/users.rake +46 -0
  357. metadata +423 -0
@@ -0,0 +1,683 @@
1
+ /**
2
+ * jquery.meio.mask.js
3
+ * @author: fabiomcosta
4
+ * @version: 1.1.3
5
+ *
6
+ * Created by Fabio M. Costa on 2008-09-16. Please report any bug at http://www.meiocodigo.com
7
+ *
8
+ * Copyright (c) 2008 Fabio M. Costa http://www.meiocodigo.com
9
+ *
10
+ * The MIT License (http://www.opensource.org/licenses/mit-license.php)
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person
13
+ * obtaining a copy of this software and associated documentation
14
+ * files (the "Software"), to deal in the Software without
15
+ * restriction, including without limitation the rights to use,
16
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following
19
+ * conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be
22
+ * included in all copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31
+ * OTHER DEALINGS IN THE SOFTWARE.
32
+ */
33
+
34
+ (function($){
35
+
36
+ var isIphone = (window.orientation != undefined),
37
+ // browsers like firefox2 and before and opera doenst have the onPaste event, but the paste feature can be done with the onInput event.
38
+ pasteEvent = (($.browser.opera || ($.browser.mozilla && parseFloat($.browser.version.substr(0,3)) < 1.9 ))? 'input': 'paste');
39
+
40
+ $.event.special.paste = {
41
+ setup: function() {
42
+ if(this.addEventListener)
43
+ this.addEventListener(pasteEvent, pasteHandler, false);
44
+ else if (this.attachEvent)
45
+ this.attachEvent(pasteEvent, pasteHandler);
46
+ },
47
+
48
+ teardown: function() {
49
+ if(this.removeEventListener)
50
+ this.removeEventListener(pasteEvent, pasteHandler, false);
51
+ else if (this.detachEvent)
52
+ this.detachEvent(pasteEvent, pasteHandler);
53
+ }
54
+ };
55
+
56
+ // the timeout is set because we can't get the value from the input without it
57
+ function pasteHandler(e){
58
+ var self = this;
59
+ e = $.event.fix(e || window.e);
60
+ e.type = 'paste';
61
+ // Execute the right handlers by setting the event type to paste
62
+ setTimeout(function(){ $.event.handle.call(self, e); }, 1);
63
+ };
64
+
65
+ $.extend({
66
+ mask : {
67
+
68
+ // the mask rules. You may add yours!
69
+ // number rules will be overwritten
70
+ rules : {
71
+ 'z': /[a-z]/,
72
+ 'Z': /[A-Z]/,
73
+ 'a': /[a-zA-Z]/,
74
+ '*': /[0-9a-zA-Z]/,
75
+ '@': /[0-9a-zA-ZçÇáàãâéèêíìóòôõúùü]/
76
+ },
77
+
78
+ // these keys will be ignored by the mask.
79
+ // all these numbers where obtained on the keydown event
80
+ keyRepresentation : {
81
+ 8 : 'backspace',
82
+ 9 : 'tab',
83
+ 13 : 'enter',
84
+ 16 : 'shift',
85
+ 17 : 'control',
86
+ 18 : 'alt',
87
+ 27 : 'esc',
88
+ 33 : 'page up',
89
+ 34 : 'page down',
90
+ 35 : 'end',
91
+ 36 : 'home',
92
+ 37 : 'left',
93
+ 38 : 'up',
94
+ 39 : 'right',
95
+ 40 : 'down',
96
+ 45 : 'insert',
97
+ 46 : 'delete',
98
+ 116 : 'f5',
99
+ 123 : 'f12',
100
+ 224 : 'command'
101
+ },
102
+
103
+ iphoneKeyRepresentation : {
104
+ 10 : 'go',
105
+ 127 : 'delete'
106
+ },
107
+
108
+ signals : {
109
+ '+' : '',
110
+ '-' : '-'
111
+ },
112
+
113
+ // default settings for the plugin
114
+ options : {
115
+ attr: 'alt', // an attr to look for the mask name or the mask itself
116
+ mask: null, // the mask to be used on the input
117
+ type: 'fixed', // the mask of this mask
118
+ maxLength: -1, // the maxLength of the mask
119
+ defaultValue: '', // the default value for this input
120
+ signal: false, // this should not be set, to use signal at masks put the signal you want ('-' or '+') at the default value of this mask.
121
+ // See the defined masks for a better understanding.
122
+
123
+ textAlign: true, // use false to not use text-align on any mask (at least not by the plugin, you may apply it using css)
124
+ selectCharsOnFocus: true, // select all chars from input on its focus
125
+ autoTab: true, // auto focus the next form element when you type the mask completely
126
+ setSize: false, // sets the input size based on the length of the mask (work with fixed and reverse masks only)
127
+ fixedChars : '[(),.:/ -]', // fixed chars to be used on the masks. You may change it for your needs!
128
+
129
+ onInvalid : function(){},
130
+ onValid : function(){},
131
+ onOverflow : function(){}
132
+ },
133
+
134
+ // masks. You may add yours!
135
+ // Ex: $.fn.setMask.masks.msk = {mask: '999'}
136
+ // and then if the 'attr' options value is 'alt', your input should look like:
137
+ // <input type="text" name="some_name" id="some_name" alt="msk" />
138
+ masks : {
139
+ 'phone' : { mask : '(99) 9999-9999' },
140
+ 'phone-us' : { mask : '(999) 999-9999' },
141
+ 'cpf' : { mask : '999.999.999-99' }, // cadastro nacional de pessoa fisica
142
+ 'cnpj' : { mask : '99.999.999/9999-99' },
143
+ 'date' : { mask : '39/19/9999' }, //uk date
144
+ 'date-us' : { mask : '19/39/9999' },
145
+ 'cep' : { mask : '99999-999' },
146
+ 'time' : { mask : '29:59' },
147
+ 'cc' : { mask : '9999 9999 9999 9999' }, //credit card mask
148
+ 'integer' : { mask : '999.999.999.999', type : 'reverse' },
149
+ 'decimal' : { mask : '99,999.999.999.999', type : 'reverse', defaultValue : '000' },
150
+ 'decimal-us' : { mask : '99.999,999,999,999', type : 'reverse', defaultValue : '000' },
151
+ 'signed-decimal' : { mask : '99,999.999.999.999', type : 'reverse', defaultValue : '+000' },
152
+ 'signed-decimal-us' : { mask : '99,999.999.999.999', type : 'reverse', defaultValue : '+000' }
153
+ },
154
+
155
+ init : function(){
156
+ // if has not inited...
157
+ if( !this.hasInit ){
158
+
159
+ var self = this, i,
160
+ keyRep = (isIphone)? this.iphoneKeyRepresentation: this.keyRepresentation;
161
+
162
+ this.ignore = false;
163
+
164
+ // constructs number rules
165
+ for(i=0; i<=9; i++) this.rules[i] = new RegExp('[0-'+i+']');
166
+
167
+ this.keyRep = keyRep;
168
+ // ignore keys array creation for iphone or the normal ones
169
+ this.ignoreKeys = [];
170
+ $.each(keyRep,function(key){
171
+ self.ignoreKeys.push( parseInt(key) );
172
+ });
173
+
174
+ this.hasInit = true;
175
+ }
176
+ },
177
+
178
+ set: function(el,options){
179
+
180
+ var maskObj = this,
181
+ $el = $(el),
182
+ mlStr = 'maxLength';
183
+
184
+ options = options || {};
185
+ this.init();
186
+
187
+ return $el.each(function(){
188
+
189
+ if(options.attr) maskObj.options.attr = options.attr;
190
+
191
+ var $this = $(this),
192
+ o = $.extend({}, maskObj.options),
193
+ attrValue = $this.attr(o.attr),
194
+ tmpMask = '';
195
+
196
+ // then we look for the 'attr' option
197
+ tmpMask = (typeof options == 'string')? options: (attrValue != '')? attrValue: null;
198
+ if(tmpMask) o.mask = tmpMask;
199
+
200
+ // then we see if it's a defined mask
201
+ if(maskObj.masks[tmpMask]) o = $.extend(o, maskObj.masks[tmpMask]);
202
+
203
+ // then it looks if the options is an object, if it is we will overwrite the actual options
204
+ if(typeof options == 'object' && options.constructor != Array) o = $.extend(o, options);
205
+
206
+ //then we look for some metadata on the input
207
+ if($.metadata) o = $.extend(o, $this.metadata());
208
+
209
+ if(o.mask != null){
210
+
211
+ if($this.data('mask')) maskObj.unset($this);
212
+
213
+ var defaultValue = o.defaultValue,
214
+ reverse = (o.type=='reverse'),
215
+ fixedCharsRegG = new RegExp(o.fixedChars, 'g');
216
+
217
+ if(o.maxLength == -1) o.maxLength = $this.attr(mlStr);
218
+
219
+ o = $.extend({}, o,{
220
+ fixedCharsReg: new RegExp(o.fixedChars),
221
+ fixedCharsRegG: fixedCharsRegG,
222
+ maskArray: o.mask.split(''),
223
+ maskNonFixedCharsArray: o.mask.replace(fixedCharsRegG, '').split('')
224
+ });
225
+
226
+ //setSize option (this is not removed from the input (while removing the mask) since this would be kind of funky)
227
+ if((o.type=='fixed' || reverse) && o.setSize && !$this.attr('size')) $this.attr('size', o.mask.length);
228
+
229
+ //sets text-align right for reverse masks
230
+ if(reverse && o.textAlign) $this.css('text-align', 'right');
231
+
232
+ if(this.value!='' || defaultValue!=''){
233
+ // apply mask to the current value of the input or to the default value
234
+ var val = maskObj.string((this.value!='')? this.value: defaultValue, o);
235
+ //setting defaultValue fixes the reset button from the form
236
+ this.defaultValue = val;
237
+ $this.val(val);
238
+ }
239
+
240
+ // compatibility patch for infinite mask, that is now repeat
241
+ if(o.type=='infinite') o.type = 'repeat';
242
+
243
+ $this.data('mask', o);
244
+
245
+ // removes the maxLength attribute (it will be set again if you use the unset method)
246
+ $this.removeAttr(mlStr);
247
+
248
+ // setting the input events
249
+ $this.bind('keydown.mask', {func:maskObj._onKeyDown, thisObj:maskObj}, maskObj._onMask)
250
+ .bind('keypress.mask', {func:maskObj._onKeyPress, thisObj:maskObj}, maskObj._onMask)
251
+ .bind('keyup.mask', {func:maskObj._onKeyUp, thisObj:maskObj}, maskObj._onMask)
252
+ .bind('paste.mask', {func:maskObj._onPaste, thisObj:maskObj}, maskObj._onMask)
253
+ .bind('focus.mask', maskObj._onFocus)
254
+ .bind('blur.mask', maskObj._onBlur)
255
+ .bind('change.mask', maskObj._onChange);
256
+ }
257
+ });
258
+ },
259
+
260
+ //unsets the mask from el
261
+ unset : function(el){
262
+ var $el = $(el);
263
+
264
+ return $el.each(function(){
265
+ var $this = $(this);
266
+ if($this.data('mask')){
267
+ var maxLength = $this.data('mask').maxLength;
268
+ if(maxLength != -1) $this.attr('maxLength', maxLength);
269
+ $this.unbind('.mask')
270
+ .removeData('mask');
271
+ }
272
+ });
273
+ },
274
+
275
+ //masks a string
276
+ string : function(str, options){
277
+ this.init();
278
+ var o={};
279
+ if(typeof str != 'string') str = String(str);
280
+ switch(typeof options){
281
+ case 'string':
282
+ // then we see if it's a defined mask
283
+ if(this.masks[options]) o = $.extend(o, this.masks[options]);
284
+ else o.mask = options;
285
+ break;
286
+ case 'object':
287
+ o = options;
288
+ }
289
+ if(!o.fixedChars) o.fixedChars = this.options.fixedChars;
290
+
291
+ var fixedCharsReg = new RegExp(o.fixedChars),
292
+ fixedCharsRegG = new RegExp(o.fixedChars, 'g');
293
+
294
+ // insert signal if any
295
+ if( (o.type=='reverse') && o.defaultValue ){
296
+ if( typeof this.signals[o.defaultValue.charAt(0)] != 'undefined' ){
297
+ var maybeASignal = str.charAt(0);
298
+ o.signal = (typeof this.signals[maybeASignal] != 'undefined') ? this.signals[maybeASignal] : this.signals[o.defaultValue.charAt(0)];
299
+ o.defaultValue = o.defaultValue.substring(1);
300
+ }
301
+ }
302
+
303
+ return this.__maskArray(str.split(''),
304
+ o.mask.replace(fixedCharsRegG, '').split(''),
305
+ o.mask.split(''),
306
+ o.type,
307
+ o.maxLength,
308
+ o.defaultValue,
309
+ fixedCharsReg,
310
+ o.signal);
311
+ },
312
+
313
+ // all the 3 events below are here just to fix the change event on reversed masks.
314
+ // It isn't fired in cases that the keypress event returns false (needed).
315
+ _onFocus: function(e){
316
+ var $this = $(this), dataObj = $this.data('mask');
317
+ dataObj.inputFocusValue = $this.val();
318
+ dataObj.changed = false;
319
+ if(dataObj.selectCharsOnFocus) $this.select();
320
+ },
321
+
322
+ _onBlur: function(e){
323
+ var $this = $(this), dataObj = $this.data('mask');
324
+ if(dataObj.inputFocusValue != $this.val() && !dataObj.changed)
325
+ $this.trigger('change');
326
+ },
327
+
328
+ _onChange: function(e){
329
+ $(this).data('mask').changed = true;
330
+ },
331
+
332
+ _onMask : function(e){
333
+ var thisObj = e.data.thisObj,
334
+ o = {};
335
+ o._this = e.target;
336
+ o.$this = $(o._this);
337
+ // if the input is readonly it does nothing
338
+ if(o.$this.attr('readonly')) return true;
339
+ o.data = o.$this.data('mask');
340
+ o[o.data.type] = true;
341
+ o.value = o.$this.val();
342
+ o.nKey = thisObj.__getKeyNumber(e);
343
+ o.range = thisObj.__getRange(o._this);
344
+ o.valueArray = o.value.split('');
345
+ return e.data.func.call(thisObj, e, o);
346
+ },
347
+
348
+ _onKeyDown : function(e,o){
349
+ // lets say keypress at desktop == keydown at iphone (theres no keypress at iphone)
350
+ this.ignore = $.inArray(o.nKey, this.ignoreKeys) > -1 || e.ctrlKey || e.metaKey || e.altKey;
351
+ if(this.ignore){
352
+ var rep = this.keyRep[o.nKey];
353
+ o.data.onValid.call(o._this, rep? rep: '', o.nKey);
354
+ }
355
+ return isIphone ? this._keyPress(e, o) : true;
356
+ },
357
+
358
+ _onKeyUp : function(e, o){
359
+ //9=TAB_KEY 16=SHIFT_KEY
360
+ //this is a little bug, when you go to an input with tab key
361
+ //it would remove the range selected by default, and that's not a desired behavior
362
+ if(o.nKey==9 || o.nKey==16) return true;
363
+
364
+ if(o.data.type=='repeat'){
365
+ this.__autoTab(o);
366
+ return true;
367
+ }
368
+
369
+ return this._onPaste(e, o);
370
+ },
371
+
372
+ _onPaste : function(e,o){
373
+ // changes the signal at the data obj from the input
374
+ if(o.reverse) this.__changeSignal(e.type, o);
375
+
376
+ var $thisVal = this.__maskArray(
377
+ o.valueArray,
378
+ o.data.maskNonFixedCharsArray,
379
+ o.data.maskArray,
380
+ o.data.type,
381
+ o.data.maxLength,
382
+ o.data.defaultValue,
383
+ o.data.fixedCharsReg,
384
+ o.data.signal
385
+ );
386
+
387
+ o.$this.val( $thisVal );
388
+ // this makes the caret stay at first position when
389
+ // the user removes all values in an input and the plugin adds the default value to it (if it haves one).
390
+ if( !o.reverse && o.data.defaultValue.length && (o.range.start==o.range.end) )
391
+ this.__setRange(o._this, o.range.start, o.range.end);
392
+
393
+ //fix so ie's and safari's caret won't go to the end of the input value.
394
+ if( ($.browser.msie || $.browser.safari) && !o.reverse)
395
+ this.__setRange(o._this,o.range.start,o.range.end);
396
+
397
+ if(this.ignore) return true;
398
+
399
+ this.__autoTab(o);
400
+ return true;
401
+ },
402
+
403
+ _onKeyPress: function(e, o){
404
+
405
+ if(this.ignore) return true;
406
+
407
+ // changes the signal at the data obj from the input
408
+ if(o.reverse) this.__changeSignal(e.type, o);
409
+
410
+ var c = String.fromCharCode(o.nKey),
411
+ rangeStart = o.range.start,
412
+ rawValue = o.value,
413
+ maskArray = o.data.maskArray;
414
+
415
+ if(o.reverse){
416
+ // the input value from the range start to the value start
417
+ var valueStart = rawValue.substr(0, rangeStart),
418
+ // the input value from the range end to the value end
419
+ valueEnd = rawValue.substr(o.range.end, rawValue.length);
420
+
421
+ rawValue = valueStart+c+valueEnd;
422
+ //necessary, if not decremented you will be able to input just the mask.length-1 if signal!=''
423
+ //ex: mask:99,999.999.999 you will be able to input 99,999.999.99
424
+ if(o.data.signal && (rangeStart-o.data.signal.length > 0)) rangeStart-=o.data.signal.length;
425
+ }
426
+
427
+ var valueArray = rawValue.replace(o.data.fixedCharsRegG, '').split(''),
428
+ // searches for fixed chars begining from the range start position, till it finds a non fixed
429
+ extraPos = this.__extraPositionsTill(rangeStart, maskArray, o.data.fixedCharsReg);
430
+
431
+ o.rsEp = rangeStart+extraPos;
432
+
433
+ if(o.repeat) o.rsEp = 0;
434
+
435
+ // if the rule for this character doesnt exist (value.length is bigger than mask.length)
436
+ // added a verification for maxLength in the case of the repeat type mask
437
+ if( !this.rules[maskArray[o.rsEp]] || (o.data.maxLength != -1 && valueArray.length >= o.data.maxLength && o.repeat)){
438
+ // auto focus on the next input of the current form
439
+ o.data.onOverflow.call(o._this, c, o.nKey);
440
+ return false;
441
+ }
442
+
443
+ // if the new character is not obeying the law... :P
444
+ else if( !this.rules[maskArray[o.rsEp]].test( c ) ){
445
+ o.data.onInvalid.call(o._this, c, o.nKey);
446
+ return false;
447
+ }
448
+
449
+ else o.data.onValid.call(o._this, c, o.nKey);
450
+
451
+ var $thisVal = this.__maskArray(
452
+ valueArray,
453
+ o.data.maskNonFixedCharsArray,
454
+ maskArray,
455
+ o.data.type,
456
+ o.data.maxLength,
457
+ o.data.defaultValue,
458
+ o.data.fixedCharsReg,
459
+ o.data.signal,
460
+ extraPos
461
+ );
462
+
463
+ o.$this.val( $thisVal );
464
+
465
+ return (o.reverse)? this._keyPressReverse(e, o): (o.fixed)? this._keyPressFixed(e, o): true;
466
+ },
467
+
468
+ _keyPressFixed: function(e, o){
469
+
470
+ if(o.range.start==o.range.end){
471
+ // the 0 thing is cause theres a particular behavior i wasnt liking when you put a default
472
+ // value on a fixed mask and you select the value from the input the range would go to the
473
+ // end of the string when you enter a char. with this it will overwrite the first char wich is a better behavior.
474
+ // opera fix, cant have range value bigger than value length, i think it loops thought the input value...
475
+ if((o.rsEp==0 && o.value.length==0) || o.rsEp < o.value.length)
476
+ this.__setRange(o._this, o.rsEp, o.rsEp+1);
477
+ }
478
+ else
479
+ this.__setRange(o._this, o.range.start, o.range.end);
480
+
481
+ return true;
482
+ },
483
+
484
+ _keyPressReverse: function(e, o){
485
+ //fix for ie
486
+ //this bug was pointed by Pedro Martins
487
+ //it fixes a strange behavior that ie was having after a char was inputted in a text input that
488
+ //had its content selected by any range
489
+ if($.browser.msie && ((o.range.start==0 && o.range.end==0) || o.range.start != o.range.end ))
490
+ this.__setRange(o._this, o.value.length);
491
+ return false;
492
+ },
493
+
494
+ __autoTab: function(o){
495
+ if(o.data.autoTab
496
+ && (
497
+ (
498
+ o.$this.val().length >= o.data.maskArray.length
499
+ && !o.repeat
500
+ ) || (
501
+ o.data.maxLength != -1
502
+ && o.valueArray.length >= o.data.maxLength
503
+ && o.repeat
504
+ )
505
+ )
506
+ ){
507
+ var nextEl = this.__getNextInput(o._this, o.data.autoTab);
508
+ if(nextEl){
509
+ o.$this.trigger('blur');
510
+ nextEl.focus().select();
511
+ }
512
+ }
513
+ },
514
+
515
+ // changes the signal at the data obj from the input
516
+ __changeSignal : function(eventType,o){
517
+ if(o.data.signal!==false){
518
+ var inputChar = (eventType=='paste')? o.value.charAt(0): String.fromCharCode(o.nKey);
519
+ if( this.signals && (typeof this.signals[inputChar] != 'undefined') ){
520
+ o.data.signal = this.signals[inputChar];
521
+ }
522
+ }
523
+ },
524
+
525
+ __getKeyNumber : function(e){
526
+ return (e.charCode||e.keyCode||e.which);
527
+ },
528
+
529
+ // this function is totaly specific to be used with this plugin, youll never need it
530
+ // it gets the array representing an unmasked string and masks it depending on the type of the mask
531
+ __maskArray : function(valueArray, maskNonFixedCharsArray, maskArray, type, maxlength, defaultValue, fixedCharsReg, signal, extraPos){
532
+ if(type == 'reverse') valueArray.reverse();
533
+ valueArray = this.__removeInvalidChars(valueArray, maskNonFixedCharsArray, type=='repeat'||type=='infinite');
534
+ if(defaultValue) valueArray = this.__applyDefaultValue.call(valueArray, defaultValue);
535
+ valueArray = this.__applyMask(valueArray, maskArray, extraPos, fixedCharsReg);
536
+ switch(type){
537
+ case 'reverse':
538
+ valueArray.reverse();
539
+ return (signal || '')+valueArray.join('').substring(valueArray.length-maskArray.length);
540
+ case 'infinite': case 'repeat':
541
+ var joinedValue = valueArray.join('');
542
+ return (maxlength != -1 && valueArray.length >= maxlength)? joinedValue.substring(0, maxlength): joinedValue;
543
+ default:
544
+ return valueArray.join('').substring(0, maskArray.length);
545
+ }
546
+ return '';
547
+ },
548
+
549
+ // applyes the default value to the result string
550
+ __applyDefaultValue : function(defaultValue){
551
+ var defLen = defaultValue.length,thisLen = this.length,i;
552
+ //removes the leading chars
553
+ for(i=thisLen-1;i>=0;i--){
554
+ if(this[i]==defaultValue.charAt(0)) this.pop();
555
+ else break;
556
+ }
557
+ // apply the default value
558
+ for(i=0;i<defLen;i++) if(!this[i])
559
+ this[i] = defaultValue.charAt(i);
560
+
561
+ return this;
562
+ },
563
+
564
+ // Removes values that doesnt match the mask from the valueArray
565
+ // Returns the array without the invalid chars.
566
+ __removeInvalidChars : function(valueArray, maskNonFixedCharsArray, repeatType){
567
+ // removes invalid chars
568
+ for(var i=0, y=0; i<valueArray.length; i++ ){
569
+ if( maskNonFixedCharsArray[y] &&
570
+ this.rules[maskNonFixedCharsArray[y]] &&
571
+ !this.rules[maskNonFixedCharsArray[y]].test(valueArray[i]) ){
572
+ valueArray.splice(i,1);
573
+ if(!repeatType) y--;
574
+ i--;
575
+ }
576
+ if(!repeatType) y++;
577
+ }
578
+ return valueArray;
579
+ },
580
+
581
+ // Apply the current input mask to the valueArray and returns it.
582
+ __applyMask : function(valueArray, maskArray, plus, fixedCharsReg){
583
+ if( typeof plus == 'undefined' ) plus = 0;
584
+ // apply the current mask to the array of chars
585
+ for(var i=0; i<valueArray.length+plus; i++ ){
586
+ if( maskArray[i] && fixedCharsReg.test(maskArray[i]) )
587
+ valueArray.splice(i, 0, maskArray[i]);
588
+ }
589
+ return valueArray;
590
+ },
591
+
592
+ // searches for fixed chars begining from the range start position, till it finds a non fixed
593
+ __extraPositionsTill : function(rangeStart, maskArray, fixedCharsReg){
594
+ var extraPos = 0;
595
+ while(fixedCharsReg.test(maskArray[rangeStart++])){
596
+ extraPos++;
597
+ }
598
+ return extraPos;
599
+ },
600
+
601
+ __getNextInput: function(input, selector){
602
+ var formEls = input.form.elements,
603
+ initialInputIndex = $.inArray(input, formEls) + 1,
604
+ $input = null,
605
+ i;
606
+ // look for next input on the form of the pased input
607
+ for(i = initialInputIndex; i < formEls.length; i++){
608
+ $input = $(formEls[i]);
609
+ if(this.__isNextInput($input, selector))
610
+ return $input;
611
+ }
612
+
613
+ var forms = document.forms,
614
+ initialFormIndex = $.inArray(input.form, forms) + 1,
615
+ y, tmpFormEls = null;
616
+ // look for the next forms for the next input
617
+ for(y = initialFormIndex; y < forms.length; y++){
618
+ tmpFormEls = forms[y].elements;
619
+ for(i = 0; i < tmpFormEls.length; i++){
620
+ $input = $(tmpFormEls[i]);
621
+ if(this.__isNextInput($input, selector))
622
+ return $input;
623
+ }
624
+ }
625
+ return null;
626
+ },
627
+
628
+ __isNextInput: function($formEl, selector){
629
+ var formEl = $formEl.get(0);
630
+ return formEl
631
+ && (formEl.offsetWidth > 0 || formEl.offsetHeight > 0)
632
+ && formEl.nodeName != 'FIELDSET'
633
+ && (selector === true || (typeof selector == 'string' && $formEl.is(selector)));
634
+ },
635
+
636
+ // http://www.bazon.net/mishoo/articles.epl?art_id=1292
637
+ __setRange : function(input, start, end) {
638
+ if(typeof end == 'undefined') end = start;
639
+ if (input.setSelectionRange){
640
+ input.setSelectionRange(start, end);
641
+ }
642
+ else{
643
+ // assumed IE
644
+ var range = input.createTextRange();
645
+ range.collapse();
646
+ range.moveStart('character', start);
647
+ range.moveEnd('character', end - start);
648
+ range.select();
649
+ }
650
+ },
651
+
652
+ // adaptation from http://digitarald.de/project/autocompleter/
653
+ __getRange : function(input){
654
+ if (!$.browser.msie) return {start: input.selectionStart, end: input.selectionEnd};
655
+ var pos = {start: 0, end: 0},
656
+ range = document.selection.createRange();
657
+ pos.start = 0 - range.duplicate().moveStart('character', -100000);
658
+ pos.end = pos.start + range.text.length;
659
+ return pos;
660
+ },
661
+
662
+ //deprecated
663
+ unmaskedVal : function(el){
664
+ return $(el).val().replace($.mask.fixedCharsRegG, '');
665
+ }
666
+
667
+ }
668
+ });
669
+
670
+ $.fn.extend({
671
+ setMask : function(options){
672
+ return $.mask.set(this, options);
673
+ },
674
+ unsetMask : function(){
675
+ return $.mask.unset(this);
676
+ },
677
+ //deprecated
678
+ unmaskedVal : function(){
679
+ return $.mask.unmaskedVal(this[0]);
680
+ }
681
+ });
682
+ })(jQuery);
683
+