formagic 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/CONTRIBUTING.md +24 -0
- data/Gemfile +3 -0
- data/LICENSE.md +21 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/assets/images/datedropper/done.png +0 -0
- data/app/assets/images/datedropper/done.svg +1 -0
- data/app/assets/images/datedropper/next.png +0 -0
- data/app/assets/images/datedropper/next.svg +1 -0
- data/app/assets/images/datedropper/prev.png +0 -0
- data/app/assets/images/datedropper/prev.svg +1 -0
- data/app/assets/javascripts/formagic/form.coffee +229 -0
- data/app/assets/javascripts/formagic/group.coffee +28 -0
- data/app/assets/javascripts/formagic/inputs/checkbox.coffee +83 -0
- data/app/assets/javascripts/formagic/inputs/color.coffee +55 -0
- data/app/assets/javascripts/formagic/inputs/date.coffee +69 -0
- data/app/assets/javascripts/formagic/inputs/datetime.coffee +130 -0
- data/app/assets/javascripts/formagic/inputs/document.coffee +0 -0
- data/app/assets/javascripts/formagic/inputs/documents.coffee +173 -0
- data/app/assets/javascripts/formagic/inputs/documents_reorder.coffee +67 -0
- data/app/assets/javascripts/formagic/inputs/file.coffee +114 -0
- data/app/assets/javascripts/formagic/inputs/hidden.coffee +57 -0
- data/app/assets/javascripts/formagic/inputs/html.coffee +81 -0
- data/app/assets/javascripts/formagic/inputs/image.coffee +28 -0
- data/app/assets/javascripts/formagic/inputs/list.coffee +154 -0
- data/app/assets/javascripts/formagic/inputs/list_reorder.coffee +39 -0
- data/app/assets/javascripts/formagic/inputs/list_typeahead.coffee +55 -0
- data/app/assets/javascripts/formagic/inputs/markdown.coffee +93 -0
- data/app/assets/javascripts/formagic/inputs/password.coffee +32 -0
- data/app/assets/javascripts/formagic/inputs/redactor.coffee +53 -0
- data/app/assets/javascripts/formagic/inputs/redactor_character.coffee +75 -0
- data/app/assets/javascripts/formagic/inputs/redactor_images.coffee +166 -0
- data/app/assets/javascripts/formagic/inputs/select.coffee +84 -0
- data/app/assets/javascripts/formagic/inputs/select2.coffee +33 -0
- data/app/assets/javascripts/formagic/inputs/string.coffee +160 -0
- data/app/assets/javascripts/formagic/inputs/text.coffee +43 -0
- data/app/assets/javascripts/formagic/inputs/time.coffee +0 -0
- data/app/assets/javascripts/formagic.coffee +22 -0
- data/app/assets/javascripts/vendor/ace.js +18280 -0
- data/app/assets/javascripts/vendor/datedropper.js +1005 -0
- data/app/assets/javascripts/vendor/jquery.scrollparent.js +14 -0
- data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +55 -0
- data/app/assets/javascripts/vendor/jquery.typeahead.js +1782 -0
- data/app/assets/javascripts/vendor/marked.js +1272 -0
- data/app/assets/javascripts/vendor/mode-html.js +2436 -0
- data/app/assets/javascripts/vendor/mode-markdown.js +2820 -0
- data/app/assets/javascripts/vendor/moment.js +3083 -0
- data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +107 -0
- data/app/assets/javascripts/vendor/select2.js +5274 -0
- data/app/assets/stylesheets/formagic/checkbox.scss +8 -0
- data/app/assets/stylesheets/formagic/color.scss +12 -0
- data/app/assets/stylesheets/formagic/date.scss +37 -0
- data/app/assets/stylesheets/formagic/file.scss +29 -0
- data/app/assets/stylesheets/formagic/form.scss +36 -0
- data/app/assets/stylesheets/formagic/group.scss +22 -0
- data/app/assets/stylesheets/formagic/image.scss +19 -0
- data/app/assets/stylesheets/formagic/list.scss +39 -0
- data/app/assets/stylesheets/formagic/nested-form.scss +23 -0
- data/app/assets/stylesheets/formagic/redactor.scss +41 -0
- data/app/assets/stylesheets/formagic/select.scss +5 -0
- data/app/assets/stylesheets/formagic/select2.scss +95 -0
- data/app/assets/stylesheets/formagic/string.scss +14 -0
- data/app/assets/stylesheets/formagic/switch.scss +86 -0
- data/app/assets/stylesheets/formagic/text.scss +9 -0
- data/app/assets/stylesheets/formagic.scss +15 -0
- data/app/assets/stylesheets/vendor/datedropper.scss +523 -0
- data/app/assets/stylesheets/vendor/select2.scss +258 -0
- data/formagic.gemspec +30 -0
- data/lib/formagic/engine.rb +5 -0
- data/lib/formagic/version.rb +3 -0
- data/lib/formagic.rb +5 -0
- 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));
|