formagic 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/CONTRIBUTING.md +24 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.md +21 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/app/assets/images/datedropper/done.png +0 -0
  9. data/app/assets/images/datedropper/done.svg +1 -0
  10. data/app/assets/images/datedropper/next.png +0 -0
  11. data/app/assets/images/datedropper/next.svg +1 -0
  12. data/app/assets/images/datedropper/prev.png +0 -0
  13. data/app/assets/images/datedropper/prev.svg +1 -0
  14. data/app/assets/javascripts/formagic/form.coffee +229 -0
  15. data/app/assets/javascripts/formagic/group.coffee +28 -0
  16. data/app/assets/javascripts/formagic/inputs/checkbox.coffee +83 -0
  17. data/app/assets/javascripts/formagic/inputs/color.coffee +55 -0
  18. data/app/assets/javascripts/formagic/inputs/date.coffee +69 -0
  19. data/app/assets/javascripts/formagic/inputs/datetime.coffee +130 -0
  20. data/app/assets/javascripts/formagic/inputs/document.coffee +0 -0
  21. data/app/assets/javascripts/formagic/inputs/documents.coffee +173 -0
  22. data/app/assets/javascripts/formagic/inputs/documents_reorder.coffee +67 -0
  23. data/app/assets/javascripts/formagic/inputs/file.coffee +114 -0
  24. data/app/assets/javascripts/formagic/inputs/hidden.coffee +57 -0
  25. data/app/assets/javascripts/formagic/inputs/html.coffee +81 -0
  26. data/app/assets/javascripts/formagic/inputs/image.coffee +28 -0
  27. data/app/assets/javascripts/formagic/inputs/list.coffee +154 -0
  28. data/app/assets/javascripts/formagic/inputs/list_reorder.coffee +39 -0
  29. data/app/assets/javascripts/formagic/inputs/list_typeahead.coffee +55 -0
  30. data/app/assets/javascripts/formagic/inputs/markdown.coffee +93 -0
  31. data/app/assets/javascripts/formagic/inputs/password.coffee +32 -0
  32. data/app/assets/javascripts/formagic/inputs/redactor.coffee +53 -0
  33. data/app/assets/javascripts/formagic/inputs/redactor_character.coffee +75 -0
  34. data/app/assets/javascripts/formagic/inputs/redactor_images.coffee +166 -0
  35. data/app/assets/javascripts/formagic/inputs/select.coffee +84 -0
  36. data/app/assets/javascripts/formagic/inputs/select2.coffee +33 -0
  37. data/app/assets/javascripts/formagic/inputs/string.coffee +160 -0
  38. data/app/assets/javascripts/formagic/inputs/text.coffee +43 -0
  39. data/app/assets/javascripts/formagic/inputs/time.coffee +0 -0
  40. data/app/assets/javascripts/formagic.coffee +22 -0
  41. data/app/assets/javascripts/vendor/ace.js +18280 -0
  42. data/app/assets/javascripts/vendor/datedropper.js +1005 -0
  43. data/app/assets/javascripts/vendor/jquery.scrollparent.js +14 -0
  44. data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +55 -0
  45. data/app/assets/javascripts/vendor/jquery.typeahead.js +1782 -0
  46. data/app/assets/javascripts/vendor/marked.js +1272 -0
  47. data/app/assets/javascripts/vendor/mode-html.js +2436 -0
  48. data/app/assets/javascripts/vendor/mode-markdown.js +2820 -0
  49. data/app/assets/javascripts/vendor/moment.js +3083 -0
  50. data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +107 -0
  51. data/app/assets/javascripts/vendor/select2.js +5274 -0
  52. data/app/assets/stylesheets/formagic/checkbox.scss +8 -0
  53. data/app/assets/stylesheets/formagic/color.scss +12 -0
  54. data/app/assets/stylesheets/formagic/date.scss +37 -0
  55. data/app/assets/stylesheets/formagic/file.scss +29 -0
  56. data/app/assets/stylesheets/formagic/form.scss +36 -0
  57. data/app/assets/stylesheets/formagic/group.scss +22 -0
  58. data/app/assets/stylesheets/formagic/image.scss +19 -0
  59. data/app/assets/stylesheets/formagic/list.scss +39 -0
  60. data/app/assets/stylesheets/formagic/nested-form.scss +23 -0
  61. data/app/assets/stylesheets/formagic/redactor.scss +41 -0
  62. data/app/assets/stylesheets/formagic/select.scss +5 -0
  63. data/app/assets/stylesheets/formagic/select2.scss +95 -0
  64. data/app/assets/stylesheets/formagic/string.scss +14 -0
  65. data/app/assets/stylesheets/formagic/switch.scss +86 -0
  66. data/app/assets/stylesheets/formagic/text.scss +9 -0
  67. data/app/assets/stylesheets/formagic.scss +15 -0
  68. data/app/assets/stylesheets/vendor/datedropper.scss +523 -0
  69. data/app/assets/stylesheets/vendor/select2.scss +258 -0
  70. data/formagic.gemspec +30 -0
  71. data/lib/formagic/engine.rb +5 -0
  72. data/lib/formagic/version.rb +3 -0
  73. data/lib/formagic.rb +5 -0
  74. metadata +146 -0
@@ -0,0 +1,107 @@
1
+ /*
2
+ * webhook-redactor
3
+ *
4
+ *
5
+ * Copyright (c) 2014 Webhook
6
+ * Licensed under the MIT license.
7
+ */
8
+
9
+ (function ($) {
10
+ "use strict";
11
+
12
+ // namespacing
13
+ var Fixedtoolbar = function (redactor) {
14
+ this.redactor = redactor;
15
+ this.$window = $('.content:visible'); //$(window);
16
+ this.viewHeaderHeight = 40;
17
+
18
+ this.$window.on('scroll', $.proxy(this.checkOffset, this));
19
+ redactor.$box.on('scroll', $.proxy(this.checkOffset, this));
20
+
21
+ this.redactor.$editor.on('focus', $.proxy(function () {
22
+ this.isFocused = true;
23
+ }, this));
24
+
25
+ this.redactor.$editor.on('blur', $.proxy(function () {
26
+ this.isFocused = false;
27
+ }, this));
28
+ };
29
+ Fixedtoolbar.prototype = {
30
+ isFixed: false,
31
+ isFocused: false,
32
+
33
+ checkOffset: function () {
34
+ var boxOffset = this.redactor.$box.offset();
35
+
36
+ var isBelowBoxTop = boxOffset.top - this.viewHeaderHeight <= 0;
37
+ //var isAboveBoxBottom = boxOffset.top + this.redactor.$box.outerHeight() - this.redactor.$toolbar.outerHeight() - this.$window.scrollTop() >= 0;
38
+ var isAboveBoxBottom = this.redactor.$box.outerHeight() + boxOffset.top - this.viewHeaderHeight - this.redactor.$toolbar.outerHeight() >= 0;
39
+
40
+ if (isBelowBoxTop && isAboveBoxBottom) {
41
+ this.fix();
42
+ } else {
43
+ this.unfix();
44
+ }
45
+ },
46
+
47
+ fix: function () {
48
+
49
+ if (this.isFixed) {
50
+
51
+ // webkit does not recalc top: 0 when focused on contenteditable
52
+ if (this.redactor.utils.isMobile() && this.isFocused) {
53
+ this.redactor.$toolbar.css({
54
+ position: 'absolute',
55
+ top : this.$window.scrollTop() - this.redactor.$box.offset().top,
56
+ left : this.redactor.$box.offset().left
57
+ });
58
+ }
59
+
60
+ return;
61
+ }
62
+
63
+ var border_left = parseInt(this.redactor.$box.css('border-left-width').replace('px', ''), 10);
64
+
65
+ this.redactor.$toolbar.css({
66
+ position: 'fixed',
67
+ top : this.viewHeaderHeight,
68
+ left : this.redactor.$box.offset().left + border_left,
69
+ width : this.redactor.$box.width(),
70
+ zIndex : 300
71
+ });
72
+
73
+ this.redactor.$editor.css('padding-top', this.redactor.$toolbar.height() + 10);
74
+
75
+ this.isFixed = true;
76
+
77
+ },
78
+
79
+ unfix: function () {
80
+ if (!this.isFixed) {
81
+ return;
82
+ }
83
+
84
+ this.redactor.$toolbar.css({
85
+ position: 'relative',
86
+ left : '',
87
+ width : '',
88
+ top : ''
89
+ });
90
+
91
+ this.redactor.$editor.css('padding-top', 10);
92
+
93
+ this.isFixed = false;
94
+ }
95
+ };
96
+
97
+ // Hook up plugin to Redactor.
98
+ window.RedactorPlugins = window.RedactorPlugins || {};
99
+ window.RedactorPlugins.fixedtoolbar = function() {
100
+ return {
101
+ init: function () {
102
+ this.fixedtoolbar = new Fixedtoolbar(this);
103
+ }
104
+ };
105
+ };
106
+
107
+ }(jQuery));