push_type_admin 0.1.1 → 0.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/push_type/admin.js.coffee +6 -20
- data/app/assets/javascripts/push_type/admin_assets.js.coffee.erb +1 -0
- data/app/assets/javascripts/push_type/assets.js.coffee +2 -10
- data/app/assets/stylesheets/push_type/admin.scss +1 -6
- data/app/assets/stylesheets/push_type/admin_assets.scss.erb +1 -0
- data/app/assets/stylesheets/push_type/tagsinput.scss +51 -0
- data/app/controllers/push_type/assets_controller.rb +11 -5
- data/app/controllers/push_type/nodes_controller.rb +2 -2
- data/app/controllers/push_type/users_controller.rb +1 -1
- data/app/helpers/push_type/assets_helper.rb +20 -7
- data/app/helpers/push_type/nodes_helper.rb +15 -0
- data/app/views/layouts/push_type/admin.html.erb +2 -2
- data/app/views/push_type/assets/_form.html.haml +2 -2
- data/app/views/push_type/assets/index.html.haml +2 -2
- data/app/views/push_type/fields/_tags.html.haml +3 -0
- data/app/views/push_type/nodes/_form_fields.html.haml +1 -1
- data/app/views/push_type/nodes/_new_node_button.html.haml +10 -10
- data/app/views/push_type/nodes/index.html.haml +4 -3
- data/lib/push_type/admin/assets.rb +19 -0
- data/lib/push_type/admin/engine.rb +10 -1
- data/lib/push_type/admin.rb +1 -2
- data/test/controllers/push_type/assets_controller_test.rb +21 -0
- data/test/dummy/app/assets/javascripts/application.js +1 -1
- data/test/dummy/app/assets/stylesheets/application.css +1 -1
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/environments/development.rb +4 -0
- data/test/dummy/config/environments/production.rb +13 -12
- data/test/dummy/config/environments/test.rb +5 -2
- data/test/dummy/config/initializers/assets.rb +3 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/dummy/config/initializers/push_type.rb +11 -1
- data/test/dummy/config/secrets.yml +2 -2
- data/test/dummy/config.ru +1 -1
- data/test/dummy/db/migrate/{20150108182226_create_push_type_users.push_type.rb → 20150208150316_create_push_type_users.push_type.rb} +1 -1
- data/test/dummy/db/migrate/{20150108182227_create_push_type_nodes.push_type.rb → 20150208150317_create_push_type_nodes.push_type.rb} +1 -1
- data/test/dummy/db/migrate/{20150108182228_create_push_type_node_hierarchies.push_type.rb → 20150208150318_create_push_type_node_hierarchies.push_type.rb} +0 -0
- data/test/dummy/db/migrate/{20150108182229_create_push_type_assets.push_type.rb → 20150208150319_create_push_type_assets.push_type.rb} +0 -0
- data/test/dummy/db/schema.rb +7 -7
- data/test/dummy/log/test.log +2577 -1693
- data/test/dummy/tmp/cache/assets/test/sass/2df752541ff0a319141a1cb83ca971d2ffd2d050/admin.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/2df752541ff0a319141a1cb83ca971d2ffd2d050/admin_assets.scss.erbc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/{4192f8fb8ca1d6fcdfe4b8f89f72b4ba9c4efa8f → 2df752541ff0a319141a1cb83ca971d2ffd2d050}/foundation_and_overrides.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/2df752541ff0a319141a1cb83ca971d2ffd2d050/tagsinput.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/356cbb24ba380fa6c5255d546317e2ce23ea8cd6/_functions.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_accordion.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_alert-boxes.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_block-grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_breadcrumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_button-groups.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_clearing.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_dropdown-buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_dropdown.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_flex-video.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_forms.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_global.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_icon-bar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_inline-lists.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_joyride.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_keystrokes.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_labels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_magellan.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_offcanvas.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_orbit.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_pagination.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_panels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_pricing-tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_progress-bars.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_range-slider.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_reveal.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_side-nav.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_split-buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_sub-nav.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_switches.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_tabs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_thumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_tooltips.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_top-bar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_type.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/b51672fface3a4ec5947e1db3f21f77baa80aed8/_visibility.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/d416499186bc6a8ba276a69cc9d9fffa030e66bc/foundation-icons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/deb1394852fa60b8a5f9d5ea21f0c1f44e511075/foundation.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/00ae61e049df7e5570b8c57835868cfe +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/042e6dec69dbf88f86f5e8c360b52bcb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/090f2c9bc57f8e73105a98a800051354 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0a01f1c3288f982772ed595695292767 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0b83e9e8467b82a0991df336697846e0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0e01ae9de0f3914c8317853aedd9ace4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1505f3ddd93d7be2405c81d84a45cbfb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/161b66dc0b76d65e577b5465f86cb767 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1da46bb361bbd7b80dc66e5737dbf2a7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/226a629ec094e8ad208f2c273121699a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/23c10c485dbe7ea46614928874120ecf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2599cde7c63354f12928a204c42fe68b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/25da091131e25acf0f55a6528a94f309 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2821176477eee8de7b9581f0564d0947 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2a00ce050c10f75691b820576ec3aefd +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2c745da65bdbc8ebb88b6bce026972b9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3508023b6222e6b0876c773e38ec700d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/488d63b20534d2642d48b86b5a267a3b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4fc498f23125a9811434c6d5d5b43b64 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/508e9ca93a5c6a60e79e3496654497cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/55d7985953b175268932d2f7e50f64e0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/67d67f783372c9b99e2ff84c12d38dfb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6d21cd96abbcb6506d99fb93e8a11196 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7326e3e660754d56c46671c7347c5e97 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7879ec7699a19e017377e1b57702e3e5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7925f8f38f5165ad9d36a7d73dd00c06 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7ea9d575b03f8effb678d4dcedf3d079 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7f0b91f5fa71c52d3cbe1f108fb7c942 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/81ba6a364949bd4ffe2732ae5745012d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/81e2498e0e1457dd93b47780ae28fc03 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/81ebadcc1f5568d97bfe59f0929ab498 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/897553ff72f546645e24e94feec75255 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8a34d99aaa243ebb4e60f483a5b5a817 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8d531fdb806de0724337e0b80e253914 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8da458b8df4bfbd9fb0eed86c36442d4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8df98e9b5189ffce4cf77a33533416a6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/91e13d81afe9041372ad8f79ee9159f4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/92716c1d1cdd92efe79de35a47956fc9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/959fa77a7302a3002d5fb1394575117b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/969e05674f51d3b5b500e605e0292573 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/987bf17b1a3915d5c6d95ebda01e8f49 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9aef3ae1f0c62b895d86ab60901dd450 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a010781c05d478892856f75c751d6ab4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a590260912e62280bb115dd52a953b18 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a6453a78eb0c813a0b69a12cb7c4ab2c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a721a930039ed66bd3f092ab1e9c8de6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a970f64c67051f35069f45d8dad113a5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a9b8decaa2942e8913458c9f35da2693 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/aaf7959dea629271d23756ab876bc035 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ac1b1f0c521a6acb5833209d7b18d888 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ada55ab3ebb32ffd74145d341fbbcb06 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b24f2d6f62512f4cb11c6a2e44bf90e4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b3d0193a1439465426a4d051a161291d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b657c356e24f45a8b92d4f4da9ff361d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b76beafa9aef0c7a18bf63fe612ecd17 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b771c2de3967bda011cf04e0979497cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b78741de2e56d8ac6629bb0dbf1d5c20 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ba87909b8d71ddaedd84c3f6c00dce72 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bbfc8dec2c2cc07cf4c1708597316a77 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bc732efa6ca399217b023bd1e04f0404 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bd5b45287cfdac63ed7199b7982da02f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bee4e1605077e29abd380b05b645cbb4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c206fbd33f49ab785c6ddf4bcffd3b93 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c2b59fd99edc4b53754f7cb4e160452f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cb761fc7bfc4c192abf5c946f863ab1e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cf51890ac703ed5a5d704515a4721815 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d2215e57429ecae68a054210e665d787 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d30a320df486e076298c602d428f3145 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d3921fc37cc437f0933c4dee9d089fd8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d8daf6c8e5df881485c0e1139a275f6d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d9e5382620928a6b4a8cd70bdac10aa3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/df90022afc0d52f16bc498be20a5967d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e1c3eff1f3886da4c71a854d42077d10 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e28b8ab6a5b3ff792f45d5a6b7d806bc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e540a9dc1aa001f8c4cba7a6b00f69d2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e6e78e14e8c962d31e6148ca56230af9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/edaf2543a96ee921c30a071b3a73036f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/edd24c59de6c00e4e68dbbdf2775984a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/eeb045e353d91335ea6ec8a8869c322f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f100237ea34e5360da23f95cca21c340 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{505162da4e90217e5f52f5e8f1922a0d → f4b5b11e7111666c7eac22f943308692} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f5fcab9d313889bf6d14a05040aff5bc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f66bf7665e75e4d537977c71a5e39a4e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cf86568d1c692cb0a565614f282572 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f96cec87308c4d1efa7993c38b770ba3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fa7e1f9a13f606e2603a17f8e00aa32a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{fcce52ee43ecad8cb3f18fc8f13a66b7 → fada546ecac912f7782a46cf40ec29af} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fd06309bc284d80f9c2a30f32ed8df14 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fd5e59fed8301f86b74e551534fce2b2 +0 -0
- data/test/helpers/push_type/assets_helper_test.rb +30 -0
- data/test/helpers/push_type/nodes_helper_test.rb +29 -0
- data/test/lib/push_type/admin/assets_test.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/vendor/assets/javascripts/bootstrap-tagsinput.js +617 -0
- metadata +153 -201
- data/app/assets/javascripts/push_type/asset_pipeline.js.coffee.erb +0 -17
- data/app/assets/stylesheets/push_type/froala_theme.scss +0 -373
- data/config/initializers/kaminari_config.rb +0 -10
- data/test/dummy/tmp/cache/assets/test/sass/4192f8fb8ca1d6fcdfe4b8f89f72b4ba9c4efa8f/admin.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/4192f8fb8ca1d6fcdfe4b8f89f72b4ba9c4efa8f/froala_theme.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/53cc07db53069364c4116d03ae9493d85566d502/_functions.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_accordion.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_alert-boxes.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_block-grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_breadcrumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_button-groups.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_clearing.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_dropdown-buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_dropdown.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_flex-video.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_forms.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_global.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_icon-bar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_inline-lists.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_joyride.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_keystrokes.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_labels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_magellan.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_offcanvas.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_orbit.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_pagination.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_panels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_pricing-tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_progress-bars.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_range-slider.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_reveal.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_side-nav.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_split-buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_sub-nav.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_switches.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_tabs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_thumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_tooltips.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_top-bar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_type.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/669496e8548de1a6ba1641898c1b30c67ab8fac2/_visibility.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/68968d876746de0885a03aacd18ec354e154ffed/foundation-icons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/805c0b657f4b79d174c13bc42a4759a57d5a5484/foundation.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0448802b256c25a379824969bf01241e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/0a170bcd46595a69e9181ea5eb52ec6f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1c63cb75109171c505bf1b6b3f26513b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/22578effd3d5017b533efd147a1b4407 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2479bd5cbccdeac3ab4df62c2c12e8d3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/25b238c2ec907a80d53955a0bb81073c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2d1bc2b9dc5ee0ed5635abc31fb1bc88 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/31c57ad31a65f9a951c6d7268cdedae5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3d4f40cd6363f1841fa7c17dcbd281ce +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/47dcfb84d9a092ad939f512e1d3db43c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/55d58e1add1ca367e262464e83ad82cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/59992ed1702654aa166f8572af80a301 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5ef293117afc54aeaa16d32cbd16dd38 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/600202d00479f08d2e69019e34d12e65 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/75c5663a92b2003b794d5f5d184fde44 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7b63c613f1053bde6004342003178a0e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7d07558d12b9bd9b9dfa778344bab4ac +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/805c63977d339feb2ea7b61e1141a32f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/853c1095ab6e7f4eba1f3406f0f3bba6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8f8914547a4f22638b676f968bc18d68 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8feb3d758b7824f15b301f9dc024c3f6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/932f699ead87a4b9910d47334ed14d60 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9896c5d1de4e8661c3b424aec81f7e8c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a427bb8cde4beaf2d4483ad3554d2297 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a96494099d559bfd8cb5257e21cb196c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/aaa6dc2bd59e21dd14b0c86a308a1d1f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/badf6e6ab7c3d1cc2b180e5883005a40 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c190d0bdd188c43629f35b9f463b86af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c42a7aac68d827f88bcc25a41cdb5591 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c5ef052e357af6829f6c522a38916fc7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c988fd2c5c9497ccef54f79a9e444ac6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cd078b38e48bcd1e121d801b46b2616f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d1cebb5323d93da406dfb152a0c55568 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e568172da8ab8581f83f98dad0a73d29 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e5e4aa0b0cc633e1e2e25614fd922803 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f02093872b151ddb0fd1074fe83ff846 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7013d94f76b09bce94f78e2453f7eae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f92aeb6f9539612517848945ee03aff8 +0 -0
@@ -0,0 +1,617 @@
|
|
1
|
+
(function ($) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var defaultOptions = {
|
5
|
+
tagClass: function(item) {
|
6
|
+
return 'label label-info';
|
7
|
+
},
|
8
|
+
itemValue: function(item) {
|
9
|
+
return item ? item.toString() : item;
|
10
|
+
},
|
11
|
+
itemText: function(item) {
|
12
|
+
return this.itemValue(item);
|
13
|
+
},
|
14
|
+
freeInput: true,
|
15
|
+
addOnBlur: true,
|
16
|
+
maxTags: undefined,
|
17
|
+
maxChars: undefined,
|
18
|
+
confirmKeys: [13, 44],
|
19
|
+
onTagExists: function(item, $tag) {
|
20
|
+
$tag.hide().fadeIn();
|
21
|
+
},
|
22
|
+
trimValue: false,
|
23
|
+
allowDuplicates: false
|
24
|
+
};
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Constructor function
|
28
|
+
*/
|
29
|
+
function TagsInput(element, options) {
|
30
|
+
this.itemsArray = [];
|
31
|
+
|
32
|
+
this.$element = $(element);
|
33
|
+
this.$element.hide();
|
34
|
+
|
35
|
+
this.isSelect = (element.tagName === 'SELECT');
|
36
|
+
this.multiple = (this.isSelect && element.hasAttribute('multiple'));
|
37
|
+
this.objectItems = options && options.itemValue;
|
38
|
+
this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : '';
|
39
|
+
this.inputSize = Math.max(1, this.placeholderText.length);
|
40
|
+
|
41
|
+
this.$container = $('<div class="bootstrap-tagsinput"></div>');
|
42
|
+
this.$input = $('<input type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);
|
43
|
+
|
44
|
+
this.$element.after(this.$container);
|
45
|
+
|
46
|
+
var inputWidth = (this.inputSize < 3 ? 3 : this.inputSize) + "em";
|
47
|
+
this.$input.get(0).style.cssText = "width: " + inputWidth + " !important;";
|
48
|
+
this.build(options);
|
49
|
+
}
|
50
|
+
|
51
|
+
TagsInput.prototype = {
|
52
|
+
constructor: TagsInput,
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Adds the given item as a new tag. Pass true to dontPushVal to prevent
|
56
|
+
* updating the elements val()
|
57
|
+
*/
|
58
|
+
add: function(item, dontPushVal) {
|
59
|
+
var self = this;
|
60
|
+
|
61
|
+
if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags)
|
62
|
+
return;
|
63
|
+
|
64
|
+
// Ignore falsey values, except false
|
65
|
+
if (item !== false && !item)
|
66
|
+
return;
|
67
|
+
|
68
|
+
// Trim value
|
69
|
+
if (typeof item === "string" && self.options.trimValue) {
|
70
|
+
item = $.trim(item);
|
71
|
+
}
|
72
|
+
|
73
|
+
// Throw an error when trying to add an object while the itemValue option was not set
|
74
|
+
if (typeof item === "object" && !self.objectItems)
|
75
|
+
throw("Can't add objects when itemValue option is not set");
|
76
|
+
|
77
|
+
// Ignore strings only containg whitespace
|
78
|
+
if (item.toString().match(/^\s*$/))
|
79
|
+
return;
|
80
|
+
|
81
|
+
// If SELECT but not multiple, remove current tag
|
82
|
+
if (self.isSelect && !self.multiple && self.itemsArray.length > 0)
|
83
|
+
self.remove(self.itemsArray[0]);
|
84
|
+
|
85
|
+
if (typeof item === "string" && this.$element[0].tagName === 'INPUT') {
|
86
|
+
var items = item.split(',');
|
87
|
+
if (items.length > 1) {
|
88
|
+
for (var i = 0; i < items.length; i++) {
|
89
|
+
this.add(items[i], true);
|
90
|
+
}
|
91
|
+
|
92
|
+
if (!dontPushVal)
|
93
|
+
self.pushVal();
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
var itemValue = self.options.itemValue(item),
|
99
|
+
itemText = self.options.itemText(item),
|
100
|
+
tagClass = self.options.tagClass(item);
|
101
|
+
|
102
|
+
// Ignore items allready added
|
103
|
+
var existing = $.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0];
|
104
|
+
if (existing && !self.options.allowDuplicates) {
|
105
|
+
// Invoke onTagExists
|
106
|
+
if (self.options.onTagExists) {
|
107
|
+
var $existingTag = $(".tag", self.$container).filter(function() { return $(this).data("item") === existing; });
|
108
|
+
self.options.onTagExists(item, $existingTag);
|
109
|
+
}
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
|
113
|
+
// if length greater than limit
|
114
|
+
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
|
115
|
+
return;
|
116
|
+
|
117
|
+
// raise beforeItemAdd arg
|
118
|
+
var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false });
|
119
|
+
self.$element.trigger(beforeItemAddEvent);
|
120
|
+
if (beforeItemAddEvent.cancel)
|
121
|
+
return;
|
122
|
+
|
123
|
+
// register item in internal array and map
|
124
|
+
self.itemsArray.push(item);
|
125
|
+
|
126
|
+
// add a tag element
|
127
|
+
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
|
128
|
+
$tag.data('item', item);
|
129
|
+
self.findInputWrapper().before($tag);
|
130
|
+
$tag.after(' ');
|
131
|
+
|
132
|
+
// add <option /> if item represents a value not present in one of the <select />'s options
|
133
|
+
if (self.isSelect && !$('option[value="' + encodeURIComponent(itemValue) + '"]',self.$element)[0]) {
|
134
|
+
var $option = $('<option selected>' + htmlEncode(itemText) + '</option>');
|
135
|
+
$option.data('item', item);
|
136
|
+
$option.attr('value', itemValue);
|
137
|
+
self.$element.append($option);
|
138
|
+
}
|
139
|
+
|
140
|
+
if (!dontPushVal)
|
141
|
+
self.pushVal();
|
142
|
+
|
143
|
+
// Add class when reached maxTags
|
144
|
+
if (self.options.maxTags === self.itemsArray.length || self.items().toString().length === self.options.maxInputLength)
|
145
|
+
self.$container.addClass('bootstrap-tagsinput-max');
|
146
|
+
|
147
|
+
self.$element.trigger($.Event('itemAdded', { item: item }));
|
148
|
+
},
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Removes the given item. Pass true to dontPushVal to prevent updating the
|
152
|
+
* elements val()
|
153
|
+
*/
|
154
|
+
remove: function(item, dontPushVal) {
|
155
|
+
var self = this;
|
156
|
+
|
157
|
+
if (self.objectItems) {
|
158
|
+
if (typeof item === "object")
|
159
|
+
item = $.grep(self.itemsArray, function(other) { return self.options.itemValue(other) == self.options.itemValue(item); } );
|
160
|
+
else
|
161
|
+
item = $.grep(self.itemsArray, function(other) { return self.options.itemValue(other) == item; } );
|
162
|
+
|
163
|
+
item = item[item.length-1];
|
164
|
+
}
|
165
|
+
|
166
|
+
if (item) {
|
167
|
+
var beforeItemRemoveEvent = $.Event('beforeItemRemove', { item: item, cancel: false });
|
168
|
+
self.$element.trigger(beforeItemRemoveEvent);
|
169
|
+
if (beforeItemRemoveEvent.cancel)
|
170
|
+
return;
|
171
|
+
|
172
|
+
$('.tag', self.$container).filter(function() { return $(this).data('item') === item; }).remove();
|
173
|
+
$('option', self.$element).filter(function() { return $(this).data('item') === item; }).remove();
|
174
|
+
if($.inArray(item, self.itemsArray) !== -1)
|
175
|
+
self.itemsArray.splice($.inArray(item, self.itemsArray), 1);
|
176
|
+
}
|
177
|
+
|
178
|
+
if (!dontPushVal)
|
179
|
+
self.pushVal();
|
180
|
+
|
181
|
+
// Remove class when reached maxTags
|
182
|
+
if (self.options.maxTags > self.itemsArray.length)
|
183
|
+
self.$container.removeClass('bootstrap-tagsinput-max');
|
184
|
+
|
185
|
+
self.$element.trigger($.Event('itemRemoved', { item: item }));
|
186
|
+
},
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Removes all items
|
190
|
+
*/
|
191
|
+
removeAll: function() {
|
192
|
+
var self = this;
|
193
|
+
|
194
|
+
$('.tag', self.$container).remove();
|
195
|
+
$('option', self.$element).remove();
|
196
|
+
|
197
|
+
while(self.itemsArray.length > 0)
|
198
|
+
self.itemsArray.pop();
|
199
|
+
|
200
|
+
self.pushVal();
|
201
|
+
},
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Refreshes the tags so they match the text/value of their corresponding
|
205
|
+
* item.
|
206
|
+
*/
|
207
|
+
refresh: function() {
|
208
|
+
var self = this;
|
209
|
+
$('.tag', self.$container).each(function() {
|
210
|
+
var $tag = $(this),
|
211
|
+
item = $tag.data('item'),
|
212
|
+
itemValue = self.options.itemValue(item),
|
213
|
+
itemText = self.options.itemText(item),
|
214
|
+
tagClass = self.options.tagClass(item);
|
215
|
+
|
216
|
+
// Update tag's class and inner text
|
217
|
+
$tag.attr('class', null);
|
218
|
+
$tag.addClass('tag ' + htmlEncode(tagClass));
|
219
|
+
$tag.contents().filter(function() {
|
220
|
+
return this.nodeType == 3;
|
221
|
+
})[0].nodeValue = htmlEncode(itemText);
|
222
|
+
|
223
|
+
if (self.isSelect) {
|
224
|
+
var option = $('option', self.$element).filter(function() { return $(this).data('item') === item; });
|
225
|
+
option.attr('value', itemValue);
|
226
|
+
}
|
227
|
+
});
|
228
|
+
},
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Returns the items added as tags
|
232
|
+
*/
|
233
|
+
items: function() {
|
234
|
+
return this.itemsArray;
|
235
|
+
},
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Assembly value by retrieving the value of each item, and set it on the
|
239
|
+
* element.
|
240
|
+
*/
|
241
|
+
pushVal: function() {
|
242
|
+
var self = this,
|
243
|
+
val = $.map(self.items(), function(item) {
|
244
|
+
return self.options.itemValue(item).toString();
|
245
|
+
});
|
246
|
+
|
247
|
+
self.$element.val(val, true).trigger('change');
|
248
|
+
},
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Initializes the tags input behaviour on the element
|
252
|
+
*/
|
253
|
+
build: function(options) {
|
254
|
+
var self = this;
|
255
|
+
|
256
|
+
self.options = $.extend({}, defaultOptions, options);
|
257
|
+
// When itemValue is set, freeInput should always be false
|
258
|
+
if (self.objectItems)
|
259
|
+
self.options.freeInput = false;
|
260
|
+
|
261
|
+
makeOptionItemFunction(self.options, 'itemValue');
|
262
|
+
makeOptionItemFunction(self.options, 'itemText');
|
263
|
+
makeOptionFunction(self.options, 'tagClass');
|
264
|
+
|
265
|
+
// Typeahead Bootstrap version 2.3.2
|
266
|
+
if (self.options.typeahead) {
|
267
|
+
var typeahead = self.options.typeahead || {};
|
268
|
+
|
269
|
+
makeOptionFunction(typeahead, 'source');
|
270
|
+
|
271
|
+
self.$input.typeahead($.extend({}, typeahead, {
|
272
|
+
source: function (query, process) {
|
273
|
+
function processItems(items) {
|
274
|
+
var texts = [];
|
275
|
+
|
276
|
+
for (var i = 0; i < items.length; i++) {
|
277
|
+
var text = self.options.itemText(items[i]);
|
278
|
+
map[text] = items[i];
|
279
|
+
texts.push(text);
|
280
|
+
}
|
281
|
+
process(texts);
|
282
|
+
}
|
283
|
+
|
284
|
+
this.map = {};
|
285
|
+
var map = this.map,
|
286
|
+
data = typeahead.source(query);
|
287
|
+
|
288
|
+
if ($.isFunction(data.success)) {
|
289
|
+
// support for Angular callbacks
|
290
|
+
data.success(processItems);
|
291
|
+
} else if ($.isFunction(data.then)) {
|
292
|
+
// support for Angular promises
|
293
|
+
data.then(processItems);
|
294
|
+
} else {
|
295
|
+
// support for functions and jquery promises
|
296
|
+
$.when(data)
|
297
|
+
.then(processItems);
|
298
|
+
}
|
299
|
+
},
|
300
|
+
updater: function (text) {
|
301
|
+
self.add(this.map[text]);
|
302
|
+
},
|
303
|
+
matcher: function (text) {
|
304
|
+
return (text.toLowerCase().indexOf(this.query.trim().toLowerCase()) !== -1);
|
305
|
+
},
|
306
|
+
sorter: function (texts) {
|
307
|
+
return texts.sort();
|
308
|
+
},
|
309
|
+
highlighter: function (text) {
|
310
|
+
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
311
|
+
return text.replace( regex, "<strong>$1</strong>" );
|
312
|
+
}
|
313
|
+
}));
|
314
|
+
}
|
315
|
+
|
316
|
+
// typeahead.js
|
317
|
+
if (self.options.typeaheadjs) {
|
318
|
+
var typeaheadjs = self.options.typeaheadjs || {};
|
319
|
+
|
320
|
+
self.$input.typeahead(null, typeaheadjs).on('typeahead:selected', $.proxy(function (obj, datum) {
|
321
|
+
if (typeaheadjs.valueKey)
|
322
|
+
self.add(datum[typeaheadjs.valueKey]);
|
323
|
+
else
|
324
|
+
self.add(datum);
|
325
|
+
self.$input.typeahead('val', '');
|
326
|
+
}, self));
|
327
|
+
}
|
328
|
+
|
329
|
+
self.$container.on('click', $.proxy(function(event) {
|
330
|
+
if (! self.$element.attr('disabled')) {
|
331
|
+
self.$input.removeAttr('disabled');
|
332
|
+
}
|
333
|
+
self.$input.focus();
|
334
|
+
}, self));
|
335
|
+
|
336
|
+
if (self.options.addOnBlur && self.options.freeInput) {
|
337
|
+
self.$input.on('focusout', $.proxy(function(event) {
|
338
|
+
// HACK: only process on focusout when no typeahead opened, to
|
339
|
+
// avoid adding the typeahead text as tag
|
340
|
+
if ($('.typeahead, .twitter-typeahead', self.$container).length === 0) {
|
341
|
+
self.add(self.$input.val());
|
342
|
+
self.$input.val('');
|
343
|
+
}
|
344
|
+
}, self));
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
self.$container.on('keydown', 'input', $.proxy(function(event) {
|
349
|
+
var $input = $(event.target),
|
350
|
+
$inputWrapper = self.findInputWrapper();
|
351
|
+
|
352
|
+
if (self.$element.attr('disabled')) {
|
353
|
+
self.$input.attr('disabled', 'disabled');
|
354
|
+
return;
|
355
|
+
}
|
356
|
+
|
357
|
+
switch (event.which) {
|
358
|
+
// BACKSPACE
|
359
|
+
case 8:
|
360
|
+
if (doGetCaretPosition($input[0]) === 0) {
|
361
|
+
var prev = $inputWrapper.prev();
|
362
|
+
if (prev) {
|
363
|
+
self.remove(prev.data('item'));
|
364
|
+
}
|
365
|
+
}
|
366
|
+
break;
|
367
|
+
|
368
|
+
// DELETE
|
369
|
+
case 46:
|
370
|
+
if (doGetCaretPosition($input[0]) === 0) {
|
371
|
+
var next = $inputWrapper.next();
|
372
|
+
if (next) {
|
373
|
+
self.remove(next.data('item'));
|
374
|
+
}
|
375
|
+
}
|
376
|
+
break;
|
377
|
+
|
378
|
+
// LEFT ARROW
|
379
|
+
case 37:
|
380
|
+
// Try to move the input before the previous tag
|
381
|
+
var $prevTag = $inputWrapper.prev();
|
382
|
+
if ($input.val().length === 0 && $prevTag[0]) {
|
383
|
+
$prevTag.before($inputWrapper);
|
384
|
+
$input.focus();
|
385
|
+
}
|
386
|
+
break;
|
387
|
+
// RIGHT ARROW
|
388
|
+
case 39:
|
389
|
+
// Try to move the input after the next tag
|
390
|
+
var $nextTag = $inputWrapper.next();
|
391
|
+
if ($input.val().length === 0 && $nextTag[0]) {
|
392
|
+
$nextTag.after($inputWrapper);
|
393
|
+
$input.focus();
|
394
|
+
}
|
395
|
+
break;
|
396
|
+
default:
|
397
|
+
// ignore
|
398
|
+
}
|
399
|
+
|
400
|
+
// Reset internal input's size
|
401
|
+
var textLength = $input.val().length,
|
402
|
+
wordSpace = Math.ceil(textLength / 5),
|
403
|
+
size = textLength + wordSpace + 1;
|
404
|
+
$input.attr('size', Math.max(this.inputSize, $input.val().length));
|
405
|
+
}, self));
|
406
|
+
|
407
|
+
self.$container.on('keypress', 'input', $.proxy(function(event) {
|
408
|
+
var $input = $(event.target);
|
409
|
+
|
410
|
+
if (self.$element.attr('disabled')) {
|
411
|
+
self.$input.attr('disabled', 'disabled');
|
412
|
+
return;
|
413
|
+
}
|
414
|
+
|
415
|
+
var text = $input.val(),
|
416
|
+
maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;
|
417
|
+
if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached)) {
|
418
|
+
self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
|
419
|
+
$input.val('');
|
420
|
+
event.preventDefault();
|
421
|
+
}
|
422
|
+
|
423
|
+
// Reset internal input's size
|
424
|
+
var textLength = $input.val().length,
|
425
|
+
wordSpace = Math.ceil(textLength / 5),
|
426
|
+
size = textLength + wordSpace + 1;
|
427
|
+
$input.attr('size', Math.max(this.inputSize, $input.val().length));
|
428
|
+
}, self));
|
429
|
+
|
430
|
+
// Remove icon clicked
|
431
|
+
self.$container.on('click', '[data-role=remove]', $.proxy(function(event) {
|
432
|
+
if (self.$element.attr('disabled')) {
|
433
|
+
return;
|
434
|
+
}
|
435
|
+
self.remove($(event.target).closest('.tag').data('item'));
|
436
|
+
}, self));
|
437
|
+
|
438
|
+
// Only add existing value as tags when using strings as tags
|
439
|
+
if (self.options.itemValue === defaultOptions.itemValue) {
|
440
|
+
if (self.$element[0].tagName === 'INPUT') {
|
441
|
+
self.add(self.$element.val());
|
442
|
+
} else {
|
443
|
+
$('option', self.$element).each(function() {
|
444
|
+
self.add($(this).attr('value'), true);
|
445
|
+
});
|
446
|
+
}
|
447
|
+
}
|
448
|
+
},
|
449
|
+
|
450
|
+
/**
|
451
|
+
* Removes all tagsinput behaviour and unregsiter all event handlers
|
452
|
+
*/
|
453
|
+
destroy: function() {
|
454
|
+
var self = this;
|
455
|
+
|
456
|
+
// Unbind events
|
457
|
+
self.$container.off('keypress', 'input');
|
458
|
+
self.$container.off('click', '[role=remove]');
|
459
|
+
|
460
|
+
self.$container.remove();
|
461
|
+
self.$element.removeData('tagsinput');
|
462
|
+
self.$element.show();
|
463
|
+
},
|
464
|
+
|
465
|
+
/**
|
466
|
+
* Sets focus on the tagsinput
|
467
|
+
*/
|
468
|
+
focus: function() {
|
469
|
+
this.$input.focus();
|
470
|
+
},
|
471
|
+
|
472
|
+
/**
|
473
|
+
* Returns the internal input element
|
474
|
+
*/
|
475
|
+
input: function() {
|
476
|
+
return this.$input;
|
477
|
+
},
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Returns the element which is wrapped around the internal input. This
|
481
|
+
* is normally the $container, but typeahead.js moves the $input element.
|
482
|
+
*/
|
483
|
+
findInputWrapper: function() {
|
484
|
+
var elt = this.$input[0],
|
485
|
+
container = this.$container[0];
|
486
|
+
while(elt && elt.parentNode !== container)
|
487
|
+
elt = elt.parentNode;
|
488
|
+
|
489
|
+
return $(elt);
|
490
|
+
}
|
491
|
+
};
|
492
|
+
|
493
|
+
/**
|
494
|
+
* Register JQuery plugin
|
495
|
+
*/
|
496
|
+
$.fn.tagsinput = function(arg1, arg2) {
|
497
|
+
var results = [];
|
498
|
+
|
499
|
+
this.each(function() {
|
500
|
+
var tagsinput = $(this).data('tagsinput');
|
501
|
+
// Initialize a new tags input
|
502
|
+
if (!tagsinput) {
|
503
|
+
tagsinput = new TagsInput(this, arg1);
|
504
|
+
$(this).data('tagsinput', tagsinput);
|
505
|
+
results.push(tagsinput);
|
506
|
+
|
507
|
+
if (this.tagName === 'SELECT') {
|
508
|
+
$('option', $(this)).attr('selected', 'selected');
|
509
|
+
}
|
510
|
+
|
511
|
+
// Init tags from $(this).val()
|
512
|
+
$(this).val($(this).val());
|
513
|
+
} else if (!arg1 && !arg2) {
|
514
|
+
// tagsinput already exists
|
515
|
+
// no function, trying to init
|
516
|
+
results.push(tagsinput);
|
517
|
+
} else if(tagsinput[arg1] !== undefined) {
|
518
|
+
// Invoke function on existing tags input
|
519
|
+
var retVal = tagsinput[arg1](arg2);
|
520
|
+
if (retVal !== undefined)
|
521
|
+
results.push(retVal);
|
522
|
+
}
|
523
|
+
});
|
524
|
+
|
525
|
+
if ( typeof arg1 == 'string') {
|
526
|
+
// Return the results from the invoked function calls
|
527
|
+
return results.length > 1 ? results : results[0];
|
528
|
+
} else {
|
529
|
+
return results;
|
530
|
+
}
|
531
|
+
};
|
532
|
+
|
533
|
+
$.fn.tagsinput.Constructor = TagsInput;
|
534
|
+
|
535
|
+
/**
|
536
|
+
* Most options support both a string or number as well as a function as
|
537
|
+
* option value. This function makes sure that the option with the given
|
538
|
+
* key in the given options is wrapped in a function
|
539
|
+
*/
|
540
|
+
function makeOptionItemFunction(options, key) {
|
541
|
+
if (typeof options[key] !== 'function') {
|
542
|
+
var propertyName = options[key];
|
543
|
+
options[key] = function(item) { return item[propertyName]; };
|
544
|
+
}
|
545
|
+
}
|
546
|
+
function makeOptionFunction(options, key) {
|
547
|
+
if (typeof options[key] !== 'function') {
|
548
|
+
var value = options[key];
|
549
|
+
options[key] = function() { return value; };
|
550
|
+
}
|
551
|
+
}
|
552
|
+
/**
|
553
|
+
* HtmlEncodes the given value
|
554
|
+
*/
|
555
|
+
var htmlEncodeContainer = $('<div />');
|
556
|
+
function htmlEncode(value) {
|
557
|
+
if (value) {
|
558
|
+
return htmlEncodeContainer.text(value).html();
|
559
|
+
} else {
|
560
|
+
return '';
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
/**
|
565
|
+
* Returns the position of the caret in the given input field
|
566
|
+
* http://flightschool.acylt.com/devnotes/caret-position-woes/
|
567
|
+
*/
|
568
|
+
function doGetCaretPosition(oField) {
|
569
|
+
var iCaretPos = 0;
|
570
|
+
if (document.selection) {
|
571
|
+
oField.focus ();
|
572
|
+
var oSel = document.selection.createRange();
|
573
|
+
oSel.moveStart ('character', -oField.value.length);
|
574
|
+
iCaretPos = oSel.text.length;
|
575
|
+
} else if (oField.selectionStart || oField.selectionStart == '0') {
|
576
|
+
iCaretPos = oField.selectionStart;
|
577
|
+
}
|
578
|
+
return (iCaretPos);
|
579
|
+
}
|
580
|
+
|
581
|
+
/**
|
582
|
+
* Returns boolean indicates whether user has pressed an expected key combination.
|
583
|
+
* @param object keyPressEvent: JavaScript event object, refer
|
584
|
+
* http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
585
|
+
* @param object lookupList: expected key combinations, as in:
|
586
|
+
* [13, {which: 188, shiftKey: true}]
|
587
|
+
*/
|
588
|
+
function keyCombinationInList(keyPressEvent, lookupList) {
|
589
|
+
var found = false;
|
590
|
+
$.each(lookupList, function (index, keyCombination) {
|
591
|
+
if (typeof (keyCombination) === 'number' && keyPressEvent.which === keyCombination) {
|
592
|
+
found = true;
|
593
|
+
return false;
|
594
|
+
}
|
595
|
+
|
596
|
+
if (keyPressEvent.which === keyCombination.which) {
|
597
|
+
var alt = !keyCombination.hasOwnProperty('altKey') || keyPressEvent.altKey === keyCombination.altKey,
|
598
|
+
shift = !keyCombination.hasOwnProperty('shiftKey') || keyPressEvent.shiftKey === keyCombination.shiftKey,
|
599
|
+
ctrl = !keyCombination.hasOwnProperty('ctrlKey') || keyPressEvent.ctrlKey === keyCombination.ctrlKey;
|
600
|
+
if (alt && shift && ctrl) {
|
601
|
+
found = true;
|
602
|
+
return false;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
});
|
606
|
+
|
607
|
+
return found;
|
608
|
+
}
|
609
|
+
|
610
|
+
/**
|
611
|
+
* Initialize tagsinput behaviour on inputs and selects which have
|
612
|
+
* data-role=tagsinput
|
613
|
+
*/
|
614
|
+
$(function() {
|
615
|
+
$("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput();
|
616
|
+
});
|
617
|
+
})(window.jQuery);
|