sunrise-cms 1.0.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +25 -0
- data/.rubocop.yml +87 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.rdoc +11 -3
- data/Gemfile +49 -0
- data/README.md +6 -0
- data/Rakefile +4 -2
- data/app/assets/images/sunrise/icons/export.svg +4 -0
- data/app/assets/images/sunrise/icons/import.svg +5 -0
- data/app/assets/javascripts/sunrise/application.js +2 -3
- data/app/assets/javascripts/sunrise/jquery-ui-timepicker-addon.js +2143 -831
- data/app/assets/javascripts/sunrise/jquery.dialog.js.coffee +113 -40
- data/app/assets/javascripts/sunrise/jquery.editable.js.coffee +21 -21
- data/app/assets/javascripts/sunrise/manage.js.coffee +29 -28
- data/app/assets/stylesheets/sunrise/application.css +4 -4
- data/app/assets/stylesheets/sunrise/customize.css +7 -16
- data/app/assets/stylesheets/sunrise/jquery-ui-timepicker-addon.css +11 -0
- data/app/assets/stylesheets/sunrise/main.css +883 -606
- data/app/controllers/sunrise/activities_controller.rb +7 -5
- data/app/controllers/sunrise/application_controller.rb +17 -17
- data/app/controllers/sunrise/dashboard_controller.rb +6 -5
- data/app/controllers/sunrise/manager_controller.rb +145 -104
- data/app/controllers/sunrise/settings_controller.rb +5 -3
- data/app/helpers/sunrise/activities_helper.rb +8 -7
- data/app/helpers/sunrise/application_helper.rb +11 -9
- data/app/helpers/sunrise/dashboard_helper.rb +3 -1
- data/app/helpers/sunrise/manager_helper.rb +28 -27
- data/app/helpers/sunrise/structure_helper.rb +11 -8
- data/app/views/layouts/sunrise/application.html.erb +7 -6
- data/app/views/sunrise/manager/buttons/_export.html.erb +9 -2
- data/app/views/sunrise/manager/buttons/_import.html.erb +25 -0
- data/app/views/sunrise/manager/buttons/_sort.html.erb +3 -3
- data/app/views/sunrise/manager/tree/index.html.erb +1 -1
- data/config/locales/defaults/datetime.rb +7 -7
- data/config/locales/defaults/pluralize.rb +5 -3
- data/config/routes.rb +23 -20
- data/db/migrate/20111216144515_create_assets.rb +9 -7
- data/db/migrate/20111216144915_create_structures.rb +14 -12
- data/db/migrate/20111216145015_create_users.rb +20 -18
- data/db/migrate/20120611095315_create_settings.rb +7 -5
- data/lib/generators/sunrise/install_generator.rb +51 -49
- data/lib/generators/sunrise/templates/config/active_record/sunrise.rb +12 -10
- data/lib/generators/sunrise/templates/config/mongoid/sunrise.rb +14 -12
- data/lib/generators/sunrise/templates/config/seeds.rb +7 -7
- data/lib/generators/sunrise/templates/models/active_record/ability.rb +4 -3
- data/lib/generators/sunrise/templates/models/active_record/asset.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/attachment_file.rb +4 -2
- data/lib/generators/sunrise/templates/models/active_record/avatar.rb +7 -5
- data/lib/generators/sunrise/templates/models/active_record/picture.rb +6 -4
- data/lib/generators/sunrise/templates/models/active_record/position_type.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/role_type.rb +6 -4
- data/lib/generators/sunrise/templates/models/active_record/settings.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/structure.rb +3 -1
- data/lib/generators/sunrise/templates/models/active_record/structure_type.rb +7 -5
- data/lib/generators/sunrise/templates/models/active_record/user.rb +5 -3
- data/lib/generators/sunrise/templates/models/mongoid/ability.rb +4 -3
- data/lib/generators/sunrise/templates/models/mongoid/asset.rb +18 -16
- data/lib/generators/sunrise/templates/models/mongoid/attachment_file.rb +4 -2
- data/lib/generators/sunrise/templates/models/mongoid/avatar.rb +7 -5
- data/lib/generators/sunrise/templates/models/mongoid/picture.rb +4 -2
- data/lib/generators/sunrise/templates/models/mongoid/position_type.rb +5 -3
- data/lib/generators/sunrise/templates/models/mongoid/role_type.rb +6 -4
- data/lib/generators/sunrise/templates/models/mongoid/settings.rb +9 -7
- data/lib/generators/sunrise/templates/models/mongoid/structure.rb +12 -10
- data/lib/generators/sunrise/templates/models/mongoid/structure_type.rb +7 -5
- data/lib/generators/sunrise/templates/models/mongoid/user.rb +37 -35
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_navigation.rb +9 -7
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_page.rb +5 -3
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +10 -9
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb +15 -13
- data/lib/generators/sunrise/templates/spec/controllers/pages_controller_spec.rb +12 -10
- data/lib/generators/sunrise/templates/spec/controllers/welcome_controller_spec.rb +8 -6
- data/lib/generators/sunrise/templates/spec/factories/structure_factory.rb +6 -5
- data/lib/generators/sunrise/templates/spec/factories/user_factory.rb +19 -18
- data/lib/generators/sunrise/templates/spec/spec_helper.rb +9 -7
- data/lib/generators/sunrise/templates/spec/support/helpers/controller_macros.rb +10 -9
- data/lib/generators/sunrise/templates/uploaders/attachment_file_uploader.rb +4 -2
- data/lib/generators/sunrise/templates/uploaders/avatar_uploader.rb +10 -7
- data/lib/generators/sunrise/templates/uploaders/picture_uploader.rb +9 -6
- data/lib/sunrise-cms.rb +2 -0
- data/lib/sunrise.rb +20 -13
- data/lib/sunrise/abstract_model.rb +103 -106
- data/lib/sunrise/carrierwave/base_uploader.rb +43 -46
- data/lib/sunrise/carrierwave/file_size_validator.rb +16 -11
- data/lib/sunrise/carrierwave/glue.rb +9 -9
- data/lib/sunrise/config.rb +14 -12
- data/lib/sunrise/config/association.rb +4 -3
- data/lib/sunrise/config/base.rb +15 -13
- data/lib/sunrise/config/export.rb +5 -3
- data/lib/sunrise/config/field.rb +26 -24
- data/lib/sunrise/config/form.rb +2 -0
- data/lib/sunrise/config/group.rb +9 -6
- data/lib/sunrise/config/has_fields.rb +6 -5
- data/lib/sunrise/config/has_groups.rb +4 -2
- data/lib/sunrise/config/index.rb +9 -7
- data/lib/sunrise/config/model.rb +20 -14
- data/lib/sunrise/config/navigation.rb +21 -19
- data/lib/sunrise/config/navigation_item.rb +7 -5
- data/lib/sunrise/config/nested_field.rb +13 -12
- data/lib/sunrise/config/page_presenter.rb +5 -2
- data/lib/sunrise/config/show.rb +2 -0
- data/lib/sunrise/core_ext.rb +2 -0
- data/lib/sunrise/core_ext/i18n.rb +9 -9
- data/lib/sunrise/core_ext/string.rb +4 -2
- data/lib/sunrise/engine.rb +22 -16
- data/lib/sunrise/hooks/adapters/active_record.rb +3 -1
- data/lib/sunrise/hooks/adapters/mongoid.rb +4 -2
- data/lib/sunrise/models/ability.rb +12 -10
- data/lib/sunrise/models/asset.rb +43 -43
- data/lib/sunrise/models/position_type.rb +7 -6
- data/lib/sunrise/models/role_type.rb +8 -7
- data/lib/sunrise/models/structure.rb +27 -28
- data/lib/sunrise/models/structure_type.rb +7 -6
- data/lib/sunrise/models/user.rb +39 -37
- data/lib/sunrise/utils.rb +16 -17
- data/lib/sunrise/utils/csv_document.rb +23 -23
- data/lib/sunrise/utils/eval_helpers.rb +41 -39
- data/lib/sunrise/utils/search_wrapper.rb +8 -7
- data/lib/sunrise/utils/transliteration.rb +42 -41
- data/lib/sunrise/version.rb +3 -1
- data/lib/sunrise/views/date_time_input.rb +19 -17
- data/lib/sunrise/views/form_builder.rb +15 -13
- data/lib/sunrise/views/helper.rb +32 -32
- data/lib/sunrise/views/search_wrapper.rb +5 -3
- data/lib/tasks/assets.rake +11 -9
- data/sunrise-cms.gemspec +50 -0
- metadata +85 -596
- data/spec/controllers/sunrise/activities_controller_spec.rb +0 -33
- data/spec/controllers/sunrise/manager_controller_spec.rb +0 -64
- data/spec/controllers/sunrise/settings_controller_spec.rb +0 -45
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -9
- data/spec/dummy/app/assets/javascripts/sunrise/plugins.js +0 -0
- data/spec/dummy/app/assets/javascripts/welcome.js +0 -2
- data/spec/dummy/app/assets/stylesheets/application.css +0 -7
- data/spec/dummy/app/assets/stylesheets/sunrise/plugins.css +0 -0
- data/spec/dummy/app/assets/stylesheets/welcome.css +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/welcome_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -12
- data/spec/dummy/app/helpers/welcome_helper.rb +0 -2
- data/spec/dummy/app/models/active_record/post.rb +0 -18
- data/spec/dummy/app/models/mongoid/post.rb +0 -27
- data/spec/dummy/app/sunrise/sunrise_post.rb +0 -34
- data/spec/dummy/app/views/layouts/application.html.erb +0 -20
- data/spec/dummy/app/views/public_activity/post/_create.html.erb +0 -5
- data/spec/dummy/app/views/public_activity/post/_destroy.html.erb +0 -5
- data/spec/dummy/app/views/public_activity/post/_update.html.erb +0 -5
- data/spec/dummy/app/views/sunrise/manager/users/thumbs/_record.html.erb +0 -34
- data/spec/dummy/app/views/welcome/index.html.erb +0 -2
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -55
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -42
- data/spec/dummy/config/database.yml.sample +0 -34
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -33
- data/spec/dummy/config/environments/production.rb +0 -66
- data/spec/dummy/config/environments/test.rb +0 -41
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/devise.rb +0 -216
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/sunrise.rb +0 -51
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/mongoid.yml +0 -80
- data/spec/dummy/config/routes.rb +0 -10
- data/spec/dummy/db/migrate/20111227111941_install_acts_as_audited.rb +0 -28
- data/spec/dummy/db/migrate/20111227143901_create_page_parts.rb +0 -20
- data/spec/dummy/db/migrate/20111228152051_create_posts.rb +0 -14
- data/spec/dummy/db/migrate/20120105114018_create_meta_tags.rb +0 -21
- data/spec/dummy/db/migrate/20130214090723_create_activities.rb +0 -23
- data/spec/dummy/db/schema.rb +0 -90
- data/spec/dummy/log/test.log +0 -235
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/tmp/cache/696/1F0/settings%3Ato_key +0 -1
- data/spec/dummy/tmp/cache/87C/5D0/settings%3Apersisted%3F +0 -1
- data/spec/dummy/tmp/cache/91C/830/settings%3Asome_setting +0 -1
- data/spec/dummy/tmp/cache/94E/D10/settings%3Asome_setting2 +0 -1
- data/spec/dummy/tmp/cache/assets/test/sass/f4a02ee710d6db0936c29533f2166c1526a55a9e/select2.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/03bae0b322a9c8706915fdb4f8d50961 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0a4412d6feb107cf35e452cc82a01134 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0c538631f0f094ca39bdb1448da8a4bc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0c94e795dfbbbf3599fdf312aeb577b9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0e7270936d642e566d747ab335c44ec2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f894abd40c0b6114a9dff3a0599af7e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0fdc292bf2b2ddb2d0bf079950c8e770 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/10bb80e2753b3d1716765b02ad9a2db3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1349c61c2b491567c1632fcae44110a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13e20c0d57b7b851a7f025f5606f833f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/146ce2f3522fd98d4a8a1501f16c7092 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/172c139e25cc08516d5a8c72c777dd4d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/18b64b11b8b00cc21a396da25a5ff156 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/197d8d604ec08a638b656e053944b734 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1b73ae25962d8ff98f9f008b73c64bf4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1bdb903463fe67323dbadb0f78337c70 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1ea532f332f1ff667097010cda704c99 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/20215d59350863282208d478ea94cf08 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/212fc15df4fd708ebdef5bd3be2191c1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/256dcb01e7f35659d770584fd71a85d2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/27ec6453d976c5e273e6f2c25830492c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3006732de695a5dfe249dcbf6852b543 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3008328e1cba59ad00ac79ac20275f17 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/31ffcb9d2aba762160a2f4341e5cfd50 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/32ae3cda2e7c692fc9711ab76fcf1c62 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/35948a84ebda6147e5e5b67191ae37d8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/37766ae8287a873cb196a187f3253e66 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/37b44bd55598f75d532d9edbe8c98336 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/383908afbabb6096b774ab7c1856a102 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/38611f05ed0bf72a4755c136796ff5d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3b99bacd5915b4ff7fb2664bc2aa30d0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/443ca9dc693ccf91d6e1cecaffe0fa9a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/45c759123f4f6b42cdcff44b446655a5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4ca01587005a9b895bca383881bec87d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4cffdba2a7aac80c1765e060b152b382 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4d38783b41d7c000fed2419b5173f87a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/51fe2df168cee49df9d4136f59c87872 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/564db16c8d964c3505bfca526e3fccf2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/56e5bd2f3c94d7a9d0da7c4e05c7ad78 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5807e61754ed8b16702f6ad7ba34d439 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/593d990734170367188181754939b317 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5a44970074ecbfeae2cc9798ed7da7aa +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5e7901fbee32b66040fd6376a8c981d8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5ecbfe03cab317594d2bc1c6866d26db +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/609ce9936a503352d73f954f68be7f81 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/65224b6e799d399f4e6cf4bf98155de2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a1e72555b75237fffccb5de8937b4d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a8187f5c6f2e115d1a1c21ca2ec81a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6c9a2f7ab6f8d1f8e3e4cf1d7d6cc68a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6f4f668f70fb14b2132289fed6718f0e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/727e0f830601f307d4c8b9a76e464c1a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/749bd767d6654c80265f5ca0959dc8e1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7a92952d5fff10f09ce91b852d6a744f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7ad564910e515e335bb008989a97efb7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7b55037b89f2debe558b43fe7542e409 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7bb04b7318793726b5414daaa4f049d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7c5f37d1af8a5557b67d6ffb8afcc2b5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7f5092f53db371ea56be62557677a506 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7f9ced6d264f71631c80df15194abf4d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/80870efa2a2ddb1de325c224daff5712 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/831e225c0e792be993a1d1dc58f20e54 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/83f98047f864c578534b34068cb015e0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/84361af51e20dcfad7fae0f32f284ab7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/894aeaae9cc8483fa9f7a5146ff6ff6f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/89567cbb5e7770a065e88360dcd02833 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/89a5be65dc0d00fa22be4375c029d69c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8bf0319a2b612416dfde2d3b939dbf99 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8cfeb6443a5f7398e67010a202ee2de2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8e3769f6378278754105f0924e6dd1ff +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/96c321f84bd796096692021bc4a87eed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/97e875e2282fba5939cf71198faab1f0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9911ee0fc41f519a1c4faa7912547cce +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ac84ed11232b2f7fc9f80c18844abc8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ba0cab624f25b68f79447e62fbc6112 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9e9edfa954375fd0cc6498f70b883e8e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3863764f2fbc185e0d2ea584c7e2174 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a4c4a00b0d2b8334de3ee3169064adad +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a744e8f2a7ce02e7af9784f40c711ed5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a78a33e8cea959257da93b3e67786300 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a9956bd25bbe4c811a1a758f71aec748 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa4822def20c419f0e50e2a38e73a1df +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aaa24da6bd0fcf694077519e189b7392 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b0493d9dbe3afb3268b7ffce2b87bf78 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b2c398b7a51a65be12ba944bdea13415 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b81381e4a978aa69cc2ab1f892a40e97 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b82707486d5133da748e4382c62de995 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bb83cb3c179681d65c77a41e98f1c70f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bbc50f2009705d8fd7b91330bc24dcb8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bcb7548b203cc2c5a484ef7649911c2d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/becade26fead85d486f136be49b45e23 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bfc0fef30976427a03ddccb1ce78d6e7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c0dd93a468e038b3653ed4d28874e0cb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c1d2340cbfe5e80d388f95e7a08698d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c25afdb537c84a18bd62fc782164d298 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c3dc3ada4560805584739bfe7c2b24d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c4dc50a79ec929d33d9e2835d1926fd9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c5f990ee58d3727faeb4cfd3f5667e8a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c622effcf1aa225bf2920d2b63ca525c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d09dc20f2dc66183aa23ce1fd8fc9f2c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d60bdefb444e91b75e4cc2f3fc49228b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d7c40ebee2fb9471bab352337570ba40 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d9bc94e1e0cc114986f8760bc4eb42ce +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/da4488b32bd6fb75c655a077956c9034 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/daeb51b1ca3de2a1f2146dea431249d3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd0e13880601ea049b7c6d8c76ea535f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd15d7b9860a8a187c4a6c167dc56547 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd8ed9b0203321fd815ba48a5867620e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1e036b04a3a20b2fb589420ad03b926 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e4f46080338c0c52e3933999a7f8106d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e59a3c2ff941e0fdc7987168580bf4cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e6cfe2e09e34ec2b24494a74eed5243a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e8e088454cc6f38324bd168e299cf08f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e949207f9e9578cfd48ab90bb82ea384 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ee5a41236d43159aac87f9224a0bcfb8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ef5f76363cd723089ce62b8c207415a4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f2de4855fd4840abb2f6e80afee5f4ed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f5165c4d7cee0e7cb99bc069fd4c09b9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f660938bc4a80358883ba6c576e1dd13 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7379cc2d3a2fc4b87d64c68d2d8684f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f81b83e98592ff24dd8518985baa48cd +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f94b13174ed1cc7f087a66c0094ef4cf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f975cba8c490022ddfc45bab0b512879 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/face6eb5e3ee8802296bdc38e5704d72 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fc9155176668e1a56a5ca3843febe3c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fd7e46e0b42a510b40f17d1f1bacf80e +0 -0
- data/spec/factories/asset_factory.rb +0 -21
- data/spec/factories/files/rails.png +0 -0
- data/spec/factories/files/silicon_valley.jpg +0 -0
- data/spec/factories/page_factory.rb +0 -10
- data/spec/factories/post_factory.rb +0 -9
- data/spec/factories/structure_factory.rb +0 -22
- data/spec/factories/user_factory.rb +0 -49
- data/spec/generators/install_generator_spec.rb +0 -55
- data/spec/models/avatar_spec.rb +0 -138
- data/spec/models/i18n_backend.rb +0 -30
- data/spec/models/structure_spec.rb +0 -120
- data/spec/models/sunrise/abstract_model_spec.rb +0 -88
- data/spec/models/sunrise/carrierwave/picture_uploader_spec.rb +0 -49
- data/spec/models/sunrise/search_wrapper_spec.rb +0 -21
- data/spec/models/user_spec.rb +0 -63
- data/spec/orm/active_record.rb +0 -5
- data/spec/orm/kaminari/active_record.rb +0 -18
- data/spec/orm/kaminari/mongoid.rb +0 -20
- data/spec/orm/mongoid.rb +0 -15
- data/spec/requests/activities_spec.rb +0 -41
- data/spec/requests/dashboard_spec.rb +0 -35
- data/spec/requests/manager/default/create_spec.rb +0 -43
- data/spec/requests/manager/default/destroy_spec.rb +0 -36
- data/spec/requests/manager/default/edit_spec.rb +0 -72
- data/spec/requests/manager/default/export_spec.rb +0 -121
- data/spec/requests/manager/default/index_spec.rb +0 -67
- data/spec/requests/manager/default/new_spec.rb +0 -59
- data/spec/requests/manager/default/show_spec.rb +0 -41
- data/spec/requests/manager/default/update_spec.rb +0 -73
- data/spec/requests/manager/many/create_spec.rb +0 -52
- data/spec/requests/manager/many/destroy_spec.rb +0 -41
- data/spec/requests/manager/many/edit_spec.rb +0 -43
- data/spec/requests/manager/many/index_spec.rb +0 -54
- data/spec/requests/manager/many/new_spec.rb +0 -40
- data/spec/requests/manager/many/update_spec.rb +0 -55
- data/spec/spec_helper.rb +0 -90
- data/spec/sunrise_spec.rb +0 -29
- data/spec/support/helpers/controller_helper.rb +0 -27
- data/spec/support/helpers/controller_macros.rb +0 -40
- data/spec/support/hooks/structure.rb +0 -5
@@ -7,130 +7,203 @@ $.fn.extend({
|
|
7
7
|
)
|
8
8
|
})
|
9
9
|
|
10
|
+
$.fn.extend({
|
11
|
+
import_dialog: (options) ->
|
12
|
+
$(this).each((input_field) ->
|
13
|
+
new ImportDialog(this, options) unless ($ this).hasClass "dialog-init"
|
14
|
+
)
|
15
|
+
})
|
16
|
+
|
10
17
|
class Dialog
|
11
|
-
constructor: (@form_field, options = {}) ->
|
18
|
+
constructor: (@form_field, options = {}) ->
|
12
19
|
defaults =
|
13
20
|
shadow_field: "#dark-shadow"
|
14
21
|
dialog_class: "sunrise-dialog"
|
15
|
-
|
22
|
+
|
16
23
|
@options = $.extend defaults, options
|
17
|
-
|
24
|
+
|
18
25
|
this.setup()
|
19
26
|
this.register_observers()
|
20
|
-
|
27
|
+
|
21
28
|
setup: ->
|
22
29
|
dom_id = this.generate_random_id()
|
23
30
|
@element = $ @form_field
|
24
|
-
|
31
|
+
|
25
32
|
@shadow = $ @options.shadow_field
|
26
33
|
@container = $ '<div/>', { id: dom_id, class: @options.dialog_class }
|
27
|
-
@container.hide()
|
34
|
+
@container.hide()
|
28
35
|
@shadow.after @container
|
29
|
-
|
36
|
+
|
30
37
|
@element.addClass "dialog-init"
|
31
|
-
|
38
|
+
|
32
39
|
register_observers: ->
|
33
40
|
@shadow.bind 'click', (evt) => this.hide()
|
34
|
-
@element.bind 'click', (evt) =>
|
41
|
+
@element.bind 'click', (evt) =>
|
35
42
|
this.show()
|
36
43
|
false
|
37
|
-
|
44
|
+
|
38
45
|
show: ->
|
39
46
|
wnd = $(window)
|
40
47
|
body = $('body')
|
41
|
-
|
48
|
+
|
42
49
|
height = if body.innerHeight() > wnd.innerHeight() then body.innerHeight() else wnd.innerHeight()
|
43
50
|
@shadow.css 'height', height + 'px'
|
44
51
|
@container.css 'left', ($(window).innerWidth() - @container.innerWidth()) / 2 + 'px'
|
45
|
-
|
52
|
+
|
46
53
|
@shadow.show()
|
47
54
|
@container.show()
|
48
|
-
|
55
|
+
|
49
56
|
hide: ->
|
50
57
|
@shadow.hide()
|
51
58
|
@container.hide()
|
52
|
-
|
59
|
+
|
53
60
|
generate_random_id: ->
|
54
61
|
string = "dlg_" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char()
|
55
62
|
while $("#" + string).length > 0
|
56
63
|
string += this.generate_random_char()
|
57
64
|
string
|
58
|
-
|
65
|
+
|
59
66
|
generate_random_char: ->
|
60
67
|
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"
|
61
68
|
rand = Math.floor(Math.random() * chars.length)
|
62
69
|
newchar = chars.substring rand, rand+1
|
63
|
-
|
64
|
-
|
70
|
+
|
71
|
+
# SORT
|
65
72
|
class SortDialog extends Dialog
|
66
|
-
|
73
|
+
|
67
74
|
setup: ->
|
68
75
|
super
|
69
|
-
|
76
|
+
|
70
77
|
@container.addClass 'sort-wrapper'
|
71
|
-
|
78
|
+
|
72
79
|
title = $('<div/>', { class: 'sort-title' })
|
73
80
|
title.text(@element.attr 'title')
|
74
|
-
|
81
|
+
|
75
82
|
buttons_holder = $ '<div/>', { class: 'sort-buts-holder' }
|
76
83
|
@save_button = $ '<input/>', { type: 'submit', value: @element.data('save_title'), class: 'button', disabled: 'disabled'}
|
77
84
|
@cancel_button = $ '<input/>', { type: 'submit', value: @element.data('cancel_title'), class: 'button gray'}
|
78
|
-
|
85
|
+
|
79
86
|
buttons_holder.append(@save_button).append(@cancel_button)
|
80
87
|
title_holder = $ '<div/>', { class: 'sort-title-holder' }
|
81
88
|
title_holder.append(title).append(buttons_holder)
|
82
|
-
|
89
|
+
|
83
90
|
items_container = $ '<div/>', { class: 'sort-items-holder', id: 'sort_items' }
|
84
|
-
|
91
|
+
|
85
92
|
@container.append(title_holder).append(items_container)
|
86
|
-
|
93
|
+
|
87
94
|
register_observers: ->
|
88
95
|
super
|
89
|
-
|
96
|
+
|
90
97
|
@cancel_button.bind 'click', (evt) => this.hide()
|
91
98
|
@save_button.bind 'click', (evt) => this.save(evt)
|
92
|
-
|
99
|
+
|
93
100
|
show: ->
|
94
101
|
super
|
95
|
-
this.load_data()
|
96
|
-
|
102
|
+
this.load_data()
|
103
|
+
|
97
104
|
save: ->
|
98
105
|
items = {}
|
99
106
|
klass = this
|
100
|
-
|
107
|
+
|
101
108
|
$('.sort-item').each (index) ->
|
102
109
|
items['ids[' + $(this).data('record-id') + ']'] = index + 1
|
103
|
-
|
110
|
+
|
104
111
|
$.rails.ajax
|
105
112
|
url: @element.data 'url'
|
106
113
|
type: 'POST'
|
107
114
|
data: items
|
108
115
|
success: ->
|
109
116
|
klass.hide()
|
110
|
-
|
117
|
+
|
111
118
|
load_data: ->
|
112
119
|
klass = this
|
113
|
-
|
120
|
+
|
114
121
|
$.ajax
|
115
122
|
url: @element.attr 'href'
|
116
123
|
success: (data, status, xhr) ->
|
117
124
|
$('#sort_items').empty()
|
118
125
|
$("#sort-template" ).tmpl(data).appendTo('#sort_items')
|
119
126
|
# klass.refresh_counters()
|
120
|
-
|
127
|
+
|
121
128
|
$("#sort_items").sortable
|
122
129
|
cursor: 'crosshair'
|
123
130
|
opacity: 0.6
|
124
|
-
update: (event, ui) ->
|
131
|
+
update: (event, ui) ->
|
125
132
|
klass.update_sort_item(event, ui)
|
126
|
-
|
133
|
+
|
127
134
|
refresh_counters: ->
|
128
135
|
$('.sort-item .numb').each (index) ->
|
129
136
|
$(this).text index + 1
|
130
|
-
|
137
|
+
|
131
138
|
update_sort_item: (event, ui) ->
|
132
139
|
@save_button.attr 'disabled', false
|
133
140
|
this.refresh_counters()
|
134
|
-
|
135
|
-
|
136
|
-
|
141
|
+
|
142
|
+
# IMPORT
|
143
|
+
class ImportDialog extends Dialog
|
144
|
+
setup: ->
|
145
|
+
super
|
146
|
+
|
147
|
+
@container.addClass 'import-wrapper'
|
148
|
+
|
149
|
+
title = $('<div/>', { class: 'import-title' })
|
150
|
+
title.text(@element.data('title'))
|
151
|
+
|
152
|
+
@upload_input = $('<input />', { type: 'file', class: 'import-fileupload' })
|
153
|
+
@records_list = $('<ul/>')
|
154
|
+
|
155
|
+
@upload_input.fileupload
|
156
|
+
url: @element.data('url')
|
157
|
+
dataType: 'json'
|
158
|
+
autoUpload: true
|
159
|
+
uploadTemplateId: false
|
160
|
+
downloadTemplateId: false
|
161
|
+
done: (e, data) =>
|
162
|
+
$.each data.result.files, (findex, file) =>
|
163
|
+
$.each file.records, (rindex, record) =>
|
164
|
+
line = $('<li>')
|
165
|
+
|
166
|
+
if record?.html?
|
167
|
+
line.append(record.html)
|
168
|
+
else
|
169
|
+
if record.errors?.length > 0
|
170
|
+
rrr = $.extend({}, record)
|
171
|
+
delete(rrr.row)
|
172
|
+
delete(rrr.errors)
|
173
|
+
line.addClass('import-invalid-error')
|
174
|
+
line.append($("<b>ROW: #{record.row}</b>"))
|
175
|
+
line.append($('<br/>')).append(JSON.stringify(rrr)).append($('<br/>'))
|
176
|
+
line.append(record.errors.join('<br/>'))
|
177
|
+
else
|
178
|
+
line.append($("<b>ROW: #{record.row}</b>"))
|
179
|
+
line.append($('<br/>'))
|
180
|
+
line.append JSON.stringify(record)
|
181
|
+
|
182
|
+
@records_list.append(line)
|
183
|
+
|
184
|
+
@container.addClass('disabled')
|
185
|
+
$("#records").load "#{location.pathname} #records", =>
|
186
|
+
@container.removeClass('disabled')
|
187
|
+
|
188
|
+
buttons_holder = $ '<div/>', { class: 'import-buts-holder' }
|
189
|
+
@close_button = $ '<input/>', { type: 'reset', value: 'Close', class: 'button gray'}
|
190
|
+
|
191
|
+
buttons_holder.append(@save_button).append(@close_button)
|
192
|
+
title_holder = $ '<div/>', { class: 'import-title-holder' }
|
193
|
+
title_holder.append(title).append(@upload_input).append(buttons_holder)
|
194
|
+
|
195
|
+
items_container = $ '<div/>', { class: 'import-items-holder', id: 'import_items' }
|
196
|
+
items_container.append(@records_list)
|
197
|
+
|
198
|
+
@container.append(title_holder).append(items_container)
|
199
|
+
|
200
|
+
register_observers: ->
|
201
|
+
super
|
202
|
+
|
203
|
+
@close_button.bind 'click', (evt) =>
|
204
|
+
# this.hide()
|
205
|
+
# location?.reload?()
|
206
|
+
# @records_list.empty()
|
207
|
+
this.hide()
|
208
|
+
@records_list.empty()
|
209
|
+
|
@@ -9,67 +9,67 @@ class Editable
|
|
9
9
|
constructor: (@fields, options = {}) ->
|
10
10
|
this.setup()
|
11
11
|
this.register_observers()
|
12
|
-
|
12
|
+
|
13
13
|
setup: ->
|
14
14
|
@elements = $ @fields
|
15
15
|
@delete_button = @elements.filter('[data-editable=destroy]').first()
|
16
16
|
@edit_button = @elements.filter('[data-editable=edit]').first()
|
17
|
-
|
18
|
-
register_observers: ->
|
17
|
+
|
18
|
+
register_observers: ->
|
19
19
|
@elements.bind 'click', (evt) =>
|
20
20
|
element = $(evt.target)
|
21
|
-
|
21
|
+
|
22
22
|
unless element.hasClass('disabled')
|
23
23
|
switch element.data('editable')
|
24
24
|
when 'destroy' then this.destroy(element)
|
25
25
|
when 'edit' then this.edit(element)
|
26
26
|
false
|
27
|
-
|
27
|
+
|
28
28
|
$('.check-block input').bind 'change', (evt) =>
|
29
29
|
this.check_buttons()
|
30
|
-
|
30
|
+
|
31
31
|
$('.but-holder .check input').bind 'change', (evt) =>
|
32
32
|
$('.check-block input').prop("checked", $(evt.target).prop("checked"))
|
33
33
|
this.check_buttons()
|
34
|
-
|
34
|
+
|
35
35
|
check_buttons: ->
|
36
|
-
count = $('.check-block input:checked').
|
37
|
-
|
36
|
+
count = $('.check-block input:checked').length
|
37
|
+
|
38
38
|
this.toggle_button count > 0, @delete_button
|
39
39
|
this.toggle_button count == 1, @edit_button
|
40
|
-
|
40
|
+
|
41
41
|
toggle_button: (condition, button) ->
|
42
42
|
if condition then button.removeClass('disabled') else button.addClass('disabled')
|
43
|
-
|
43
|
+
|
44
44
|
destroy: (element) ->
|
45
45
|
if this.allowAction(@delete_button)
|
46
46
|
this.handleMethod(element, 'delete')
|
47
|
-
|
47
|
+
|
48
48
|
edit: (element) ->
|
49
49
|
item = $('.check-block input:checked').first()
|
50
50
|
location = element.attr('href').replace('0', item.val())
|
51
51
|
window.location = location
|
52
|
-
|
52
|
+
|
53
53
|
allowAction: (element) ->
|
54
|
-
message = element.data('confirm-message')
|
54
|
+
message = element.data('confirm-message') || element.data('confirm')
|
55
55
|
answer = false
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
callback = undefined
|
57
|
+
|
58
|
+
return true unless message
|
59
59
|
|
60
|
-
if $.rails.fire(element, 'confirm')
|
60
|
+
if $.rails.fire(element, 'confirm')
|
61
61
|
answer = $.rails.confirm(message)
|
62
62
|
callback = $.rails.fire(element, 'confirm:complete', [answer])
|
63
|
-
|
63
|
+
|
64
64
|
answer && callback
|
65
|
-
|
65
|
+
|
66
66
|
handleMethod: (link, method) ->
|
67
67
|
href = link.attr('href')
|
68
68
|
csrf_token = $('meta[name=csrf-token]').attr('content')
|
69
69
|
csrf_param = $('meta[name=csrf-param]').attr('content')
|
70
70
|
form = $('<form method="post" action="' + href + '"></form>')
|
71
71
|
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />'
|
72
|
-
|
72
|
+
|
73
73
|
$('.check-block input:checked').each (index, element) ->
|
74
74
|
metadata_input += '<input name="ids[]" value="' + $(element).val() + '" type="hidden" />'
|
75
75
|
|
@@ -5,22 +5,23 @@ class Sunrise
|
|
5
5
|
|
6
6
|
constructor: (@namespace) ->
|
7
7
|
@sortedFields = []
|
8
|
-
|
8
|
+
|
9
9
|
setup: ->
|
10
10
|
$('[title]').tooltip()
|
11
11
|
$(".ddmenu").ddmenu()
|
12
12
|
$('[data-editable]').editable()
|
13
13
|
$('[data-lang]').lang_tabs()
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if $?.fn?.select2?
|
16
|
+
$("select.select:not(.noselect2)").select2(
|
17
|
+
allowClear: true
|
18
|
+
minimumResultsForSearch: 10
|
19
|
+
width: 'resolve'
|
20
|
+
)
|
21
|
+
|
21
22
|
this.init_submit_buttons()
|
22
23
|
this.init_group_menus()
|
23
|
-
|
24
|
+
|
24
25
|
getParameterByName: (name) ->
|
25
26
|
match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search)
|
26
27
|
if match then decodeURIComponent(match[1].replace(/\+/g, ' ')) else null
|
@@ -28,11 +29,11 @@ class Sunrise
|
|
28
29
|
init_sort_select: ->
|
29
30
|
$("#sort").bind 'change', (evt) ->
|
30
31
|
this.form.submit()
|
31
|
-
|
32
|
+
|
32
33
|
init_submit_buttons: ->
|
33
34
|
$('#cancel-submit-form-button').bind 'click', (evt) ->
|
34
35
|
window.history.back()
|
35
|
-
|
36
|
+
|
36
37
|
$('#submit-form-button').bind 'click', (evt) ->
|
37
38
|
$('form:first').submit()
|
38
39
|
|
@@ -52,21 +53,21 @@ class Sunrise
|
|
52
53
|
storeQuery: () ->
|
53
54
|
query = {}
|
54
55
|
self = this
|
55
|
-
|
56
|
+
|
56
57
|
$.each ['page', 'per', 'sort', 'view'], (index) ->
|
57
58
|
value = self.getParameterByName(this)
|
58
59
|
query[this] = value if value?
|
59
|
-
|
60
|
+
|
60
61
|
$.cookie('params', $.param(query), { expires: 30, path: @namespace })
|
61
|
-
|
62
|
+
|
62
63
|
serialize: (items, options) ->
|
63
64
|
str = []
|
64
|
-
defaults =
|
65
|
+
defaults =
|
65
66
|
attribute: 'id'
|
66
67
|
listType: 'ul'
|
67
68
|
expression: /(.+)[-=_](.+)/
|
68
69
|
key: null
|
69
|
-
|
70
|
+
|
70
71
|
o = $.extend defaults, options
|
71
72
|
|
72
73
|
$(items).each((index) ->
|
@@ -82,35 +83,35 @@ class Sunrise
|
|
82
83
|
str.push(o.key + '=')
|
83
84
|
|
84
85
|
return str.join('&')
|
85
|
-
|
86
|
+
|
86
87
|
serializeTree: (element, options) ->
|
87
|
-
defaults =
|
88
|
+
defaults =
|
88
89
|
attribute: 'id'
|
89
90
|
listType: 'ul'
|
90
91
|
expression: /(.+)[-=_](.+)/
|
91
92
|
key: "tree"
|
92
93
|
startDepthCount: 0
|
93
94
|
root: false
|
94
|
-
|
95
|
+
|
95
96
|
o = $.extend defaults, options
|
96
97
|
sDepth = o.startDepthCount
|
97
98
|
ret = []
|
98
99
|
left = 1
|
99
|
-
|
100
|
+
|
100
101
|
if o.root
|
101
102
|
sDepth += 1
|
102
103
|
left += 1
|
103
|
-
|
104
|
+
|
104
105
|
fn_recursiveArray = (item, depth, left) ->
|
105
106
|
right = left + 1
|
106
107
|
|
107
108
|
if $(item).children(o.listType).children('li').length > 0
|
108
109
|
depth += 1
|
109
|
-
|
110
|
+
|
110
111
|
$(item).children(o.listType).children('li').each(() ->
|
111
112
|
right = fn_recursiveArray($(this), depth, right)
|
112
113
|
)
|
113
|
-
|
114
|
+
|
114
115
|
depth -= 1
|
115
116
|
|
116
117
|
id = ($(item).attr(o.attribute)).match(o.expression)
|
@@ -126,7 +127,7 @@ class Sunrise
|
|
126
127
|
|
127
128
|
left = right + 1
|
128
129
|
return left
|
129
|
-
|
130
|
+
|
130
131
|
if o.root
|
131
132
|
ret.push(
|
132
133
|
"item_id": 'root'
|
@@ -135,13 +136,13 @@ class Sunrise
|
|
135
136
|
"left": '1'
|
136
137
|
"right": ($('li', element).length + 1) * 2
|
137
138
|
)
|
138
|
-
|
139
|
+
|
139
140
|
$(element).children('li').each(() ->
|
140
141
|
left = fn_recursiveArray(this, sDepth, left)
|
141
142
|
)
|
142
143
|
|
143
144
|
ret = ret.sort((a,b) -> return (a.left - b.left) )
|
144
|
-
|
145
|
+
|
145
146
|
if o.key
|
146
147
|
arr = []
|
147
148
|
$.each(ret, () ->
|
@@ -150,7 +151,7 @@ class Sunrise
|
|
150
151
|
hash[param] = this
|
151
152
|
arr.push $.param(hash)
|
152
153
|
)
|
153
|
-
|
154
|
+
|
154
155
|
return arr.join("&")
|
155
156
|
else
|
156
157
|
return ret
|
@@ -165,7 +166,7 @@ class Sunrise
|
|
165
166
|
|
166
167
|
remove_fields: (link) ->
|
167
168
|
hidden_field = $(link).prev("input[type=hidden]")
|
168
|
-
|
169
|
+
|
169
170
|
if hidden_field.length isnt 0
|
170
171
|
hidden_field.val('1')
|
171
172
|
|
@@ -179,7 +180,7 @@ class Sunrise
|
|
179
180
|
handle: '.nested_input_handle'
|
180
181
|
items: '.nested_item'
|
181
182
|
opacity: 0.8
|
182
|
-
update: (event, ui) =>
|
183
|
+
update: (event, ui) =>
|
183
184
|
element = $(ui.item)
|
184
185
|
container = element.parents('div.nested')
|
185
186
|
this.updateSortContainer(container)
|