activeadmin_addons_rails6 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +24 -0
  4. data/app/assets/images/fileicons/file_extension_3gp.png +0 -0
  5. data/app/assets/images/fileicons/file_extension_7z.png +0 -0
  6. data/app/assets/images/fileicons/file_extension_ace.png +0 -0
  7. data/app/assets/images/fileicons/file_extension_ai.png +0 -0
  8. data/app/assets/images/fileicons/file_extension_aif.png +0 -0
  9. data/app/assets/images/fileicons/file_extension_aiff.png +0 -0
  10. data/app/assets/images/fileicons/file_extension_amr.png +0 -0
  11. data/app/assets/images/fileicons/file_extension_asf.png +0 -0
  12. data/app/assets/images/fileicons/file_extension_asx.png +0 -0
  13. data/app/assets/images/fileicons/file_extension_bat.png +0 -0
  14. data/app/assets/images/fileicons/file_extension_bin.png +0 -0
  15. data/app/assets/images/fileicons/file_extension_bmp.png +0 -0
  16. data/app/assets/images/fileicons/file_extension_bup.png +0 -0
  17. data/app/assets/images/fileicons/file_extension_cab.png +0 -0
  18. data/app/assets/images/fileicons/file_extension_cbr.png +0 -0
  19. data/app/assets/images/fileicons/file_extension_cda.png +0 -0
  20. data/app/assets/images/fileicons/file_extension_cdl.png +0 -0
  21. data/app/assets/images/fileicons/file_extension_cdr.png +0 -0
  22. data/app/assets/images/fileicons/file_extension_chm.png +0 -0
  23. data/app/assets/images/fileicons/file_extension_dat.png +0 -0
  24. data/app/assets/images/fileicons/file_extension_divx.png +0 -0
  25. data/app/assets/images/fileicons/file_extension_dll.png +0 -0
  26. data/app/assets/images/fileicons/file_extension_dmg.png +0 -0
  27. data/app/assets/images/fileicons/file_extension_doc.png +0 -0
  28. data/app/assets/images/fileicons/file_extension_docx.png +0 -0
  29. data/app/assets/images/fileicons/file_extension_dss.png +0 -0
  30. data/app/assets/images/fileicons/file_extension_dvf.png +0 -0
  31. data/app/assets/images/fileicons/file_extension_dwg.png +0 -0
  32. data/app/assets/images/fileicons/file_extension_eml.png +0 -0
  33. data/app/assets/images/fileicons/file_extension_eps.png +0 -0
  34. data/app/assets/images/fileicons/file_extension_exe.png +0 -0
  35. data/app/assets/images/fileicons/file_extension_fla.png +0 -0
  36. data/app/assets/images/fileicons/file_extension_flv.png +0 -0
  37. data/app/assets/images/fileicons/file_extension_gif.png +0 -0
  38. data/app/assets/images/fileicons/file_extension_gz.png +0 -0
  39. data/app/assets/images/fileicons/file_extension_hqx.png +0 -0
  40. data/app/assets/images/fileicons/file_extension_htm.png +0 -0
  41. data/app/assets/images/fileicons/file_extension_html.png +0 -0
  42. data/app/assets/images/fileicons/file_extension_ifo.png +0 -0
  43. data/app/assets/images/fileicons/file_extension_indd.png +0 -0
  44. data/app/assets/images/fileicons/file_extension_iso.png +0 -0
  45. data/app/assets/images/fileicons/file_extension_jar.png +0 -0
  46. data/app/assets/images/fileicons/file_extension_jpeg.png +0 -0
  47. data/app/assets/images/fileicons/file_extension_jpg.png +0 -0
  48. data/app/assets/images/fileicons/file_extension_lnk.png +0 -0
  49. data/app/assets/images/fileicons/file_extension_log.png +0 -0
  50. data/app/assets/images/fileicons/file_extension_m4a.png +0 -0
  51. data/app/assets/images/fileicons/file_extension_m4b.png +0 -0
  52. data/app/assets/images/fileicons/file_extension_m4p.png +0 -0
  53. data/app/assets/images/fileicons/file_extension_m4v.png +0 -0
  54. data/app/assets/images/fileicons/file_extension_mcd.png +0 -0
  55. data/app/assets/images/fileicons/file_extension_mdb.png +0 -0
  56. data/app/assets/images/fileicons/file_extension_mid.png +0 -0
  57. data/app/assets/images/fileicons/file_extension_mov.png +0 -0
  58. data/app/assets/images/fileicons/file_extension_mp2.png +0 -0
  59. data/app/assets/images/fileicons/file_extension_mp3.png +0 -0
  60. data/app/assets/images/fileicons/file_extension_mp4.png +0 -0
  61. data/app/assets/images/fileicons/file_extension_mpeg.png +0 -0
  62. data/app/assets/images/fileicons/file_extension_mpg.png +0 -0
  63. data/app/assets/images/fileicons/file_extension_msi.png +0 -0
  64. data/app/assets/images/fileicons/file_extension_mswmm.png +0 -0
  65. data/app/assets/images/fileicons/file_extension_ogg.png +0 -0
  66. data/app/assets/images/fileicons/file_extension_pdf.png +0 -0
  67. data/app/assets/images/fileicons/file_extension_png.png +0 -0
  68. data/app/assets/images/fileicons/file_extension_pps.png +0 -0
  69. data/app/assets/images/fileicons/file_extension_ppt.png +0 -0
  70. data/app/assets/images/fileicons/file_extension_pptx.png +0 -0
  71. data/app/assets/images/fileicons/file_extension_ps.png +0 -0
  72. data/app/assets/images/fileicons/file_extension_psd.png +0 -0
  73. data/app/assets/images/fileicons/file_extension_pst.png +0 -0
  74. data/app/assets/images/fileicons/file_extension_ptb.png +0 -0
  75. data/app/assets/images/fileicons/file_extension_pub.png +0 -0
  76. data/app/assets/images/fileicons/file_extension_qbb.png +0 -0
  77. data/app/assets/images/fileicons/file_extension_qbw.png +0 -0
  78. data/app/assets/images/fileicons/file_extension_qxd.png +0 -0
  79. data/app/assets/images/fileicons/file_extension_ram.png +0 -0
  80. data/app/assets/images/fileicons/file_extension_rar.png +0 -0
  81. data/app/assets/images/fileicons/file_extension_rm.png +0 -0
  82. data/app/assets/images/fileicons/file_extension_rmvb.png +0 -0
  83. data/app/assets/images/fileicons/file_extension_rtf.png +0 -0
  84. data/app/assets/images/fileicons/file_extension_sea.png +0 -0
  85. data/app/assets/images/fileicons/file_extension_ses.png +0 -0
  86. data/app/assets/images/fileicons/file_extension_sit.png +0 -0
  87. data/app/assets/images/fileicons/file_extension_sitx.png +0 -0
  88. data/app/assets/images/fileicons/file_extension_ss.png +0 -0
  89. data/app/assets/images/fileicons/file_extension_swf.png +0 -0
  90. data/app/assets/images/fileicons/file_extension_tgz.png +0 -0
  91. data/app/assets/images/fileicons/file_extension_thm.png +0 -0
  92. data/app/assets/images/fileicons/file_extension_tif.png +0 -0
  93. data/app/assets/images/fileicons/file_extension_tmp.png +0 -0
  94. data/app/assets/images/fileicons/file_extension_torrent.png +0 -0
  95. data/app/assets/images/fileicons/file_extension_ttf.png +0 -0
  96. data/app/assets/images/fileicons/file_extension_txt.png +0 -0
  97. data/app/assets/images/fileicons/file_extension_unknown.png +0 -0
  98. data/app/assets/images/fileicons/file_extension_vcd.png +0 -0
  99. data/app/assets/images/fileicons/file_extension_vob.png +0 -0
  100. data/app/assets/images/fileicons/file_extension_wav.png +0 -0
  101. data/app/assets/images/fileicons/file_extension_wma.png +0 -0
  102. data/app/assets/images/fileicons/file_extension_wmv.png +0 -0
  103. data/app/assets/images/fileicons/file_extension_wps.png +0 -0
  104. data/app/assets/images/fileicons/file_extension_xls.png +0 -0
  105. data/app/assets/images/fileicons/file_extension_xlsx.png +0 -0
  106. data/app/assets/images/fileicons/file_extension_xpi.png +0 -0
  107. data/app/assets/images/fileicons/file_extension_zip.png +0 -0
  108. data/app/assets/images/material/icons/keyboard_arrow_down.svg +4 -0
  109. data/app/assets/images/material/icons/keyboard_arrow_left.svg +4 -0
  110. data/app/assets/images/material/icons/keyboard_arrow_right.svg +4 -0
  111. data/app/assets/images/material/icons/keyboard_arrow_up.svg +4 -0
  112. data/app/assets/images/material/icons/today.svg +4 -0
  113. data/app/assets/javascripts/activeadmin_addons/all.js +753 -0
  114. data/app/assets/stylesheets/activeadmin_addons/addons/interactive_select_tag.scss +30 -0
  115. data/app/assets/stylesheets/activeadmin_addons/addons/material-datepicker.scss +173 -0
  116. data/app/assets/stylesheets/activeadmin_addons/addons/material-toggle_bool.scss +52 -0
  117. data/app/assets/stylesheets/activeadmin_addons/addons/toggle_bool.scss +52 -0
  118. data/app/assets/stylesheets/activeadmin_addons/all.scss +19 -0
  119. data/app/assets/stylesheets/activeadmin_addons/imports/jquery-datepicker.scss +1 -0
  120. data/app/assets/stylesheets/activeadmin_addons/imports/webpack/jquery-datepicker.scss +1 -0
  121. data/app/assets/stylesheets/activeadmin_addons/inputs/color-picker.scss +4 -0
  122. data/app/assets/stylesheets/activeadmin_addons/inputs/date-time-picker.scss +5 -0
  123. data/app/assets/stylesheets/activeadmin_addons/inputs/numeric-range-filter.scss +12 -0
  124. data/app/assets/stylesheets/activeadmin_addons/inputs/select2.scss +3 -0
  125. data/app/assets/stylesheets/activeadmin_addons/inputs/selected-list.scss +27 -0
  126. data/app/assets/stylesheets/activeadmin_addons/material.scss +53 -0
  127. data/app/assets/stylesheets/activeadmin_addons/vendor/palette-color-picker.scss +155 -0
  128. data/app/inputs/active_admin/inputs/select_input.rb +11 -0
  129. data/app/inputs/ajax_filter_input.rb +6 -0
  130. data/app/inputs/color_picker_input.rb +37 -0
  131. data/app/inputs/date_range_input.rb +5 -0
  132. data/app/inputs/date_time_picker_input.rb +64 -0
  133. data/app/inputs/nested_level_input.rb +51 -0
  134. data/app/inputs/nested_select_input.rb +88 -0
  135. data/app/inputs/numeric_range_filter_input.rb +27 -0
  136. data/app/inputs/range_select_input.rb +6 -0
  137. data/app/inputs/search_select_filter_input.rb +12 -0
  138. data/app/inputs/search_select_input.rb +29 -0
  139. data/app/inputs/selected_list_input.rb +54 -0
  140. data/app/inputs/tags_input.rb +55 -0
  141. data/app/javascript/activeadmin_addons/addons/interactive_select_tag.js +95 -0
  142. data/app/javascript/activeadmin_addons/addons/toggle_bool.js +39 -0
  143. data/app/javascript/activeadmin_addons/all.js +14 -0
  144. data/app/javascript/activeadmin_addons/config.js +10 -0
  145. data/app/javascript/activeadmin_addons/inputs/color-picker.js +16 -0
  146. data/app/javascript/activeadmin_addons/inputs/date-time-picker.js +28 -0
  147. data/app/javascript/activeadmin_addons/inputs/nested-select.js +170 -0
  148. data/app/javascript/activeadmin_addons/inputs/search-select.js +76 -0
  149. data/app/javascript/activeadmin_addons/inputs/select2.js +52 -0
  150. data/app/javascript/activeadmin_addons/inputs/selected-list.js +107 -0
  151. data/app/javascript/activeadmin_addons/inputs/tags.js +76 -0
  152. data/app/javascript/activeadmin_addons/vendor/jquery_palette_color_picker/palette-color-picker.js +265 -0
  153. data/lib/activeadmin_addons.rb +27 -0
  154. data/lib/activeadmin_addons/active_admin_config.rb +9 -0
  155. data/lib/activeadmin_addons/addons/attachment_builder.rb +60 -0
  156. data/lib/activeadmin_addons/addons/bool_builder.rb +31 -0
  157. data/lib/activeadmin_addons/addons/image_builder.rb +12 -0
  158. data/lib/activeadmin_addons/addons/list_builder.rb +73 -0
  159. data/lib/activeadmin_addons/addons/number_builder.rb +25 -0
  160. data/lib/activeadmin_addons/addons/state_builder.rb +39 -0
  161. data/lib/activeadmin_addons/addons/tag_builder.rb +91 -0
  162. data/lib/activeadmin_addons/addons/toggle_bool_builder.rb +44 -0
  163. data/lib/activeadmin_addons/engine.rb +19 -0
  164. data/lib/activeadmin_addons/support/custom_builder.rb +91 -0
  165. data/lib/activeadmin_addons/support/enumerize_formtastic_support.rb +18 -0
  166. data/lib/activeadmin_addons/support/input_base.rb +53 -0
  167. data/lib/activeadmin_addons/support/input_helpers/filter_input.rb +8 -0
  168. data/lib/activeadmin_addons/support/input_helpers/filter_input_methods.rb +32 -0
  169. data/lib/activeadmin_addons/support/input_helpers/input_html_helpers.rb +43 -0
  170. data/lib/activeadmin_addons/support/input_helpers/input_methods.rb +67 -0
  171. data/lib/activeadmin_addons/support/input_helpers/input_options_handler.rb +90 -0
  172. data/lib/activeadmin_addons/support/input_helpers/select_helpers.rb +89 -0
  173. data/lib/activeadmin_addons/support/set_datepicker.rb +13 -0
  174. data/lib/activeadmin_addons/version.rb +3 -0
  175. data/lib/activeadmin_addons_rails_6.rb +5 -0
  176. data/lib/generators/activeadmin_addons/assets/assets_generator.rb +53 -0
  177. data/lib/generators/activeadmin_addons/install/install_generator.rb +19 -0
  178. data/lib/generators/activeadmin_addons/install/templates/initializer.rb +12 -0
  179. data/lib/generators/activeadmin_addons/webpacker/webpacker_generator.rb +35 -0
  180. data/lib/tasks/activeadmin_addons_tasks.rake +4 -0
  181. data/vendor/assets/select2/select2.css +481 -0
  182. data/vendor/assets/select2/select2.full.js +6820 -0
  183. metadata +544 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34f71311406e0192de4e323d80e5231ae1f4a3796e042765ecf82d1339a39e6c
4
+ data.tar.gz: 33fbb46da18da5d10791b05a169380a3dbd44d598877b98244664769acaeb6db
5
+ SHA512:
6
+ metadata.gz: cc5dbc68bcf3fb5853a4bb0042a5e40672fcc21a9c5d75b6bd3bdd55a95d4ea481047e9babf9c6667d96ab2cfb7a01a28b4a893e559db56fbb7cea65a800f19d
7
+ data.tar.gz: a8b71940dda7f6a9f316012856a8883c54e130270f7840d81e168414ccb857c5ddf288cebe4e0c53be6f7ccc7591e3228786ecd76630ee01bb8fbd3b44efb580
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 PLATANUS SPA
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ActiveadminAddons'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ task :tests do
18
+ sh "bin/setup"
19
+ sh "rspec"
20
+ sh "bin/setup --use_webpacker"
21
+ sh "rspec"
22
+ end
23
+
24
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,4 @@
1
+ <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z"/>
3
+ <path d="M0-.75h24v24H0z" fill="none"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/>
3
+ <path d="M0-.5h24v24H0z" fill="none"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/>
3
+ <path d="M0-.25h24v24H0z" fill="none"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/>
3
+ <path d="M0 0h24v24H0z" fill="none"/>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0 0h24v24H0z" fill="none"/>
3
+ <path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
4
+ </svg>
@@ -0,0 +1,753 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Warning: This file is auto-generated, do not modify. Instead, make your changes in 'app/javascript/activeadmin_addons/' and run `yarn build`
4
+ */
5
+ //= require select2.full
6
+ //= require jquery.xdan.datetimepicker.full
7
+
8
+ (function(factory) {
9
+ typeof define === "function" && define.amd ? define([ "select2", "jquery-datetimepicker" ], factory) : factory();
10
+ })(function() {
11
+ "use strict";
12
+ (function($) {
13
+ $.paletteColorPicker = function(el, options) {
14
+ var ns = "palette-color-picker", $el = $(el), plugin = this, current_value = $el.val(), target = $el.attr("name"), $button = $("<div>").addClass(ns + "-button").attr("data-target", target), $bubble = $("<div>").addClass(ns + "-bubble"), defaults = {
15
+ custom_class: null,
16
+ colors: null,
17
+ position: "upside",
18
+ insert: "before",
19
+ clear_btn: "first",
20
+ timeout: 2e3,
21
+ set_background: false,
22
+ close_all_but_this: false
23
+ }, click_handler = "ontouchstart" in document.documentElement ? "touchstart click" : "click";
24
+ plugin.init = function() {
25
+ plugin.settings = $.extend({}, defaults, options);
26
+ var val = $el.attr("value");
27
+ if (typeof val === typeof undefined || val === false) {
28
+ val = "";
29
+ $el.attr("value", val);
30
+ }
31
+ $el.attr("data-initialvalue", $el.attr("value"));
32
+ if (plugin.settings.colors === null) {
33
+ plugin.settings.colors = $el.data("palette");
34
+ }
35
+ if (typeof plugin.settings.colors[0] === "string") {
36
+ plugin.settings.colors = $.map(plugin.settings.colors, function(el, idx) {
37
+ var b = {};
38
+ b[el] = el;
39
+ return b;
40
+ });
41
+ }
42
+ plugin.settings.insert = plugin.settings.insert.charAt(0).toUpperCase() + plugin.settings.insert.slice(1);
43
+ if (plugin.settings.custom_class) {
44
+ $bubble.addClass(plugin.settings.custom_class);
45
+ }
46
+ $.each(plugin.settings.colors, function(idx, obj) {
47
+ var key = Object.keys(obj)[0], col = obj[key], $sw = $("<span>").addClass("swatch").attr({
48
+ title: key,
49
+ "data-color": col,
50
+ "data-name": key
51
+ }).css("background-color", col);
52
+ if (key === current_value) {
53
+ $sw.addClass("active");
54
+ $button.css("background", col);
55
+ }
56
+ $sw.appendTo($bubble);
57
+ });
58
+ if (plugin.settings.clear_btn !== null) {
59
+ var $clear_btn = $("<span>").addClass("swatch clear").attr("title", "Clear selection");
60
+ if (plugin.settings.clear_btn === "last") {
61
+ $clear_btn.addClass("last").appendTo($bubble);
62
+ } else {
63
+ $clear_btn.prependTo($bubble);
64
+ }
65
+ }
66
+ plugin.destroy = function() {
67
+ $button.remove();
68
+ $.removeData($el[0]);
69
+ };
70
+ plugin.clear = function() {
71
+ $bubble.find(".active").removeClass("active");
72
+ $button.removeAttr("style");
73
+ $el.val("");
74
+ };
75
+ plugin.reset = function() {
76
+ if ($el.attr("data-initialvalue") === "") {
77
+ plugin.clear();
78
+ } else {
79
+ var iv = $el.attr("data-initialvalue");
80
+ $bubble.find('[data-name="' + iv + '"]').trigger("click");
81
+ }
82
+ };
83
+ plugin.reload = function() {
84
+ var newVal = $el.val();
85
+ if (newVal === "" || typeof newVal === typeof undefined || newVal === false) {
86
+ plugin.reset();
87
+ } else {
88
+ if ($bubble.find('[data-name="' + newVal + '"]').length) {
89
+ $bubble.find('[data-name="' + newVal + '"]').trigger("click");
90
+ } else {
91
+ plugin.reset();
92
+ }
93
+ }
94
+ };
95
+ $button.append($bubble).on(click_handler, function(e) {
96
+ e.preventDefault();
97
+ e.stopPropagation();
98
+ var $b = $(this);
99
+ if (!$(e.target).hasClass(ns + "-bubble")) {
100
+ if (typeof plugin.settings.onbeforeshow_callback === "function") {
101
+ plugin.settings.onbeforeshow_callback(this);
102
+ }
103
+ $b.toggleClass("active");
104
+ var $current_bubble = $b.find("." + ns + "-bubble");
105
+ if (plugin.settings.close_all_but_this) {
106
+ $("." + ns + "-bubble").not($current_bubble).fadeOut();
107
+ }
108
+ $current_bubble.fadeToggle();
109
+ if ($b.hasClass("active")) {
110
+ clearTimeout(plugin.timer);
111
+ plugin.timer = setTimeout(function() {
112
+ $b.trigger("pcp.fadeout");
113
+ }, plugin.settings.timeout);
114
+ }
115
+ }
116
+ }).on("pcp.fadeout", function() {
117
+ $(this).removeClass("active").find("." + ns + "-bubble").fadeOut();
118
+ }).on("mouseenter", "." + ns + "-bubble", function() {
119
+ clearTimeout(plugin.timer);
120
+ }).on("mouseleave", "." + ns + "-bubble", function() {
121
+ plugin.timer = setTimeout(function() {
122
+ $button.trigger("pcp.fadeout");
123
+ }, plugin.settings.timeout);
124
+ }).on(click_handler, "." + ns + "-bubble span.swatch", function(e) {
125
+ e.preventDefault();
126
+ e.stopPropagation();
127
+ var col = $(this).attr("data-color"), name = $(this).attr("data-name"), $button = $("." + ns + '-button[data-target="' + $(this).closest("." + ns + "-button").attr("data-target") + '"]'), $bubble = $(this).closest("." + ns + "-bubble");
128
+ $bubble.find(".active").removeClass("active");
129
+ if ($(e.target).is(".clear")) {
130
+ $button.removeAttr("style");
131
+ col = "";
132
+ } else {
133
+ $(this).addClass("active");
134
+ $button.css("background", col);
135
+ }
136
+ if (typeof plugin.settings.onchange_callback === "function") {
137
+ plugin.settings.onchange_callback(col);
138
+ }
139
+ if (plugin.settings.set_background === false) {
140
+ $('[name="' + $button.attr("data-target") + '"]').val(name);
141
+ } else {
142
+ $('[name="' + $button.attr("data-target") + '"]').css({
143
+ "background-color": col
144
+ });
145
+ }
146
+ })["insert" + plugin.settings.insert]($el);
147
+ if (plugin.settings.position === "downside" || $el.offset().top + 20 < $bubble.outerHeight()) {
148
+ $bubble.addClass("downside");
149
+ }
150
+ };
151
+ $("body").on(click_handler, function(event) {
152
+ if (!$(event.target).hasClass(ns + "-button")) {
153
+ $($button).removeClass("active").find("." + ns + "-bubble").fadeOut();
154
+ }
155
+ });
156
+ plugin.init();
157
+ };
158
+ $.fn.paletteColorPicker = function(options) {
159
+ return this.each(function() {
160
+ if (typeof $(this).data("paletteColorPickerPlugin") === "undefined") {
161
+ $(this).data("paletteColorPickerPlugin", new $.paletteColorPicker(this, options));
162
+ }
163
+ });
164
+ };
165
+ })(jQuery);
166
+ var initializer = function() {
167
+ window.ActiveadminAddons = {
168
+ config: {
169
+ defaultSelect: $("body").data("default-select")
170
+ }
171
+ };
172
+ };
173
+ $(initializer);
174
+ $(document).on("turbolinks:load", initializer);
175
+ var initializer$1 = function() {
176
+ configureSelect2(document);
177
+ $(document).on("has_many_add:after", function(event, container) {
178
+ configureSelect2(container);
179
+ });
180
+ function configureSelect2(container) {
181
+ if (window.ActiveadminAddons.config.defaultSelect == "select2") {
182
+ $("select:not(.default-select)", container).each(function(i, el) {
183
+ setupSelect2(el);
184
+ });
185
+ }
186
+ $("select.select2", container).each(function(i, el) {
187
+ setupSelect2(el);
188
+ });
189
+ function setupSelect2(select) {
190
+ var selectConfig = {
191
+ placeholder: "",
192
+ width: "80%",
193
+ allowClear: true
194
+ };
195
+ function isFilter(path) {
196
+ return $(select).closest(path).length > 0;
197
+ }
198
+ if (isFilter(".select_and_search")) {
199
+ selectConfig.width = "resolve";
200
+ selectConfig.allowClear = false;
201
+ } else if (isFilter(".filter_select")) {
202
+ selectConfig.width = "resolve";
203
+ }
204
+ $(select).select2(selectConfig);
205
+ $(select).on("select2:unselecting", function() {
206
+ $(this).data("unselecting", true);
207
+ }).on("select2:open", function() {
208
+ if ($(this).data("unselecting")) {
209
+ $(this).select2("close").removeData("unselecting");
210
+ }
211
+ });
212
+ }
213
+ }
214
+ };
215
+ $(initializer$1);
216
+ $(document).on("turbolinks:load", initializer$1);
217
+ var initializer$2 = function() {
218
+ setupSearchSelect(document);
219
+ $(document).on("has_many_add:after", function(event, container) {
220
+ setupSearchSelect(container);
221
+ });
222
+ function setupSearchSelect(container) {
223
+ $(".search-select-input, .search-select-filter-input, ajax-filter-input", container).each(function(i, el) {
224
+ var element = $(el);
225
+ var url = element.data("url");
226
+ var fields = element.data("fields");
227
+ var predicate = element.data("predicate");
228
+ var displayName = element.data("display-name");
229
+ var width = element.data("width");
230
+ var responseRoot = element.data("response-root");
231
+ var minimumInputLength = element.data("minimum-input-length");
232
+ var order = element.data("order");
233
+ var selectOptions = {
234
+ width: width,
235
+ minimumInputLength: minimumInputLength,
236
+ placeholder: "",
237
+ allowClear: true,
238
+ ajax: {
239
+ url: url,
240
+ dataType: "json",
241
+ delay: 250,
242
+ cache: true,
243
+ data: function(params) {
244
+ var textQuery = {
245
+ m: "or"
246
+ };
247
+ fields.forEach(function(field) {
248
+ if (field == "id") {
249
+ textQuery[field + "_eq"] = params.term;
250
+ } else {
251
+ textQuery[field + "_" + predicate] = params.term;
252
+ }
253
+ });
254
+ var query = {
255
+ order: order,
256
+ q: {
257
+ groupings: [ textQuery ],
258
+ combinator: "and"
259
+ }
260
+ };
261
+ return query;
262
+ },
263
+ processResults: function(data) {
264
+ if (data.constructor == Object) {
265
+ data = data[responseRoot];
266
+ }
267
+ return {
268
+ results: jQuery.map(data, function(resource) {
269
+ if (!resource[displayName]) {
270
+ resource[displayName] = "No display name for id #" + resource.id.toString();
271
+ }
272
+ return {
273
+ id: resource.id,
274
+ text: resource[displayName].toString()
275
+ };
276
+ })
277
+ };
278
+ }
279
+ }
280
+ };
281
+ $(el).select2(selectOptions);
282
+ });
283
+ }
284
+ };
285
+ $(initializer$2);
286
+ $(document).on("turbolinks:load", initializer$2);
287
+ $.fn.select2.amd.define("select2/data/nestedCustomAdapter", [ "select2/data/array", "select2/utils" ], function(ArrayData, Utils) {
288
+ function CustomData($element, options) {
289
+ CustomData.__super__.constructor.call(this, $element, options);
290
+ }
291
+ Utils.Extend(CustomData, ArrayData);
292
+ CustomData.prototype.query = function(params, callback) {
293
+ var data = {
294
+ results: []
295
+ };
296
+ var element = this.$element;
297
+ var collection = element.data("collection");
298
+ var parent = element.data("parent");
299
+ var parentId = element.data("parent-id");
300
+ collection.forEach(function(record) {
301
+ var regex = new RegExp(params.term, "i");
302
+ var matched = !!record.text.match(regex);
303
+ if ((!parent || record[parent] == parentId) && matched) {
304
+ data.results.push(record);
305
+ }
306
+ });
307
+ callback(data);
308
+ };
309
+ CustomData.prototype.current = function(callback) {
310
+ var currentOption = null;
311
+ var element = this.$element;
312
+ var selectedOption = element.data("selected");
313
+ var collection = element.data("collection");
314
+ var data = [];
315
+ $.each(collection, function(index, option) {
316
+ if (!!selectedOption && option.id == selectedOption.id) {
317
+ currentOption = option;
318
+ element.data("selected", null);
319
+ return;
320
+ }
321
+ if (element.val() == option.id) {
322
+ currentOption = option;
323
+ return;
324
+ }
325
+ });
326
+ if (currentOption) {
327
+ data.push(currentOption);
328
+ }
329
+ callback(data);
330
+ };
331
+ return CustomData;
332
+ });
333
+ var initializer$3 = function() {
334
+ configureSelect2(document);
335
+ $(document).on("has_many_add:after", function(event, container) {
336
+ configureSelect2(container);
337
+ });
338
+ function configureSelect2(container) {
339
+ var INVALID_PARENT_ID = -1;
340
+ $(".nested-level-input", container).each(function(i, el) {
341
+ var element = $(el);
342
+ var url = element.data("url");
343
+ var fields = element.data("fields");
344
+ var predicate = element.data("predicate");
345
+ var filters = element.data("filters");
346
+ var displayName = element.data("display-name");
347
+ var parent = element.data("parent");
348
+ var width = element.data("width");
349
+ var model = element.data("model");
350
+ var responseRoot = element.data("response-root");
351
+ var collection = element.data("collection");
352
+ var minimumInputLength = element.data("minimum-input-length");
353
+ var order = element.data("order");
354
+ var parentId = element.data("parent-id");
355
+ var selectInstance;
356
+ var select2Config = {
357
+ width: width,
358
+ minimumInputLength: minimumInputLength,
359
+ placeholder: "",
360
+ allowClear: true
361
+ };
362
+ if (collection) {
363
+ select2Config.dataAdapter = $.fn.select2.amd.require("select2/data/nestedCustomAdapter");
364
+ } else {
365
+ var ajaxConfig = {
366
+ url: url,
367
+ dataType: "json",
368
+ delay: 250,
369
+ cache: true,
370
+ data: function(params) {
371
+ var textQuery = {
372
+ m: "or"
373
+ };
374
+ fields.forEach(function(field) {
375
+ if (field == "id") {
376
+ textQuery[field + "_eq"] = params.term;
377
+ } else {
378
+ textQuery[field + "_" + predicate] = params.term;
379
+ }
380
+ });
381
+ var query = {
382
+ order: order,
383
+ q: {
384
+ groupings: [ textQuery ],
385
+ combinator: "and"
386
+ }
387
+ };
388
+ if (!!parent) {
389
+ query.q[parent + "_eq"] = parentId;
390
+ }
391
+ Object.assign(query.q, filters);
392
+ return query;
393
+ },
394
+ processResults: function(data) {
395
+ if (data.constructor == Object) {
396
+ data = data[responseRoot];
397
+ }
398
+ return {
399
+ results: jQuery.map(data, function(resource) {
400
+ if (!resource[displayName]) {
401
+ resource[displayName] = "No display name for id #" + resource.id.toString();
402
+ }
403
+ return {
404
+ id: resource.id,
405
+ text: resource[displayName].toString()
406
+ };
407
+ })
408
+ };
409
+ }
410
+ };
411
+ select2Config.ajax = ajaxConfig;
412
+ }
413
+ selectInstance = element.select2(select2Config);
414
+ function setParentValue(e) {
415
+ selectInstance.val(null).trigger("select2:select").trigger("change");
416
+ parentId = e.params && e.params.data.id ? e.params.data.id : INVALID_PARENT_ID;
417
+ element.data("parent-id", parentId);
418
+ }
419
+ if (!!parent) {
420
+ var parentSelectorId = "#" + model + "_" + parent;
421
+ if (!$(parentSelectorId).length) {
422
+ parentSelectorId = $(container).find("*[id*=" + parent + "]")[0];
423
+ }
424
+ var parentSelector = $(parentSelectorId)[0];
425
+ $(parentSelector).on("select2:select", setParentValue);
426
+ $(parentSelector).on("select2:unselect", setParentValue);
427
+ }
428
+ });
429
+ }
430
+ };
431
+ $(initializer$3);
432
+ $(document).on("turbolinks:load", initializer$3);
433
+ var initializer$4 = function() {
434
+ setupTags(document);
435
+ $(document).on("has_many_add:after", function(event, container) {
436
+ setupTags(container);
437
+ });
438
+ function setupTags(container) {
439
+ $(".tags-input", container).each(function(i, el) {
440
+ var model = $(el).data("model");
441
+ var method = $(el).data("method");
442
+ var prefix = model + "_" + method;
443
+ var isRelation = !!$(el).data("relation");
444
+ var collection = $(el).data("collection");
445
+ var width = $(el).data("width");
446
+ var selectOptions = {
447
+ width: width,
448
+ multiple: true,
449
+ tags: true,
450
+ data: collection
451
+ };
452
+ if (!!isRelation) {
453
+ selectOptions.createTag = function() {
454
+ return undefined;
455
+ };
456
+ }
457
+ $(el).on("select2:select", onItemAdded);
458
+ $(el).on("select2:unselect", onItemRemoved);
459
+ $(el).select2(selectOptions);
460
+ function getSelectedItems() {
461
+ var choices = $(el).parent("li.input").find(".select2-selection__choice");
462
+ return $.map(choices, function(item) {
463
+ return $(item).attr("title");
464
+ });
465
+ }
466
+ function fillHiddenInput() {
467
+ var hiddenInput = $("#" + prefix);
468
+ hiddenInput.val(getSelectedItems().join());
469
+ }
470
+ function onItemRemoved(event) {
471
+ if (isRelation) {
472
+ var itemId = "[id='" + prefix + "_" + event.params.data.id + "']";
473
+ $(itemId).remove();
474
+ } else {
475
+ fillHiddenInput();
476
+ }
477
+ }
478
+ function onItemAdded(event) {
479
+ if (isRelation) {
480
+ var value = event.params.data.id;
481
+ var selectedItemsContainer = $("[id='" + prefix + "_selected_values']");
482
+ var itemName = model + "[" + method + "][]";
483
+ var itemId = prefix + "_" + value;
484
+ $("<input>").attr({
485
+ id: itemId,
486
+ name: itemName,
487
+ type: "hidden",
488
+ value: value
489
+ }).appendTo(selectedItemsContainer);
490
+ } else {
491
+ fillHiddenInput();
492
+ }
493
+ }
494
+ });
495
+ }
496
+ };
497
+ $(initializer$4);
498
+ $(document).on("turbolinks:load", initializer$4);
499
+ var initializer$5 = function() {
500
+ setupSelectedList(document);
501
+ $(document).on("has_many_add:after", function(event, container) {
502
+ setupSelectedList(container);
503
+ });
504
+ function setupSelectedList(container) {
505
+ $(".selected-list-container").click(function(event) {
506
+ var item = $(event.target);
507
+ if (item.hasClass("selected-item")) {
508
+ item.remove();
509
+ }
510
+ });
511
+ $(".selected-list-input", container).each(function(i, el) {
512
+ var element = $(el);
513
+ var url = element.data("url");
514
+ var fields = element.data("fields");
515
+ var predicate = element.data("predicate");
516
+ var displayName = element.data("display-name");
517
+ var method = element.data("method");
518
+ var model = element.data("model");
519
+ var prefix = model + "_" + method;
520
+ var responseRoot = element.data("response-root");
521
+ var minimumInputLength = element.data("minimum-input-length");
522
+ var order = element.data("order");
523
+ var selectOptions = {
524
+ minimumInputLength: minimumInputLength,
525
+ allowClear: true,
526
+ ajax: {
527
+ url: url,
528
+ dataType: "json",
529
+ delay: 250,
530
+ cache: true,
531
+ data: function(params) {
532
+ var textQuery = {
533
+ m: "or"
534
+ };
535
+ fields.forEach(function(field) {
536
+ textQuery[field + "_" + predicate] = params.term;
537
+ });
538
+ var query = {
539
+ order: order,
540
+ q: {
541
+ groupings: [ textQuery ],
542
+ combinator: "and"
543
+ }
544
+ };
545
+ return query;
546
+ },
547
+ processResults: function(data) {
548
+ if (data.constructor == Object) {
549
+ data = data[responseRoot];
550
+ }
551
+ return {
552
+ results: jQuery.map(data, function(resource) {
553
+ return {
554
+ id: resource.id,
555
+ text: resource[displayName].toString()
556
+ };
557
+ })
558
+ };
559
+ }
560
+ }
561
+ };
562
+ $(el).on("select2:select", onItemSelected);
563
+ $(el).on("select2:close", onSelectClosed);
564
+ $(el).select2(selectOptions);
565
+ function onItemSelected(event) {
566
+ var data = event.params.data;
567
+ var selectedItemsContainer = $("[id='" + prefix + "_selected_values']");
568
+ var itemName = model + "[" + method + "][]";
569
+ var itemId = prefix + "_" + data.id;
570
+ if ($("#" + itemId).length > 0) {
571
+ return;
572
+ }
573
+ var item = $("<div>" + data.text + "</div>").attr({
574
+ class: "selected-item",
575
+ id: itemId
576
+ });
577
+ var hiddenInput = $("<input>").attr({
578
+ name: itemName,
579
+ type: "hidden",
580
+ value: data.id
581
+ });
582
+ item.appendTo(selectedItemsContainer);
583
+ hiddenInput.appendTo(item);
584
+ }
585
+ function onSelectClosed() {
586
+ $(el).val(null).trigger("change");
587
+ }
588
+ });
589
+ }
590
+ };
591
+ $(initializer$5);
592
+ $(document).on("turbolinks:load", initializer$5);
593
+ var initializer$6 = function() {
594
+ setupDateTimePicker(document);
595
+ $(document).on("has_many_add:after", ".has_many_container", function(event, fieldset) {
596
+ return setupDateTimePicker(fieldset);
597
+ });
598
+ function setupDateTimePicker(container) {
599
+ var defaults = {
600
+ formatDate: "y-m-d",
601
+ format: "Y-m-d H:i",
602
+ allowBlank: true,
603
+ defaultSelect: false,
604
+ validateOnBlur: false,
605
+ scrollInput: false
606
+ };
607
+ var entries = $(container).find("input.date-time-picker-input");
608
+ return entries.each(function(index, entry) {
609
+ var options = $(entry).data("picker-options");
610
+ var mixedOptions = $.extend(defaults, options);
611
+ return $(entry).datetimepicker(mixedOptions);
612
+ });
613
+ }
614
+ };
615
+ $(initializer$6);
616
+ $(document).on("turbolinks:load", initializer$6);
617
+ var initializer$7 = function() {
618
+ setupColorPicker();
619
+ $(document).on("has_many_add:after", setupColorPicker);
620
+ function setupColorPicker() {
621
+ $(".color-picker-input").each(function(i, el) {
622
+ $(el).paletteColorPicker({
623
+ clear_btn: "last"
624
+ });
625
+ });
626
+ }
627
+ };
628
+ $(initializer$7);
629
+ $(document).on("turbolinks:load", initializer$7);
630
+ var initializer$8 = function() {
631
+ $(".toggle-bool-switch").click(function(e) {
632
+ var boolSwitch = $(e.target);
633
+ var objectId = boolSwitch.data("object_id");
634
+ var model = boolSwitch.data("model");
635
+ var field = boolSwitch.data("field");
636
+ var url = boolSwitch.data("url");
637
+ var value = boolSwitch.data("value");
638
+ var successMessage = boolSwitch.data("success_message");
639
+ var data = {
640
+ id: objectId
641
+ };
642
+ data[model] = {};
643
+ data[model][field] = !value;
644
+ $.ajax({
645
+ url: url,
646
+ data: data,
647
+ dataType: "json",
648
+ headers: {
649
+ "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content")
650
+ },
651
+ error: function() {
652
+ var errorMsg = "Error: Update Unsuccessful";
653
+ alert(errorMsg);
654
+ },
655
+ success: function() {
656
+ boolSwitch.data("value", !value);
657
+ boolSwitch.toggleClass("on");
658
+ if (!boolSwitch.hasClass("notify-success")) return;
659
+ $(function() {
660
+ setTimeout(alert(successMessage), 500);
661
+ });
662
+ },
663
+ type: "PATCH"
664
+ });
665
+ });
666
+ };
667
+ $(initializer$8);
668
+ $(document).on("turbolinks:load", initializer$8);
669
+ var initializer$9 = function() {
670
+ configureInteractiveSelect(document);
671
+ $(document).on("has_many_add:after", function(event, container) {
672
+ configureInteractiveSelect(container);
673
+ });
674
+ function configureInteractiveSelect(container) {
675
+ $(".interactive-tag-select select", container).each(function(i, el) {
676
+ setupSelect2(el);
677
+ });
678
+ function setupSelect2(select) {
679
+ var selectConfig = {
680
+ placeholder: "",
681
+ allowClear: false,
682
+ width: "125px"
683
+ };
684
+ $(select).select2(selectConfig);
685
+ $(select).on("select2:unselecting", function() {
686
+ $(this).data("unselecting", true);
687
+ }).on("select2:open", function() {
688
+ if ($(this).data("unselecting")) {
689
+ $(this).select2("close").removeData("unselecting");
690
+ }
691
+ });
692
+ }
693
+ }
694
+ $(".interactive-tag").click(function(e) {
695
+ var tag = $(e.target).parent();
696
+ var model = tag.data("model");
697
+ var objectId = tag.data("object_id");
698
+ var field = tag.data("field");
699
+ var selectTag = $("." + model + "-" + field + "-" + objectId + "-select");
700
+ selectTag.removeClass("select-container-hidden");
701
+ tag.addClass("interactive-tag-hidden");
702
+ selectTag.find("select").select2("open");
703
+ });
704
+ $(".interactive-tag-select").on("select2:close", function(e) {
705
+ var selectTag = $(e.target).parent();
706
+ var model = selectTag.data("model");
707
+ var objectId = selectTag.data("object_id");
708
+ var field = selectTag.data("field");
709
+ var tagContainer = $("." + model + "-" + field + "-" + objectId + "-tag");
710
+ var statusTag = tagContainer.find(".status_tag");
711
+ var newValue = e.target.value;
712
+ var newText = e.target.selectedOptions[0].text;
713
+ var oldValue = selectTag.data("value");
714
+ if (newValue === oldValue) {
715
+ selectTag.addClass("select-container-hidden");
716
+ tagContainer.removeClass("interactive-tag-hidden");
717
+ } else {
718
+ var url = tagContainer.data("url");
719
+ var data = {
720
+ id: objectId
721
+ };
722
+ data[model] = {};
723
+ data[model][field] = newValue;
724
+ $.ajax({
725
+ url: url,
726
+ data: data,
727
+ dataType: "json",
728
+ headers: {
729
+ "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content")
730
+ },
731
+ error: function() {
732
+ var errorMsg = "Error: Update Unsuccessful";
733
+ console.log(errorMsg);
734
+ },
735
+ success: function() {
736
+ statusTag.text(newText);
737
+ statusTag.removeClass(oldValue);
738
+ statusTag.addClass(newValue);
739
+ tagContainer.data("value", newValue);
740
+ selectTag.data("value", newValue);
741
+ },
742
+ complete: function() {
743
+ selectTag.addClass("select-container-hidden");
744
+ tagContainer.removeClass("interactive-tag-hidden");
745
+ },
746
+ type: "PATCH"
747
+ });
748
+ }
749
+ });
750
+ };
751
+ $(initializer$9);
752
+ $(document).on("turbolinks:load", initializer$9);
753
+ });