guara 0.0.1.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.travis.yml +33 -0
- data/Gemfile +82 -0
- data/Gemfile.lock +323 -0
- data/Guardfile +32 -0
- data/MIT-LICENSE +20 -0
- data/README.md +8 -0
- data/Rakefile +7 -0
- data/app/admin/business_activities.rb +3 -0
- data/app/admin/business_departments.rb +3 -0
- data/app/admin/business_segments.rb +13 -0
- data/app/admin/cities.rb +3 -0
- data/app/admin/company_businesses.rb +3 -0
- data/app/admin/dashboard.rb +39 -0
- data/app/admin/districts.rb +3 -0
- data/app/admin/states.rb +3 -0
- data/app/admin/task_types.rb +3 -0
- data/app/admin/user_groups.rb +3 -0
- data/app/admin/users.rb +3 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/custom/logo.png +0 -0
- data/app/assets/images/custom/nav_logo.png +0 -0
- data/app/assets/images/custom/nav_logo.psd +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/active_admin.js +5 -0
- data/app/assets/javascripts/application.js +97 -0
- data/app/assets/javascripts/business_departments.js.coffee +3 -0
- data/app/assets/javascripts/company_businesses.js.coffee +3 -0
- data/app/assets/javascripts/crm.js.coffee +14 -0
- data/app/assets/javascripts/fcbk.js +556 -0
- data/app/assets/javascripts/jquery-ui-timepicker-addon.js +1326 -0
- data/app/assets/javascripts/jquery.mask.1.3.js +7 -0
- data/app/assets/javascripts/jquery.multiselect.filter.xjs +173 -0
- data/app/assets/javascripts/jquery.multiselect.xjs +668 -0
- data/app/assets/javascripts/system_task_status.js.coffee +3 -0
- data/app/assets/javascripts/tests/ajaxes.js.coffee +3 -0
- data/app/assets/stylesheets/abilities.css.scss +6 -0
- data/app/assets/stylesheets/active_admin.css.scss +65 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/business_departments.css.scss +3 -0
- data/app/assets/stylesheets/company_businesses.css.scss +3 -0
- data/app/assets/stylesheets/custom.css.scss +322 -0
- data/app/assets/stylesheets/customer.scss +7 -0
- data/app/assets/stylesheets/fcbk.css +165 -0
- data/app/assets/stylesheets/guara.css.scss +159 -0
- data/app/assets/stylesheets/jquery-ui.css +567 -0
- data/app/assets/stylesheets/jquery_bootstrap.css.scss +92 -0
- data/app/assets/stylesheets/jquery_multiselect_filter.xcss +3 -0
- data/app/assets/stylesheets/scaffolds.css.scss +42 -0
- data/app/assets/stylesheets/users.css.scss +10 -0
- data/app/controllers/abilities_controller.rb +37 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/business_activities_controller.rb +87 -0
- data/app/controllers/business_departments_controller.rb +90 -0
- data/app/controllers/business_segments_controller.rb +88 -0
- data/app/controllers/company_businesses_controller.rb +46 -0
- data/app/controllers/contacts_controller.rb +105 -0
- data/app/controllers/customers_controller.rb +117 -0
- data/app/controllers/microposts_controller.rb +31 -0
- data/app/controllers/sessions_controller.rb +32 -0
- data/app/controllers/static_pages_controller.rb +23 -0
- data/app/controllers/system_task_status_controller.rb +84 -0
- data/app/controllers/task_feedbacks_controller.rb +6 -0
- data/app/controllers/task_types_controller.rb +85 -0
- data/app/controllers/tasks_controller.rb +107 -0
- data/app/controllers/tests/ajaxes_controller.rb +115 -0
- data/app/controllers/tests/lab_ajax_controller.rb +27 -0
- data/app/controllers/users_controller.rb +62 -0
- data/app/helpers/ability_helper.rb +15 -0
- data/app/helpers/application_helper.rb +32 -0
- data/app/helpers/business_activities_helper.rb +2 -0
- data/app/helpers/business_departments_helper.rb +2 -0
- data/app/helpers/business_segments_helper.rb +2 -0
- data/app/helpers/company_businesses_helper.rb +2 -0
- data/app/helpers/contacts_helper.rb +2 -0
- data/app/helpers/customers_helper.rb +23 -0
- data/app/helpers/email_helper.rb +8 -0
- data/app/helpers/form_ajax_helper.rb +8 -0
- data/app/helpers/guara_views_helper.rb +38 -0
- data/app/helpers/locale_helper.rb +24 -0
- data/app/helpers/menu_helper.rb +55 -0
- data/app/helpers/sessions_helper.rb +56 -0
- data/app/helpers/tasks_helper.rb +20 -0
- data/app/helpers/tests/ajaxes_helper.rb +2 -0
- data/app/helpers/user_abilities_helper.rb +12 -0
- data/app/helpers/users_helper.rb +29 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +52 -0
- data/app/models/address.rb +7 -0
- data/app/models/business_activity.rb +5 -0
- data/app/models/business_department.rb +3 -0
- data/app/models/business_segment.rb +5 -0
- data/app/models/city.rb +7 -0
- data/app/models/company_business.rb +6 -0
- data/app/models/contact.rb +69 -0
- data/app/models/customer.rb +117 -0
- data/app/models/customer_activity.rb +9 -0
- data/app/models/customer_financial.rb +10 -0
- data/app/models/customer_has_customers.rb +7 -0
- data/app/models/customer_pf.rb +13 -0
- data/app/models/customer_pj.rb +71 -0
- data/app/models/customer_pj_has_customers_pj.rb +7 -0
- data/app/models/customer_product.rb +3 -0
- data/app/models/customer_segment.rb +9 -0
- data/app/models/district.rb +6 -0
- data/app/models/email.rb +7 -0
- data/app/models/micropost.rb +10 -0
- data/app/models/relationship.rb +9 -0
- data/app/models/search.rb +17 -0
- data/app/models/state.rb +3 -0
- data/app/models/system_ability.rb +16 -0
- data/app/models/system_module.rb +16 -0
- data/app/models/system_task_resolution.rb +26 -0
- data/app/models/system_task_status.rb +19 -0
- data/app/models/task.rb +76 -0
- data/app/models/task_feedback.rb +11 -0
- data/app/models/task_type.rb +12 -0
- data/app/models/tests.rb +5 -0
- data/app/models/tests/ajax.rb +3 -0
- data/app/models/user.rb +126 -0
- data/app/models/user_ability.rb +23 -0
- data/app/models/user_group.rb +9 -0
- data/app/models/user_type.rb +9 -0
- data/app/models/users_has_groups.rb +9 -0
- data/app/validators/customer_cnpj_validator.rb +14 -0
- data/app/validators/email_validator.rb +21 -0
- data/app/views/abilities/index.html.erb +25 -0
- data/app/views/active_extend/_one_to_many_inputs.html.erb +7 -0
- data/app/views/active_extend/_one_to_many_inputs_fields.html.erb +10 -0
- data/app/views/active_extend/_one_to_many_inputs_with_glyph.html.erb +21 -0
- data/app/views/business_activities/_business_activity.html.erb +0 -0
- data/app/views/business_activities/_form.html.erb +25 -0
- data/app/views/business_activities/edit.html.erb +6 -0
- data/app/views/business_activities/index.html.erb +33 -0
- data/app/views/business_activities/new.html.erb +5 -0
- data/app/views/business_activities/show.html.erb +15 -0
- data/app/views/business_departments/_form.html.erb +10 -0
- data/app/views/business_departments/edit.html.erb +6 -0
- data/app/views/business_departments/index.html.erb +33 -0
- data/app/views/business_departments/new.html.erb +5 -0
- data/app/views/business_departments/show.html.erb +15 -0
- data/app/views/business_segments/_business_segment.html.erb +8 -0
- data/app/views/business_segments/_form.html.erb +25 -0
- data/app/views/business_segments/edit.html.erb +6 -0
- data/app/views/business_segments/index.html.erb +33 -0
- data/app/views/business_segments/new.html.erb +5 -0
- data/app/views/business_segments/show.html.erb +15 -0
- data/app/views/company_businesses/_form.html.erb +10 -0
- data/app/views/company_businesses/edit.html.erb +6 -0
- data/app/views/company_businesses/index.html.erb +25 -0
- data/app/views/company_businesses/new.html.erb +5 -0
- data/app/views/company_businesses/show.html.erb +15 -0
- data/app/views/contacts/_form.html.erb +53 -0
- data/app/views/contacts/_header.html.erb +3 -0
- data/app/views/contacts/_list.html.erb +46 -0
- data/app/views/contacts/_side_panel.html.erb +61 -0
- data/app/views/contacts/edit.html.erb +6 -0
- data/app/views/contacts/index.html.erb +72 -0
- data/app/views/contacts/new.html.erb +5 -0
- data/app/views/contacts/show.html.erb +52 -0
- data/app/views/customers/_businesses_done.html.erb +18 -0
- data/app/views/customers/_customer_segment.html.erb +9 -0
- data/app/views/customers/_form.html.erb +177 -0
- data/app/views/customers/_form_search.html.erb +119 -0
- data/app/views/customers/_modules.html.erb +6 -0
- data/app/views/customers/_navbar.html.erb +23 -0
- data/app/views/customers/_segment.html.erb +10 -0
- data/app/views/customers/edit.html.erb +8 -0
- data/app/views/customers/index.html.erb +46 -0
- data/app/views/customers/new.pj.html.erb +4 -0
- data/app/views/customers/show.pj.html.erb +200 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +24 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/app/views/emails/_email_fields.html.erb +1 -0
- data/app/views/layouts/_active_admin_footer.html.erb +4 -0
- data/app/views/layouts/_active_admin_header.html.erb +5 -0
- data/app/views/layouts/_footer.html.erb +12 -0
- data/app/views/layouts/_header.html.erb +51 -0
- data/app/views/layouts/_shim.html.erb +3 -0
- data/app/views/layouts/active_admin.html.arb +1 -0
- data/app/views/layouts/application.html.erb +24 -0
- data/app/views/microposts/_micropost.html.erb +11 -0
- data/app/views/sessions/new.html.erb +18 -0
- data/app/views/shared/_calendar.html.erb +17 -0
- data/app/views/shared/_error_messages.html.erb +13 -0
- data/app/views/shared/_feed.html.erb +10 -0
- data/app/views/shared/_feed_item.html.erb +15 -0
- data/app/views/shared/_micropost_form.html.erb +7 -0
- data/app/views/shared/_multi_selection.html.erb +16 -0
- data/app/views/shared/_multi_selection.html_checkbox.erb +11 -0
- data/app/views/shared/_multi_selection_autocomple.html.erb +5 -0
- data/app/views/shared/_notifies.html.erb +17 -0
- data/app/views/shared/_user_info.html.erb +14 -0
- data/app/views/static_pages/about.html.erb +5 -0
- data/app/views/static_pages/contact.html.erb +5 -0
- data/app/views/static_pages/help.html.erb +5 -0
- data/app/views/static_pages/home.html.erb +37 -0
- data/app/views/static_pages/news.html.erb +2 -0
- data/app/views/system_task_status/_form.html.erb +9 -0
- data/app/views/system_task_status/edit.html.erb +6 -0
- data/app/views/system_task_status/index.html.erb +23 -0
- data/app/views/system_task_status/new.html.erb +5 -0
- data/app/views/system_task_status/show.html.erb +10 -0
- data/app/views/task_feedbacks/_list.html.erb +51 -0
- data/app/views/task_feedbacks/_side_form.html.erb +56 -0
- data/app/views/task_feedbacks/_side_panel.html.erb +64 -0
- data/app/views/task_types/_form.html.erb +10 -0
- data/app/views/task_types/edit.html.erb +6 -0
- data/app/views/task_types/index.html.erb +23 -0
- data/app/views/task_types/new.html.erb +5 -0
- data/app/views/task_types/show.html.erb +10 -0
- data/app/views/tasks/_form.html.erb +52 -0
- data/app/views/tasks/_header.html.erb +3 -0
- data/app/views/tasks/_list.html.erb +50 -0
- data/app/views/tasks/_side_panel.html.erb +64 -0
- data/app/views/tasks/create.js.erb +1 -0
- data/app/views/tasks/edit.html.erb +6 -0
- data/app/views/tasks/index.html.erb +61 -0
- data/app/views/tasks/new.html.erb +5 -0
- data/app/views/tasks/show.html.erb +46 -0
- data/app/views/tests/ajaxes/_form.html.erb +10 -0
- data/app/views/tests/ajaxes/_list.html.erb +6 -0
- data/app/views/tests/ajaxes/add_and_update.html.erb +22 -0
- data/app/views/tests/ajaxes/all.js.erb +2 -0
- data/app/views/tests/ajaxes/edit.html.erb +6 -0
- data/app/views/tests/ajaxes/index.html.erb +25 -0
- data/app/views/tests/ajaxes/new.html.erb +5 -0
- data/app/views/tests/ajaxes/show.html.erb +15 -0
- data/app/views/tests/js.js +51 -0
- data/app/views/tests/lab_ajax/multiselection.html.erb +84 -0
- data/app/views/users/_user.html.erb +8 -0
- data/app/views/users/edit.html.erb +27 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +24 -0
- data/app/views/users/show.html.erb +26 -0
- data/bundle +0 -0
- data/config.ru +4 -0
- data/config/application.rb +73 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +38 -0
- data/config/environment.rb +31 -0
- data/config/environments/development.rb +42 -0
- data/config/environments/production.rb +68 -0
- data/config/environments/test.rb +39 -0
- data/config/guara/menus.rb +34 -0
- data/config/initializers/active_admin.rb +210 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cmgb_rules.rb +2 -0
- data/config/initializers/devise.rb +216 -0
- data/config/initializers/formtastic.rb +77 -0
- data/config/initializers/inflections.rb +19 -0
- data/config/initializers/json_paches_utf8.rb +13 -0
- data/config/initializers/kaminari.rb +21 -0
- data/config/initializers/locale.rb +7 -0
- data/config/initializers/meta_search.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/string.rb +9 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/devise.pt-BR.yml +62 -0
- data/config/locales/pt-BR.yml +404 -0
- data/config/routes.rb +129 -0
- data/db/migrate/20120610142404_create_users.rb +10 -0
- data/db/migrate/20120610183820_add_index_to_users_email.rb +5 -0
- data/db/migrate/20120610185217_add_password_digest_to_users.rb +5 -0
- data/db/migrate/20120612000411_add_remember_token_to_users.rb +6 -0
- data/db/migrate/20120616162515_add_admin_to_users.rb +5 -0
- data/db/migrate/20120616215835_create_microposts.rb +11 -0
- data/db/migrate/20120617224530_create_relationships.rb +14 -0
- data/db/migrate/20120621095918_create_customers.rb +36 -0
- data/db/migrate/20120621100528_create_customer_pfs.rb +14 -0
- data/db/migrate/20120621100534_create_customer_pjs.rb +13 -0
- data/db/migrate/20120621100557_create_emails.rb +13 -0
- data/db/migrate/20120621100618_create_tasks.rb +26 -0
- data/db/migrate/20120621100639_create_customer_products.rb +14 -0
- data/db/migrate/20120621100705_create_districts.rb +11 -0
- data/db/migrate/20120621100720_create_cities.rb +11 -0
- data/db/migrate/20120624192444_create_business_segments.rb +10 -0
- data/db/migrate/20120624224245_create_business_activities.rb +13 -0
- data/db/migrate/20120628092744_create_customer_activities.rb +9 -0
- data/db/migrate/20120628092754_create_customer_segments.rb +9 -0
- data/db/migrate/20120703102859_create_states.rb +10 -0
- data/db/migrate/20120705121011_create_contacts.rb +18 -0
- data/db/migrate/20120711233943_add_devise_to_users.rb +56 -0
- data/db/migrate/20120723102847_create_user_abilities.rb +10 -0
- data/db/migrate/20120723104500_create_system_modules.rb +9 -0
- data/db/migrate/20120723104639_create_system_abilities.rb +9 -0
- data/db/migrate/20120728181903_create_user_groups.rb +10 -0
- data/db/migrate/20120729112600_create_users_has_groups.rb +14 -0
- data/db/migrate/20120729121922_add_groups_to_users.rb +6 -0
- data/db/migrate/20120910002835_create_system_task_status.rb +7 -0
- data/db/migrate/20120910010153_create_system_task_resolutions.rb +7 -0
- data/db/migrate/20120911021535_create_task_types.rb +10 -0
- data/db/migrate/20120911070836_create_task_feedbacks.rb +14 -0
- data/db/migrate/20120924022719_create_tests_ajaxes.rb +10 -0
- data/db/migrate/20121007131035_create_business_departments.rb +10 -0
- data/db/migrate/20121013120849_add_notes_and_other_contacts_to_customer.rb +5 -0
- data/db/migrate/20121014201255_create_company_businesses.rb +10 -0
- data/db/migrate/20121014202449_add_company_business_to_task_type.rb +6 -0
- data/db/migrate/20121014212430_add_primary_company_business_to_user.rb +5 -0
- data/db/migrate/20121015101844_add_parent_id_to_system_task_resolution.rb +5 -0
- data/db/migrate/20121026231241_create_customer_has_customers.rb +10 -0
- data/db/migrate/20121026232755_create_customer_pj_has_customers_pjs.rb +10 -0
- data/db/migrate/20121029094047_create_admin_notes.rb +17 -0
- data/db/migrate/20121029094048_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20121103183646_add_enabled_to_cities.rb +5 -0
- data/db/migrate/20121104135014_create_customer_financials.rb +17 -0
- data/db/migrate/20121104141751_create_addresses.rb +19 -0
- data/db/migrate/20121205150619_add_type_id_to_users.rb +5 -0
- data/db/schema.rb~ +378 -0
- data/db/seeds.rb +99 -0
- data/gemfiles/Gemfile.rails.3.2.x +82 -0
- data/guara.gemspec +31 -0
- data/lib/active_extend/README.md +19 -0
- data/lib/active_extend/active_disablable.rb +59 -0
- data/lib/active_extend/string_helper.rb +9 -0
- data/lib/active_migration.rb +4 -0
- data/lib/active_migration/converters/rtf_to_html.rb +123 -0
- data/lib/active_migration/dictionary.rb +19 -0
- data/lib/active_migration/migration.rb +211 -0
- data/lib/active_migration/schemas.rb +143 -0
- data/lib/active_migration/spelling_fix.rb +20 -0
- data/lib/active_migration/transformer/grouped_field_fixed_spelling.rb +110 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/cmgb_rules/app/models/task.rb +19 -0
- data/lib/guara/version.rb +3 -0
- data/lib/spec/asserts/sheet1.xls +0 -0
- data/lib/spec/lib/active_migration_schemas_spec.rb +40 -0
- data/lib/spec/lib/active_migration_spec.rb +78 -0
- data/lib/spec/spec_helper.rb +121 -0
- data/lib/spec/support/active_migration_helper.rb +109 -0
- data/lib/spec/support/utilities.rb +7 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/add_privilegies.rake +6 -0
- data/lib/tasks/external_migration.rake +22 -0
- data/lib/tasks/sample_data.rake +77 -0
- data/lib/tasks/smaple_data_test.rake +13 -0
- data/lib/templates/erb/scaffold/_form.html.erb +11 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/data.txt +1 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/autocomplete-rails.js +16 -0
- data/public/robots.txt +5 -0
- data/script/create_db +5 -0
- data/script/rails +6 -0
- data/script/recreate_db +5 -0
- data/script/recreate_db.bat +9 -0
- data/script/recreate_db_test +5 -0
- data/script/recreate_development_db +10 -0
- data/spec/controllers/business_activities_controller_spec.disabled +167 -0
- data/spec/controllers/business_departments_controller_spec.disabled +164 -0
- data/spec/controllers/business_segments_controller_spec.disabled +165 -0
- data/spec/controllers/company_businesses_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_spec.disabled +11 -0
- data/spec/controllers/task_types_controller_spec.disabled +164 -0
- data/spec/controllers/tasks_controller_spec.disabled +23 -0
- data/spec/controllers/tests/ajaxes_controller_spec.disabled +164 -0
- data/spec/factories.rb +101 -0
- data/spec/factories/addresses.rb +13 -0
- data/spec/factories/business_departments.rb +8 -0
- data/spec/factories/company_businesses.rb +8 -0
- data/spec/factories/customer_financials.rb +11 -0
- data/spec/factories/customer_has_customers.rb +8 -0
- data/spec/factories/customer_pj_has_customers_pjs.rb +8 -0
- data/spec/factories/system_task_resolutions.rb +7 -0
- data/spec/factories/system_task_status.rb +7 -0
- data/spec/factories/task.rb +17 -0
- data/spec/factories/task_feedbacks.rb +19 -0
- data/spec/factories/task_types.rb +8 -0
- data/spec/factories/tests_ajaxes.rb +8 -0
- data/spec/helpers/business_activities_helper_spec.rb +15 -0
- data/spec/helpers/business_departments_helper_spec.rb +15 -0
- data/spec/helpers/business_segments_helper_spec.rb +15 -0
- data/spec/helpers/company_businesses_helper_spec.rb +15 -0
- data/spec/helpers/customers/contacts_helper_spec.rb +15 -0
- data/spec/helpers/menu_helper_spec.rb +25 -0
- data/spec/helpers/tests/ajaxes_helper_spec.rb +15 -0
- data/spec/helpers/users_helpers_spec.rb +32 -0
- data/spec/models/address_spec.rb +5 -0
- data/spec/models/business_activity_spec.rb +5 -0
- data/spec/models/business_department_spec.rb +5 -0
- data/spec/models/business_segment_spec.rb +5 -0
- data/spec/models/city_spec.rb +5 -0
- data/spec/models/company_business_spec.rb +19 -0
- data/spec/models/contact_spec.rb +60 -0
- data/spec/models/customer_activity_spec.rb +5 -0
- data/spec/models/customer_financial_spec.rb +48 -0
- data/spec/models/customer_has_customers_spec.rb +18 -0
- data/spec/models/customer_pf_spec.rb +24 -0
- data/spec/models/customer_pj_has_customers_pj_spec.rb +34 -0
- data/spec/models/customer_pj_spec.rb +72 -0
- data/spec/models/customer_product_spec.rb +5 -0
- data/spec/models/customer_segment_spec.rb +5 -0
- data/spec/models/customer_spec.rb +135 -0
- data/spec/models/district_spec.rb +5 -0
- data/spec/models/emails_spec.rb +24 -0
- data/spec/models/micropost_spec.rb +49 -0
- data/spec/models/relationship_spec.rb +38 -0
- data/spec/models/state_spec.rb +5 -0
- data/spec/models/system_ability_spec.rb +5 -0
- data/spec/models/system_module_spec.rb +5 -0
- data/spec/models/system_task_resolution_spec.rb +17 -0
- data/spec/models/system_task_status_spec.rb +17 -0
- data/spec/models/task_feedback_spec.rb +46 -0
- data/spec/models/task_spec.rb +176 -0
- data/spec/models/task_type_spec.rb +27 -0
- data/spec/models/tests/ajax_spec.rb +5 -0
- data/spec/models/user_ability_spec.rb +35 -0
- data/spec/models/user_group_spec.rb +26 -0
- data/spec/models/user_spec.rb +274 -0
- data/spec/models/users_has_groups_spec.rb +29 -0
- data/spec/requests/authentication_pages_spec.rb +157 -0
- data/spec/requests/business_activities_spec.rb +7 -0
- data/spec/requests/business_departments_spec.rb +7 -0
- data/spec/requests/business_segments_spec.rb +7 -0
- data/spec/requests/company_businesses_spec.rb +11 -0
- data/spec/requests/customer_contacts_pages_spec.rb +96 -0
- data/spec/requests/customer_pages_spec.rb +60 -0
- data/spec/requests/micropost_pages_spec.rb +58 -0
- data/spec/requests/static_pages_spec.rb +57 -0
- data/spec/requests/task_pages_spec.rb +124 -0
- data/spec/requests/tests/tests_ajaxes_spec.rb +11 -0
- data/spec/requests/user_abilities_pages_spec.rb +73 -0
- data/spec/requests/user_pages_spec.rb +116 -0
- data/spec/routing/business_activities_routing_spec.rb +35 -0
- data/spec/routing/business_departments_routing_spec.rb +35 -0
- data/spec/routing/business_segments_routing_spec.rb +35 -0
- data/spec/routing/company_businesses_routing_spec.rb +35 -0
- data/spec/routing/system_task_status_routing_spec.rb +35 -0
- data/spec/routing/task_types_routing_spec.rb +35 -0
- data/spec/routing/tests/ajaxes_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +123 -0
- data/spec/support/custom_matchers.rb +9 -0
- data/spec/support/utilities.rb +120 -0
- data/spec/views/business_departments/edit.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/index.html.erb_spec.disabled +23 -0
- data/spec/views/business_departments/new.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/show.html.erb_spec.rb +17 -0
- data/spec/views/company_businesses/edit.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/index.html.erb_spec.rb +23 -0
- data/spec/views/company_businesses/new.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/show.html.erb_spec.rb +17 -0
- data/spec/views/task_types/edit.html.erb_spec.rb +18 -0
- data/spec/views/task_types/index.html.erb_spec.rb +20 -0
- data/spec/views/task_types/new.html.erb_spec.rb +18 -0
- data/spec/views/task_types/show.html.erb_spec.rb +15 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/integration/.gitkeep +0 -0
- data/test/performance/browsing_test.rb +12 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/.gitkeep +0 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/active_admin/_base.css.scss +45 -0
- data/vendor/assets/stylesheets/active_admin/_forms.css.scss +270 -0
- data/vendor/assets/stylesheets/active_admin/_header.css.scss +137 -0
- data/vendor/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
- data/vendor/assets/stylesheets/active_admin/_typography.css.scss +100 -0
- data/vendor/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/vendor/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/vendor/assets/stylesheets/active_admin/components/_buttons.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_columns.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/components/_comments.css.scss +40 -0
- data/vendor/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
- data/vendor/assets/stylesheets/active_admin/components/_flash_messages.css.scss +39 -0
- data/vendor/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/vendor/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/vendor/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/vendor/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/vendor/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/vendor/assets/stylesheets/active_admin/components/_table_tools.css.scss +94 -0
- data/vendor/assets/stylesheets/active_admin/components/_tables.css.scss +108 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_all.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_buttons.css.scss +66 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_gradients.css.scss +37 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_icons.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_reset.css.scss +165 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_rounded.css.scss +43 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_sections.css.scss +36 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_shadows.css.scss +22 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_utilities.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_variables.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/vendor/assets/stylesheets/active_admin/print.css.scss +290 -0
- data/vendor/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/vendor/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +731 -0
data/Guardfile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
|
5
|
+
watch('config/application.rb')
|
6
|
+
watch('config/environment.rb')
|
7
|
+
watch(%r{^config/environments/.+\.rb$})
|
8
|
+
watch(%r{^config/initializers/.+\.rb$})
|
9
|
+
watch('Gemfile')
|
10
|
+
watch('Gemfile.lock')
|
11
|
+
watch('spec/spec_helper.rb')
|
12
|
+
watch('test/test_helper.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
guard 'rspec', :version => 2, :all_after_pass => false, :cli => '--drb' do
|
16
|
+
watch(%r{^spec/.+_spec\.rb$})
|
17
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
18
|
+
watch('spec/spec_helper.rb') { "spec" }
|
19
|
+
|
20
|
+
# Rails example
|
21
|
+
watch(%r{^spec/.+_spec\.rb$})
|
22
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
23
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
24
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
25
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
26
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
27
|
+
watch('spec/spec_helper.rb') { "spec" }
|
28
|
+
watch('config/routes.rb') { "spec/routing" }
|
29
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
30
|
+
# Capybara request specs
|
31
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
32
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2009-2012 Plataformatec. http://plataformatec.com.br
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Guara-CRM
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/woese/guara-crm.png)](http://travis-ci.org/woese/guara-crm)
|
5
|
+
[![Dependency Status](https://gemnasium.com/woese/guara-crm.png)](https://gemnasium.com/woese/guara-crm)
|
6
|
+
[![Code Quality](https://codeclimate.com/badge.png)](https://codeclimate.com/github/woese/guara-crm)
|
7
|
+
|
8
|
+
## Guara CRM
|
data/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
GUARACRM::Application.load_tasks
|
data/app/admin/cities.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
ActiveAdmin.register_page "Dashboard" do
|
2
|
+
|
3
|
+
controller.skip_authorization_check
|
4
|
+
|
5
|
+
def authenticate_admin!
|
6
|
+
redirect_to new_user_session_path unless current_user.is_admin?
|
7
|
+
end
|
8
|
+
|
9
|
+
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
|
10
|
+
|
11
|
+
content :title => proc{ I18n.t("active_admin.dashboard") } do
|
12
|
+
div :class => "blank_slate_container", :id => "dashboard_default_message" do
|
13
|
+
span :class => "blank_slate" do
|
14
|
+
span "Welcome to Active Admin. This is the default dashboard page."
|
15
|
+
small "To add dashboard sections, checkout 'app/admin/dashboards.rb'"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Here is an example of a simple dashboard with columns and panels.
|
20
|
+
#
|
21
|
+
# columns do
|
22
|
+
# column do
|
23
|
+
# panel "Recent Posts" do
|
24
|
+
# ul do
|
25
|
+
# Post.recent(5).map do |post|
|
26
|
+
# li link_to(post.title, admin_post_path(post))
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
# column do
|
33
|
+
# panel "Info" do
|
34
|
+
# para "Welcome to ActiveAdmin."
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
end # content
|
39
|
+
end
|
data/app/admin/states.rb
ADDED
data/app/admin/users.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery-ui
|
15
|
+
//= require jquery_ujs
|
16
|
+
//= require bootstrap
|
17
|
+
//= #require bootstrap-datepicker
|
18
|
+
//= #require bootstrap-datepicker/locales/bootstrap-datepicker.pt
|
19
|
+
//= require jquery-ui-timepicker-addon
|
20
|
+
//= require_tree .
|
21
|
+
|
22
|
+
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
|
23
|
+
$(this).datepicker({"format": "dd/mm/yyyy hh:mm", "weekStart": 1, "autoclose": true});
|
24
|
+
});
|
25
|
+
|
26
|
+
$(document).on("focus", "[data-behaviour~='datetimepicker']", function(e){
|
27
|
+
$(this).datetimepicker({ dateFormat: "dd/mm/yy", timeFormat: "hh:mm", "weekStart": 1, "autoclose": true,
|
28
|
+
hourGrid: 4, minuteGrid: 10});
|
29
|
+
});
|
30
|
+
|
31
|
+
$(document).ready(function(){
|
32
|
+
|
33
|
+
$('.remote_form')
|
34
|
+
.bind("ajax:beforeSend", function(evt, xhr, settings){
|
35
|
+
var $submitButton = $(this).find('input[name="commit"]');
|
36
|
+
|
37
|
+
// Update the text of the submit button to let the user know stuff is happening.
|
38
|
+
// But first, store the original text of the submit button, so it can be restored when the request is finished.
|
39
|
+
$submitButton.data( 'origText', $(this).text() );
|
40
|
+
$submitButton.text( "Submitting..." );
|
41
|
+
|
42
|
+
})
|
43
|
+
.bind("ajax:success", function(evt, data, status, xhr){
|
44
|
+
var $form = $(this);
|
45
|
+
|
46
|
+
// Reset fields and any validation errors, so form can be used again, but leave hidden_field values intact.
|
47
|
+
$form.find('textarea,input[type="text"],input[type="file"]').val("");
|
48
|
+
$form.find('div.validation-error').empty();
|
49
|
+
|
50
|
+
// Insert response partial into page below the form.
|
51
|
+
$('#comments').append(xhr.responseText);
|
52
|
+
|
53
|
+
})
|
54
|
+
.bind('ajax:complete', function(evt, xhr, status){
|
55
|
+
var $submitButton = $(this).find('input[name="commit"]');
|
56
|
+
|
57
|
+
// Restore the original submit button text
|
58
|
+
$submitButton.text( $(this).data('origText') );
|
59
|
+
})
|
60
|
+
.bind("ajax:error", function(evt, xhr, status, error){
|
61
|
+
var $form = $(this),
|
62
|
+
errors,
|
63
|
+
errorText;
|
64
|
+
|
65
|
+
try {
|
66
|
+
// Populate errorText with the comment errors
|
67
|
+
errors = $.parseJSON(xhr.responseText);
|
68
|
+
} catch(err) {
|
69
|
+
// If the responseText is not valid JSON (like if a 500 exception was thrown), populate errors with a generic error message.
|
70
|
+
errors = {message: "Por favor, ocorreu um erro ao tratar a resposta do servidor, tente mais tarde."};
|
71
|
+
}
|
72
|
+
|
73
|
+
// Build an unordered list from the list of errors
|
74
|
+
errorText = "<div class=\"alert alert-block alert-error\"><h4>Erros ao registrar dados:</h4> \n<ul>";
|
75
|
+
|
76
|
+
for ( error in errors ) {
|
77
|
+
errorText += "<li>" + error + ': ' + errors[error] + "</li> ";
|
78
|
+
}
|
79
|
+
|
80
|
+
errorText += "</ul></div>";
|
81
|
+
|
82
|
+
$(document).scrollTop();
|
83
|
+
|
84
|
+
// Insert error list into form
|
85
|
+
$form.find('div.validation-error').html(errorText);
|
86
|
+
});
|
87
|
+
|
88
|
+
});
|
89
|
+
|
90
|
+
function showMessage(message_content) {
|
91
|
+
$(".alert-ajax").show().html(message_content);
|
92
|
+
$(document).scrollTop();
|
93
|
+
}
|
94
|
+
|
95
|
+
$(function() {
|
96
|
+
$( "#accordion" ).accordion();
|
97
|
+
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
# All this logic will automatically be available in application.js.
|
3
|
+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
4
|
+
jQuery ->
|
5
|
+
$('form').on 'click', '.remove_fields', (event) ->
|
6
|
+
$(this).prev('input[type=hidden]').val('1')
|
7
|
+
$(this).closest('fieldset').hide()
|
8
|
+
event.preventDefault()
|
9
|
+
|
10
|
+
$('form').on 'click', '.add_fields', (event) ->
|
11
|
+
time = new Date().getTime()
|
12
|
+
regexp = new RegExp($(this).data('id'), 'g')
|
13
|
+
$(this).before($(this).data('fields').replace(regexp, time))
|
14
|
+
event.preventDefault()
|
@@ -0,0 +1,556 @@
|
|
1
|
+
/** FCBKcomplete v2.8.9.3 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */
|
2
|
+
(function($, undefined) {
|
3
|
+
$.fn.fcbkcomplete = function(opt) {
|
4
|
+
return this.queue(function() {
|
5
|
+
function init() {
|
6
|
+
createFCBK();
|
7
|
+
addInput(0)
|
8
|
+
}
|
9
|
+
function createFCBK() {
|
10
|
+
holder = $('<ul class="holder"></ul>').width(options.width);
|
11
|
+
if (options.attachto) {
|
12
|
+
if (typeof(options.attachto) == "object") {
|
13
|
+
options.attachto.append(holder)
|
14
|
+
} else {
|
15
|
+
$(options.attachto).append(holder)
|
16
|
+
}
|
17
|
+
} else {
|
18
|
+
element.after(holder)
|
19
|
+
}
|
20
|
+
complete = $('<div class="facebook-auto">').width(options.width);
|
21
|
+
if (options.complete_text != "") {
|
22
|
+
var completeText = options.complete_text;
|
23
|
+
complete.append('<div class="default">' + completeText + '</div>');
|
24
|
+
if (options.select_all_text) {
|
25
|
+
complete.children('.default').append(
|
26
|
+
$('<a href="" class="select_all_items">' + options.select_all_text + '</a>').click(function() {
|
27
|
+
$(element).trigger('selectAll');
|
28
|
+
return false
|
29
|
+
}))
|
30
|
+
}
|
31
|
+
}
|
32
|
+
complete.hover(function() {
|
33
|
+
complete_hover = 0
|
34
|
+
},
|
35
|
+
function() {
|
36
|
+
complete_hover = 1
|
37
|
+
});
|
38
|
+
feed = $('<ul id="' + elemid + '_feed"></ul>').width(options.width);
|
39
|
+
holder.after(complete.prepend(feed));
|
40
|
+
elPrepare()
|
41
|
+
}
|
42
|
+
function elPrepare() {
|
43
|
+
name = element.attr("name");
|
44
|
+
if (options.bricket) {
|
45
|
+
if (typeof(name) != 'undefined' && name.indexOf("[]") == -1) {
|
46
|
+
name = name + "[]"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
var temp_elem = $('<' + element.get(0).tagName + ' name="' + name + '" id="' + elemid + '" multiple="multiple" class="' + element.get(0).className + ' hidden">').data('cache', {});
|
50
|
+
$.each(element.children('option'),
|
51
|
+
function(i, option) {
|
52
|
+
option = $(option);
|
53
|
+
temp_elem.data('cache')[option.val()] = option.text();
|
54
|
+
if (option.hasClass("selected")) {
|
55
|
+
var id = addItem(option.text(), option.val(), true, option.hasClass("locked"));
|
56
|
+
temp_elem.append('<option value="' + option.val() + '" selected="selected" id="opt_' + id + '"class="selected">' + option.text() + '</option>')
|
57
|
+
}
|
58
|
+
});
|
59
|
+
element.after(temp_elem);
|
60
|
+
element.remove();
|
61
|
+
element = temp_elem;
|
62
|
+
$(element).bind("addItem",
|
63
|
+
function(event, data) {
|
64
|
+
addItem(data.title, data.value, 0, 0, 0)
|
65
|
+
});
|
66
|
+
$(element).bind("removeItem",
|
67
|
+
function(event, data) {
|
68
|
+
var item = holder.children('li[rel=' + data.value + ']');
|
69
|
+
if (item.length) {
|
70
|
+
removeItem(item)
|
71
|
+
}
|
72
|
+
});
|
73
|
+
$(element).bind("destroy",
|
74
|
+
function(event, data) {
|
75
|
+
holder.remove();
|
76
|
+
complete.remove();
|
77
|
+
element.show()
|
78
|
+
});
|
79
|
+
$(element).bind("selectAll",
|
80
|
+
function(event, data) {
|
81
|
+
var currVals = $(element).val() || [];
|
82
|
+
$.each($(element).data('cache'),
|
83
|
+
function(key, value) {
|
84
|
+
if ($.inArray(key, currVals) === -1) {
|
85
|
+
addItem(value, key, 0, 0, 0)
|
86
|
+
}
|
87
|
+
});
|
88
|
+
feed.parent().hide()
|
89
|
+
})
|
90
|
+
}
|
91
|
+
function addItem(title, value, preadded, locked, focusme) {
|
92
|
+
if (!maxItems()) {
|
93
|
+
return false
|
94
|
+
}
|
95
|
+
var liclass = "bit-box" + (locked ? " locked": "");
|
96
|
+
var id = randomId();
|
97
|
+
var txt = document.createTextNode(xssDisplay(title));
|
98
|
+
var aclose = $('<a class="closebutton" href="#"></a>');
|
99
|
+
var li = $('<li class="' + liclass + '" rel="' + value + '" id="pt_' + id + '"></li>').prepend(txt).append(aclose);
|
100
|
+
holder.append(li);
|
101
|
+
aclose.click(function() {
|
102
|
+
removeItem($(this).parent("li"));
|
103
|
+
return false
|
104
|
+
});
|
105
|
+
if (!preadded) {
|
106
|
+
$("#" + elemid + "_annoninput").remove();
|
107
|
+
addInput(focusme);
|
108
|
+
var _item = $('<option value="' + xssDisplay(value, 1) + '" id="opt_' + id + '" class="selected" selected="selected">' + xssDisplay(title) + '</option>');
|
109
|
+
element.append(_item);
|
110
|
+
if (options.onselect) {
|
111
|
+
funCall(options.onselect, _item)
|
112
|
+
}
|
113
|
+
element.change()
|
114
|
+
}
|
115
|
+
holder.children("li.bit-box.deleted").removeClass("deleted");
|
116
|
+
clear_feed(1);
|
117
|
+
return id
|
118
|
+
}
|
119
|
+
function removeItem(item) {
|
120
|
+
if (!item.hasClass('locked')) {
|
121
|
+
item.fadeOut("fast");
|
122
|
+
var id = item.attr('id');
|
123
|
+
if (options.onremove) {
|
124
|
+
var _item = id ? $("#o" + id + "") : element.children("option[value=" + item.attr("rel") + "]");
|
125
|
+
funCall(options.onremove, _item)
|
126
|
+
}
|
127
|
+
if (id) {
|
128
|
+
$("#o" + id + "").remove()
|
129
|
+
} else {
|
130
|
+
element.children('option[value="' + item.attr("rel") + '"]').remove()
|
131
|
+
}
|
132
|
+
item.remove();
|
133
|
+
element.change();
|
134
|
+
deleting = 0
|
135
|
+
}
|
136
|
+
}
|
137
|
+
function addInput(focusme) {
|
138
|
+
var li = $('<li class="bit-input" id="' + elemid + '_annoninput">');
|
139
|
+
var input = $('<input type="text" class="maininput" size="' + options.input_min_size + '" autocomplete="off">');
|
140
|
+
if (options.input_tabindex > 0) input.attr("tabindex", options.input_tabindex);
|
141
|
+
if (options.input_name != "") input.attr("name", options.input_name);
|
142
|
+
holder.append(li.append(input));
|
143
|
+
input.focus(function() {
|
144
|
+
isactive = true;
|
145
|
+
if (maxItems()) {
|
146
|
+
complete.fadeIn("fast")
|
147
|
+
}
|
148
|
+
});
|
149
|
+
input.blur(function() {
|
150
|
+
isactive = false;
|
151
|
+
if (complete_hover) {
|
152
|
+
complete.fadeOut("fast")
|
153
|
+
} else {
|
154
|
+
input.focus()
|
155
|
+
}
|
156
|
+
});
|
157
|
+
holder.click(function() {
|
158
|
+
if (options.input_min_size < 0 && feed.length) {
|
159
|
+
load_feed(xssPrevent(input.val(), 1))
|
160
|
+
}
|
161
|
+
input.focus();
|
162
|
+
if (feed.length && input.val().length > options.input_min_size) {
|
163
|
+
feed.show()
|
164
|
+
} else {
|
165
|
+
clear_feed(1);
|
166
|
+
complete.children(".default").show()
|
167
|
+
}
|
168
|
+
});
|
169
|
+
input.keypress(function(event) {
|
170
|
+
if (event.keyCode == _key.enter) {
|
171
|
+
return false
|
172
|
+
}
|
173
|
+
var newsize = (options.input_min_size > input.val().length) ? options.input_min_size: (input.val().length + 1);
|
174
|
+
input.attr("size", newsize).width(parseInt(input.css('font-size')) * newsize)
|
175
|
+
});
|
176
|
+
input.keyup(function(event) {
|
177
|
+
var etext = xssPrevent(input.val(), 1);
|
178
|
+
if (event.keyCode == _key.backspace && etext.length == 0) {
|
179
|
+
clear_feed(1);
|
180
|
+
if (!holder.children("li.bit-box:last").hasClass('locked')) {
|
181
|
+
if (holder.children("li.bit-box.deleted").length == 0) {
|
182
|
+
holder.children("li.bit-box:last").addClass("deleted");
|
183
|
+
return false
|
184
|
+
} else {
|
185
|
+
if (deleting) {
|
186
|
+
return
|
187
|
+
}
|
188
|
+
deleting = 1;
|
189
|
+
holder.children("li.bit-box.deleted").fadeOut("fast",
|
190
|
+
function() {
|
191
|
+
removeItem($(this));
|
192
|
+
return false
|
193
|
+
})
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
if (event.keyCode != _key.downarrow && event.keyCode != _key.uparrow && event.keyCode != _key.leftarrow && event.keyCode != _key.rightarrow && etext.length > options.input_min_size) {
|
198
|
+
load_feed(etext);
|
199
|
+
complete.children(".default").hide();
|
200
|
+
feed.show()
|
201
|
+
}
|
202
|
+
});
|
203
|
+
if (options.oncreate) {
|
204
|
+
funCall(options.oncreate, input)
|
205
|
+
}
|
206
|
+
if (focusme) {
|
207
|
+
setTimeout(function() {
|
208
|
+
input.focus();
|
209
|
+
complete.children(".default").show()
|
210
|
+
},
|
211
|
+
1)
|
212
|
+
}
|
213
|
+
}
|
214
|
+
function addMembers(etext, data) {
|
215
|
+
feed.html('');
|
216
|
+
if (!options.cache && data != null) {
|
217
|
+
cache.clear()
|
218
|
+
}
|
219
|
+
addTextItem(etext);
|
220
|
+
if (data != null && data.length) {
|
221
|
+
$.each(data,
|
222
|
+
function(i, val) {
|
223
|
+
cache.set(xssPrevent(val.key), xssPrevent(val.value))
|
224
|
+
})
|
225
|
+
}
|
226
|
+
var maximum = options.maxshownitems < cache.length() ? options.maxshownitems: cache.length();
|
227
|
+
var content = '';
|
228
|
+
$.each(cache.search(etext),
|
229
|
+
function(i, object) {
|
230
|
+
if (maximum) {
|
231
|
+
if (options.filter_selected && element.children('option[value="' + object.key + '"]').hasClass("selected")) {} else {
|
232
|
+
content += '<li rel="' + object.key + '">' + xssDisplay(itemIllumination(object.value, etext)) + '</li>';
|
233
|
+
counter++;
|
234
|
+
maximum--
|
235
|
+
}
|
236
|
+
}
|
237
|
+
});
|
238
|
+
feed.append(content);
|
239
|
+
if (options.firstselected) {
|
240
|
+
focuson = feed.children("li:visible:first");
|
241
|
+
focuson.addClass("auto-focus")
|
242
|
+
}
|
243
|
+
if (counter > options.height) {
|
244
|
+
feed.css({
|
245
|
+
"height": (options.height * 24) + "px",
|
246
|
+
"overflow": "auto"
|
247
|
+
})
|
248
|
+
} else {
|
249
|
+
feed.css("height", "auto")
|
250
|
+
}
|
251
|
+
if (maxItems() && complete.is(':hidden')) {
|
252
|
+
complete.show()
|
253
|
+
}
|
254
|
+
}
|
255
|
+
function itemIllumination(text, etext) {
|
256
|
+
var string_regex_adder = options.filter_begin ? '': '(.*)';
|
257
|
+
var regex_result = options.filter_begin ? '<em>$1</em>$2': '$1<em>$2</em>$3';
|
258
|
+
var string_regex = string_regex_adder + (options.filter_case ? "(" + etext + ")(.*)": "(" + etext.toLowerCase() + ")(.*)");
|
259
|
+
try {
|
260
|
+
var regex = new RegExp(string_regex, ((options.filter_case) ? "g": "gi"));
|
261
|
+
var text = text.replace(regex, regex_result)
|
262
|
+
} catch(ex) {};
|
263
|
+
return text
|
264
|
+
}
|
265
|
+
function bindFeedEvent() {
|
266
|
+
feed.children("li").mouseover(function() {
|
267
|
+
feed.children("li").removeClass("auto-focus");
|
268
|
+
focuson = $(this);
|
269
|
+
focuson.addClass("auto-focus")
|
270
|
+
});
|
271
|
+
feed.children("li").mouseout(function() {
|
272
|
+
$(this).removeClass("auto-focus");
|
273
|
+
focuson = null
|
274
|
+
})
|
275
|
+
}
|
276
|
+
function removeFeedEvent() {
|
277
|
+
feed.unbind("mouseover").unbind("mouseout").mousemove(function() {
|
278
|
+
bindFeedEvent();
|
279
|
+
feed.unbind("mousemove")
|
280
|
+
})
|
281
|
+
}
|
282
|
+
function bindEvents() {
|
283
|
+
var maininput = $("#" + elemid + "_annoninput").children(".maininput");
|
284
|
+
bindFeedEvent();
|
285
|
+
feed.children("li").unbind("mousedown").mousedown(function() {
|
286
|
+
var option = $(this);
|
287
|
+
addItem(option.text(), option.attr("rel"), 0, 0, 1);
|
288
|
+
clear_feed(1);
|
289
|
+
complete.hide()
|
290
|
+
});
|
291
|
+
maininput.unbind("keydown");
|
292
|
+
maininput.keydown(function(event) {
|
293
|
+
if (event.keyCode != _key.backspace) {
|
294
|
+
holder.children("li.bit-box.deleted").removeClass("deleted")
|
295
|
+
}
|
296
|
+
if ((event.keyCode == _key.enter || event.keyCode == _key.tab || event.keyCode == _key.comma) && checkFocusOn()) {
|
297
|
+
var option = focuson;
|
298
|
+
addItem(option.text(), option.attr("rel"), 0, 0, 1);
|
299
|
+
return _preventDefault(event)
|
300
|
+
}
|
301
|
+
if ((event.keyCode == _key.enter || event.keyCode == _key.tab || event.keyCode == _key.comma) && !checkFocusOn()) {
|
302
|
+
if (options.newel) {
|
303
|
+
var value = xssPrevent($(this).val());
|
304
|
+
addItem(value, value, 0, 0, 1);
|
305
|
+
return _preventDefault(event)
|
306
|
+
}
|
307
|
+
if ((options.addontab || options.addoncomma) && options.newel) {
|
308
|
+
focuson = feed.children("li:visible:first");
|
309
|
+
var option = focuson;
|
310
|
+
addItem(option.text(), option.attr("rel"), 0, 0, 1);
|
311
|
+
return _preventDefault(event)
|
312
|
+
}
|
313
|
+
}
|
314
|
+
if (event.keyCode == _key.downarrow) {
|
315
|
+
nextItem('first')
|
316
|
+
}
|
317
|
+
if (event.keyCode == _key.uparrow) {
|
318
|
+
nextItem('last')
|
319
|
+
}
|
320
|
+
})
|
321
|
+
}
|
322
|
+
function nextItem(position) {
|
323
|
+
removeFeedEvent();
|
324
|
+
if (focuson == null || focuson.length == 0) {
|
325
|
+
focuson = feed.children("li:visible:" + position);
|
326
|
+
feed.get(0).scrollTop = position == 'first' ? 0: parseInt(focuson.get(0).scrollHeight, 10) * (parseInt(feed.children("li:visible").length, 10) - Math.round(options.height / 2))
|
327
|
+
} else {
|
328
|
+
focuson.removeClass("auto-focus");
|
329
|
+
focuson = position == 'first' ? focuson.nextAll("li:visible:first") : focuson.prevAll("li:visible:first");
|
330
|
+
var prev = parseInt(focuson.prevAll("li:visible").length, 10);
|
331
|
+
var next = parseInt(focuson.nextAll("li:visible").length, 10);
|
332
|
+
if (((position == 'first' ? prev: next) > Math.round(options.height / 2) || (position == 'first' ? prev: next) <= Math.round(options.height / 2)) && typeof(focuson.get(0)) != "undefined") {
|
333
|
+
feed.get(0).scrollTop = parseInt(focuson.get(0).scrollHeight, 10) * (prev - Math.round(options.height / 2))
|
334
|
+
}
|
335
|
+
}
|
336
|
+
feed.children("li").removeClass("auto-focus");
|
337
|
+
focuson.addClass("auto-focus")
|
338
|
+
}
|
339
|
+
function _preventDefault(event) {
|
340
|
+
complete.hide();
|
341
|
+
event.preventDefault();
|
342
|
+
focuson = null;
|
343
|
+
return false
|
344
|
+
}
|
345
|
+
function maxItems() {
|
346
|
+
return options.maxitems != 0 && (holder.children("li.bit-box").length < options.maxitems)
|
347
|
+
}
|
348
|
+
function addTextItem(value) {
|
349
|
+
if (options.newel && maxItems()) {
|
350
|
+
feed.children("li[fckb=1]").remove();
|
351
|
+
if (value.length == 0) {
|
352
|
+
return
|
353
|
+
}
|
354
|
+
var li = $('<li rel="' + value + '" fckb="1">').html(xssDisplay(value));
|
355
|
+
feed.prepend(li);
|
356
|
+
counter++
|
357
|
+
}
|
358
|
+
return
|
359
|
+
}
|
360
|
+
function funCall(func, item) {
|
361
|
+
var _object = {};
|
362
|
+
for (i = 0; i < item.get(0).attributes.length; i++) {
|
363
|
+
if (item.get(0).attributes[i].nodeValue != null) {
|
364
|
+
_object["_" + item.get(0).attributes[i].nodeName] = item.get(0).attributes[i].nodeValue
|
365
|
+
}
|
366
|
+
}
|
367
|
+
return func.call(func, _object)
|
368
|
+
}
|
369
|
+
function checkFocusOn() {
|
370
|
+
if (focuson == null || focuson.length == 0) {
|
371
|
+
return false
|
372
|
+
}
|
373
|
+
return true
|
374
|
+
}
|
375
|
+
function xssPrevent(string, flag) {
|
376
|
+
if (typeof flag != "undefined") {
|
377
|
+
for (i = 0; i < string.length; i++) {
|
378
|
+
var charcode = string.charCodeAt(i);
|
379
|
+
if ((_key.exclamation <= charcode && charcode <= _key.slash) || (_key.colon <= charcode && charcode <= _key.at) || (_key.squarebricket_left <= charcode && charcode <= _key.apostrof)) {
|
380
|
+
string = string.replace(string[i], escape(string[i]))
|
381
|
+
}
|
382
|
+
}
|
383
|
+
string = string.replace(/(\{|\}|\*)/i, "\\$1")
|
384
|
+
}
|
385
|
+
return string.replace(/script(.*)/g, "")
|
386
|
+
}
|
387
|
+
function xssDisplay(string, flag) {
|
388
|
+
string = string.toString();
|
389
|
+
string = string.replace('\\', "");
|
390
|
+
if (typeof flag != "undefined") {
|
391
|
+
return string
|
392
|
+
}
|
393
|
+
return unescape(string)
|
394
|
+
}
|
395
|
+
function clear_feed(flag) {
|
396
|
+
feed.children().remove();
|
397
|
+
if (flag) {
|
398
|
+
feed.hide()
|
399
|
+
}
|
400
|
+
}
|
401
|
+
function load_feed(etext) {
|
402
|
+
counter = 0;
|
403
|
+
if (options.json_url && maxItems()) {
|
404
|
+
if (options.cache && json_cache_object.get(etext)) {
|
405
|
+
addMembers(etext);
|
406
|
+
bindEvents()
|
407
|
+
} else {
|
408
|
+
getBoxTimeout++;
|
409
|
+
var getBoxTimeoutValue = getBoxTimeout;
|
410
|
+
setTimeout(function() {
|
411
|
+
if (getBoxTimeoutValue != getBoxTimeout) return;
|
412
|
+
$.getJSON(options.json_url, {
|
413
|
+
"tag": xssDisplay(etext)
|
414
|
+
},
|
415
|
+
function(data) {
|
416
|
+
if (!isactive) return;
|
417
|
+
addMembers(etext, data);
|
418
|
+
json_cache_object.set(etext, 1);
|
419
|
+
bindEvents()
|
420
|
+
})
|
421
|
+
},
|
422
|
+
options.delay)
|
423
|
+
}
|
424
|
+
} else {
|
425
|
+
addMembers(etext);
|
426
|
+
bindEvents()
|
427
|
+
}
|
428
|
+
}
|
429
|
+
var options = $.extend({
|
430
|
+
json_url: null,
|
431
|
+
width: 512,
|
432
|
+
cache: false,
|
433
|
+
height: "10",
|
434
|
+
newel: false,
|
435
|
+
addontab: false,
|
436
|
+
addoncomma: false,
|
437
|
+
firstselected: false,
|
438
|
+
filter_case: false,
|
439
|
+
filter_selected: false,
|
440
|
+
filter_begin: false,
|
441
|
+
complete_text: "Comece a digitar...",
|
442
|
+
select_all_text: null,
|
443
|
+
maxshownitems: 30,
|
444
|
+
maxitems: 10,
|
445
|
+
oncreate: null,
|
446
|
+
onselect: null,
|
447
|
+
onremove: null,
|
448
|
+
attachto: null,
|
449
|
+
delay: 350,
|
450
|
+
input_tabindex: 0,
|
451
|
+
input_min_size: 1,
|
452
|
+
input_name: "",
|
453
|
+
bricket: true
|
454
|
+
},
|
455
|
+
opt);
|
456
|
+
var holder = null;
|
457
|
+
var feed = null;
|
458
|
+
var complete = null;
|
459
|
+
var counter = 0;
|
460
|
+
var isactive = false;
|
461
|
+
var focuson = null;
|
462
|
+
var deleting = 0;
|
463
|
+
var complete_hover = 1;
|
464
|
+
var element = $(this);
|
465
|
+
var elemid = element.attr("id");
|
466
|
+
var getBoxTimeout = 0;
|
467
|
+
var json_cache_object = {
|
468
|
+
'set': function(id, val) {
|
469
|
+
var data = element.data("jsoncache");
|
470
|
+
data[id] = val;
|
471
|
+
element.data("jsoncache", data)
|
472
|
+
},
|
473
|
+
'get': function(id) {
|
474
|
+
return element.data("jsoncache")[id] != 'undefined' ? element.data("jsoncache")[id] : null
|
475
|
+
},
|
476
|
+
'init': function() {
|
477
|
+
element.data("jsoncache", {})
|
478
|
+
}
|
479
|
+
};
|
480
|
+
var _key = {
|
481
|
+
'enter': 13,
|
482
|
+
'tab': 9,
|
483
|
+
'comma': 188,
|
484
|
+
'backspace': 8,
|
485
|
+
'leftarrow': 37,
|
486
|
+
'uparrow': 38,
|
487
|
+
'rightarrow': 39,
|
488
|
+
'downarrow': 40,
|
489
|
+
'exclamation': 33,
|
490
|
+
'slash': 47,
|
491
|
+
'colon': 58,
|
492
|
+
'at': 64,
|
493
|
+
'squarebricket_left': 91,
|
494
|
+
'apostrof': 96
|
495
|
+
};
|
496
|
+
var randomId = function() {
|
497
|
+
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
498
|
+
var randomstring = '';
|
499
|
+
for (var i = 0; i < 32; i++) {
|
500
|
+
var rnum = Math.floor(Math.random() * chars.length);
|
501
|
+
randomstring += chars.substring(rnum, rnum + 1)
|
502
|
+
}
|
503
|
+
return randomstring
|
504
|
+
};
|
505
|
+
var cache = {
|
506
|
+
'search': function(text, callback) {
|
507
|
+
var temp = new Array();
|
508
|
+
var regex = new RegExp((options.filter_begin ? '^': '') + text, (options.filter_case ? "g": "gi"));
|
509
|
+
$.each(element.data("cache"),
|
510
|
+
function(i, _elem) {
|
511
|
+
if (typeof _elem.search === 'function') {
|
512
|
+
if (_elem.search(regex) != -1) {
|
513
|
+
temp.push({
|
514
|
+
'key': i,
|
515
|
+
'value': _elem
|
516
|
+
})
|
517
|
+
}
|
518
|
+
}
|
519
|
+
});
|
520
|
+
return temp
|
521
|
+
},
|
522
|
+
'set': function(id, val) {
|
523
|
+
var data = element.data("cache");
|
524
|
+
data[id] = val;
|
525
|
+
element.data("cache", data)
|
526
|
+
},
|
527
|
+
'get': function(id) {
|
528
|
+
return element.data("cache")[id] != 'undefined' ? element.data("cache")[id] : null
|
529
|
+
},
|
530
|
+
'clear': function() {
|
531
|
+
element.data("cache", {})
|
532
|
+
},
|
533
|
+
'length': function() {
|
534
|
+
if (typeof(element.data('cache')) == "object") {
|
535
|
+
var _length = 0;
|
536
|
+
for (i in element.data('cache')) {
|
537
|
+
_length++
|
538
|
+
}
|
539
|
+
return _length
|
540
|
+
} else {
|
541
|
+
return element.data("cache").length
|
542
|
+
}
|
543
|
+
},
|
544
|
+
'init': function() {
|
545
|
+
if (element.data("cache") == 'undefined') {
|
546
|
+
element.data("cache", {})
|
547
|
+
}
|
548
|
+
}
|
549
|
+
};
|
550
|
+
init();
|
551
|
+
json_cache_object.init();
|
552
|
+
cache.init();
|
553
|
+
return this
|
554
|
+
})
|
555
|
+
}
|
556
|
+
})(jQuery);
|