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,8 @@
1
+ // checkbox
2
+
3
+ .form {
4
+ .input-checkbox { padding: .8em 1em 1em;
5
+ input { display: inline; width: auto; margin-right: .5em; }
6
+ .label { display: inline; cursor: pointer; }
7
+ }
8
+ }
@@ -0,0 +1,12 @@
1
+ // color
2
+
3
+ .form {
4
+ .input-color {
5
+ position: relative; padding-left: 4.75em;
6
+
7
+ .preview {
8
+ @include position(absolute, .65em null null 1em);
9
+ width: 50px; height: 50px; border-radius: 4px; background-color: #eee;
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,37 @@
1
+ // date
2
+
3
+ @import "vendor/datedropper";
4
+
5
+ .form .input-stacked input.input-datetime-date {
6
+ @include position(absolute); width: 7em; opacity: .0; cursor: pointer;
7
+ }
8
+
9
+ .form .input-stacked input.input-datetime-time { width: auto; display: inline-block; }
10
+
11
+ .input-date-label { display: inline-block; min-width: 7em; cursor: pointer; }
12
+ .input-timedate-at { color: $stableColor; margin: 0 .25em; }
13
+
14
+ .dd_ .dd_sw_ .dd_nav_.dd_prev_ { background-image: image-url('datedropper/prev.png'); }
15
+ .dd_ .dd_sw_ .dd_nav_.dd_next_ { background-image: image-url('datedropper/next.png'); }
16
+ .dd_ .dd_submit { background-image: image-url('datedropper/done.png'); }
17
+
18
+ .dd_ { border: 0; }
19
+ .dd_:after {
20
+ top: -6px!important;
21
+ border-left: 1px solid $contrastColor!important;
22
+ border-top: 1px solid $contrastColor !important;
23
+ }
24
+
25
+ .dd_ .dd_m_ { font-size: 16px; }
26
+ .dd_ .dd_d_ { font-size: 38px; border-color: $neutralColor; }
27
+ .dd_ .dd_d_ .dd_sl_ ul li em { color: $stableColor!important; font-size: 13px; bottom: 4px; }
28
+ .dd_ .dd_d_ .dd_sl_ ul li.dd_sunday { color: $assertiveColor!important; }
29
+ .dd_ .dd_sw_ .dd_sl_ li:hover { background-color: $neutralColor; }
30
+
31
+ .dd_ .dd_m_ {
32
+ border-top-left-radius: 4px!important;
33
+ border-top-right-radius: 4px!important;
34
+ }
35
+
36
+ .dd_r_ { display: none; }
37
+ .dd_ .dd_submit { background-color: $positiveColor!important; }
@@ -0,0 +1,29 @@
1
+ // file
2
+
3
+ .form {
4
+
5
+ // calculated based on image thumbnail size
6
+
7
+ .input-file { min-height: 102px;
8
+
9
+ a { color: $positiveColor; @include truncate; }
10
+ a:hover { text-decoration: underline; }
11
+
12
+ input[type=file] { margin-top: .5em; margin-left: 1.75em; }
13
+ input[type=checkbox] { display: inline; width: auto; margin-right: .5em; margin-left: 1em; }
14
+ label { display: inline; font-size: .8em; }
15
+
16
+ &.empty {
17
+ img, a, label, input[type=checkbox] { @include hide; }
18
+ input[type=file] { margin-top: .2em; }
19
+ }
20
+ }
21
+
22
+ .input-file-clear {
23
+ display: inline-block; width: 1.5em; height: 1.5em; background-color: rgba(0,0,0,.05);
24
+ @include position(absolute); border-radius: 1em; margin-top: -22px;
25
+ &:before { content: '\00d7'; color: $stableColor; line-height: 1.35em; @include position(absolute, null 7px null null); }
26
+ &:hover { background-color: $positiveColor; &:before { color: $white; } }
27
+ }
28
+
29
+ }
@@ -0,0 +1,36 @@
1
+ // form ::: generic components
2
+
3
+ .form {
4
+
5
+ // label
6
+
7
+ label { display: block; }
8
+
9
+ // general
10
+
11
+ .input-stacked {
12
+ @include position(relative); padding: .5em 1em .9em;
13
+ @include bottom-border($neutralColor); &:last-child { @include no-bottom-border; }
14
+
15
+ textarea, input { width: 100%; @include no-outline; @include placeholder { color: $lightColor; } }
16
+
17
+ .label { display: block; line-height: 1.8; color: $stableColor; }
18
+ }
19
+
20
+ // validation error
21
+
22
+ .error-message { color: $assertiveColor; font-size: .8em; margin-left: .5em; }
23
+
24
+ // required
25
+
26
+ .input-required .label:before { content: '*'; color: $assertiveColor; @include position(absolute, null null null .38em); }
27
+
28
+ // disabled
29
+
30
+ .input-disabled { textarea, input { color: $stableColor; } }
31
+
32
+ // character counter
33
+
34
+ .input-character-counter { font-size: .8em; margin-left: .5em; &.exceeds { color: $assertiveColor; } }
35
+
36
+ }
@@ -0,0 +1,22 @@
1
+ // group
2
+
3
+ .form {
4
+ .group .input-stacked:last-child { @include bottom-border($neutralColor); }
5
+ }
6
+
7
+ // expandable group
8
+
9
+ .group-edit { color: $stableColor; font-size: .9em; @include position(absolute, null .5em null null); text-transform: lowercase; margin-top: -1.5em;
10
+ &:hover { color: $positiveColor; }
11
+ }
12
+
13
+ .group-edit:before {
14
+ content: '-';
15
+ display: block; width: 1em; height: 1em;
16
+ @include position(absolute, null null null -.75em);
17
+ }
18
+
19
+ .group-edit.hidden:before { content: '+'; }
20
+ .group-edit.hidden + .group { display: none; }
21
+
22
+
@@ -0,0 +1,19 @@
1
+ // image ::: based on file
2
+
3
+ .form {
4
+
5
+ .input-image { @extend .input-file; }
6
+
7
+ .input-image:not(.empty) {
8
+ padding-left: 6.5em;
9
+ position: relative;
10
+ img {
11
+ position: absolute;
12
+ border-radius: 4px;
13
+ left: 1em;
14
+ top: .8em;
15
+ width: 4.7em;
16
+ }
17
+ }
18
+
19
+ }
@@ -0,0 +1,39 @@
1
+ // list :: supports reordering + typeahead
2
+
3
+ .form {
4
+
5
+ .input-list {
6
+ input { padding-left: 2em; margin-top: .1em; }
7
+ ul { line-height: 1.5; margin: 0 0 0 2em; list-style: none; padding: 0; }
8
+ ul li { @include user-select(none); position: relative; }
9
+ ul li a { color: $assertiveColor; font-size: .75em; }
10
+
11
+ .slip-reordering { color: $positiveColor; }
12
+
13
+ .icon-reorder {
14
+ width: 25px;
15
+ height: 25px;
16
+ left: -1.75em;
17
+ &:before { left: 0; top: 9px; }
18
+ &:after { left: 0; top: 14px; }
19
+ }
20
+
21
+ .twitter-typeahead { width: 100%; }
22
+ .twitter-typeahead:after {
23
+ content: '+';
24
+ display: block;
25
+ width: 40px;
26
+ height: 24px;
27
+ position: absolute; left: 12px; top: -3px;
28
+ font-size: 22px;
29
+ color: $contrastColor;
30
+ }
31
+
32
+ .tt-suggestions { padding: .1em .5em; margin: 0 0 0 1.55em; background: rgba(255,255,255, .95); }
33
+ .tt-suggestion { cursor: pointer; opacity: .5;
34
+ p { line-height: 1.5; margin: 0; }
35
+ &.tt-cursor { opacity: 1; }
36
+ }
37
+ }
38
+
39
+ }
@@ -0,0 +1,23 @@
1
+ // nested form
2
+
3
+ .nested-forms {
4
+ & > .label { margin-bottom: .25em; }
5
+ & > ul { margin: 0; padding: 0; }
6
+ & > ul > li { list-style-type: none; margin-top: 1em; @include position(relative); border: 1px solid $neutralColor; }
7
+ & > ul > li:first-child { margin-top: 0; }
8
+ & > ul > li > .icon-reorder { left: 0; top: 1em; }
9
+ & > ul li.reorderable { background-color: $white; }
10
+ & > ul li.reorderable > .input-stacked:first-child { padding-left: 2.4em; }
11
+ }
12
+
13
+ .nested-form-new {
14
+ color: $positiveColor; margin-top: .75em; display: inline-block; font-size: .9em;
15
+ &:hover { opacity: .5; }
16
+ }
17
+
18
+ .nested-form-delete {
19
+ @include position(absolute, .35em .3em null null); border-radius: 1em;
20
+ @include hide-text; width: 1.5em; height: 1.5em; background-color: rgba(0,0,0,.05);
21
+ &:before { content: '\00d7'; color: $stableColor; line-height: 1.35em; @include position(absolute, null 7px null null); }
22
+ &:hover { background-color: $positiveColor; &:before { color: $white; } }
23
+ }
@@ -0,0 +1,41 @@
1
+ // redactor
2
+
3
+ @import "redactor";
4
+
5
+ // input
6
+
7
+ .input-inverter,
8
+ .input-redactor {
9
+ .redactor-box { margin-bottom: 0; }
10
+ .redactor-toolbar { box-shadow: none; border-bottom: 2px solid $neutralColor; }
11
+ .redactor-editor { border: 0; padding: 1em .5em 0 .5em; }
12
+ }
13
+
14
+ // toolbar
15
+
16
+ .redactor-toolbar li a:hover { background-color: $positiveColor; }
17
+ .redactor-dropdown a:hover { background-color: $positiveColor; }
18
+
19
+ // placeholder
20
+
21
+ .redactor-placeholder:after { color: $lightColor!important; left: .5em; top: 18px; }
22
+
23
+ // scrollbars
24
+
25
+ .redactor-editor, textarea.redactor { @include custom-scrollbar; }
26
+
27
+ // line-height issue fix
28
+
29
+ .redactor-editor { line-height: inherit !important; }
30
+
31
+ // modal
32
+
33
+ #redactor-modal-close { line-height: 30px; text-align: center; }
34
+ #redactor-modal footer button {
35
+ &.redactor-modal-close-btn { background-color: $lightColor;
36
+ &:hover { background-color: $lightColor; opacity: .75; } }
37
+ &.redactor-modal-action-btn { background-color: $positiveColor;
38
+ &:hover { background-color: $positiveColor; opacity: .75; color: $white; } }
39
+ &.redactor-modal-delete-btn { background-color: $assertiveColor;
40
+ &:hover { background-color: $assertiveColor; opacity: .75; color: $white; } }
41
+ }
@@ -0,0 +1,5 @@
1
+ // select
2
+
3
+ .form {
4
+ .input-select select { margin-top: 0.15em; }
5
+ }
@@ -0,0 +1,95 @@
1
+ // select2
2
+
3
+ @import "vendor/select2";
4
+
5
+ .input-stacked.input-select2 {
6
+ padding-bottom: .3em;
7
+ }
8
+
9
+ .select2-dropdown,
10
+ .select2-container--default .select2-selection--single {
11
+ border-color: $neutralColor;
12
+ border-radius: 0;
13
+ }
14
+
15
+ .select2-container--default .select2-selection--single {
16
+ border: 0;
17
+ }
18
+
19
+ .select2-container--open .select2-dropdown--above {
20
+ border: 1px solid $neutralColor; border-top: none;
21
+ }
22
+
23
+ .select2-container--default .select2-selection--single .select2-selection__rendered {
24
+ line-height: 1.4em;
25
+ color: $black;
26
+ }
27
+
28
+ .select2-container--default .select2-selection--single .select2-selection__arrow b {
29
+ border-color: $positiveColor transparent transparent transparent;
30
+ }
31
+
32
+ .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
33
+ border-color: transparent transparent $positiveColor transparent;
34
+ }
35
+
36
+ .select2-container--default .select2-search--dropdown .select2-search__field {
37
+ border-color: $contrastColor;
38
+ &:focus {
39
+ border-color: $stableColor;
40
+ }
41
+ }
42
+
43
+ .select2-container--default * {
44
+ &:focus {
45
+ outline: none;
46
+ }
47
+ }
48
+
49
+ .select2-container--default .select2-results__option[aria-selected=true] {
50
+ background-color: $neutralColor;
51
+ color: $black;
52
+ }
53
+
54
+ .select2-results__option {
55
+ font-weight: 300;
56
+ }
57
+
58
+ .select2-container--default .select2-results__option--highlighted[aria-selected] {
59
+ background-color: $positiveColor;
60
+ color: $white;
61
+ }
62
+
63
+ .select2-container--default .select2-results__option[aria-selected=true] {
64
+ &:hover {
65
+ background-color: $positiveColor;
66
+ color: $white;
67
+ }
68
+ }
69
+
70
+ .select2-container--default .select2-results > .select2-results__options {
71
+ @include custom-scrollbar();
72
+ }
73
+
74
+ .select2-dropdown--below {
75
+ top: -4px;
76
+ }
77
+
78
+ .select2-container--default .select2-selection--single .select2-selection__arrow {
79
+ left: 1px;
80
+ top: -1px;
81
+ }
82
+
83
+ .select2-container .select2-selection--single .select2-selection__rendered {
84
+ padding-left: 20px;
85
+ padding-right: 8px;
86
+ }
87
+
88
+ .select2-search--dropdown {
89
+ padding: 0;
90
+ margin: 0 -1px;
91
+ }
92
+
93
+
94
+
95
+
@@ -0,0 +1,14 @@
1
+ // string
2
+
3
+ .form {
4
+
5
+ .input-string {
6
+ .twitter-typeahead { width: 100%; }
7
+ .tt-suggestions { padding: .1em .5em; margin: 0 0 0 -.5em; background: rgba(255,255,255, .95); }
8
+ .tt-suggestion { cursor: pointer; opacity: .5;
9
+ p { line-height: 1.5; margin: 0; }
10
+ &.tt-cursor { opacity: 1; }
11
+ }
12
+ }
13
+
14
+ }
@@ -0,0 +1,86 @@
1
+ // switch
2
+
3
+ /* Switch ------------------------------------------------- */
4
+ @mixin switch {
5
+ $switch-width: 52px;
6
+ $switch-padding: 2px;
7
+ $switch-height: 32px;
8
+ $switch-radius: $switch-height;
9
+ $knob-size: $switch-height - ($switch-padding * 2);
10
+ $knob-radius: $switch-height - ($switch-padding * 2);
11
+ $knob-width: $knob-size;
12
+ $switch-background: $white;
13
+ $switch-border-background: $contrastColor;
14
+ $switch-shadow: 0 0px 2px transparentize(black, 0.6);
15
+
16
+ border-radius: $switch-radius;
17
+ cursor: pointer;
18
+ display: inline-block;
19
+ height: $switch-height;
20
+ position: relative;
21
+ width: $switch-width;
22
+
23
+ input[type="checkbox"] {
24
+ display: none;
25
+
26
+ + .checkbox {
27
+ @include transition(all 0.3s ease);
28
+ background: $switch-border-background;
29
+ border-radius: $switch-radius;
30
+ border: none;
31
+ cursor: pointer;
32
+ height: $switch-height;
33
+ margin: 0;
34
+ padding: 0;
35
+ position: relative;
36
+ width: $switch-width;
37
+ z-index: 0;
38
+
39
+ &:before {
40
+ @include position(absolute, 2px 0 0 2px);
41
+ @include transform(scale(1));
42
+ @include transition(all 0.3s ease);
43
+ background: $switch-background;
44
+ border-radius: $switch-radius;
45
+ content: "";
46
+ height: $knob-radius;
47
+ width: $switch-width - ($switch-padding * 2);
48
+ z-index: 1;
49
+ }
50
+
51
+ &:after {
52
+ @include position(absolute, 2px 0 0 2px);
53
+ @include transition(all 0.3s ease);
54
+ @include size($knob-size);
55
+ background: $switch-background;
56
+ border-radius: $knob-radius;
57
+ box-shadow: $switch-shadow;
58
+ content: "";
59
+ z-index: 2;
60
+ }
61
+ }
62
+
63
+ &:checked {
64
+ + .checkbox {
65
+ background: $positiveColor;
66
+
67
+ &:before {
68
+ @include transform(scale(0));
69
+ }
70
+
71
+ &:after {
72
+ left: $switch-width - $knob-width - ($switch-padding);
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+ .form {
80
+
81
+ .input-switch { padding-top: .75em;
82
+ .label { cursor: pointer; }
83
+ .switch { @include switch; float: right; }
84
+ }
85
+
86
+ }
@@ -0,0 +1,9 @@
1
+ // text
2
+
3
+ .form {
4
+
5
+ .input-text { min-height: 82px;
6
+ textarea { resize: none; overflow: auto; box-sizing: border-box; min-height: 20px; }
7
+ }
8
+
9
+ }
@@ -0,0 +1,15 @@
1
+ @import "formagic/form";
2
+ @import "formagic/checkbox";
3
+ @import "formagic/color";
4
+ @import "formagic/date";
5
+ @import "formagic/file";
6
+ @import "formagic/group";
7
+ @import "formagic/image";
8
+ @import "formagic/list";
9
+ @import "formagic/nested-form";
10
+ @import "formagic/redactor";
11
+ @import "formagic/select";
12
+ @import "formagic/select2";
13
+ @import "formagic/string";
14
+ @import "formagic/switch";
15
+ @import "formagic/text";