bookyt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/16x16/add.png +0 -0
- data/app/assets/images/16x16/alert.png +0 -0
- data/app/assets/images/16x16/combolink.png +0 -0
- data/app/assets/images/16x16/copy.png +0 -0
- data/app/assets/images/16x16/delete.png +0 -0
- data/app/assets/images/16x16/edit.png +0 -0
- data/app/assets/images/16x16/filter.png +0 -0
- data/app/assets/images/16x16/index.png +0 -0
- data/app/assets/images/16x16/notice.png +0 -0
- data/app/assets/images/16x16/pdf.png +0 -0
- data/app/assets/images/16x16/print.png +0 -0
- data/app/assets/images/16x16/show.png +0 -0
- data/app/assets/images/22x22/arrow-right.png +0 -0
- data/app/assets/images/22x22/edit.png +0 -0
- data/app/assets/images/22x22/insert_booking.png +0 -0
- data/app/assets/images/22x22/remove.png +0 -0
- data/app/assets/images/32x32/edit.png +0 -0
- data/app/assets/images/32x32/remove.png +0 -0
- data/app/assets/images/48x48/accounting.png +0 -0
- data/app/assets/images/48x48/basic_claims_data.png +0 -0
- data/app/assets/images/48x48/contacts.png +0 -0
- data/app/assets/images/48x48/invoicing.png +0 -0
- data/app/assets/images/48x48/nav_users.png +0 -0
- data/app/assets/images/48x48/settings.png +0 -0
- data/app/assets/images/48x48/store.png +0 -0
- data/app/assets/images/button_bg.png +0 -0
- data/app/assets/images/crystal-icons/16x16/filter.png +0 -0
- data/app/assets/images/down.png +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/flavour-extended/48x48/invoice.png +0 -0
- data/app/assets/images/free-business-desktop-icons/48x48/business.png +0 -0
- data/app/assets/images/gnome-web-icons/48x48/Gnome-X-Office-Address-Book-48.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_75_759fcf_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_85_aeb9cf_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_gloss-wave_55_aeb9cf_500x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_759fcf_1x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-bg_inset-hard_100_f6f6f6_1x100.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_217bc0_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_469bdd_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_6da8d5_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_d8e7f3_256x240.png +0 -0
- data/app/assets/images/jquery-ui/ui-icons_f9bd01_256x240.png +0 -0
- data/app/assets/images/jquery/tooltip/black_arrow.png +0 -0
- data/app/assets/images/letter-logo.alpha.png +0 -0
- data/app/assets/images/letter-logo.big.png +0 -0
- data/app/assets/images/letter-logo.orig.png +0 -0
- data/app/assets/images/letter-logo.png +0 -0
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/images/logo.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/application-pdf.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/document-preview.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/document-print.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/edit-copy.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/go-next.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/mail-mark-notjunk.png +0 -0
- data/app/assets/images/oxygen-icons/16x16/status_unknown.png +0 -0
- data/app/assets/images/oxygen-icons/48x48/system-users.png +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/images/up.png +0 -0
- data/app/assets/javascripts/application.js +49 -0
- data/app/assets/javascripts/cyt.js +86 -0
- data/app/assets/javascripts/jquery-ui.js +11437 -0
- data/app/assets/javascripts/jquery.dirtyform.js +242 -0
- data/app/assets/javascripts/jquery.form.js +785 -0
- data/app/assets/javascripts/jquery.js +8936 -0
- data/app/assets/javascripts/jquery.meio.mask.js +683 -0
- data/app/assets/javascripts/jquery.remotipart.js +46 -0
- data/app/assets/javascripts/jquery.ui.combobox.js +77 -0
- data/app/assets/javascripts/jquery_ujs.js +316 -0
- data/app/assets/javascripts/nested_form.js +51 -0
- data/app/assets/javascripts/tooltip.js +343 -0
- data/app/assets/stylesheets/.gitkeep +0 -0
- data/app/assets/stylesheets/ie.scss +16 -0
- data/app/assets/stylesheets/ie6.scss +4 -0
- data/app/assets/stylesheets/partials/_base.sass +39 -0
- data/app/assets/stylesheets/partials/_content.sass +60 -0
- data/app/assets/stylesheets/partials/_jquery.sass +2 -0
- data/app/assets/stylesheets/partials/_layout.sass +21 -0
- data/app/assets/stylesheets/partials/_sidebar.sass +5 -0
- data/app/assets/stylesheets/partials/content/_accounting.sass +41 -0
- data/app/assets/stylesheets/partials/content/_ajax_indicator.sass +28 -0
- data/app/assets/stylesheets/partials/content/_app.sass +43 -0
- data/app/assets/stylesheets/partials/content/_combobox.sass +8 -0
- data/app/assets/stylesheets/partials/content/_cyt.sass +200 -0
- data/app/assets/stylesheets/partials/content/_fancy_buttons.sass +10 -0
- data/app/assets/stylesheets/partials/content/_flash_errors.sass +46 -0
- data/app/assets/stylesheets/partials/content/_form_view.sass +20 -0
- data/app/assets/stylesheets/partials/content/_icons.sass +35 -0
- data/app/assets/stylesheets/partials/content/_invoice.sass +6 -0
- data/app/assets/stylesheets/partials/content/_overview.sass +40 -0
- data/app/assets/stylesheets/partials/content/_pagination.sass +61 -0
- data/app/assets/stylesheets/partials/content/_person.sass +5 -0
- data/app/assets/stylesheets/partials/content/_scaffold.sass +67 -0
- data/app/assets/stylesheets/partials/content/_table_list.sass +26 -0
- data/app/assets/stylesheets/partials/content/formtastic/_formtastic.sass +201 -0
- data/app/assets/stylesheets/partials/content/formtastic/_formtastic_cyt.sass +90 -0
- data/app/assets/stylesheets/partials/formtastic/_custom_fields.sass +2 -0
- data/app/assets/stylesheets/partials/formtastic/_formtastic_base.sass +652 -0
- data/app/assets/stylesheets/partials/jquery/_jquery_ui.sass +1461 -0
- data/app/assets/stylesheets/partials/jquery/_tooltip.sass +21 -0
- data/app/assets/stylesheets/partials/layout/_header.sass +29 -0
- data/app/assets/stylesheets/partials/layout/_navigation.sass +2 -0
- data/app/assets/stylesheets/partials/layout/navigation/_main.sass +34 -0
- data/app/assets/stylesheets/partials/layout/navigation/_sidebar.sass +18 -0
- data/app/assets/stylesheets/partials/print/_app.sass +21 -0
- data/app/assets/stylesheets/partials/print/_layout.sass +24 -0
- data/app/assets/stylesheets/print.scss +5 -0
- data/app/assets/stylesheets/screen.scss +12 -0
- data/app/controllers/account_types_controller.rb +2 -0
- data/app/controllers/accounts_controller.rb +30 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/attachments_controller.rb +15 -0
- data/app/controllers/authorized_controller.rb +24 -0
- data/app/controllers/bank_accounts_controller.rb +2 -0
- data/app/controllers/booking_imports_controller.rb +2 -0
- data/app/controllers/booking_templates_controller.rb +8 -0
- data/app/controllers/bookings_controller.rb +64 -0
- data/app/controllers/charge_booking_templates_controller.rb +2 -0
- data/app/controllers/charge_rates_controller.rb +2 -0
- data/app/controllers/companies_controller.rb +8 -0
- data/app/controllers/credit_invoices_controller.rb +29 -0
- data/app/controllers/customers_controller.rb +12 -0
- data/app/controllers/debit_invoices_controller.rb +43 -0
- data/app/controllers/direct_bookings_controller.rb +17 -0
- data/app/controllers/employees_controller.rb +3 -0
- data/app/controllers/employments_controller.rb +2 -0
- data/app/controllers/invoices_controller.rb +21 -0
- data/app/controllers/notes_controller.rb +34 -0
- data/app/controllers/overview_controller.rb +6 -0
- data/app/controllers/people_controller.rb +13 -0
- data/app/controllers/salaries_controller.rb +46 -0
- data/app/controllers/tenants_controller.rb +39 -0
- data/app/controllers/users_controller.rb +26 -0
- data/app/helpers/application_helper.rb +52 -0
- data/app/helpers/booking_helper.rb +10 -0
- data/app/helpers/booking_template_helper.rb +17 -0
- data/app/helpers/charge_rate_helper.rb +5 -0
- data/app/helpers/invoice_helper.rb +9 -0
- data/app/helpers/vat_rate_helper.rb +10 -0
- data/app/inputs/combobox_input.rb +23 -0
- data/app/inputs/date_field_input.rb +5 -0
- data/app/inputs/hour_field_input.rb +5 -0
- data/app/models/ability.rb +34 -0
- data/app/models/attachment.rb +13 -0
- data/app/models/booking_import.rb +8 -0
- data/app/models/booking_import_observer.rb +7 -0
- data/app/models/booking_reference.rb +4 -0
- data/app/models/booking_template.rb +92 -0
- data/app/models/charge_booking_template.rb +57 -0
- data/app/models/charge_rate.rb +30 -0
- data/app/models/civil_status.rb +5 -0
- data/app/models/company.rb +5 -0
- data/app/models/credit_invoice.rb +32 -0
- data/app/models/customer.rb +4 -0
- data/app/models/debit_invoice.rb +24 -0
- data/app/models/employee.rb +6 -0
- data/app/models/employment.rb +28 -0
- data/app/models/invoice.rb +145 -0
- data/app/models/line_item.rb +22 -0
- data/app/models/note.rb +8 -0
- data/app/models/person.rb +65 -0
- data/app/models/product.rb +2 -0
- data/app/models/profit.rb +9 -0
- data/app/models/religion.rb +5 -0
- data/app/models/role.rb +9 -0
- data/app/models/salary.rb +93 -0
- data/app/models/tenant.rb +43 -0
- data/app/models/user.rb +44 -0
- data/app/models/vat_rate.rb +11 -0
- data/app/uploaders/attachment_uploader.rb +12 -0
- data/app/views/account_types/_account_type.html.haml +6 -0
- data/app/views/account_types/_form.html.haml +7 -0
- data/app/views/account_types/_list.html.haml +7 -0
- data/app/views/account_types/index.html.haml +6 -0
- data/app/views/account_types/show.html.haml +6 -0
- data/app/views/accounts/_account.html.haml +12 -0
- data/app/views/accounts/_booking_item.html.haml +15 -0
- data/app/views/accounts/_booking_list.html.haml +19 -0
- data/app/views/accounts/_booking_list_footer.html.haml +2 -0
- data/app/views/accounts/_booking_list_header.html.haml +8 -0
- data/app/views/accounts/_booking_list_paginate.html.haml +5 -0
- data/app/views/accounts/_booking_list_saldo.html.haml +8 -0
- data/app/views/accounts/_booking_list_turnover.html.haml +9 -0
- data/app/views/accounts/_carry_booking.html.haml +9 -0
- data/app/views/accounts/_form.html.haml +10 -0
- data/app/views/accounts/_list_footer.html.haml +2 -0
- data/app/views/accounts/_list_header.html.haml +5 -0
- data/app/views/accounts/index.html.haml +8 -0
- data/app/views/accounts/show.html.haml +10 -0
- data/app/views/application/_form.html.haml +7 -0
- data/app/views/application/_list.html.haml +15 -0
- data/app/views/application/_search_form.html.haml +5 -0
- data/app/views/application/_show.html.haml +2 -0
- data/app/views/application/create.js.erb +3 -0
- data/app/views/application/destroy.js.erb +2 -0
- data/app/views/application/edit.html.haml +5 -0
- data/app/views/application/edit.js.erb +3 -0
- data/app/views/application/index.html.haml +7 -0
- data/app/views/application/new.html.haml +5 -0
- data/app/views/application/new.js.erb +3 -0
- data/app/views/application/show.html.haml +5 -0
- data/app/views/application/update.js.erb +3 -0
- data/app/views/attachments/_attachment.html.haml +5 -0
- data/app/views/attachments/_form.html.haml +15 -0
- data/app/views/attachments/_list.html.haml +6 -0
- data/app/views/bank_accounts/_bank_account.html.haml +1 -0
- data/app/views/booking_imports/_booking_import.html.haml +5 -0
- data/app/views/booking_imports/_form.html.haml +6 -0
- data/app/views/booking_imports/_list.html.haml +7 -0
- data/app/views/booking_imports/create.js.erb +4 -0
- data/app/views/booking_imports/index.html.haml +6 -0
- data/app/views/booking_imports/show.html.haml +6 -0
- data/app/views/booking_templates/_booking_template.html.haml +16 -0
- data/app/views/booking_templates/_form.html.haml +12 -0
- data/app/views/booking_templates/_list.html.haml +10 -0
- data/app/views/booking_templates/index.html.haml +6 -0
- data/app/views/bookings/_booking.html.haml +17 -0
- data/app/views/bookings/_form.html.haml +14 -0
- data/app/views/bookings/_list.html.haml +11 -0
- data/app/views/bookings/_new_form.html.haml +8 -0
- data/app/views/bookings/_sidebar.html.haml +7 -0
- data/app/views/bookings/_simple_form.html.haml +12 -0
- data/app/views/bookings/index.html.haml +9 -0
- data/app/views/bookings/new.html.haml +8 -0
- data/app/views/bookings/select.html.haml +11 -0
- data/app/views/bookings/show.html.haml +27 -0
- data/app/views/bookings/simple_edit.html.haml +4 -0
- data/app/views/charge_booking_templates/_charge_booking_template.html.haml +15 -0
- data/app/views/charge_booking_templates/_form.html.haml +12 -0
- data/app/views/charge_booking_templates/_list.html.haml +10 -0
- data/app/views/charge_rates/_form.html.haml +14 -0
- data/app/views/companies/_company.html.haml +5 -0
- data/app/views/companies/_form.html.haml +8 -0
- data/app/views/companies/_list.html.haml +6 -0
- data/app/views/companies/index.html.haml +6 -0
- data/app/views/companies/show.html.haml +27 -0
- data/app/views/credit_invoices/_credit_invoice.html.haml +9 -0
- data/app/views/credit_invoices/_form.html.haml +41 -0
- data/app/views/credit_invoices/_list.html.haml +20 -0
- data/app/views/credit_invoices/index.html.haml +7 -0
- data/app/views/credit_invoices/show.html.haml +56 -0
- data/app/views/customers/_customer.html.haml +5 -0
- data/app/views/customers/_form.html.haml +8 -0
- data/app/views/customers/_list.html.haml +6 -0
- data/app/views/customers/index.html.haml +6 -0
- data/app/views/customers/show.html.haml +22 -0
- data/app/views/debit_invoices/_debit_invoice.html.haml +9 -0
- data/app/views/debit_invoices/_form.html.haml +38 -0
- data/app/views/debit_invoices/_invoice_body.html.haml +8 -0
- data/app/views/debit_invoices/_invoice_info.html.haml +10 -0
- data/app/views/debit_invoices/_invoice_parties.html.haml +9 -0
- data/app/views/debit_invoices/_list.html.haml +21 -0
- data/app/views/debit_invoices/index.html.haml +7 -0
- data/app/views/debit_invoices/letter.html.haml +9 -0
- data/app/views/debit_invoices/letter.pdf.prawn +57 -0
- data/app/views/debit_invoices/show.html.haml +56 -0
- data/app/views/devise/confirmations/new.html.haml +10 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +6 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +10 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +8 -0
- data/app/views/devise/passwords/edit.html.haml +15 -0
- data/app/views/devise/passwords/new.html.haml +11 -0
- data/app/views/devise/sessions/new.html.haml +13 -0
- data/app/views/devise/shared/_links.haml +15 -0
- data/app/views/devise/unlocks/new.html.haml +11 -0
- data/app/views/direct_bookings/_form.html.haml +12 -0
- data/app/views/direct_bookings/_item.html.haml +17 -0
- data/app/views/direct_bookings/_list.html.haml +10 -0
- data/app/views/direct_bookings/_list_footer.html.haml +6 -0
- data/app/views/direct_bookings/_show.html.haml +3 -0
- data/app/views/direct_bookings/_show_all.html.haml +8 -0
- data/app/views/direct_bookings/list.js.erb +2 -0
- data/app/views/direct_bookings/new.js.erb +2 -0
- data/app/views/employees/_employee.html.haml +5 -0
- data/app/views/employees/_form.html.haml +19 -0
- data/app/views/employees/_list.html.haml +6 -0
- data/app/views/employees/index.html.haml +6 -0
- data/app/views/employees/show.html.haml +31 -0
- data/app/views/employments/_employment.html.haml +10 -0
- data/app/views/employments/_form.html.haml +24 -0
- data/app/views/employments/_list.html.haml +11 -0
- data/app/views/employments/_show.html.haml +9 -0
- data/app/views/employments/index.html.haml +5 -0
- data/app/views/invoices/_form.html.haml +13 -0
- data/app/views/invoices/_invoice.html.haml +7 -0
- data/app/views/invoices/_list.html.haml +20 -0
- data/app/views/invoices/_sidebar.html.haml +11 -0
- data/app/views/invoices/index.html.haml +17 -0
- data/app/views/invoices/show.html.haml +56 -0
- data/app/views/layouts/_flash_new.html.haml +1 -0
- data/app/views/layouts/_list_item_actions_for.html.haml +3 -0
- data/app/views/layouts/application.html.haml +46 -0
- data/app/views/line_items/_form.html.haml +6 -0
- data/app/views/line_items/_line_item.html.haml +7 -0
- data/app/views/line_items/_list_footer.html.haml +7 -0
- data/app/views/notes/_form.html.haml +10 -0
- data/app/views/notes/_list.html.haml +15 -0
- data/app/views/notes/index.html.haml +9 -0
- data/app/views/notes/show.html.haml +12 -0
- data/app/views/overview/index.html.haml +14 -0
- data/app/views/people/_form.html.haml +8 -0
- data/app/views/people/_list.html.haml +7 -0
- data/app/views/people/_person.html.haml +6 -0
- data/app/views/people/_show.html.haml +6 -0
- data/app/views/people/show.html.haml +21 -0
- data/app/views/persons/_civil.html.haml +5 -0
- data/app/views/persons/_show.html.haml +6 -0
- data/app/views/salaries/_form.html.haml +14 -0
- data/app/views/salaries/_list.html.haml +12 -0
- data/app/views/salaries/_salary.html.haml +10 -0
- data/app/views/salaries/_salary_certificate.html.haml +25 -0
- data/app/views/salaries/payslip.html.haml +40 -0
- data/app/views/salaries/show.html.haml +30 -0
- data/app/views/salaries/statistics.html.haml +6 -0
- data/app/views/tenants/_account.html.haml +7 -0
- data/app/views/tenants/_account_group_sheet.html.haml +8 -0
- data/app/views/tenants/_form.html.haml +17 -0
- data/app/views/tenants/_list.html.haml +7 -0
- data/app/views/tenants/_tenant.html.haml +7 -0
- data/app/views/tenants/balance_sheet.html.haml +43 -0
- data/app/views/tenants/index.html.haml +6 -0
- data/app/views/tenants/new.js.erb +1 -0
- data/app/views/tenants/profit_sheet.html.haml +26 -0
- data/app/views/tenants/show.html.haml +18 -0
- data/app/views/users/_demo.de-CH.html.haml +7 -0
- data/app/views/users/_demo.de.html.haml +7 -0
- data/app/views/users/_demo.html.haml +7 -0
- data/app/views/users/_form.html.haml +17 -0
- data/app/views/users/_list.html.haml +9 -0
- data/app/views/users/_show.html.haml +13 -0
- data/app/views/users/_user.html.haml +7 -0
- data/app/views/users/index.html.haml +6 -0
- data/app/views/users/new.js.erb +1 -0
- data/app/views/users/show.html.haml +14 -0
- data/lib/acts_as_csv.rb +113 -0
- data/lib/bookyt/engine.rb +18 -0
- data/lib/bookyt/version.rb +3 -0
- data/lib/float.rb +17 -0
- data/lib/pagination_list_link_renderer.rb +63 -0
- data/lib/parse_date.rb +27 -0
- data/lib/prawn/letter_document.rb +136 -0
- data/lib/raiffeisen_importer.rb +15 -0
- data/lib/recipes/bookyt.rb +15 -0
- data/lib/simple_navigation/renderer/list.rb +20 -0
- data/lib/simple_navigation/renderer/overview.rb +46 -0
- data/lib/sqlite3_extensions.rb +45 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/bookyt.rake +15 -0
- data/lib/tasks/cucumber.rake +53 -0
- data/lib/tasks/environment_seeds.rake +7 -0
- data/lib/tasks/users.rake +46 -0
- metadata +423 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
jQuery(function ($) {
|
2
|
+
$.fn.extend({
|
3
|
+
/**
|
4
|
+
* Handles execution of remote calls involving file uploads, firing overridable events along the way
|
5
|
+
*/
|
6
|
+
callRemotipart: function () {
|
7
|
+
var el = this,
|
8
|
+
url = el.attr('action');
|
9
|
+
|
10
|
+
if (url === undefined) {
|
11
|
+
throw "No URL specified for remote call (action must be present).";
|
12
|
+
} else {
|
13
|
+
if (el.triggerAndReturn('ajax:before')) {
|
14
|
+
if(url.substr(-3) != '.js') url += '.js'; //force rails to respond to respond to the request with :format = js
|
15
|
+
el.ajaxSubmit({
|
16
|
+
url: url,
|
17
|
+
dataType: 'script',
|
18
|
+
beforeSend: function (xhr) {
|
19
|
+
el.trigger('ajax:loading', xhr);
|
20
|
+
},
|
21
|
+
success: function (data, status, xhr) {
|
22
|
+
el.trigger('ajax:success', [data, status, xhr]);
|
23
|
+
},
|
24
|
+
complete: function (xhr) {
|
25
|
+
el.trigger('ajax:complete', xhr);
|
26
|
+
},
|
27
|
+
error: function (xhr, status, error) {
|
28
|
+
el.trigger('ajax:failure', [xhr, status, error]);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
el.trigger('ajax:after');
|
34
|
+
}
|
35
|
+
},
|
36
|
+
_callRemote: $.fn.callRemote, //store the original rails callRemote
|
37
|
+
callRemote: function(){ //override the rails callRemote and check for a file input
|
38
|
+
if(this.find('input:file').length){
|
39
|
+
this.callRemotipart();
|
40
|
+
} else {
|
41
|
+
this._callRemote();
|
42
|
+
}
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
});
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/*
|
2
|
+
combobox 0.1 : Combobox jQuery plugin.
|
3
|
+
|
4
|
+
Authors:
|
5
|
+
jQuery UI Team
|
6
|
+
Simon Hürlimann <simon.huerlimann@cyt.ch>
|
7
|
+
|
8
|
+
Version: 0.1
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function( $ ) {
|
12
|
+
$.widget( "ui.combobox", {
|
13
|
+
_create: function() {
|
14
|
+
var self = this,
|
15
|
+
select = this.element.hide(),
|
16
|
+
selected = select.children( ":selected" ),
|
17
|
+
value = selected.val() ? selected.text() : "";
|
18
|
+
|
19
|
+
var input = $( "<input>" )
|
20
|
+
.insertAfter( select )
|
21
|
+
.val( value )
|
22
|
+
.autocomplete({
|
23
|
+
delay: 0,
|
24
|
+
minLength: 0,
|
25
|
+
source: function( request, response ) {
|
26
|
+
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
|
27
|
+
response( select.children( "option" ).map(function() {
|
28
|
+
var text = $( this ).text();
|
29
|
+
if ( this.value && ( !request.term || matcher.test(text) ) )
|
30
|
+
return {
|
31
|
+
label: text.replace(
|
32
|
+
new RegExp(
|
33
|
+
"(?![^&;]+;)(?!<[^<>]*)(" +
|
34
|
+
$.ui.autocomplete.escapeRegex(request.term) +
|
35
|
+
")(?![^<>]*>)(?![^&;]+;)", "gi"
|
36
|
+
), "<strong>$1</strong>" ),
|
37
|
+
value: text,
|
38
|
+
option: this
|
39
|
+
};
|
40
|
+
}) );
|
41
|
+
},
|
42
|
+
select: function( event, ui ) {
|
43
|
+
ui.item.option.selected = true;
|
44
|
+
self._trigger( "selected", event, {
|
45
|
+
item: ui.item.option
|
46
|
+
});
|
47
|
+
},
|
48
|
+
change: function( event, ui ) {
|
49
|
+
if ( !ui.item ) {
|
50
|
+
var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
|
51
|
+
valid = false;
|
52
|
+
select.children( "option" ).each(function() {
|
53
|
+
if ( this.value.match( matcher ) ) {
|
54
|
+
this.selected = valid = true;
|
55
|
+
return false;
|
56
|
+
}
|
57
|
+
});
|
58
|
+
if ( !valid ) {
|
59
|
+
// remove invalid value, as it didn't match anything
|
60
|
+
$( this ).val( "" );
|
61
|
+
select.val( "" );
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
})
|
67
|
+
.addClass( "ui-widget ui-widget-content ui-corner-left" );
|
68
|
+
|
69
|
+
input.data( "autocomplete" )._renderItem = function( ul, item ) {
|
70
|
+
return $( "<li></li>" )
|
71
|
+
.data( "item.autocomplete", item )
|
72
|
+
.append( "<a>" + item.label + "</a>" )
|
73
|
+
.appendTo( ul );
|
74
|
+
};
|
75
|
+
}
|
76
|
+
});
|
77
|
+
})( jQuery );
|
@@ -0,0 +1,316 @@
|
|
1
|
+
/**
|
2
|
+
* Unobtrusive scripting adapter for jQuery
|
3
|
+
*
|
4
|
+
* Requires jQuery 1.4.4 or later.
|
5
|
+
* https://github.com/rails/jquery-ujs
|
6
|
+
|
7
|
+
* Uploading file using rails.js
|
8
|
+
* =============================
|
9
|
+
*
|
10
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
11
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
12
|
+
*
|
13
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
14
|
+
*
|
15
|
+
* Ex:
|
16
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
17
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
18
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
19
|
+
* return false;
|
20
|
+
* });
|
21
|
+
*
|
22
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
23
|
+
*
|
24
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
25
|
+
* techniques like the iframe method to upload the file instead.
|
26
|
+
*
|
27
|
+
* Required fields in rails.js
|
28
|
+
* ===========================
|
29
|
+
*
|
30
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
31
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
32
|
+
*
|
33
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
34
|
+
*
|
35
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
36
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
37
|
+
*
|
38
|
+
* Ex:
|
39
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
40
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
41
|
+
* // The blank required inputs are passed to this function in `elements`.
|
42
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
43
|
+
* });
|
44
|
+
*/
|
45
|
+
|
46
|
+
(function($, undefined) {
|
47
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
48
|
+
var rails;
|
49
|
+
|
50
|
+
$.rails = rails = {
|
51
|
+
// Link elements bound by jquery-ujs
|
52
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
|
53
|
+
|
54
|
+
// Form elements bound by jquery-ujs
|
55
|
+
formSubmitSelector: 'form',
|
56
|
+
|
57
|
+
// Form input elements bound by jquery-ujs
|
58
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
|
59
|
+
|
60
|
+
// Form input elements disabled during form submission
|
61
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
62
|
+
|
63
|
+
// Form input elements re-enabled after form submission
|
64
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
65
|
+
|
66
|
+
// Form required input elements
|
67
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
68
|
+
|
69
|
+
// Form file input elements
|
70
|
+
fileInputSelector: 'input:file',
|
71
|
+
|
72
|
+
// Make sure that every Ajax request sends the CSRF token
|
73
|
+
CSRFProtection: function(xhr) {
|
74
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
75
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
76
|
+
},
|
77
|
+
|
78
|
+
// Triggers an event on an element and returns false if the event result is false
|
79
|
+
fire: function(obj, name, data) {
|
80
|
+
var event = $.Event(name);
|
81
|
+
obj.trigger(event, data);
|
82
|
+
return event.result !== false;
|
83
|
+
},
|
84
|
+
|
85
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
86
|
+
confirm: function(message) {
|
87
|
+
return confirm(message);
|
88
|
+
},
|
89
|
+
|
90
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
91
|
+
ajax: function(options) {
|
92
|
+
return $.ajax(options);
|
93
|
+
},
|
94
|
+
|
95
|
+
// Submits "remote" forms and links with ajax
|
96
|
+
handleRemote: function(element) {
|
97
|
+
var method, url, data,
|
98
|
+
crossDomain = element.data('cross-domain') || null,
|
99
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
100
|
+
|
101
|
+
if (rails.fire(element, 'ajax:before')) {
|
102
|
+
|
103
|
+
if (element.is('form')) {
|
104
|
+
method = element.attr('method');
|
105
|
+
url = element.attr('action');
|
106
|
+
data = element.serializeArray();
|
107
|
+
// memoized value from clicked submit button
|
108
|
+
var button = element.data('ujs:submit-button');
|
109
|
+
if (button) {
|
110
|
+
data.push(button);
|
111
|
+
element.data('ujs:submit-button', null);
|
112
|
+
}
|
113
|
+
} else {
|
114
|
+
method = element.data('method');
|
115
|
+
url = element.attr('href');
|
116
|
+
data = element.data('params') || null;
|
117
|
+
}
|
118
|
+
|
119
|
+
rails.ajax({
|
120
|
+
url: url, type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
|
121
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
122
|
+
beforeSend: function(xhr, settings) {
|
123
|
+
if (settings.dataType === undefined) {
|
124
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
125
|
+
}
|
126
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
127
|
+
},
|
128
|
+
success: function(data, status, xhr) {
|
129
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
130
|
+
},
|
131
|
+
complete: function(xhr, status) {
|
132
|
+
element.trigger('ajax:complete', [xhr, status]);
|
133
|
+
},
|
134
|
+
error: function(xhr, status, error) {
|
135
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
136
|
+
}
|
137
|
+
});
|
138
|
+
}
|
139
|
+
},
|
140
|
+
|
141
|
+
// Handles "data-method" on links such as:
|
142
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
143
|
+
handleMethod: function(link) {
|
144
|
+
var href = link.attr('href'),
|
145
|
+
method = link.data('method'),
|
146
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
147
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
148
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
149
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
150
|
+
|
151
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
152
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
153
|
+
}
|
154
|
+
|
155
|
+
form.hide().append(metadata_input).appendTo('body');
|
156
|
+
form.submit();
|
157
|
+
},
|
158
|
+
|
159
|
+
/* Disables form elements:
|
160
|
+
- Caches element value in 'ujs:enable-with' data store
|
161
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
162
|
+
- Adds disabled=disabled attribute
|
163
|
+
*/
|
164
|
+
disableFormElements: function(form) {
|
165
|
+
form.find(rails.disableSelector).each(function() {
|
166
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
167
|
+
element.data('ujs:enable-with', element[method]());
|
168
|
+
element[method](element.data('disable-with'));
|
169
|
+
element.attr('disabled', 'disabled');
|
170
|
+
});
|
171
|
+
},
|
172
|
+
|
173
|
+
/* Re-enables disabled form elements:
|
174
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
175
|
+
- Removes disabled attribute
|
176
|
+
*/
|
177
|
+
enableFormElements: function(form) {
|
178
|
+
form.find(rails.enableSelector).each(function() {
|
179
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
180
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
181
|
+
element.removeAttr('disabled');
|
182
|
+
});
|
183
|
+
},
|
184
|
+
|
185
|
+
/* For 'data-confirm' attribute:
|
186
|
+
- Fires `confirm` event
|
187
|
+
- Shows the confirmation dialog
|
188
|
+
- Fires the `confirm:complete` event
|
189
|
+
|
190
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
191
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
192
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
193
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
194
|
+
*/
|
195
|
+
allowAction: function(element) {
|
196
|
+
var message = element.data('confirm'),
|
197
|
+
answer = false, callback;
|
198
|
+
if (!message) { return true; }
|
199
|
+
|
200
|
+
if (rails.fire(element, 'confirm')) {
|
201
|
+
answer = rails.confirm(message);
|
202
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
203
|
+
}
|
204
|
+
return answer && callback;
|
205
|
+
},
|
206
|
+
|
207
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
208
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
209
|
+
var inputs = $(), input,
|
210
|
+
selector = specifiedSelector || 'input,textarea';
|
211
|
+
form.find(selector).each(function() {
|
212
|
+
input = $(this);
|
213
|
+
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
214
|
+
if (nonBlank ? input.val() : !input.val()) {
|
215
|
+
inputs = inputs.add(input);
|
216
|
+
}
|
217
|
+
});
|
218
|
+
return inputs.length ? inputs : false;
|
219
|
+
},
|
220
|
+
|
221
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
222
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
223
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
224
|
+
},
|
225
|
+
|
226
|
+
// Helper function, needed to provide consistent behavior in IE
|
227
|
+
stopEverything: function(e) {
|
228
|
+
$(e.target).trigger('ujs:everythingStopped');
|
229
|
+
e.stopImmediatePropagation();
|
230
|
+
return false;
|
231
|
+
},
|
232
|
+
|
233
|
+
// find all the submit events directly bound to the form and
|
234
|
+
// manually invoke them. If anyone returns false then stop the loop
|
235
|
+
callFormSubmitBindings: function(form) {
|
236
|
+
var events = form.data('events'), continuePropagation = true;
|
237
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
238
|
+
$.each(events['submit'], function(i, obj){
|
239
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
|
240
|
+
});
|
241
|
+
}
|
242
|
+
return continuePropagation;
|
243
|
+
}
|
244
|
+
};
|
245
|
+
|
246
|
+
// ajaxPrefilter is a jQuery 1.5 feature
|
247
|
+
if ('ajaxPrefilter' in $) {
|
248
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
249
|
+
} else {
|
250
|
+
$(document).ajaxSend(function(e, xhr, options){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
251
|
+
}
|
252
|
+
|
253
|
+
$(rails.linkClickSelector).live('click.rails', function(e) {
|
254
|
+
var link = $(this);
|
255
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
256
|
+
|
257
|
+
if (link.data('remote') !== undefined) {
|
258
|
+
rails.handleRemote(link);
|
259
|
+
return false;
|
260
|
+
} else if (link.data('method')) {
|
261
|
+
rails.handleMethod(link);
|
262
|
+
return false;
|
263
|
+
}
|
264
|
+
});
|
265
|
+
|
266
|
+
$(rails.formSubmitSelector).live('submit.rails', function(e) {
|
267
|
+
var form = $(this),
|
268
|
+
remote = form.data('remote') !== undefined,
|
269
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
270
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
271
|
+
|
272
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
273
|
+
|
274
|
+
// skip other logic when required values are missing or file upload is present
|
275
|
+
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
276
|
+
return rails.stopEverything(e);
|
277
|
+
}
|
278
|
+
|
279
|
+
if (remote) {
|
280
|
+
if (nonBlankFileInputs) {
|
281
|
+
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
282
|
+
}
|
283
|
+
|
284
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
285
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
286
|
+
if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
|
287
|
+
|
288
|
+
rails.handleRemote(form);
|
289
|
+
return false;
|
290
|
+
} else {
|
291
|
+
// slight timeout so that the submit button gets properly serialized
|
292
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
293
|
+
}
|
294
|
+
});
|
295
|
+
|
296
|
+
$(rails.formInputClickSelector).live('click.rails', function(event) {
|
297
|
+
var button = $(this);
|
298
|
+
|
299
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
300
|
+
|
301
|
+
// register the pressed submit button
|
302
|
+
var name = button.attr('name'),
|
303
|
+
data = name ? {name:name, value:button.val()} : null;
|
304
|
+
|
305
|
+
button.closest('form').data('ujs:submit-button', data);
|
306
|
+
});
|
307
|
+
|
308
|
+
$(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
|
309
|
+
if (this == event.target) rails.disableFormElements($(this));
|
310
|
+
});
|
311
|
+
|
312
|
+
$(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
|
313
|
+
if (this == event.target) rails.enableFormElements($(this));
|
314
|
+
});
|
315
|
+
|
316
|
+
})( jQuery );
|
@@ -0,0 +1,51 @@
|
|
1
|
+
jQuery(function($) {
|
2
|
+
$('form a.add_nested_fields').live('click', function() {
|
3
|
+
// Setup
|
4
|
+
var assoc = $(this).attr('data-association'); // Name of child
|
5
|
+
var content = $('#' + assoc + '_fields_blueprint').html(); // Fields template
|
6
|
+
|
7
|
+
// Make the context correct by replacing new_<parents> with the generated ID
|
8
|
+
// of each of the parent objects
|
9
|
+
var context = ($(this).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), '');
|
10
|
+
|
11
|
+
// context will be something like this for a brand new form:
|
12
|
+
// project[tasks_attributes][new_1255929127459][assignments_attributes][new_1255929128105]
|
13
|
+
// or for an edit form:
|
14
|
+
// project[tasks_attributes][0][assignments_attributes][1]
|
15
|
+
if(context) {
|
16
|
+
var parent_names = context.match(/[a-z_]+_attributes/g) || [];
|
17
|
+
var parent_ids = context.match(/(new_)?[0-9]+/g) || [];
|
18
|
+
|
19
|
+
for(var i = 0; i < parent_names.length; i++) {
|
20
|
+
if(parent_ids[i]) {
|
21
|
+
content = content.replace(
|
22
|
+
new RegExp('(_' + parent_names[i] + ')_.+?_', 'g'),
|
23
|
+
'$1_' + parent_ids[i] + '_');
|
24
|
+
|
25
|
+
content = content.replace(
|
26
|
+
new RegExp('(\\[' + parent_names[i] + '\\])\\[.+?\\]', 'g'),
|
27
|
+
'$1[' + parent_ids[i] + ']');
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// Make a unique ID for the new child
|
33
|
+
var regexp = new RegExp('new_' + assoc, 'g');
|
34
|
+
var new_id = new Date().getTime();
|
35
|
+
content = content.replace(regexp, "new_" + new_id);
|
36
|
+
|
37
|
+
var field = $(content).insertBefore(this);
|
38
|
+
$(this).closest("form").trigger({type: 'nested:fieldAdded', field: field});
|
39
|
+
return false;
|
40
|
+
});
|
41
|
+
|
42
|
+
$('form a.remove_nested_fields').live('click', function() {
|
43
|
+
var hidden_field = $(this).prev('input[type=hidden]')[0];
|
44
|
+
if(hidden_field) {
|
45
|
+
hidden_field.value = '1';
|
46
|
+
}
|
47
|
+
$(this).closest('.fields').hide();
|
48
|
+
$(this).closest("form").trigger('nested:fieldRemoved');
|
49
|
+
return false;
|
50
|
+
});
|
51
|
+
});
|