rmails 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +167 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +9 -0
- data/Rakefile +31 -0
- data/Rakefile1 +9 -0
- data/Vagrantfile +51 -0
- data/app/assets/images/arrow_bottom.gif +0 -0
- data/app/assets/images/arrow_right.gif +0 -0
- data/app/assets/images/at-sign.png +0 -0
- data/app/assets/images/checkerboard.gif +0 -0
- data/app/assets/images/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/glyphicons-halflings.png +0 -0
- data/app/assets/images/icon_draft.gif +0 -0
- data/app/assets/images/icon_layout.gif +0 -0
- data/app/assets/images/icon_move.gif +0 -0
- data/app/assets/images/icon_regular.gif +0 -0
- data/app/assets/images/icon_snippet.gif +0 -0
- data/app/assets/images/nav_arrow.png +0 -0
- data/app/assets/images/x.png +0 -0
- data/app/assets/javascripts/application.coffee.erb +27 -0
- data/app/assets/javascripts/canjs/can.construct.proxy.js +60 -0
- data/app/assets/javascripts/canjs/can.construct.super.js +44 -0
- data/app/assets/javascripts/canjs/can.control.plugin.js +245 -0
- data/app/assets/javascripts/canjs/can.control.view.js +88 -0
- data/app/assets/javascripts/canjs/can.dojo.js +3669 -0
- data/app/assets/javascripts/canjs/can.dojo.min.js +66 -0
- data/app/assets/javascripts/canjs/can.fixture.js +1020 -0
- data/app/assets/javascripts/canjs/can.jquery.js +2995 -0
- data/app/assets/javascripts/canjs/can.jquery.min.js +52 -0
- data/app/assets/javascripts/canjs/can.mootools.js +3462 -0
- data/app/assets/javascripts/canjs/can.mootools.min.js +63 -0
- data/app/assets/javascripts/canjs/can.observe.attributes.js +293 -0
- data/app/assets/javascripts/canjs/can.observe.backup.js +368 -0
- data/app/assets/javascripts/canjs/can.observe.delegate.js +359 -0
- data/app/assets/javascripts/canjs/can.observe.setter.js +58 -0
- data/app/assets/javascripts/canjs/can.observe.validations.js +374 -0
- data/app/assets/javascripts/canjs/can.view.modifiers.js +292 -0
- data/app/assets/javascripts/canjs/can.yui.js +3530 -0
- data/app/assets/javascripts/canjs/can.yui.min.js +65 -0
- data/app/assets/javascripts/canjs/can.zepto.js +3426 -0
- data/app/assets/javascripts/canjs/can.zepto.min.js +62 -0
- data/app/assets/javascripts/controls/admins.coffee.erb +105 -0
- data/app/assets/javascripts/controls/aliases.coffee.erb +91 -0
- data/app/assets/javascripts/controls/domains.coffee.erb +115 -0
- data/app/assets/javascripts/controls/settings.coffee.erb +47 -0
- data/app/assets/javascripts/controls/users.coffee.erb +94 -0
- data/app/assets/javascripts/lib/facebox.js +311 -0
- data/app/assets/javascripts/lib/html5.js +2 -0
- data/app/assets/javascripts/lib/jquery.js +9301 -0
- data/app/assets/javascripts/lib/jquery_formparams.js +108 -0
- data/app/assets/javascripts/lib/jquery_input_hint.js +20 -0
- data/app/assets/javascripts/lib/jquery_paginate.js +120 -0
- data/app/assets/javascripts/lib/jquery_ui_custom.js +6 -0
- data/app/assets/javascripts/lib/json2.js +487 -0
- data/app/assets/javascripts/lib/utils.coffee.erb +48 -0
- data/app/assets/javascripts/models/admin.coffee.erb +42 -0
- data/app/assets/javascripts/models/alias.coffee.erb +28 -0
- data/app/assets/javascripts/models/domain.coffee.erb +39 -0
- data/app/assets/javascripts/models/property.coffee.erb +18 -0
- data/app/assets/javascripts/models/user.coffee.erb +29 -0
- data/app/assets/stylesheets/application.sass +156 -0
- data/app/assets/stylesheets/base.css.sass +243 -0
- data/app/assets/stylesheets/facebox.css +80 -0
- data/app/assets/stylesheets/lib/bootstrap.css +9 -0
- data/app/assets/stylesheets/twitter/bootstrap-responsive.scss +1 -0
- data/app/assets/stylesheets/twitter/bootstrap.scss +63 -0
- data/app/assets/stylesheets/twitter/bootstrap/_accordion.scss +34 -0
- data/app/assets/stylesheets/twitter/bootstrap/_alerts.scss +79 -0
- data/app/assets/stylesheets/twitter/bootstrap/_breadcrumbs.scss +24 -0
- data/app/assets/stylesheets/twitter/bootstrap/_button-groups.scss +229 -0
- data/app/assets/stylesheets/twitter/bootstrap/_buttons.scss +228 -0
- data/app/assets/stylesheets/twitter/bootstrap/_carousel.scss +158 -0
- data/app/assets/stylesheets/twitter/bootstrap/_close.scss +32 -0
- data/app/assets/stylesheets/twitter/bootstrap/_code.scss +61 -0
- data/app/assets/stylesheets/twitter/bootstrap/_component-animations.scss +22 -0
- data/app/assets/stylesheets/twitter/bootstrap/_dropdowns.scss +237 -0
- data/app/assets/stylesheets/twitter/bootstrap/_forms.scss +689 -0
- data/app/assets/stylesheets/twitter/bootstrap/_grid.scss +21 -0
- data/app/assets/stylesheets/twitter/bootstrap/_hero-unit.scss +25 -0
- data/app/assets/stylesheets/twitter/bootstrap/_labels-badges.scss +83 -0
- data/app/assets/stylesheets/twitter/bootstrap/_layouts.scss +16 -0
- data/app/assets/stylesheets/twitter/bootstrap/_media.scss +55 -0
- data/app/assets/stylesheets/twitter/bootstrap/_mixins.scss +690 -0
- data/app/assets/stylesheets/twitter/bootstrap/_modals.scss +95 -0
- data/app/assets/stylesheets/twitter/bootstrap/_navbar.scss +497 -0
- data/app/assets/stylesheets/twitter/bootstrap/_navs.scss +409 -0
- data/app/assets/stylesheets/twitter/bootstrap/_pager.scss +43 -0
- data/app/assets/stylesheets/twitter/bootstrap/_pagination.scss +123 -0
- data/app/assets/stylesheets/twitter/bootstrap/_popovers.scss +133 -0
- data/app/assets/stylesheets/twitter/bootstrap/_progress-bars.scss +122 -0
- data/app/assets/stylesheets/twitter/bootstrap/_reset.scss +216 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-1200px-min.scss +28 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-767px-max.scss +193 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-768px-979px.scss +19 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-navbar.scss +189 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-utilities.scss +74 -0
- data/app/assets/stylesheets/twitter/bootstrap/_scaffolding.scss +53 -0
- data/app/assets/stylesheets/twitter/bootstrap/_sprites.scss +197 -0
- data/app/assets/stylesheets/twitter/bootstrap/_tables.scss +235 -0
- data/app/assets/stylesheets/twitter/bootstrap/_thumbnails.scss +53 -0
- data/app/assets/stylesheets/twitter/bootstrap/_tooltip.scss +70 -0
- data/app/assets/stylesheets/twitter/bootstrap/_type.scss +247 -0
- data/app/assets/stylesheets/twitter/bootstrap/_utilities.scss +45 -0
- data/app/assets/stylesheets/twitter/bootstrap/_variables.scss +301 -0
- data/app/assets/stylesheets/twitter/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/twitter/bootstrap/responsive.scss +48 -0
- data/app/controllers/admin_users_controller.rb +62 -0
- data/app/controllers/aliases_controller.rb +35 -0
- data/app/controllers/application_controller.rb +20 -0
- data/app/controllers/domains_controller.rb +48 -0
- data/app/controllers/server_controller.rb +28 -0
- data/app/controllers/users_controller.rb +35 -0
- data/app/helpers/admin_users_helper.rb +11 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/domains_helper.rb +25 -0
- data/app/helpers/server_helper.rb +30 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/admin_user.rb +54 -0
- data/app/models/certificate_manager.rb +46 -0
- data/app/models/property.rb +103 -0
- data/app/models/property/awstats.rb +15 -0
- data/app/models/property/dovecot.rb +61 -0
- data/app/models/property/dspam.rb +45 -0
- data/app/models/property/nginx.rb +47 -0
- data/app/models/property/postfix.rb +64 -0
- data/app/models/property_value_validator.rb +41 -0
- data/app/models/system_manager.rb +88 -0
- data/app/models/virtual_alias.rb +13 -0
- data/app/models/virtual_domain.rb +15 -0
- data/app/models/virtual_user.rb +51 -0
- data/app/views/admin_users/_form.html.haml +21 -0
- data/app/views/admin_users/first.html.haml +12 -0
- data/app/views/admin_users/index.html.haml +61 -0
- data/app/views/aliases/_form.html.haml +11 -0
- data/app/views/aliases/_list.html.haml +0 -0
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/devise/passwords/edit.html.haml +14 -0
- data/app/views/devise/passwords/new.html.haml +12 -0
- data/app/views/devise/registrations/edit.html.haml +18 -0
- data/app/views/devise/registrations/new.html.haml +10 -0
- data/app/views/devise/sessions/new.html.haml +16 -0
- data/app/views/devise/shared/_links.haml +17 -0
- data/app/views/devise/unlocks/new.html.haml +11 -0
- data/app/views/domains/_fields.html.haml +0 -0
- data/app/views/domains/_form.html.haml +7 -0
- data/app/views/domains/index.html.haml +133 -0
- data/app/views/domains/show.html.haml +1 -0
- data/app/views/layouts/_nav.html.haml +3 -0
- data/app/views/layouts/application.html.haml +29 -0
- data/app/views/server/_certificates.html.haml +10 -0
- data/app/views/server/_dovecot.html.haml +27 -0
- data/app/views/server/_dspam.html.haml +9 -0
- data/app/views/server/_postfix_info.html.haml +5 -0
- data/app/views/server/_postfix_test.html.haml +5 -0
- data/app/views/server/_status.html.haml +11 -0
- data/app/views/server/index.html.haml +36 -0
- data/app/views/users/_form.html.haml +11 -0
- data/app/views/users/_list.html.haml +0 -0
- data/bin/rmails +43 -0
- data/config.ru +4 -0
- data/config/application.rb +62 -0
- data/config/boot.rb +6 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +37 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +37 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/devise.rb +240 -0
- data/config/initializers/devise_encryptable.rb +37 -0
- data/config/initializers/devise_models.rb +86 -0
- data/config/initializers/inflections.rb +15 -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/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/cz.yml +45 -0
- data/config/locales/devise.cz.yml +47 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/server/cz.yml +14 -0
- data/config/locales/server/en.yml +7 -0
- data/config/locales/server/help/dovecot/cz.yml +21 -0
- data/config/locales/server/help/dovecot/en.yml +18 -0
- data/config/locales/server/help/dspam/cz.yml +10 -0
- data/config/locales/server/help/dspam/en.yml +4 -0
- data/config/locales/server/key/dovecot/cz.yml +23 -0
- data/config/locales/server/key/dovecot/en.yml +20 -0
- data/config/locales/server/key/dspam/cz.yml +10 -0
- data/config/locales/server/key/dspam/en.yml +4 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/admin_users/cz.yml +25 -0
- data/config/locales/views/admin_users/en.yml +5 -0
- data/config/locales/views/aliases/cz.yml +17 -0
- data/config/locales/views/aliases/en.yml +1 -0
- data/config/locales/views/devise/cz.yml +26 -0
- data/config/locales/views/devise/en.yml +13 -0
- data/config/locales/views/domains/cz.yml +15 -0
- data/config/locales/views/domains/en.yml +15 -0
- data/config/locales/views/server/cz.yml +19 -0
- data/config/locales/views/server/en.yml +3 -0
- data/config/locales/views/users/cz.yml +18 -0
- data/config/locales/views/users/en.yml +1 -0
- data/config/routes.rb +80 -0
- data/db/migrate/20121112201233_virtual_domain.rb +11 -0
- data/db/migrate/20121112201247_virtual_alias.rb +10 -0
- data/db/migrate/20121112201341_virtual_user.rb +34 -0
- data/db/migrate/20121112201359_create_admin_user.rb +30 -0
- data/db/migrate/20121112201411_server_configuration.rb +13 -0
- data/db/migrate/20130304083938_join_domains_users.rb +12 -0
- data/db/migrate/20130311214040_create_versions.rb +18 -0
- data/db/seeds.rb +45 -0
- data/lib/devise-encryptable.rb +1 -0
- data/lib/rmails.rb +5 -0
- data/lib/rmails/installer.rb +37 -0
- data/lib/rmails/version.rb +3 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/templates/haml/scaffold/_form.html.haml +10 -0
- data/locals +0 -0
- data/log/.gitkeep +0 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/favicon.ico +0 -0
- data/public/fonts/London.eot +0 -0
- data/public/fonts/London.otf +0 -0
- data/public/fonts/London.woff +0 -0
- data/public/fonts/LondonBold.otf +0 -0
- data/public/robots.txt +5 -0
- data/rmails.gemspec +35 -0
- data/script/prepflog.pl +576 -0
- data/script/rails +6 -0
- data/system/config/automateit_env.rb +16 -0
- data/system/config/fields.yml +48 -0
- data/system/config/tags.yml +39 -0
- data/system/dist/README_AutomateIt_dist.txt +20 -0
- data/system/dist/amavis/spamassassin.cf.erb +85 -0
- data/system/dist/amavis/user.erb +33 -0
- data/system/dist/awstats/awstats.mail.conf.erb +41 -0
- data/system/dist/awstats/prepflog.pl +576 -0
- data/system/dist/dovecot/dovecot-sql.conf.ext.erb +14 -0
- data/system/dist/dovecot/dovecot.conf.erb +297 -0
- data/system/dist/dovecot/old_dovecot.conf.erb +63 -0
- data/system/dist/dspam/conf.erb +96 -0
- data/system/dist/dspam/pgsql.conf +33 -0
- data/system/dist/nginx/awstats.erb +17 -0
- data/system/dist/nginx/rmails.erb +40 -0
- data/system/dist/postfix/email2email.cf.erb +5 -0
- data/system/dist/postfix/main.cf.erb +118 -0
- data/system/dist/postfix/master.cf.erb +74 -0
- data/system/dist/postfix/sasl.conf.erb +3 -0
- data/system/dist/postfix/sender_login_maps.cf.erb +5 -0
- data/system/dist/postfix/virtual_alias_maps.cf.erb +5 -0
- data/system/dist/postfix/virtual_mailbox_domains.cf.erb +5 -0
- data/system/dist/postfix/virtual_mailbox_maps.cf.erb +5 -0
- data/system/dist/postgresql/postgresql.conf.erb +54 -0
- data/system/dist/rmails/Gemfile.1 +8 -0
- data/system/dist/rmails/Gemfile.2 +24 -0
- data/system/dist/rmails/database.yml.erb +15 -0
- data/system/dist/sudoers +37 -0
- data/system/lib/README_AutomateIt_lib.txt +22 -0
- data/system/lib/dkim_key.rb +9 -0
- data/system/lib/smtpd_key.rb +39 -0
- data/system/lib/ssl.rb +23 -0
- data/system/recipes/01_prepare_server.rb +84 -0
- data/system/recipes/02_setup_database.rb +65 -0
- data/system/recipes/03_setup_postfix.rb +124 -0
- data/system/recipes/04_setup_dovecot.rb +78 -0
- data/system/recipes/05_setup_nginx.rb +29 -0
- data/system/recipes/06_setup_dspam.rb +24 -0
- data/system/recipes/07_setup_amavis.rb +16 -0
- data/system/recipes/08_setup_spamassassin.rb +22 -0
- data/system/recipes/09_setup_awstats.rb +49 -0
- data/system/recipes/XX_start_services.rb +5 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/functional/aliases_controller_test.rb +7 -0
- data/test/functional/domains_controller_test.rb +7 -0
- data/test/functional/users_controller_test.rb +7 -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/test/unit/helpers/aliases_helper_test.rb +4 -0
- data/test/unit/helpers/domains_helper_test.rb +4 -0
- data/test/unit/helpers/users_helper_test.rb +4 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/canjs/can.construct.proxy.js +60 -0
- data/vendor/assets/javascripts/canjs/can.construct.super.js +44 -0
- data/vendor/assets/javascripts/canjs/can.control.plugin.js +245 -0
- data/vendor/assets/javascripts/canjs/can.control.view.js +88 -0
- data/vendor/assets/javascripts/canjs/can.dojo.js +3669 -0
- data/vendor/assets/javascripts/canjs/can.dojo.min.js +66 -0
- data/vendor/assets/javascripts/canjs/can.fixture.js +1020 -0
- data/vendor/assets/javascripts/canjs/can.jquery.js +2995 -0
- data/vendor/assets/javascripts/canjs/can.jquery.min.js +52 -0
- data/vendor/assets/javascripts/canjs/can.mootools.js +3462 -0
- data/vendor/assets/javascripts/canjs/can.mootools.min.js +63 -0
- data/vendor/assets/javascripts/canjs/can.observe.attributes.js +293 -0
- data/vendor/assets/javascripts/canjs/can.observe.backup.js +368 -0
- data/vendor/assets/javascripts/canjs/can.observe.delegate.js +359 -0
- data/vendor/assets/javascripts/canjs/can.observe.setter.js +58 -0
- data/vendor/assets/javascripts/canjs/can.observe.validations.js +374 -0
- data/vendor/assets/javascripts/canjs/can.view.modifiers.js +292 -0
- data/vendor/assets/javascripts/canjs/can.yui.js +3530 -0
- data/vendor/assets/javascripts/canjs/can.yui.min.js +65 -0
- data/vendor/assets/javascripts/canjs/can.zepto.js +3426 -0
- data/vendor/assets/javascripts/canjs/can.zepto.min.js +62 -0
- data/vendor/assets/javascripts/twitter/bootstrap-affix.js +104 -0
- data/vendor/assets/javascripts/twitter/bootstrap-alert.js +90 -0
- data/vendor/assets/javascripts/twitter/bootstrap-button.js +96 -0
- data/vendor/assets/javascripts/twitter/bootstrap-carousel.js +176 -0
- data/vendor/assets/javascripts/twitter/bootstrap-collapse.js +158 -0
- data/vendor/assets/javascripts/twitter/bootstrap-dropdown.js +150 -0
- data/vendor/assets/javascripts/twitter/bootstrap-modal.js +239 -0
- data/vendor/assets/javascripts/twitter/bootstrap-popover.js +103 -0
- data/vendor/assets/javascripts/twitter/bootstrap-scrollspy.js +151 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tooltip.js +275 -0
- data/vendor/assets/javascripts/twitter/bootstrap-transition.js +60 -0
- data/vendor/assets/javascripts/twitter/bootstrap-typeahead.js +300 -0
- data/vendor/assets/javascripts/twitter/my/bootstrap-typeahead.js +311 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- metadata +470 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* ===================================================
|
|
2
|
+
* bootstrap-transition.js v2.1.1
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#transitions
|
|
4
|
+
* ===================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ========================================================== */
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
!function ($) {
|
|
22
|
+
|
|
23
|
+
$(function () {
|
|
24
|
+
|
|
25
|
+
"use strict"; // jshint ;_;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
|
|
29
|
+
* ======================================================= */
|
|
30
|
+
|
|
31
|
+
$.support.transition = (function () {
|
|
32
|
+
|
|
33
|
+
var transitionEnd = (function () {
|
|
34
|
+
|
|
35
|
+
var el = document.createElement('bootstrap')
|
|
36
|
+
, transEndEventNames = {
|
|
37
|
+
'WebkitTransition' : 'webkitTransitionEnd'
|
|
38
|
+
, 'MozTransition' : 'transitionend'
|
|
39
|
+
, 'OTransition' : 'oTransitionEnd otransitionend'
|
|
40
|
+
, 'transition' : 'transitionend'
|
|
41
|
+
}
|
|
42
|
+
, name
|
|
43
|
+
|
|
44
|
+
for (name in transEndEventNames){
|
|
45
|
+
if (el.style[name] !== undefined) {
|
|
46
|
+
return transEndEventNames[name]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}())
|
|
51
|
+
|
|
52
|
+
return transitionEnd && {
|
|
53
|
+
end: transitionEnd
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
})()
|
|
57
|
+
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
}(window.jQuery);
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/* =============================================================
|
|
2
|
+
* bootstrap-typeahead.js v2.1.1
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
|
4
|
+
* =============================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ============================================================ */
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
!function($){
|
|
22
|
+
|
|
23
|
+
"use strict"; // jshint ;_;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/* TYPEAHEAD PUBLIC CLASS DEFINITION
|
|
27
|
+
* ================================= */
|
|
28
|
+
|
|
29
|
+
var Typeahead = function (element, options) {
|
|
30
|
+
this.$element = $(element)
|
|
31
|
+
this.options = $.extend({}, $.fn.typeahead.defaults, options)
|
|
32
|
+
this.matcher = this.options.matcher || this.matcher
|
|
33
|
+
this.sorter = this.options.sorter || this.sorter
|
|
34
|
+
this.highlighter = this.options.highlighter || this.highlighter
|
|
35
|
+
this.updater = this.options.updater || this.updater
|
|
36
|
+
this.$menu = $(this.options.menu).appendTo('body')
|
|
37
|
+
this.source = this.options.source
|
|
38
|
+
this.shown = false
|
|
39
|
+
this.listen()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Typeahead.prototype = {
|
|
43
|
+
|
|
44
|
+
constructor: Typeahead
|
|
45
|
+
|
|
46
|
+
, select: function () {
|
|
47
|
+
var val = this.$menu.find('.active').attr('data-value')
|
|
48
|
+
this.$element
|
|
49
|
+
.val(this.updater(val))
|
|
50
|
+
.change()
|
|
51
|
+
return this.hide()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
, updater: function (item) {
|
|
55
|
+
return item
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
, show: function () {
|
|
59
|
+
var pos = $.extend({}, this.$element.offset(), {
|
|
60
|
+
height: this.$element[0].offsetHeight
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
this.$menu.css({
|
|
64
|
+
top: pos.top + pos.height
|
|
65
|
+
, left: pos.left
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
this.$menu.show()
|
|
69
|
+
this.shown = true
|
|
70
|
+
return this
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
, hide: function () {
|
|
74
|
+
this.$menu.hide()
|
|
75
|
+
this.shown = false
|
|
76
|
+
return this
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
, lookup: function (event) {
|
|
80
|
+
var items
|
|
81
|
+
|
|
82
|
+
this.query = this.$element.val()
|
|
83
|
+
|
|
84
|
+
if (!this.query || this.query.length < this.options.minLength) {
|
|
85
|
+
return this.shown ? this.hide() : this
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
|
|
89
|
+
|
|
90
|
+
return items ? this.process(items) : this
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
, process: function (items) {
|
|
94
|
+
var that = this
|
|
95
|
+
|
|
96
|
+
items = $.grep(items, function (item) {
|
|
97
|
+
return that.matcher(item)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
items = this.sorter(items)
|
|
101
|
+
|
|
102
|
+
if (!items.length) {
|
|
103
|
+
return this.shown ? this.hide() : this
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this.render(items.slice(0, this.options.items)).show()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
, matcher: function (item) {
|
|
110
|
+
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
, sorter: function (items) {
|
|
114
|
+
var beginswith = []
|
|
115
|
+
, caseSensitive = []
|
|
116
|
+
, caseInsensitive = []
|
|
117
|
+
, item
|
|
118
|
+
|
|
119
|
+
while (item = items.shift()) {
|
|
120
|
+
if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
|
|
121
|
+
else if (~item.indexOf(this.query)) caseSensitive.push(item)
|
|
122
|
+
else caseInsensitive.push(item)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return beginswith.concat(caseSensitive, caseInsensitive)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
, highlighter: function (item) {
|
|
129
|
+
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
|
|
130
|
+
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
|
131
|
+
return '<strong>' + match + '</strong>'
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
, render: function (items) {
|
|
136
|
+
var that = this
|
|
137
|
+
|
|
138
|
+
items = $(items).map(function (i, item) {
|
|
139
|
+
i = $(that.options.item).attr('data-value', item)
|
|
140
|
+
i.find('a').html(that.highlighter(item))
|
|
141
|
+
return i[0]
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
items.first().addClass('active')
|
|
145
|
+
this.$menu.html(items)
|
|
146
|
+
return this
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
, next: function (event) {
|
|
150
|
+
var active = this.$menu.find('.active').removeClass('active')
|
|
151
|
+
, next = active.next()
|
|
152
|
+
|
|
153
|
+
if (!next.length) {
|
|
154
|
+
next = $(this.$menu.find('li')[0])
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
next.addClass('active')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
, prev: function (event) {
|
|
161
|
+
var active = this.$menu.find('.active').removeClass('active')
|
|
162
|
+
, prev = active.prev()
|
|
163
|
+
|
|
164
|
+
if (!prev.length) {
|
|
165
|
+
prev = this.$menu.find('li').last()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
prev.addClass('active')
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
, listen: function () {
|
|
172
|
+
this.$element
|
|
173
|
+
.on('blur', $.proxy(this.blur, this))
|
|
174
|
+
.on('keypress', $.proxy(this.keypress, this))
|
|
175
|
+
.on('keyup', $.proxy(this.keyup, this))
|
|
176
|
+
|
|
177
|
+
if ($.browser.chrome || $.browser.webkit || $.browser.msie) {
|
|
178
|
+
this.$element.on('keydown', $.proxy(this.keydown, this))
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.$menu
|
|
182
|
+
.on('click', $.proxy(this.click, this))
|
|
183
|
+
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
, move: function (e) {
|
|
187
|
+
if (!this.shown) return
|
|
188
|
+
|
|
189
|
+
switch(e.keyCode) {
|
|
190
|
+
case 9: // tab
|
|
191
|
+
case 13: // enter
|
|
192
|
+
case 27: // escape
|
|
193
|
+
e.preventDefault()
|
|
194
|
+
break
|
|
195
|
+
|
|
196
|
+
case 38: // up arrow
|
|
197
|
+
e.preventDefault()
|
|
198
|
+
this.prev()
|
|
199
|
+
break
|
|
200
|
+
|
|
201
|
+
case 40: // down arrow
|
|
202
|
+
e.preventDefault()
|
|
203
|
+
this.next()
|
|
204
|
+
break
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
e.stopPropagation()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
, keydown: function (e) {
|
|
211
|
+
this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
|
|
212
|
+
this.move(e)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
, keypress: function (e) {
|
|
216
|
+
if (this.suppressKeyPressRepeat) return
|
|
217
|
+
this.move(e)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
, keyup: function (e) {
|
|
221
|
+
switch(e.keyCode) {
|
|
222
|
+
case 40: // down arrow
|
|
223
|
+
case 38: // up arrow
|
|
224
|
+
break
|
|
225
|
+
|
|
226
|
+
case 9: // tab
|
|
227
|
+
case 13: // enter
|
|
228
|
+
if (!this.shown) return
|
|
229
|
+
this.select()
|
|
230
|
+
break
|
|
231
|
+
|
|
232
|
+
case 27: // escape
|
|
233
|
+
if (!this.shown) return
|
|
234
|
+
this.hide()
|
|
235
|
+
break
|
|
236
|
+
|
|
237
|
+
default:
|
|
238
|
+
this.lookup()
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
e.stopPropagation()
|
|
242
|
+
e.preventDefault()
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
, blur: function (e) {
|
|
246
|
+
var that = this
|
|
247
|
+
setTimeout(function () { that.hide() }, 150)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
, click: function (e) {
|
|
251
|
+
e.stopPropagation()
|
|
252
|
+
e.preventDefault()
|
|
253
|
+
this.select()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
, mouseenter: function (e) {
|
|
257
|
+
this.$menu.find('.active').removeClass('active')
|
|
258
|
+
$(e.currentTarget).addClass('active')
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
/* TYPEAHEAD PLUGIN DEFINITION
|
|
265
|
+
* =========================== */
|
|
266
|
+
|
|
267
|
+
$.fn.typeahead = function (option) {
|
|
268
|
+
return this.each(function () {
|
|
269
|
+
var $this = $(this)
|
|
270
|
+
, data = $this.data('typeahead')
|
|
271
|
+
, options = typeof option == 'object' && option
|
|
272
|
+
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
|
|
273
|
+
if (typeof option == 'string') data[option]()
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
$.fn.typeahead.defaults = {
|
|
278
|
+
source: []
|
|
279
|
+
, items: 8
|
|
280
|
+
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
|
281
|
+
, item: '<li><a href="#"></a></li>'
|
|
282
|
+
, minLength: 1
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
$.fn.typeahead.Constructor = Typeahead
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
/* TYPEAHEAD DATA-API
|
|
289
|
+
* ================== */
|
|
290
|
+
|
|
291
|
+
$(function () {
|
|
292
|
+
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
|
293
|
+
var $this = $(this)
|
|
294
|
+
if ($this.data('typeahead')) return
|
|
295
|
+
e.preventDefault()
|
|
296
|
+
$this.typeahead($this.data())
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
}(window.jQuery);
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/* =============================================================
|
|
2
|
+
* bootstrap-typeahead.js v2.0.0
|
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
|
4
|
+
* =============================================================
|
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
* ============================================================ */
|
|
19
|
+
|
|
20
|
+
!function( $ ){
|
|
21
|
+
|
|
22
|
+
"use strict"
|
|
23
|
+
|
|
24
|
+
var Typeahead = function ( element, options ) {
|
|
25
|
+
this.$element = $(element)
|
|
26
|
+
this.options = $.extend({}, $.fn.typeahead.defaults, options)
|
|
27
|
+
this.matcher = this.options.matcher || this.matcher
|
|
28
|
+
this.sorter = this.options.sorter || this.sorter
|
|
29
|
+
this.highlighter = this.options.highlighter || this.highlighter
|
|
30
|
+
this.$menu = $(this.options.menu).appendTo('body')
|
|
31
|
+
this.source = this.options.source
|
|
32
|
+
this.onselect = this.options.onselect
|
|
33
|
+
this.strings = true
|
|
34
|
+
this.shown = false
|
|
35
|
+
this.listen()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Typeahead.prototype = {
|
|
39
|
+
|
|
40
|
+
constructor: Typeahead
|
|
41
|
+
|
|
42
|
+
, select: function () {
|
|
43
|
+
var val = JSON.parse(this.$menu.find('.active').attr('data-value'))
|
|
44
|
+
, text
|
|
45
|
+
|
|
46
|
+
if (!this.strings) text = val[this.options.property]
|
|
47
|
+
else text = val
|
|
48
|
+
|
|
49
|
+
this.$element.val(text)
|
|
50
|
+
|
|
51
|
+
if (typeof this.onselect == "function")
|
|
52
|
+
this.onselect(val)
|
|
53
|
+
|
|
54
|
+
return this.hide()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
, show: function () {
|
|
58
|
+
var pos = $.extend({}, this.$element.offset(), {
|
|
59
|
+
height: this.$element[0].offsetHeight
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
this.$menu.css({
|
|
63
|
+
top: pos.top + pos.height
|
|
64
|
+
, left: pos.left
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
this.$menu.show()
|
|
68
|
+
this.shown = true
|
|
69
|
+
return this
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
, hide: function () {
|
|
73
|
+
this.$menu.hide()
|
|
74
|
+
this.shown = false
|
|
75
|
+
return this
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
, lookup: function (event) {
|
|
79
|
+
var that = this
|
|
80
|
+
, items
|
|
81
|
+
, q
|
|
82
|
+
, value
|
|
83
|
+
|
|
84
|
+
this.query = this.$element.val()
|
|
85
|
+
|
|
86
|
+
if (typeof this.source == "function") {
|
|
87
|
+
value = this.source(this, this.query)
|
|
88
|
+
if (value) this.process(value)
|
|
89
|
+
} else {
|
|
90
|
+
this.process(this.source)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
, process: function (results) {
|
|
95
|
+
var that = this
|
|
96
|
+
, items
|
|
97
|
+
, q
|
|
98
|
+
|
|
99
|
+
if (results.length && typeof results[0] != "string")
|
|
100
|
+
this.strings = false
|
|
101
|
+
|
|
102
|
+
this.query = this.$element.val()
|
|
103
|
+
|
|
104
|
+
if (!this.query) {
|
|
105
|
+
return this.shown ? this.hide() : this
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
items = $.grep(results, function (item) {
|
|
109
|
+
if (!that.strings)
|
|
110
|
+
item = item[that.options.property]
|
|
111
|
+
if (that.matcher(item)) return item
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
items = this.sorter(items)
|
|
115
|
+
|
|
116
|
+
if (!items.length) {
|
|
117
|
+
return this.shown ? this.hide() : this
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return this.render(items.slice(0, this.options.items)).show()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
, matcher: function (item) {
|
|
124
|
+
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
, sorter: function (items) {
|
|
128
|
+
var beginswith = []
|
|
129
|
+
, caseSensitive = []
|
|
130
|
+
, caseInsensitive = []
|
|
131
|
+
, item
|
|
132
|
+
, sortby
|
|
133
|
+
|
|
134
|
+
while (item = items.shift()) {
|
|
135
|
+
if (this.strings) sortby = item
|
|
136
|
+
else sortby = item[this.options.property]
|
|
137
|
+
|
|
138
|
+
if (!sortby.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
|
|
139
|
+
else if (~sortby.indexOf(this.query)) caseSensitive.push(item)
|
|
140
|
+
else caseInsensitive.push(item)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return beginswith.concat(caseSensitive, caseInsensitive)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
, highlighter: function (item) {
|
|
147
|
+
return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) {
|
|
148
|
+
return '<strong>' + match + '</strong>'
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
, render: function (items) {
|
|
153
|
+
var that = this
|
|
154
|
+
|
|
155
|
+
items = $(items).map(function (i, item) {
|
|
156
|
+
i = $(that.options.item).attr('data-value', JSON.stringify(item))
|
|
157
|
+
if (!that.strings)
|
|
158
|
+
item = item[that.options.property]
|
|
159
|
+
i.find('a').html(that.highlighter(item))
|
|
160
|
+
return i[0]
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
items.first().addClass('active')
|
|
164
|
+
this.$menu.html(items)
|
|
165
|
+
return this
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
, next: function (event) {
|
|
169
|
+
var active = this.$menu.find('.active').removeClass('active')
|
|
170
|
+
, next = active.next()
|
|
171
|
+
|
|
172
|
+
if (!next.length) {
|
|
173
|
+
next = $(this.$menu.find('li')[0])
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
next.addClass('active')
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
, prev: function (event) {
|
|
180
|
+
var active = this.$menu.find('.active').removeClass('active')
|
|
181
|
+
, prev = active.prev()
|
|
182
|
+
|
|
183
|
+
if (!prev.length) {
|
|
184
|
+
prev = this.$menu.find('li').last()
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
prev.addClass('active')
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
, listen: function () {
|
|
191
|
+
this.$element
|
|
192
|
+
.on('blur', $.proxy(this.blur, this))
|
|
193
|
+
.on('keypress', $.proxy(this.keypress, this))
|
|
194
|
+
.on('keyup', $.proxy(this.keyup, this))
|
|
195
|
+
|
|
196
|
+
if ($.browser.webkit || $.browser.msie) {
|
|
197
|
+
this.$element.on('keydown', $.proxy(this.keypress, this))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
this.$menu
|
|
201
|
+
.on('click', $.proxy(this.click, this))
|
|
202
|
+
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
, keyup: function (e) {
|
|
206
|
+
e.stopPropagation()
|
|
207
|
+
e.preventDefault()
|
|
208
|
+
|
|
209
|
+
switch(e.keyCode) {
|
|
210
|
+
case 40: // down arrow
|
|
211
|
+
case 38: // up arrow
|
|
212
|
+
break
|
|
213
|
+
|
|
214
|
+
case 9: // tab
|
|
215
|
+
case 13: // enter
|
|
216
|
+
if (!this.shown) return
|
|
217
|
+
this.select()
|
|
218
|
+
break
|
|
219
|
+
|
|
220
|
+
case 27: // escape
|
|
221
|
+
this.hide()
|
|
222
|
+
break
|
|
223
|
+
|
|
224
|
+
default:
|
|
225
|
+
this.lookup()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
, keypress: function (e) {
|
|
231
|
+
e.stopPropagation()
|
|
232
|
+
if (!this.shown) return
|
|
233
|
+
|
|
234
|
+
switch(e.keyCode) {
|
|
235
|
+
case 9: // tab
|
|
236
|
+
case 13: // enter
|
|
237
|
+
case 27: // escape
|
|
238
|
+
e.preventDefault()
|
|
239
|
+
break
|
|
240
|
+
|
|
241
|
+
case 38: // up arrow
|
|
242
|
+
e.preventDefault()
|
|
243
|
+
this.prev()
|
|
244
|
+
break
|
|
245
|
+
|
|
246
|
+
case 40: // down arrow
|
|
247
|
+
e.preventDefault()
|
|
248
|
+
this.next()
|
|
249
|
+
break
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
, blur: function (e) {
|
|
254
|
+
var that = this
|
|
255
|
+
e.stopPropagation()
|
|
256
|
+
e.preventDefault()
|
|
257
|
+
setTimeout(function () { that.hide() }, 150)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
, click: function (e) {
|
|
261
|
+
e.stopPropagation()
|
|
262
|
+
e.preventDefault()
|
|
263
|
+
this.select()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
, mouseenter: function (e) {
|
|
267
|
+
this.$menu.find('.active').removeClass('active')
|
|
268
|
+
$(e.currentTarget).addClass('active')
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/* TYPEAHEAD PLUGIN DEFINITION
|
|
275
|
+
* =========================== */
|
|
276
|
+
|
|
277
|
+
$.fn.typeahead = function ( option ) {
|
|
278
|
+
return this.each(function () {
|
|
279
|
+
var $this = $(this)
|
|
280
|
+
, data = $this.data('typeahead')
|
|
281
|
+
, options = typeof option == 'object' && option
|
|
282
|
+
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
|
|
283
|
+
if (typeof option == 'string') data[option]()
|
|
284
|
+
})
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
$.fn.typeahead.defaults = {
|
|
288
|
+
source: []
|
|
289
|
+
, items: 8
|
|
290
|
+
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
|
291
|
+
, item: '<li><a href="#"></a></li>'
|
|
292
|
+
, onselect: null
|
|
293
|
+
, property: 'value'
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
$.fn.typeahead.Constructor = Typeahead
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
/* TYPEAHEAD DATA-API
|
|
300
|
+
* ================== */
|
|
301
|
+
|
|
302
|
+
$(function () {
|
|
303
|
+
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
|
304
|
+
var $this = $(this)
|
|
305
|
+
if ($this.data('typeahead')) return
|
|
306
|
+
e.preventDefault()
|
|
307
|
+
$this.typeahead($this.data())
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
}( window.jQuery );
|