camaleon_cms 2.1.1.4 → 2.1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/app/apps/plugins/contact_form/contact_form_helper.rb +3 -44
  4. data/app/apps/plugins/contact_form/contact_form_html_helper.rb +1 -1
  5. data/app/apps/plugins/contact_form/views/contact_form/{_submission.html.erb → _email_content.html.erb} +0 -0
  6. data/app/apps/themes/camaleon_first/views/index.html.erb +1 -1
  7. data/app/apps/themes/default/views/category.html.erb +1 -1
  8. data/app/apps/themes/default/views/page.html.erb +1 -1
  9. data/app/apps/themes/default/views/partials/_comments.html.erb +5 -5
  10. data/app/apps/themes/default/views/post.html.erb +1 -1
  11. data/app/apps/themes/default/views/post_tag.html.erb +1 -1
  12. data/app/apps/themes/default/views/post_type.html.erb +1 -1
  13. data/app/apps/themes/default/views/search.html.erb +2 -2
  14. data/app/apps/themes/new/views/category.html.erb +1 -1
  15. data/app/apps/themes/new/views/page.html.erb +1 -1
  16. data/app/apps/themes/new/views/post_tag.html.erb +1 -1
  17. data/app/apps/themes/new/views/post_type.html.erb +1 -1
  18. data/app/apps/themes/new/views/search.html.erb +2 -2
  19. data/app/assets/javascripts/camaleon_cms/admin/_actions.js +1 -1
  20. data/app/assets/javascripts/camaleon_cms/admin/{bootstrap-datepicker.js → _bootstrap-datepicker.js} +0 -0
  21. data/app/assets/javascripts/camaleon_cms/admin/_bootstrap-select.js +7 -0
  22. data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +9 -0
  23. data/app/assets/javascripts/camaleon_cms/admin/admin-manifest.js +2 -1
  24. data/app/assets/javascripts/camaleon_cms/admin/jquery.validate.js +3 -1
  25. data/app/assets/javascripts/camaleon_cms/admin/nav_menu.js.coffee +125 -0
  26. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +53 -23
  27. data/app/assets/javascripts/camaleon_cms/admin/user_profile.js +23 -29
  28. data/app/assets/stylesheets/camaleon_cms/admin/{bootstrap-datepicker.css.scss → _bootstrap-datepicker.css.scss} +0 -0
  29. data/app/assets/stylesheets/camaleon_cms/admin/_bootstrap-select.css +6 -0
  30. data/app/assets/stylesheets/camaleon_cms/admin/admin-manifest.css +2 -3
  31. data/app/assets/stylesheets/camaleon_cms/admin/colorpicker.css.scss +9 -8
  32. data/app/assets/stylesheets/camaleon_cms/admin/uploader/_uploadfile.css.scss +1 -12
  33. data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +102 -81
  34. data/app/controllers/camaleon_cms/admin/media_controller.rb +8 -25
  35. data/app/controllers/camaleon_cms/admin_controller.rb +1 -1
  36. data/app/controllers/camaleon_cms/camaleon_controller.rb +24 -0
  37. data/app/controllers/camaleon_cms/frontend_controller.rb +0 -1
  38. data/app/decorators/camaleon_cms/application_decorator.rb +5 -8
  39. data/app/decorators/camaleon_cms/post_decorator.rb +5 -5
  40. data/app/decorators/camaleon_cms/post_type_decorator.rb +2 -5
  41. data/app/decorators/camaleon_cms/site_decorator.rb +12 -0
  42. data/app/decorators/camaleon_cms/term_taxonomy_decorator.rb +1 -1
  43. data/app/helpers/camaleon_cms/admin/application_helper.rb +8 -1
  44. data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +17 -16
  45. data/app/helpers/camaleon_cms/admin/menus_helper.rb +1 -1
  46. data/app/helpers/camaleon_cms/camaleon_helper.rb +2 -2
  47. data/app/helpers/camaleon_cms/captcha_helper.rb +15 -14
  48. data/app/helpers/camaleon_cms/email_helper.rb +7 -3
  49. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +7 -1
  50. data/app/helpers/camaleon_cms/html_helper.rb +1 -1
  51. data/app/helpers/camaleon_cms/site_helper.rb +6 -15
  52. data/app/helpers/camaleon_cms/uploader_helper.rb +31 -187
  53. data/app/mailers/camaleon_cms/html_mailer.rb +4 -8
  54. data/app/models/camaleon_cms/custom_field_group.rb +1 -0
  55. data/app/models/camaleon_cms/nav_menu.rb +1 -20
  56. data/app/models/camaleon_cms/nav_menu_item.rb +13 -0
  57. data/app/models/camaleon_cms/post.rb +1 -1
  58. data/app/models/camaleon_cms/post_type.rb +8 -7
  59. data/app/models/camaleon_cms/site.rb +22 -2
  60. data/app/models/camaleon_cms/user.rb +2 -1
  61. data/app/models/concerns/camaleon_cms/custom_fields_read.rb +21 -29
  62. data/app/models/concerns/camaleon_cms/metas.rb +4 -3
  63. data/app/uploaders/camaleon_cms_aws_uploader.rb +81 -0
  64. data/app/uploaders/camaleon_cms_local_uploader.rb +84 -0
  65. data/app/uploaders/camaleon_cms_uploader.rb +146 -0
  66. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_fields.html.erb +3 -5
  67. data/app/views/camaleon_cms/admin/appearances/nav_menus/_external_menu.html.erb +7 -6
  68. data/app/views/camaleon_cms/admin/appearances/nav_menus/_form.html.erb +13 -0
  69. data/app/views/camaleon_cms/admin/appearances/nav_menus/_left_menu_items.html.erb +77 -0
  70. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items.html.erb +18 -0
  71. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items_list.html.erb +12 -0
  72. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_options.html.erb +21 -0
  73. data/app/views/camaleon_cms/admin/appearances/nav_menus/index.html.erb +5 -98
  74. data/app/views/camaleon_cms/admin/media/_files_list.html.erb +2 -7
  75. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +28 -26
  76. data/app/views/camaleon_cms/admin/media/_render_folder_item.html.erb +14 -12
  77. data/app/views/camaleon_cms/admin/media/index.html.erb +23 -22
  78. data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +4 -5
  79. data/app/views/camaleon_cms/admin/posts/form.html.erb +1 -0
  80. data/app/views/camaleon_cms/admin/sessions/forgot.html.erb +6 -6
  81. data/app/views/camaleon_cms/admin/sessions/login.html.erb +7 -7
  82. data/app/views/camaleon_cms/admin/sessions/register.html.erb +8 -8
  83. data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +30 -6
  84. data/app/views/camaleon_cms/admin/settings/_email_settings.html.erb +26 -23
  85. data/app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb +25 -20
  86. data/app/views/camaleon_cms/admin/settings/_media_settings.html.erb +10 -0
  87. data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +2 -3
  88. data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +2 -2
  89. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb +1 -1
  90. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_colorpicker.html.erb +2 -2
  91. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb +1 -1
  92. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_field_attrs.html.erb +2 -2
  93. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_file.html.erb +1 -1
  94. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb +1 -1
  95. data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_video.html.erb +1 -1
  96. data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +2 -2
  97. data/app/views/camaleon_cms/admin/settings/post_types/index.html.erb +1 -1
  98. data/app/views/camaleon_cms/admin/settings/site.html.erb +11 -13
  99. data/app/views/camaleon_cms/admin/settings/sites/index.html.erb +5 -3
  100. data/app/views/camaleon_cms/admin/users/form.html.erb +14 -22
  101. data/app/views/camaleon_cms/default_theme/category.html.erb +1 -1
  102. data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +5 -5
  103. data/app/views/camaleon_cms/default_theme/partials/_search_form.html.erb +1 -1
  104. data/app/views/camaleon_cms/default_theme/partials/_sidebar.html.erb +4 -4
  105. data/app/views/camaleon_cms/default_theme/post_tag.html.erb +1 -1
  106. data/app/views/camaleon_cms/default_theme/post_type.html.erb +1 -1
  107. data/app/views/camaleon_cms/default_theme/search.html.erb +1 -1
  108. data/app/views/camaleon_cms/default_theme/single.html.erb +1 -1
  109. data/config/locales/camaleon_cms/admin/en.yml +1 -1
  110. data/config/locales/camaleon_cms/admin/es.yml +36 -0
  111. data/config/locales/camaleon_cms/common.yml +4 -2
  112. data/config/routes/admin.rb +13 -7
  113. data/config/routes/frontend.rb +9 -7
  114. data/config/system.json +1 -0
  115. data/lib/camaleon_cms/engine.rb +1 -1
  116. data/lib/camaleon_cms/version.rb +1 -1
  117. data/lib/ext/string.rb +12 -0
  118. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +1 -1
  119. data/lib/plugin_routes.rb +1 -1
  120. metadata +17 -24
  121. data/app/assets/javascripts/camaleon_cms/admin/bootstrap-select.js +0 -1022
  122. data/app/assets/javascripts/camaleon_cms/admin/nav-menu.js +0 -177
  123. data/app/assets/stylesheets/camaleon_cms/admin/nav-menu.css.scss +0 -33
  124. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_form.html.erb +0 -36
  125. data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_list.html.erb +0 -22
@@ -41,21 +41,23 @@ Rails.application.routes.draw do
41
41
  get "rss", defaults: { format: "rss" }
42
42
  get "ajax"
43
43
 
44
+ # post types
44
45
  controller "camaleon_cms/frontend" do
45
46
  PluginRoutes.get_sites.each do |s|
46
- constraints(PluginRoutes.get_sites.count <= 1 ? {} : {host: s.slug.split(":").first}) do
47
+ h = s.slug.split(":").first
48
+ constraints(PluginRoutes.get_sites.count <= 1 ? {} : {host: h.include?(".") ? h : "#{h}.#{Cama::Site.main_site.slug.split(':').first}" }) do
47
49
  s.post_types.pluck(:slug, :id).each do |pt_slug, pt_id|
48
- PluginRoutes.all_locales.split("|").each do |_l|
49
- get "#{I18n.t("routes.post_types.#{pt_slug}", default: pt_slug, locale: _l)}" => :post_type, as: "post_type_#{pt_id}_#{_l}", defaults: {post_type_id: pt_id}
50
- end
50
+ get ":post_type_slug" => :post_type, as: "post_type_#{pt_id}", post_type_id: pt_id, constraints: {post_type_slug: /(#{PluginRoutes.all_locales.split("|").map{|_l| I18n.t("routes.post_types.#{pt_slug}", default: pt_slug, locale: _l) }.uniq.join('|') })/}
51
51
  end
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
- get ':parent_title/*slug' => :post, as: :hierarchy_post, constraints:{ parent_title: /(?!(#{PluginRoutes.all_locales}))[\w\.\-]+/ }
57
- get ":slug" => :post, format: true, :as => :post1, defaults: { format: :html }, constraints: { slug: /[a-zA-Z0-9\._=\s\-]+/}
58
- get ":slug" => :post, :as => :post, constraints: { slug: /[a-zA-Z0-9\._=\s\-]+/}
56
+ # posts
57
+ constraints(format: /html|rss/) do
58
+ get ':parent_title/*slug(.:format)' => :post, as: :hierarchy_post, constraints:{ parent_title: /(?!(#{PluginRoutes.all_locales}))[\w\-]+/, slug: /[a-zA-Z0-9_=\s\-\/]+/ }
59
+ get ":slug(.:format)" => :post, :as => :post, constraints: { slug: /[a-zA-Z0-9_=\s\-]+/}
60
+ end
59
61
  end
60
62
  end
61
63
  end
data/config/system.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "users_share_sites": true, //(boolean) true: permit to share users between sites, false: All users are assigned for an unique site.
10
10
  "db_prefix": "", // prefix name for database tables
11
11
  "relative_url_root": "", // URL prefix, for example to get http://localhost:3000/blog/, this should be "blog"
12
+ "admin_path_name": "admin", // URL prefix for admin panel, for example to get http://localhost:3000/sekret/, this should be "sekret"
12
13
 
13
14
  "media_slug_folder": false // permit to use site slug for upload media folder instead of site-id
14
15
  }
@@ -9,7 +9,7 @@ require 'protected_attributes'
9
9
  require 'will_paginate'
10
10
  require 'will_paginate-bootstrap'
11
11
  require 'breadcrumbs_on_rails'
12
- require 'fog'
12
+ require 'aws-sdk'
13
13
  require 'font-awesome-rails'
14
14
  require 'tinymce-rails'
15
15
 
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = '2.1.1.4'
2
+ VERSION = '2.1.2.0'
3
3
  end
data/lib/ext/string.rb CHANGED
@@ -127,4 +127,16 @@ class String
127
127
  self.gsub("Decorator","").gsub("CamaleonCms::","")
128
128
  end
129
129
 
130
+ # convert url into custom url with postfix,
131
+ # sample: "http://localhost/company/rack_multipart20160124_2288_8xcdjs.jpg".cama_add_postfix_url('thumbs/') into http://localhost/company/thumbs/rack_multipart20160124_2288_8xcdjs.jpg
132
+ def cama_add_postfix_url(postfix)
133
+ File.join(File.dirname(self), "#{postfix}#{File.basename(self)}")
134
+ end
135
+
136
+ # Sample:
137
+ # /var/www/media/132/logo.png ==> /var/www/media/132/logo_2.png
138
+ def cama_add_postfix_file_name(postfix)
139
+ File.join(File.dirname(self), "#{File.basename(self, File.extname(self))}#{postfix}#{File.extname(self)}")
140
+ end
141
+
130
142
  end
@@ -71,7 +71,7 @@ module CamaleonCms
71
71
  end
72
72
 
73
73
  #Admin Panel
74
- scope 'admin', as: 'admin' do
74
+ scope :admin, path: (PluginRoutes.system_info['admin_path_name'] || 'admin') do
75
75
  namespace 'plugins' do
76
76
  namespace '#{get_plugin_name}' do
77
77
  get 'index' => 'admin#index'
data/lib/plugin_routes.rb CHANGED
@@ -203,7 +203,7 @@ class PluginRoutes
203
203
  # return all sites registered for Plugin routes
204
204
  def self.get_sites
205
205
  begin
206
- @@all_sites ||= CamaleonCms::Site.order(id: :asc).all
206
+ @@all_sites ||= CamaleonCms::Site.order(id: :asc).all.to_a
207
207
  rescue
208
208
  []
209
209
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1.4
4
+ version: 2.1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -178,20 +178,6 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: fog
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '1.34'
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '1.34'
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: aws-sdk
197
183
  requirement: !ruby/object:Gem::Requirement
@@ -248,7 +234,7 @@ files:
248
234
  - app/apps/plugins/contact_form/views/admin_forms/edit.html.erb
249
235
  - app/apps/plugins/contact_form/views/admin_forms/index.html.erb
250
236
  - app/apps/plugins/contact_form/views/admin_forms/responses.html.erb
251
- - app/apps/plugins/contact_form/views/contact_form/_submission.html.erb
237
+ - app/apps/plugins/contact_form/views/contact_form/_email_content.html.erb
252
238
  - app/apps/plugins/contact_form/views/forms_shorcode.html.erb
253
239
  - app/apps/plugins/contact_form/views/front/index.html.erb
254
240
  - app/apps/plugins/front_cache/admin_controller.rb
@@ -381,6 +367,8 @@ files:
381
367
  - app/assets/images/camaleon_cms/loader.gif
382
368
  - app/assets/images/camaleon_cms/users/no-image.jpg
383
369
  - app/assets/javascripts/camaleon_cms/admin/_actions.js
370
+ - app/assets/javascripts/camaleon_cms/admin/_bootstrap-datepicker.js
371
+ - app/assets/javascripts/camaleon_cms/admin/_bootstrap-select.js
384
372
  - app/assets/javascripts/camaleon_cms/admin/_custom_fields.js
385
373
  - app/assets/javascripts/camaleon_cms/admin/_data.js
386
374
  - app/assets/javascripts/camaleon_cms/admin/_i18n.js
@@ -395,8 +383,6 @@ files:
395
383
  - app/assets/javascripts/camaleon_cms/admin/admin-basic-manifest.js
396
384
  - app/assets/javascripts/camaleon_cms/admin/admin-manifest.js
397
385
  - app/assets/javascripts/camaleon_cms/admin/bootstrap-colorpicker.js
398
- - app/assets/javascripts/camaleon_cms/admin/bootstrap-datepicker.js
399
- - app/assets/javascripts/camaleon_cms/admin/bootstrap-select.js
400
386
  - app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js
401
387
  - app/assets/javascripts/camaleon_cms/admin/form-builder/formbuilder.js
402
388
  - app/assets/javascripts/camaleon_cms/admin/form-builder/vendor.js
@@ -427,7 +413,7 @@ files:
427
413
  - app/assets/javascripts/camaleon_cms/admin/momentjs/pt_br.js
428
414
  - app/assets/javascripts/camaleon_cms/admin/momentjs/ru.js
429
415
  - app/assets/javascripts/camaleon_cms/admin/momentjs/zh.js
430
- - app/assets/javascripts/camaleon_cms/admin/nav-menu.js
416
+ - app/assets/javascripts/camaleon_cms/admin/nav_menu.js.coffee
431
417
  - app/assets/javascripts/camaleon_cms/admin/tageditor/_jquery.caret.min.js
432
418
  - app/assets/javascripts/camaleon_cms/admin/tageditor/_jquery.tag-editor.js
433
419
  - app/assets/javascripts/camaleon_cms/admin/tinymce/langs/en.js
@@ -444,11 +430,12 @@ files:
444
430
  - app/assets/javascripts/camaleon_cms/admin/user_profile.js
445
431
  - app/assets/javascripts/camaleon_cms/bootstrap.min.js
446
432
  - app/assets/javascripts/camaleon_cms/gibberish-aes.js
433
+ - app/assets/stylesheets/camaleon_cms/admin/_bootstrap-datepicker.css.scss
434
+ - app/assets/stylesheets/camaleon_cms/admin/_bootstrap-select.css
447
435
  - app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss
448
436
  - app/assets/stylesheets/camaleon_cms/admin/_jquery.tagsinput.css
449
437
  - app/assets/stylesheets/camaleon_cms/admin/admin-basic-manifest.css
450
438
  - app/assets/stylesheets/camaleon_cms/admin/admin-manifest.css
451
- - app/assets/stylesheets/camaleon_cms/admin/bootstrap-datepicker.css.scss
452
439
  - app/assets/stylesheets/camaleon_cms/admin/colorpicker.css.scss
453
440
  - app/assets/stylesheets/camaleon_cms/admin/cropper/cropper.min.css
454
441
  - app/assets/stylesheets/camaleon_cms/admin/form-builder/formbuilder.css
@@ -492,7 +479,6 @@ files:
492
479
  - app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-red.css
493
480
  - app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-yellow-light.css
494
481
  - app/assets/stylesheets/camaleon_cms/admin/lte/skins/skin-yellow.css
495
- - app/assets/stylesheets/camaleon_cms/admin/nav-menu.css.scss
496
482
  - app/assets/stylesheets/camaleon_cms/admin/nestable/jquery.nestable.css
497
483
  - app/assets/stylesheets/camaleon_cms/admin/tageditor/_jquery.tag-editor.css.scss
498
484
  - app/assets/stylesheets/camaleon_cms/admin/uploader/_uploadfile.css.scss
@@ -598,14 +584,20 @@ files:
598
584
  - app/models/concerns/camaleon_cms/metas.rb
599
585
  - app/models/plugins.rb
600
586
  - app/models/themes.rb
587
+ - app/uploaders/camaleon_cms_aws_uploader.rb
588
+ - app/uploaders/camaleon_cms_local_uploader.rb
589
+ - app/uploaders/camaleon_cms_uploader.rb
601
590
  - app/views/camaleon_cms/404.html.erb
602
591
  - app/views/camaleon_cms/500.html.erb
603
592
  - app/views/camaleon_cms/_flash_messages.html.erb
604
593
  - app/views/camaleon_cms/admin/appearances/nav_menus/_custom_fields.html.erb
605
594
  - app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb
606
595
  - app/views/camaleon_cms/admin/appearances/nav_menus/_external_menu.html.erb
607
- - app/views/camaleon_cms/admin/appearances/nav_menus/_menu_form.html.erb
608
- - app/views/camaleon_cms/admin/appearances/nav_menus/_menu_list.html.erb
596
+ - app/views/camaleon_cms/admin/appearances/nav_menus/_form.html.erb
597
+ - app/views/camaleon_cms/admin/appearances/nav_menus/_left_menu_items.html.erb
598
+ - app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items.html.erb
599
+ - app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items_list.html.erb
600
+ - app/views/camaleon_cms/admin/appearances/nav_menus/_menu_options.html.erb
609
601
  - app/views/camaleon_cms/admin/appearances/nav_menus/index.html.erb
610
602
  - app/views/camaleon_cms/admin/appearances/themes/index.html.erb
611
603
  - app/views/camaleon_cms/admin/appearances/themes/preview.html.erb
@@ -646,6 +638,7 @@ files:
646
638
  - app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb
647
639
  - app/views/camaleon_cms/admin/settings/_email_settings.html.erb
648
640
  - app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb
641
+ - app/views/camaleon_cms/admin/settings/_media_settings.html.erb
649
642
  - app/views/camaleon_cms/admin/settings/_seo_settings.html.erb
650
643
  - app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb
651
644
  - app/views/camaleon_cms/admin/settings/custom_fields/_meta_data.html.erb
@@ -1,1022 +0,0 @@
1
- (function ($) {
2
-
3
- 'use strict';
4
-
5
- $.expr[':'].icontains = function (obj, index, meta) {
6
- return $(obj).text().toUpperCase().indexOf(meta[3].toUpperCase()) >= 0;
7
- };
8
-
9
- var Selectpicker = function (element, options, e) {
10
- if (e) {
11
- e.stopPropagation();
12
- e.preventDefault();
13
- }
14
-
15
- this.$element = $(element);
16
- this.$newElement = null;
17
- this.$button = null;
18
- this.$menu = null;
19
- this.$lis = null;
20
- this.options = options;
21
-
22
- //If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute
23
- if (this.options.title === null) {
24
- this.options.title = this.$element.attr('title');
25
- }
26
-
27
- //Expose public methods
28
- this.val = Selectpicker.prototype.val;
29
- this.render = Selectpicker.prototype.render;
30
- this.refresh = Selectpicker.prototype.refresh;
31
- this.setStyle = Selectpicker.prototype.setStyle;
32
- this.selectAll = Selectpicker.prototype.selectAll;
33
- this.deselectAll = Selectpicker.prototype.deselectAll;
34
- this.destroy = Selectpicker.prototype.destroy;
35
- this.show = Selectpicker.prototype.show;
36
- this.hide = Selectpicker.prototype.hide;
37
-
38
- this.init();
39
- };
40
-
41
- Selectpicker.VERSION = '1.5.4';
42
-
43
- Selectpicker.prototype = {
44
-
45
- constructor: Selectpicker,
46
-
47
- init: function () {
48
- var that = this,
49
- id = this.$element.attr('id');
50
-
51
- this.$element.hide();
52
- this.multiple = this.$element.prop('multiple');
53
- this.autofocus = this.$element.prop('autofocus');
54
- this.$newElement = this.createView();
55
- this.$element.after(this.$newElement);
56
- this.$menu = this.$newElement.find('> .dropdown-menu');
57
- this.$button = this.$newElement.find('> button');
58
- this.$searchbox = this.$newElement.find('input');
59
-
60
- if (id !== undefined) {
61
- this.$button.attr('data-id', id);
62
- $('label[for="' + id + '"]').click(function (e) {
63
- e.preventDefault();
64
- that.$button.focus();
65
- });
66
- }
67
-
68
- this.checkDisabled();
69
- this.clickListener();
70
- if (this.options.liveSearch) this.liveSearchListener();
71
- this.render();
72
- this.liHeight();
73
- this.setStyle();
74
- this.setWidth();
75
- if (this.options.container) this.selectPosition();
76
- this.$menu.data('this', this);
77
- this.$newElement.data('this', this);
78
- if (this.options.mobile) this.mobile();
79
- },
80
-
81
- createDropdown: function () {
82
- //If we are multiple, then add the show-tick class by default
83
- var multiple = this.multiple ? ' show-tick' : '';
84
- var inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '';
85
- var autofocus = this.autofocus ? ' autofocus' : '';
86
- var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + '</div>' : '';
87
- var searchbox = this.options.liveSearch ? '<div class="bootstrap-select-searchbox"><input type="text" class="input-block-level form-control" autocomplete="off" /></div>' : '';
88
- var actionsbox = this.options.actionsBox ? '<div class="bs-actionsbox">' +
89
- '<div class="btn-group btn-block">' +
90
- '<button class="actions-btn bs-select-all btn btn-sm btn-default">' +
91
- 'Select All' +
92
- '</button>' +
93
- '<button class="actions-btn bs-deselect-all btn btn-sm btn-default">' +
94
- 'Deselect All' +
95
- '</button>' +
96
- '</div>' +
97
- '</div>' : '';
98
- var drop =
99
- '<div class="btn-group bootstrap-select' + multiple + inputGroup + '">' +
100
- '<button type="button" class="btn dropdown-toggle selectpicker" data-toggle="dropdown"' + autofocus + '>' +
101
- '<span class="filter-option pull-left"></span>&nbsp;' +
102
- '<span class="caret"></span>' +
103
- '</button>' +
104
- '<div class="dropdown-menu open">' +
105
- header +
106
- searchbox +
107
- actionsbox +
108
- '<ul class="dropdown-menu inner selectpicker" role="menu">' +
109
- '</ul>' +
110
- '</div>' +
111
- '</div>';
112
-
113
- return $(drop);
114
- },
115
-
116
- createView: function () {
117
- var $drop = this.createDropdown();
118
- var $li = this.createLi();
119
- $drop.find('ul').append($li);
120
- return $drop;
121
- },
122
-
123
- reloadLi: function () {
124
- //Remove all children.
125
- this.destroyLi();
126
- //Re build
127
- var $li = this.createLi();
128
- this.$menu.find('ul').append($li);
129
- },
130
-
131
- destroyLi: function () {
132
- this.$menu.find('li').remove();
133
- },
134
-
135
- createLi: function () {
136
- var that = this,
137
- _liA = [],
138
- _liHtml = '',
139
- optID = 0;
140
-
141
- this.$element.find('option').each(function () {
142
- var $this = $(this);
143
-
144
- //Get the class and text for the option
145
- var optionClass = $this.attr('class') || '';
146
- var inline = $this.attr('style') || '';
147
- var text = $this.data('content') ? $this.data('content') : $this.html();
148
- var subtext = $this.data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.data('subtext') + '</small>' : '';
149
- var icon = $this.data('icon') !== undefined ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
150
- if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
151
- icon = '<span>' + icon + '</span>';
152
- }
153
-
154
- if (!$this.data('content')) {
155
- //Prepend any icon and append any subtext to the main text.
156
- text = icon + '<span class="text">' + text + subtext + '</span>';
157
- }
158
-
159
- if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
160
- _liA.push('<a style="min-height: 0; padding: 0"></a>');
161
- } else if ($this.parent().is('optgroup') && $this.data('divider') !== true) {
162
- if ($this.index() === 0) {
163
- //Get the opt group label
164
- var label = $this.parent().attr('label');
165
- var labelSubtext = $this.parent().data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.parent().data('subtext') + '</small>' : '';
166
- var labelIcon = $this.parent().data('icon') ? '<i class="' + that.options.iconBase + ' ' + $this.parent().data('icon') + '"></i> ' : '';
167
- label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
168
-
169
- optID += 1;
170
-
171
- if ($this[0].index !== 0) {
172
- _liA.push(
173
- '<div class="div-contain"><div class="divider"></div></div>' +
174
- '<dt>' + label + '</dt>' +
175
- that.createA(text, 'opt ' + optionClass, inline, optID)
176
- );
177
- } else {
178
- _liA.push(
179
- '<dt>' + label + '</dt>' +
180
- that.createA(text, 'opt ' + optionClass, inline, optID));
181
- }
182
- } else {
183
- _liA.push(that.createA(text, 'opt ' + optionClass, inline, optID));
184
- }
185
- } else if ($this.data('divider') === true) {
186
- _liA.push('<div class="div-contain"><div class="divider"></div></div>');
187
- } else if ($(this).data('hidden') === true) {
188
- _liA.push('<a></a>');
189
- } else {
190
- _liA.push(that.createA(text, optionClass, inline));
191
- }
192
- });
193
-
194
- $.each(_liA, function (i, item) {
195
- var hide = item === '<a></a>' ? 'class="hide is-hidden"' : '';
196
- _liHtml += '<li rel="' + i + '"' + hide + '>' + item + '</li>';
197
- });
198
-
199
- //If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button
200
- if (!this.multiple && this.$element.find('option:selected').length === 0 && !this.options.title) {
201
- this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
202
- }
203
-
204
- return $(_liHtml);
205
- },
206
-
207
- /**
208
- *
209
- * @param text
210
- * @param classes
211
- * @param inline
212
- * @param [optgroup]
213
- * @returns {string}
214
- */
215
- createA: function (text, classes, inline, optgroup) {
216
- return '<a tabindex="0" class="' + classes + '" style="' + inline + '"' +
217
- (typeof optgroup !== 'undefined' ? 'data-optgroup="' + optgroup + '"' : '') + '>' +
218
- text +
219
- '<i class="' + this.options.iconBase + ' ' + this.options.tickIcon + ' icon-ok check-mark"></i>' +
220
- '</a>';
221
- },
222
-
223
- /**
224
- * @param [updateLi]
225
- */
226
- render: function (updateLi) {
227
- var that = this;
228
-
229
- //Update the LI to match the SELECT
230
- if (updateLi !== false) {
231
- this.$element.find('option').each(function (index) {
232
- that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled'));
233
- that.setSelected(index, $(this).is(':selected'));
234
- });
235
- }
236
-
237
- this.tabIndex();
238
-
239
- var selectedItems = this.$element.find('option:selected').map(function () {
240
- var $this = $(this);
241
- var icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
242
- var subtext;
243
- if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) {
244
- subtext = ' <small class="muted text-muted">' + $this.data('subtext') + '</small>';
245
- } else {
246
- subtext = '';
247
- }
248
- if ($this.data('content') && that.options.showContent) {
249
- return $this.data('content');
250
- } else if ($this.attr('title') !== undefined) {
251
- return $this.attr('title');
252
- } else {
253
- return icon + $this.html() + subtext;
254
- }
255
- }).toArray();
256
-
257
- //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled
258
- //Convert all the values into a comma delimited string
259
- var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator);
260
-
261
- //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
262
- if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
263
- var max = this.options.selectedTextFormat.split('>');
264
- var notDisabled = this.options.hideDisabled ? ':not([disabled])' : '';
265
- if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) {
266
- title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"], [data-hidden="true"])' + notDisabled).length);
267
- }
268
- }
269
-
270
- this.options.title = this.$element.attr('title');
271
-
272
- if (this.options.selectedTextFormat == 'static') {
273
- title = this.options.title;
274
- }
275
-
276
- //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
277
- if (!title) {
278
- title = this.options.title !== undefined ? this.options.title : this.options.noneSelectedText;
279
- }
280
-
281
- this.$button.attr('title', $.trim($("<div/>").html(title).text()).replace(/\s\s+/g, ' '));
282
- this.$newElement.find('.filter-option').html(title);
283
- },
284
-
285
- /**
286
- * @param [style]
287
- * @param [status]
288
- */
289
- setStyle: function (style, status) {
290
- if (this.$element.attr('class')) {
291
- this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|validate\[.*\]/gi, ''));
292
- }
293
-
294
- var buttonClass = style ? style : this.options.style;
295
-
296
- if (status == 'add') {
297
- this.$button.addClass(buttonClass);
298
- } else if (status == 'remove') {
299
- this.$button.removeClass(buttonClass);
300
- } else {
301
- this.$button.removeClass(this.options.style);
302
- this.$button.addClass(buttonClass);
303
- }
304
- },
305
-
306
- liHeight: function () {
307
- if (this.options.size === false) return;
308
-
309
- var $selectClone = this.$menu.parent().clone().find('> .dropdown-toggle').prop('autofocus', false).end().appendTo('body'),
310
- $menuClone = $selectClone.addClass('open').find('> .dropdown-menu'),
311
- liHeight = $menuClone.find('li > a').outerHeight(),
312
- headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0,
313
- searchHeight = this.options.liveSearch ? $menuClone.find('.bootstrap-select-searchbox').outerHeight() : 0,
314
- actionsHeight = this.options.actionsBox ? $menuClone.find('.bs-actionsbox').outerHeight() : 0;
315
-
316
- $selectClone.remove();
317
-
318
- this.$newElement
319
- .data('liHeight', liHeight)
320
- .data('headerHeight', headerHeight)
321
- .data('searchHeight', searchHeight)
322
- .data('actionsHeight', actionsHeight);
323
- },
324
-
325
- setSize: function () {
326
- var that = this,
327
- menu = this.$menu,
328
- menuInner = menu.find('.inner'),
329
- selectHeight = this.$newElement.outerHeight(),
330
- liHeight = this.$newElement.data('liHeight'),
331
- headerHeight = this.$newElement.data('headerHeight'),
332
- searchHeight = this.$newElement.data('searchHeight'),
333
- actionsHeight = this.$newElement.data('actionsHeight'),
334
- divHeight = menu.find('li .divider').outerHeight(true),
335
- menuPadding = parseInt(menu.css('padding-top')) +
336
- parseInt(menu.css('padding-bottom')) +
337
- parseInt(menu.css('border-top-width')) +
338
- parseInt(menu.css('border-bottom-width')),
339
- notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '',
340
- $window = $(window),
341
- menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2,
342
- menuHeight,
343
- selectOffsetTop,
344
- selectOffsetBot,
345
- posVert = function () {
346
- //JQuery defines a scrollTop function, but in pure JS it's a property
347
- //noinspection JSValidateTypes
348
- selectOffsetTop = that.$newElement.offset().top - $window.scrollTop();
349
- selectOffsetBot = $window.height() - selectOffsetTop - selectHeight;
350
- };
351
- posVert();
352
- if (this.options.header) menu.css('padding-top', 0);
353
-
354
- if (this.options.size == 'auto') {
355
- var getSize = function () {
356
- var minHeight,
357
- lisVis = that.$lis.not('.hide');
358
-
359
- posVert();
360
- menuHeight = selectOffsetBot - menuExtras;
361
-
362
- if (that.options.dropupAuto) {
363
- that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && ((menuHeight - menuExtras) < menu.height()));
364
- }
365
- if (that.$newElement.hasClass('dropup')) {
366
- menuHeight = selectOffsetTop - menuExtras;
367
- }
368
-
369
- if ((lisVis.length + lisVis.find('dt').length) > 3) {
370
- minHeight = liHeight * 3 + menuExtras - 2;
371
- } else {
372
- minHeight = 0;
373
- }
374
-
375
- menu.css({'max-height': menuHeight + 'px', 'overflow': 'hidden', 'min-height': minHeight + headerHeight + searchHeight + actionsHeight + 'px'});
376
- menuInner.css({'max-height': menuHeight - headerHeight - searchHeight - actionsHeight - menuPadding + 'px', 'overflow-y': 'auto', 'min-height': Math.max(minHeight - menuPadding, 0) + 'px'});
377
- };
378
- getSize();
379
- this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize);
380
- $(window).off('resize.getSize').on('resize.getSize', getSize);
381
- $(window).off('scroll.getSize').on('scroll.getSize', getSize);
382
- } else if (this.options.size && this.options.size != 'auto' && menu.find('li' + notDisabled).length > this.options.size) {
383
- var optIndex = menu.find('li' + notDisabled + ' > *').not('.div-contain').slice(0, this.options.size).last().parent().index();
384
- var divLength = menu.find('li').slice(0, optIndex + 1).find('.div-contain').length;
385
- menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding;
386
- if (that.options.dropupAuto) {
387
- this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight < menu.height()));
388
- }
389
- menu.css({'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + 'px', 'overflow': 'hidden'});
390
- menuInner.css({'max-height': menuHeight - menuPadding + 'px', 'overflow-y': 'auto'});
391
- }
392
- },
393
-
394
- setWidth: function () {
395
- if (this.options.width == 'auto') {
396
- this.$menu.css('min-width', '0');
397
-
398
- // Get correct width if element hidden
399
- var selectClone = this.$newElement.clone().appendTo('body');
400
- var ulWidth = selectClone.find('> .dropdown-menu').css('width');
401
- var btnWidth = selectClone.css('width', 'auto').find('> button').css('width');
402
- selectClone.remove();
403
-
404
- // Set width to whatever's larger, button title or longest option
405
- this.$newElement.css('width', Math.max(parseInt(ulWidth), parseInt(btnWidth)) + 'px');
406
- } else if (this.options.width == 'fit') {
407
- // Remove inline min-width so width can be changed from 'auto'
408
- this.$menu.css('min-width', '');
409
- this.$newElement.css('width', '').addClass('fit-width');
410
- } else if (this.options.width) {
411
- // Remove inline min-width so width can be changed from 'auto'
412
- this.$menu.css('min-width', '');
413
- this.$newElement.css('width', this.options.width);
414
- } else {
415
- // Remove inline min-width/width so width can be changed
416
- this.$menu.css('min-width', '');
417
- this.$newElement.css('width', '');
418
- }
419
- // Remove fit-width class if width is changed programmatically
420
- if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
421
- this.$newElement.removeClass('fit-width');
422
- }
423
- },
424
-
425
- selectPosition: function () {
426
- var that = this,
427
- drop = '<div />',
428
- $drop = $(drop),
429
- pos,
430
- actualHeight,
431
- getPlacement = function ($element) {
432
- $drop.addClass($element.attr('class').replace(/form-control/gi, '')).toggleClass('dropup', $element.hasClass('dropup'));
433
- pos = $element.offset();
434
- actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight;
435
- $drop.css({'top': pos.top + actualHeight, 'left': pos.left, 'width': $element[0].offsetWidth, 'position': 'absolute'});
436
- };
437
- this.$newElement.on('click', function () {
438
- if (that.isDisabled()) {
439
- return;
440
- }
441
- getPlacement($(this));
442
- $drop.appendTo(that.options.container);
443
- $drop.toggleClass('open', !$(this).hasClass('open'));
444
- $drop.append(that.$menu);
445
- });
446
- $(window).resize(function () {
447
- getPlacement(that.$newElement);
448
- });
449
- $(window).on('scroll', function () {
450
- getPlacement(that.$newElement);
451
- });
452
- $('html').on('click', function (e) {
453
- if ($(e.target).closest(that.$newElement).length < 1) {
454
- $drop.removeClass('open');
455
- }
456
- });
457
- },
458
-
459
- mobile: function () {
460
- this.$element.addClass('mobile-device').appendTo(this.$newElement);
461
- if (this.options.container) this.$menu.hide();
462
- },
463
-
464
- refresh: function () {
465
- this.$lis = null;
466
- this.reloadLi();
467
- this.render();
468
- this.setWidth();
469
- this.setStyle();
470
- this.checkDisabled();
471
- this.liHeight();
472
- },
473
-
474
- update: function () {
475
- this.reloadLi();
476
- this.setWidth();
477
- this.setStyle();
478
- this.checkDisabled();
479
- this.liHeight();
480
- },
481
-
482
- setSelected: function (index, selected) {
483
- if (this.$lis == null) this.$lis = this.$menu.find('li');
484
- $(this.$lis[index]).toggleClass('selected', selected);
485
- },
486
-
487
- setDisabled: function (index, disabled) {
488
- if (this.$lis == null) this.$lis = this.$menu.find('li');
489
- if (disabled) {
490
- $(this.$lis[index]).addClass('disabled').find('a').attr('href', '#').attr('tabindex', -1);
491
- } else {
492
- $(this.$lis[index]).removeClass('disabled').find('a').removeAttr('href').attr('tabindex', 0);
493
- }
494
- },
495
-
496
- isDisabled: function () {
497
- return this.$element.is(':disabled');
498
- },
499
-
500
- checkDisabled: function () {
501
- var that = this;
502
-
503
- if (this.isDisabled()) {
504
- this.$button.addClass('disabled').attr('tabindex', -1);
505
- } else {
506
- if (this.$button.hasClass('disabled')) {
507
- this.$button.removeClass('disabled');
508
- }
509
-
510
- if (this.$button.attr('tabindex') == -1) {
511
- if (!this.$element.data('tabindex')) this.$button.removeAttr('tabindex');
512
- }
513
- }
514
-
515
- this.$button.click(function () {
516
- return !that.isDisabled();
517
- });
518
- },
519
-
520
- tabIndex: function () {
521
- if (this.$element.is('[tabindex]')) {
522
- this.$element.data('tabindex', this.$element.attr('tabindex'));
523
- this.$button.attr('tabindex', this.$element.data('tabindex'));
524
- }
525
- },
526
-
527
- clickListener: function () {
528
- var that = this;
529
-
530
- $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) {
531
- e.stopPropagation();
532
- });
533
-
534
- this.$newElement.on('click', function () {
535
- that.setSize();
536
- if (!that.options.liveSearch && !that.multiple) {
537
- setTimeout(function () {
538
- that.$menu.find('.selected a').focus();
539
- }, 10);
540
- }
541
- });
542
-
543
- this.$menu.on('click', 'li a', function (e) {
544
- var clickedIndex = $(this).parent().index(),
545
- prevValue = that.$element.val(),
546
- prevIndex = that.$element.prop('selectedIndex');
547
-
548
- //Dont close on multi choice menu
549
- if (that.multiple) {
550
- e.stopPropagation();
551
- }
552
-
553
- e.preventDefault();
554
-
555
- //Dont run if we have been disabled
556
- if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) {
557
- var $options = that.$element.find('option'),
558
- $option = $options.eq(clickedIndex),
559
- state = $option.prop('selected'),
560
- $optgroup = $option.parent('optgroup'),
561
- maxOptions = that.options.maxOptions,
562
- maxOptionsGrp = $optgroup.data('maxOptions') || false;
563
-
564
- //Deselect all others if not multi select box
565
- if (!that.multiple) {
566
- $options.prop('selected', false);
567
- $option.prop('selected', true);
568
- that.$menu.find('.selected').removeClass('selected');
569
- that.setSelected(clickedIndex, true);
570
- }
571
- //Else toggle the one we have chosen if we are multi select.
572
- else {
573
- $option.prop('selected', !state);
574
- that.setSelected(clickedIndex, !state);
575
- $(this).blur();
576
-
577
- if ((maxOptions !== false) || (maxOptionsGrp !== false)) {
578
- var maxReached = maxOptions < $options.filter(':selected').length,
579
- maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length,
580
- maxOptionsArr = that.options.maxOptionsText,
581
- maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
582
- maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
583
- $notify = $('<div class="notify"></div>');
584
-
585
- if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
586
- if (maxOptions && maxOptions == 1) {
587
- $options.prop('selected', false);
588
- $option.prop('selected', true);
589
- that.$menu.find('.selected').removeClass('selected');
590
- that.setSelected(clickedIndex, true);
591
- } else if (maxOptionsGrp && maxOptionsGrp == 1) {
592
- $optgroup.find('option:selected').prop('selected', false);
593
- $option.prop('selected', true);
594
- var optgroupID = $(this).data('optgroup');
595
-
596
- that.$menu.find('.selected').has('a[data-optgroup="'+optgroupID+'"]').removeClass('selected');
597
-
598
- that.setSelected(clickedIndex, true);
599
- } else {
600
- // If {var} is set in array, replace it
601
- if (maxOptionsArr[2]) {
602
- maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
603
- maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
604
- }
605
-
606
- $option.prop('selected', false);
607
-
608
- that.$menu.append($notify);
609
-
610
- if (maxOptions && maxReached) {
611
- $notify.append($('<div>' + maxTxt + '</div>'));
612
- that.$element.trigger('maxReached.bs.select');
613
- }
614
-
615
- if (maxOptionsGrp && maxReachedGrp) {
616
- $notify.append($('<div>' + maxTxtGrp + '</div>'));
617
- that.$element.trigger('maxReachedGrp.bs.select');
618
- }
619
-
620
- setTimeout(function () {
621
- that.setSelected(clickedIndex, false);
622
- }, 10);
623
-
624
- $notify.delay(750).fadeOut(300, function () {
625
- $(this).remove();
626
- });
627
- }
628
- }
629
- }
630
- }
631
-
632
- if (!that.multiple) {
633
- that.$button.focus();
634
- } else if (that.options.liveSearch) {
635
- that.$searchbox.focus();
636
- }
637
-
638
- // Trigger select 'change'
639
- if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) {
640
- that.$element.change();
641
- }
642
- }
643
- });
644
-
645
- this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, .popover-title, .popover-title :not(.close)', function (e) {
646
- if (e.target == this) {
647
- e.preventDefault();
648
- e.stopPropagation();
649
- if (!that.options.liveSearch) {
650
- that.$button.focus();
651
- } else {
652
- that.$searchbox.focus();
653
- }
654
- }
655
- });
656
-
657
- this.$menu.on('click', '.popover-title .close', function () {
658
- that.$button.focus();
659
- });
660
-
661
- this.$searchbox.on('click', function (e) {
662
- e.stopPropagation();
663
- });
664
-
665
-
666
- this.$menu.on('click', '.actions-btn', function (e) {
667
- if (that.options.liveSearch) {
668
- that.$searchbox.focus();
669
- } else {
670
- that.$button.focus();
671
- }
672
-
673
- e.preventDefault();
674
- e.stopPropagation();
675
-
676
- if ($(this).is('.bs-select-all')) {
677
- that.selectAll();
678
- } else {
679
- that.deselectAll();
680
- }
681
- that.$element.change();
682
- });
683
-
684
- this.$element.change(function () {
685
- that.render(false);
686
- });
687
- },
688
-
689
- liveSearchListener: function () {
690
- var that = this,
691
- no_results = $('<li class="no-results"></li>');
692
-
693
- this.$newElement.on('click.dropdown.data-api', function () {
694
- that.$menu.find('.active').removeClass('active');
695
- if (!!that.$searchbox.val()) {
696
- that.$searchbox.val('');
697
- that.$lis.not('.is-hidden').removeClass('hide');
698
- if (!!no_results.parent().length) no_results.remove();
699
- }
700
- if (!that.multiple) that.$menu.find('.selected').addClass('active');
701
- setTimeout(function () {
702
- that.$searchbox.focus();
703
- }, 10);
704
- });
705
-
706
- this.$searchbox.on('input propertychange', function () {
707
- if (that.$searchbox.val()) {
708
- that.$lis.not('.is-hidden').removeClass('hide').find('a').not(':icontains(' + that.$searchbox.val() + ')').parent().addClass('hide');
709
-
710
- if (!that.$menu.find('li').filter(':visible:not(.no-results)').length) {
711
- if (!!no_results.parent().length) no_results.remove();
712
- no_results.html(that.options.noneResultsText + ' "' + that.$searchbox.val() + '"').show();
713
- that.$menu.find('li').last().after(no_results);
714
- } else if (!!no_results.parent().length) {
715
- no_results.remove();
716
- }
717
-
718
- } else {
719
- that.$lis.not('.is-hidden').removeClass('hide');
720
- if (!!no_results.parent().length) no_results.remove();
721
- }
722
-
723
- that.$menu.find('li.active').removeClass('active');
724
- that.$menu.find('li').filter(':visible:not(.divider)').eq(0).addClass('active').find('a').focus();
725
- $(this).focus();
726
- });
727
-
728
- this.$menu.on('mouseenter', 'a', function (e) {
729
- that.$menu.find('.active').removeClass('active');
730
- $(e.currentTarget).parent().not('.disabled').addClass('active');
731
- });
732
-
733
- this.$menu.on('mouseleave', 'a', function () {
734
- that.$menu.find('.active').removeClass('active');
735
- });
736
- },
737
-
738
- val: function (value) {
739
-
740
- if (value !== undefined) {
741
- this.$element.val(value);
742
- this.$element.change();
743
- this.render();
744
-
745
- return this.$element;
746
- } else {
747
- return this.$element.val();
748
- }
749
- },
750
-
751
- selectAll: function () {
752
- if (this.$lis == null) this.$lis = this.$menu.find('li');
753
- this.$element.find('option:enabled').prop('selected', true);
754
- $(this.$lis).not('.disabled').addClass('selected');
755
- this.render(false);
756
- },
757
-
758
- deselectAll: function () {
759
- if (this.$lis == null) this.$lis = this.$menu.find('li');
760
- this.$element.find('option:enabled').prop('selected', false);
761
- $(this.$lis).not('.disabled').removeClass('selected');
762
- this.render(false);
763
- },
764
-
765
- keydown: function (e) {
766
- var $this,
767
- $items,
768
- $parent,
769
- index,
770
- next,
771
- first,
772
- last,
773
- prev,
774
- nextPrev,
775
- that,
776
- prevIndex,
777
- isActive,
778
- keyCodeMap = {
779
- 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', 54: '6', 55: '7', 56: '8', 57: '9', 59: ';',
780
- 65: 'a', 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', 73: 'i', 74: 'j', 75: 'k', 76: 'l',
781
- 77: 'm', 78: 'n', 79: 'o', 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', 87: 'w', 88: 'x',
782
- 89: 'y', 90: 'z', 96: '0', 97: '1', 98: '2', 99: '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9'
783
- };
784
-
785
- $this = $(this);
786
-
787
- $parent = $this.parent();
788
-
789
- if ($this.is('input')) $parent = $this.parent().parent();
790
-
791
- that = $parent.data('this');
792
-
793
- if (that.options.liveSearch) $parent = $this.parent().parent();
794
-
795
- if (that.options.container) $parent = that.$menu;
796
-
797
- $items = $('[role=menu] li:not(.divider) a', $parent);
798
-
799
- isActive = that.$menu.parent().hasClass('open');
800
-
801
- if (!isActive && /([0-9]|[A-z])/.test(String.fromCharCode(e.keyCode))) {
802
- if (!that.options.container) {
803
- that.setSize();
804
- that.$menu.parent().addClass('open');
805
- isActive = true;
806
- } else {
807
- that.$newElement.trigger('click');
808
- }
809
- that.$searchbox.focus();
810
- }
811
-
812
- if (that.options.liveSearch) {
813
- if (/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && that.$menu.find('.active').length === 0) {
814
- e.preventDefault();
815
- that.$menu.parent().removeClass('open');
816
- that.$button.focus();
817
- }
818
- $items = $('[role=menu] li:not(.divider):visible', $parent);
819
- if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) {
820
- if ($items.filter('.active').length === 0) {
821
- $items = that.$newElement.find('li').filter(':icontains(' + keyCodeMap[e.keyCode] + ')');
822
- }
823
- }
824
- }
825
-
826
- if (!$items.length) return;
827
-
828
- if (/(38|40)/.test(e.keyCode.toString(10))) {
829
-
830
- index = $items.index($items.filter(':focus'));
831
- first = $items.parent(':not(.disabled):visible').first().index();
832
- last = $items.parent(':not(.disabled):visible').last().index();
833
- next = $items.eq(index).parent().nextAll(':not(.disabled):visible').eq(0).index();
834
- prev = $items.eq(index).parent().prevAll(':not(.disabled):visible').eq(0).index();
835
- nextPrev = $items.eq(next).parent().prevAll(':not(.disabled):visible').eq(0).index();
836
-
837
- if (that.options.liveSearch) {
838
- $items.each(function (i) {
839
- if ($(this).is(':not(.disabled)')) {
840
- $(this).data('index', i);
841
- }
842
- });
843
- index = $items.index($items.filter('.active'));
844
- first = $items.filter(':not(.disabled):visible').first().data('index');
845
- last = $items.filter(':not(.disabled):visible').last().data('index');
846
- next = $items.eq(index).nextAll(':not(.disabled):visible').eq(0).data('index');
847
- prev = $items.eq(index).prevAll(':not(.disabled):visible').eq(0).data('index');
848
- nextPrev = $items.eq(next).prevAll(':not(.disabled):visible').eq(0).data('index');
849
- }
850
-
851
- prevIndex = $this.data('prevIndex');
852
-
853
- if (e.keyCode == 38) {
854
- if (that.options.liveSearch) index -= 1;
855
- if (index != nextPrev && index > prev) index = prev;
856
- if (index < first) index = first;
857
- if (index == prevIndex) index = last;
858
- }
859
-
860
- if (e.keyCode == 40) {
861
- if (that.options.liveSearch) index += 1;
862
- if (index == -1) index = 0;
863
- if (index != nextPrev && index < next) index = next;
864
- if (index > last) index = last;
865
- if (index == prevIndex) index = first;
866
- }
867
-
868
- $this.data('prevIndex', index);
869
-
870
- if (!that.options.liveSearch) {
871
- $items.eq(index).focus();
872
- } else {
873
- e.preventDefault();
874
- if (!$this.is('.dropdown-toggle')) {
875
- $items.removeClass('active');
876
- $items.eq(index).addClass('active').find('a').focus();
877
- $this.focus();
878
- }
879
- }
880
-
881
- } else if (!$this.is('input')) {
882
-
883
- var keyIndex = [],
884
- count,
885
- prevKey;
886
-
887
- $items.each(function () {
888
- if ($(this).parent().is(':not(.disabled)')) {
889
- if ($.trim($(this).text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) {
890
- keyIndex.push($(this).parent().index());
891
- }
892
- }
893
- });
894
-
895
- count = $(document).data('keycount');
896
- count++;
897
- $(document).data('keycount', count);
898
-
899
- prevKey = $.trim($(':focus').text().toLowerCase()).substring(0, 1);
900
-
901
- if (prevKey != keyCodeMap[e.keyCode]) {
902
- count = 1;
903
- $(document).data('keycount', count);
904
- } else if (count >= keyIndex.length) {
905
- $(document).data('keycount', 0);
906
- if (count > keyIndex.length) count = 1;
907
- }
908
-
909
- $items.eq(keyIndex[count - 1]).focus();
910
- }
911
-
912
- // Select focused option if "Enter", "Spacebar", "Tab" are pressed inside the menu.
913
- if (/(13|32|^9$)/.test(e.keyCode.toString(10)) && isActive) {
914
- if (!/(32)/.test(e.keyCode.toString(10))) e.preventDefault();
915
- if (!that.options.liveSearch) {
916
- $(':focus').click();
917
- } else if (!/(32)/.test(e.keyCode.toString(10))) {
918
- that.$menu.find('.active a').click();
919
- $this.focus();
920
- }
921
- $(document).data('keycount', 0);
922
- }
923
-
924
- if ((/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode.toString(10)) && !isActive)) {
925
- that.$menu.parent().removeClass('open');
926
- that.$button.focus();
927
- }
928
-
929
- },
930
-
931
- hide: function () {
932
- this.$newElement.hide();
933
- },
934
-
935
- show: function () {
936
- this.$newElement.show();
937
- },
938
-
939
- destroy: function () {
940
- this.$newElement.remove();
941
- this.$element.remove();
942
- }
943
- };
944
-
945
- $.fn.selectpicker = function (option, event) {
946
- //get the args of the outer function..
947
- var args = arguments;
948
- var value;
949
- var chain = this.each(function () {
950
- if ($(this).is('select')) {
951
- var $this = $(this),
952
- data = $this.data('selectpicker'),
953
- options = typeof option == 'object' && option;
954
-
955
- if (!data) {
956
- $this.data('selectpicker', (data = new Selectpicker(this, $.extend({}, $.fn.selectpicker.defaults, $this.data(), options), event)));
957
- } else if (options) {
958
- for (var i in options) {
959
- if (options.hasOwnProperty(i)) {
960
- data.options[i] = options[i];
961
- }
962
- }
963
- }
964
-
965
- if (typeof option == 'string') {
966
- //Copy the value of option, as once we shift the arguments
967
- //it also shifts the value of option.
968
- var property = option;
969
- if (data[property] instanceof Function) {
970
- [].shift.apply(args);
971
- value = data[property].apply(data, args);
972
- } else {
973
- value = data.options[property];
974
- }
975
- }
976
- }
977
- });
978
-
979
- if (typeof value !== 'undefined') {
980
- //noinspection JSUnusedAssignment
981
- return value;
982
- } else {
983
- return chain;
984
- }
985
- };
986
-
987
- $.fn.selectpicker.Constructor = Selectpicker;
988
-
989
- $.fn.selectpicker.defaults = {
990
- style: 'btn-default',
991
- size: 'auto',
992
- title: null,
993
- selectedTextFormat: 'values',
994
- noneSelectedText: 'Nothing selected',
995
- noneResultsText: 'No results match',
996
- countSelectedText: '{0} of {1} selected',
997
- maxOptionsText: ['Limit reached ({n} {var} max)', 'Group limit reached ({n} {var} max)', ['items', 'item']],
998
- width: false,
999
- container: false,
1000
- hideDisabled: false,
1001
- showSubtext: false,
1002
- showIcon: true,
1003
- showContent: true,
1004
- dropupAuto: true,
1005
- header: false,
1006
- liveSearch: false,
1007
- actionsBox: false,
1008
- multipleSeparator: ', ',
1009
- iconBase: 'glyphicon',
1010
- tickIcon: 'glyphicon-ok',
1011
- maxOptions: false,
1012
- mobile: false
1013
- };
1014
-
1015
- $(document)
1016
- .data('keycount', 0)
1017
- .on('keydown', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bootstrap-select-searchbox input', Selectpicker.prototype.keydown)
1018
- .on('focusin.modal', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role=menu], .bootstrap-select-searchbox input', function (e) {
1019
- e.stopPropagation();
1020
- });
1021
-
1022
- })(jQuery);