formize 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -40
- data/VERSION +1 -1
- data/lib/assets/javascripts/formize-autocomplete.js +11 -0
- data/lib/assets/javascripts/formize-behave.js +52 -0
- data/lib/assets/javascripts/formize-datepicker.js +115 -0
- data/lib/assets/javascripts/formize-dependents.js +50 -0
- data/lib/assets/javascripts/formize-dialog.js +123 -0
- data/lib/assets/javascripts/formize-observe.js +24 -0
- data/lib/assets/javascripts/formize-popover-form.js +32 -0
- data/lib/assets/javascripts/formize-timepicker.js +57 -0
- data/lib/assets/javascripts/formize-toggle.js +24 -0
- data/lib/assets/javascripts/formize-unroll.js +30 -0
- data/lib/assets/javascripts/formize.js +10 -436
- data/lib/formize.rb +5 -65
- data/lib/formize/action_controller.rb +75 -46
- data/lib/formize/generator.rb +160 -547
- data/lib/formize/helpers/form_helper.rb +40 -38
- data/lib/formize/rails/railtie.rb +1 -1
- data/test/ci/Gemfile.rails-3.1 +9 -0
- data/test/ci/Gemfile.rails-3.2 +9 -0
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +1882 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-af.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-bg.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ca.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-cs.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-cs.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-de.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-de.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-el.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-el.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-es.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-es.js} +5 -2
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-et.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-fi.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-fr.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-fr.js} +5 -2
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-gl.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-he.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-hu.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-hu.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-id.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-id.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-it.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-it.js} +5 -2
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ja.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ko.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-lt.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-lt.js} +5 -2
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-nl.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-nl.js} +5 -2
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-no.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pl.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pt-BR.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-pt.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-ro.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-ru.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-ru.js} +7 -4
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-sk.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-sv.js +20 -0
- data/{lib/assets/javascripts/locales/jquery.ui.timepicker-tr.js → vendor/assets/javascripts/locales/jquery-ui-timepicker-tr.js} +6 -3
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-uk.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-vi.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-zh-CN.js +20 -0
- data/vendor/assets/javascripts/locales/jquery-ui-timepicker-zh-TW.js +20 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-af.js +1 -1
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ar-DZ.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ar.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-az.js +4 -4
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-be.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-bg.js +24 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-bs.js +6 -6
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ca.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-cs.js +4 -4
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-cy-GB.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-da.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-de-CH.js +0 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-de.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-el.js +2 -2
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-en-AU.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-en-GB.js +1 -1
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-en-NZ.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-eo.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-es.js +6 -6
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-et.js +3 -3
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-eu.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-fa.js +59 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-fi.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-fo.js +4 -4
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-fr-CA.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-fr-CH.js +2 -2
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-fr.js +25 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-gl.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-he.js +5 -5
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-hi.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-hr.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-hu.js +7 -7
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-hy.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-id.js +3 -3
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-is.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-it.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ja.js +4 -4
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ka.js +21 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-kk.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-km.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ko.js +8 -8
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ky.js +24 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-lb.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-lt.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-lv.js +1 -1
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-mk.js +23 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-ml.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ms.js +3 -3
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-nb.js +22 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-nl-BE.js +23 -23
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-nl.js +5 -5
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-nn.js +22 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-no.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-pl.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-pt-BR.js +7 -7
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-pt.js +22 -0
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-rm.js +21 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ro.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ru.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-sk.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-sl.js +6 -6
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-sq.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-sr-SR.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-sr.js +3 -3
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-sv.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-ta.js +1 -1
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-th.js +5 -5
- data/vendor/assets/javascripts/locales/jquery.ui.datepicker-tj.js +23 -0
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-tr.js +2 -2
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-uk.js +5 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-vi.js +3 -3
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-zh-CN.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-zh-HK.js +4 -4
- data/{lib → vendor}/assets/javascripts/locales/jquery.ui.datepicker-zh-TW.js +5 -5
- metadata +127 -92
- data/lib/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/assets/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/lib/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/assets/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/lib/assets/images/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/assets/images/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/images/ui-icons_888888_256x240.png +0 -0
- data/lib/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/assets/javascripts/jquery.ui.formize.js +0 -380
- data/lib/assets/javascripts/jquery.ui.timepicker.js +0 -1060
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-ar.js +0 -24
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-bg.js +0 -24
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-ca.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-da.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-eu.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-fa.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-fi.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-fr.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-is.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-no.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.datepicker-sv.js +0 -23
- data/lib/assets/javascripts/locales/jquery.ui.timepicker-et.js +0 -17
- data/lib/assets/javascripts/locales/jquery.ui.timepicker-vi.js +0 -17
- data/lib/assets/stylesheets/formize.css +0 -20
- data/lib/assets/stylesheets/jquery-ui.css +0 -586
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Formize
|
2
2
|
|
3
|
-
|
3
|
+
Form helpers. Will be integrated with SimpleForm.
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
@@ -38,49 +38,15 @@ To install the default configuration file (config/initializers/formize.rb), the
|
|
38
38
|
|
39
39
|
== Usage
|
40
40
|
|
41
|
-
|
41
|
+
TODO: Rewrite examples
|
42
42
|
|
43
|
-
|
44
|
-
# Generates default helpers method and a controller method :formize
|
45
|
-
# for a model Order.
|
46
|
-
formize
|
43
|
+
=== Date
|
47
44
|
|
48
|
-
|
49
|
-
formize do
|
50
|
-
field :number
|
51
|
-
field :created_on
|
52
|
-
field :client
|
53
|
-
field_set :addresses, :depend_on=>:client do
|
54
|
-
field :default_contact, :choices=>:contacts, :source=>:client
|
55
|
-
field :delivery_contact, :choices=>:contacts, :source=>:client
|
56
|
-
field :invoice_contact, :choices=>:contacts, :source=>:client
|
57
|
-
end
|
58
|
-
field_set :track do
|
59
|
-
field :responsible
|
60
|
-
field :department
|
61
|
-
end
|
62
|
-
end
|
45
|
+
=== Datetime
|
63
46
|
|
64
|
-
|
65
|
-
formize(:lines, :model=>:order_lines)
|
47
|
+
=== Unroll (replacement of ComboBox)
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
In views:
|
70
|
-
|
71
|
-
# app/views/orders/_form.html.haml
|
72
|
-
=formize_form
|
73
|
-
|
74
|
-
or:
|
75
|
-
|
76
|
-
# app/views/orders/_form.html.haml
|
77
|
-
=form_tag do
|
78
|
-
=formize_fields
|
79
|
-
|
80
|
-
or:
|
81
|
-
|
82
|
-
# app/views/orders/_form.html.haml
|
83
|
-
=formize_form :lines
|
49
|
+
=== MonoChoice (dynamic selector)
|
84
50
|
|
85
51
|
|
86
52
|
== Contributing to Formize {<img src="https://secure.travis-ci.org/burisu/formize.png"/>}[http://travis-ci.org/burisu/formize]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
@@ -0,0 +1,11 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
$(document).behave("load", "input[data-autocomplete]", function () {
|
4
|
+
var element = $(this);
|
5
|
+
element.autocomplete({
|
6
|
+
source: element.data("autocomplete"),
|
7
|
+
minLength: parseInt(element.data("min-length") || 1)
|
8
|
+
});
|
9
|
+
});
|
10
|
+
|
11
|
+
})(jQuery);
|
@@ -0,0 +1,52 @@
|
|
1
|
+
(function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$.Behave = {};
|
5
|
+
$.Behave.sequence = 0;
|
6
|
+
$.Behave.loads = [];
|
7
|
+
|
8
|
+
// Refresh one behaviour
|
9
|
+
$.Behave.refreshOne = function (behaviour) {
|
10
|
+
var element;
|
11
|
+
behaviour.ref.find(behaviour.selector).each(function (index) {
|
12
|
+
element = $(this);
|
13
|
+
if (element.prop('alreadyBound' + behaviour.key) !== true) {
|
14
|
+
behaviour.handler.call(element);
|
15
|
+
element.prop('alreadyBound' + behaviour.key, true);
|
16
|
+
}
|
17
|
+
});
|
18
|
+
};
|
19
|
+
|
20
|
+
// Refresh all behaviours
|
21
|
+
$.Behave.refresh = function () {
|
22
|
+
$.each($.Behave.loads, function (index, behaviour) {
|
23
|
+
$.Behave.refreshOne(behaviour);
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
// Same API as .on(). Takes in account load events.
|
28
|
+
$.fn.behave = function (events, selector, handler) {
|
29
|
+
var ref = $(this);
|
30
|
+
$.each(events.split(/\s+/ig), function (index, event) {
|
31
|
+
var behaviour;
|
32
|
+
if (event === "load") {
|
33
|
+
behaviour = {ref: ref, selector: selector, handler: handler, key: $.Behave.sequence * 7};
|
34
|
+
$.Behave.loads.push(behaviour);
|
35
|
+
$.Behave.refreshOne(behaviour);
|
36
|
+
$.Behave.sequence += 1;
|
37
|
+
} else {
|
38
|
+
ref.on(events, selector, handler);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
};
|
42
|
+
|
43
|
+
// Retro-compatibility
|
44
|
+
$.behave = function (selector, events, handler) {
|
45
|
+
$(document).behave(events, selector, handler);
|
46
|
+
};
|
47
|
+
|
48
|
+
|
49
|
+
// Rebinds unbound elements on each ajax request.
|
50
|
+
$(document).ajaxComplete($.Behave.refresh);
|
51
|
+
|
52
|
+
})(jQuery);
|
@@ -0,0 +1,115 @@
|
|
1
|
+
//= require locales/jquery.ui.datepicker-af
|
2
|
+
//= require locales/jquery.ui.datepicker-ar-DZ
|
3
|
+
//= require locales/jquery.ui.datepicker-ar
|
4
|
+
//= require locales/jquery.ui.datepicker-az
|
5
|
+
//= require locales/jquery.ui.datepicker-be
|
6
|
+
//= require locales/jquery.ui.datepicker-bg
|
7
|
+
//= require locales/jquery.ui.datepicker-bs
|
8
|
+
//= require locales/jquery.ui.datepicker-ca
|
9
|
+
//= require locales/jquery.ui.datepicker-cs
|
10
|
+
//= require locales/jquery.ui.datepicker-cy-GB
|
11
|
+
//= require locales/jquery.ui.datepicker-da
|
12
|
+
//= require locales/jquery.ui.datepicker-de-CH
|
13
|
+
//= require locales/jquery.ui.datepicker-de
|
14
|
+
//= require locales/jquery.ui.datepicker-el
|
15
|
+
//= require locales/jquery.ui.datepicker-en-AU
|
16
|
+
//= require locales/jquery.ui.datepicker-en-GB
|
17
|
+
//= require locales/jquery.ui.datepicker-en-NZ
|
18
|
+
//= require locales/jquery.ui.datepicker-eo
|
19
|
+
//= require locales/jquery.ui.datepicker-es
|
20
|
+
//= require locales/jquery.ui.datepicker-et
|
21
|
+
//= require locales/jquery.ui.datepicker-eu
|
22
|
+
//= require locales/jquery.ui.datepicker-fa
|
23
|
+
//= require locales/jquery.ui.datepicker-fi
|
24
|
+
//= require locales/jquery.ui.datepicker-fo
|
25
|
+
//= require locales/jquery.ui.datepicker-fr-CA
|
26
|
+
//= require locales/jquery.ui.datepicker-fr-CH
|
27
|
+
//= require locales/jquery.ui.datepicker-fr
|
28
|
+
//= require locales/jquery.ui.datepicker-gl
|
29
|
+
//= require locales/jquery.ui.datepicker-he
|
30
|
+
//= require locales/jquery.ui.datepicker-hi
|
31
|
+
//= require locales/jquery.ui.datepicker-hr
|
32
|
+
//= require locales/jquery.ui.datepicker-hu
|
33
|
+
//= require locales/jquery.ui.datepicker-hy
|
34
|
+
//= require locales/jquery.ui.datepicker-id
|
35
|
+
//= require locales/jquery.ui.datepicker-is
|
36
|
+
//= require locales/jquery.ui.datepicker-it
|
37
|
+
//= require locales/jquery.ui.datepicker-ja
|
38
|
+
//= require locales/jquery.ui.datepicker-ka
|
39
|
+
//= require locales/jquery.ui.datepicker-kk
|
40
|
+
//= require locales/jquery.ui.datepicker-km
|
41
|
+
//= require locales/jquery.ui.datepicker-ko
|
42
|
+
//= require locales/jquery.ui.datepicker-ky
|
43
|
+
//= require locales/jquery.ui.datepicker-lb
|
44
|
+
//= require locales/jquery.ui.datepicker-lt
|
45
|
+
//= require locales/jquery.ui.datepicker-lv
|
46
|
+
//= require locales/jquery.ui.datepicker-mk
|
47
|
+
//= require locales/jquery.ui.datepicker-ml
|
48
|
+
//= require locales/jquery.ui.datepicker-ms
|
49
|
+
//= require locales/jquery.ui.datepicker-nb
|
50
|
+
//= require locales/jquery.ui.datepicker-nl-BE
|
51
|
+
//= require locales/jquery.ui.datepicker-nl
|
52
|
+
//= require locales/jquery.ui.datepicker-nn
|
53
|
+
//= require locales/jquery.ui.datepicker-no
|
54
|
+
//= require locales/jquery.ui.datepicker-pl
|
55
|
+
//= require locales/jquery.ui.datepicker-pt-BR
|
56
|
+
//= require locales/jquery.ui.datepicker-pt
|
57
|
+
//= require locales/jquery.ui.datepicker-rm
|
58
|
+
//= require locales/jquery.ui.datepicker-ro
|
59
|
+
//= require locales/jquery.ui.datepicker-ru
|
60
|
+
//= require locales/jquery.ui.datepicker-sk
|
61
|
+
//= require locales/jquery.ui.datepicker-sl
|
62
|
+
//= require locales/jquery.ui.datepicker-sq
|
63
|
+
//= require locales/jquery.ui.datepicker-sr
|
64
|
+
//= require locales/jquery.ui.datepicker-sr-SR
|
65
|
+
//= require locales/jquery.ui.datepicker-sv
|
66
|
+
//= require locales/jquery.ui.datepicker-ta
|
67
|
+
//= require locales/jquery.ui.datepicker-th
|
68
|
+
//= require locales/jquery.ui.datepicker-tj
|
69
|
+
//= require locales/jquery.ui.datepicker-tr
|
70
|
+
//= require locales/jquery.ui.datepicker-uk
|
71
|
+
//= require locales/jquery.ui.datepicker-vi
|
72
|
+
//= require locales/jquery.ui.datepicker-zh-CN
|
73
|
+
//= require locales/jquery.ui.datepicker-zh-HK
|
74
|
+
//= require locales/jquery.ui.datepicker-zh-TW
|
75
|
+
|
76
|
+
(function ($) {
|
77
|
+
|
78
|
+
$.datepicker.regional["en"] = $.datepicker.regional["en-GB"]
|
79
|
+
|
80
|
+
$.datepicker.regional["arb"] = $.datepicker.regional["ar"]
|
81
|
+
$.datepicker.regional["eng"] = $.datepicker.regional["en"]
|
82
|
+
$.datepicker.regional["fra"] = $.datepicker.regional["fr"]
|
83
|
+
$.datepicker.regional["jpn"] = $.datepicker.regional["ja"]
|
84
|
+
$.datepicker.regional["spa"] = $.datepicker.regional["es"]
|
85
|
+
|
86
|
+
// Initializes date fields
|
87
|
+
$(document).behave("load", 'input[data-datepicker]', function() {
|
88
|
+
var element = $(this);
|
89
|
+
var locale = element.data("locale");
|
90
|
+
var options = $.datepicker.regional[locale];
|
91
|
+
if (options === null || options === undefined) {
|
92
|
+
options = $.datepicker.regional["en"];
|
93
|
+
}
|
94
|
+
if (element.data("date-format") !== null) {
|
95
|
+
options['dateFormat'] = element.data("date-format");
|
96
|
+
}
|
97
|
+
options['altField'] = '#'+element.data("datepicker");
|
98
|
+
options['altFormat'] = 'yy-mm-dd';
|
99
|
+
options['defaultDate'] = element.val();
|
100
|
+
// Check for dependents
|
101
|
+
triggered = $(options['altField']);
|
102
|
+
if (triggered.data('dependents') !== undefined && triggered.data('dependents') !== null) {
|
103
|
+
if (triggered.data('observe') === undefined || triggered.data('observe') === null) {
|
104
|
+
triggered.attr('data-observe', '1000');
|
105
|
+
}
|
106
|
+
}
|
107
|
+
/*options['onSelect'] = function (dateText, inst) {
|
108
|
+
triggered.trigger("emulated:change");
|
109
|
+
};*/
|
110
|
+
element.datepicker(options);
|
111
|
+
/* element.keyup(function() {
|
112
|
+
triggered.trigger("emulated:change");
|
113
|
+
}); */
|
114
|
+
});
|
115
|
+
})(jQuery);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
(function ($) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var Formize = {};
|
5
|
+
|
6
|
+
Formize.refreshDependents = function (event) {
|
7
|
+
var element = $(this), params = {}, dependents, paramName;
|
8
|
+
|
9
|
+
if (element.val() !== null && element.val() !== undefined) {
|
10
|
+
dependents = element.attr('data-dependents');
|
11
|
+
paramName = element.attr('data-parameter-name') || element.attr('id') || 'value';
|
12
|
+
params[paramName] = element.val();
|
13
|
+
$(dependents).each(function (index, item) {
|
14
|
+
// Replaces element
|
15
|
+
var url = $(item).attr('data-refresh'), mode = $(item).attr('data-refresh-mode') || 'replace';
|
16
|
+
if (url !== null) {
|
17
|
+
$.ajax(url, {
|
18
|
+
data: params,
|
19
|
+
success: function (data, textStatus, response) {
|
20
|
+
if (mode === 'update') {
|
21
|
+
$(item).html(response.responseText);
|
22
|
+
} else if (mode === 'update-value') {
|
23
|
+
if (element.data("attribute")) {
|
24
|
+
$(item).val($.parseJSON(data)[element.data("attribute")]);
|
25
|
+
} else {
|
26
|
+
$(item).val(response.responseText);
|
27
|
+
}
|
28
|
+
} else {
|
29
|
+
$(item).replaceWith(response.responseText);
|
30
|
+
}
|
31
|
+
},
|
32
|
+
error: function (jqXHR, textStatus, errorThrown) {
|
33
|
+
alert("FAILURE (Error " + textStatus + "): " + errorThrown);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
}
|
37
|
+
});
|
38
|
+
return true;
|
39
|
+
}
|
40
|
+
return false;
|
41
|
+
};
|
42
|
+
|
43
|
+
// Refresh dependents on changes
|
44
|
+
$(document).behave("change emulated:change", "*[data-dependents]", Formize.refreshDependents);
|
45
|
+
// Compensate for changes made with keyboard
|
46
|
+
$(document).behave("keypress", "select[data-dependents]", Formize.refreshDependents);
|
47
|
+
|
48
|
+
})(jQuery);
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
//= require formize-behave
|
2
|
+
|
3
|
+
(function ($) {
|
4
|
+
|
5
|
+
$.ajaxDialogCount = 0;
|
6
|
+
|
7
|
+
$.ajaxDialog = function (url, settings) {
|
8
|
+
var frame_id = "dialog-" + $.ajaxDialogCount, width = $(document).width();
|
9
|
+
var defaultSettings = {
|
10
|
+
header: "X-Return-Code",
|
11
|
+
width: 0.6,
|
12
|
+
height: 0.8
|
13
|
+
};
|
14
|
+
if (settings === null || settings === undefined) { settings = {}; }
|
15
|
+
settings = $.extend({}, defaultSettings, settings);
|
16
|
+
$.ajax(url, {
|
17
|
+
data: {dialog: frame_id},
|
18
|
+
success: function(data, textStatus, jqXHR) {
|
19
|
+
var frame = $(document.createElement('div')), width, height;
|
20
|
+
frame.attr({id: frame_id, 'class': 'dialog ajax-dialog', style: 'display:none;'});
|
21
|
+
$('body').append(frame);
|
22
|
+
frame.html(data);
|
23
|
+
frame.prop("dialogSettings", settings);
|
24
|
+
if (settings.width === 0) {
|
25
|
+
width = 'auto';
|
26
|
+
} else if (settings.width < 1) {
|
27
|
+
width = $(window).width() * settings.width;
|
28
|
+
} else {
|
29
|
+
width = settings.width;
|
30
|
+
}
|
31
|
+
if (settings.height === 0) {
|
32
|
+
height = 'auto';
|
33
|
+
} else if (settings.height < 1) {
|
34
|
+
height = $(window).height() * settings.height;
|
35
|
+
} else {
|
36
|
+
height = settings.height;
|
37
|
+
}
|
38
|
+
frame.dialog({
|
39
|
+
autoOpen: false,
|
40
|
+
show: 'fade',
|
41
|
+
modal: true,
|
42
|
+
width: width,
|
43
|
+
height: height
|
44
|
+
});
|
45
|
+
$.ajaxDialogInitialize(frame);
|
46
|
+
frame.dialog("open");
|
47
|
+
},
|
48
|
+
error: function(jqXHR, textStatus, errorThrown) {
|
49
|
+
alert("FAILURE (Error "+textStatus+"): "+errorThrown);
|
50
|
+
var frame = $("#" + frame_id);
|
51
|
+
frame.dialog("close");
|
52
|
+
frame.remove();
|
53
|
+
}
|
54
|
+
});
|
55
|
+
$.ajaxDialogCount += 1;
|
56
|
+
};
|
57
|
+
|
58
|
+
$.ajaxDialogInitialize = function(frame) {
|
59
|
+
var frame_id = frame.attr("id");
|
60
|
+
var title = frame.prop("dialogSettings")["title"];
|
61
|
+
if (title === null || title === undefined) {
|
62
|
+
var h1 = $("#" + frame_id + " h1");
|
63
|
+
if (h1[0] !== null && h1[0] !== undefined) {
|
64
|
+
title = h1.text()
|
65
|
+
h1.remove();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
frame.dialog("option", "title", title);
|
69
|
+
|
70
|
+
$("#" + frame_id + " form").each(function (index, form) {
|
71
|
+
$(form).attr('data-dialog', frame_id);
|
72
|
+
});
|
73
|
+
|
74
|
+
};
|
75
|
+
|
76
|
+
$.submitAjaxForm = function () {
|
77
|
+
var form = $(this);
|
78
|
+
var frame_id = form.attr('data-dialog');
|
79
|
+
var frame = $('#'+frame_id);
|
80
|
+
var settings = frame.prop("dialogSettings");
|
81
|
+
|
82
|
+
var field = $(document.createElement('input'));
|
83
|
+
field.attr({ type: 'hidden', name: 'dialog', value: frame_id });
|
84
|
+
form.append(field);
|
85
|
+
|
86
|
+
$.ajax(form.attr('action'), {
|
87
|
+
type: form.attr('method') || 'POST',
|
88
|
+
data: form.serialize(),
|
89
|
+
success: function(data, textStatus, request) {
|
90
|
+
var returnCode = request.getResponseHeader(settings["header"])
|
91
|
+
var returns = settings["returns"], unknownReturnCode = true;
|
92
|
+
for (var code in returns) {
|
93
|
+
if (returnCode == code && $.isFunction(returns[code])) {
|
94
|
+
returns[code].call(form, frame, data, textStatus, request);
|
95
|
+
unknownReturnCode = false;
|
96
|
+
$.ajaxDialogInitialize(frame);
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
if (unknownReturnCode) {
|
101
|
+
if ($.isFunction(settings["defaultReturn"])) {
|
102
|
+
settings["defaultReturn"].call(form, frame);
|
103
|
+
} else {
|
104
|
+
alert("FAILURE (Unknown return code for header " + settings["header"] + "): " + returnCode);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
},
|
108
|
+
error: function(jqXHR, textStatus, errorThrown) {
|
109
|
+
alert("FAILURE (Error "+textStatus+"): "+errorThrown);
|
110
|
+
var frame = $("#" + frame_id);
|
111
|
+
frame.dialog("close");
|
112
|
+
frame.remove();
|
113
|
+
// if ($.isFunction(settings["error"])) { settings["error"].call(form, frame, jqXHR, textStatus, errorThrown); }
|
114
|
+
}
|
115
|
+
});
|
116
|
+
return false;
|
117
|
+
};
|
118
|
+
|
119
|
+
// Submits dialog forms
|
120
|
+
$(document).behave("submit", ".ajax-dialog form[data-dialog]", $.submitAjaxForm);
|
121
|
+
|
122
|
+
|
123
|
+
})(jQuery);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
// Observes fields comparing its value with fixed intervals of time
|
4
|
+
// Compensates not quite sure "change" events.
|
5
|
+
$(document).behave("load", "*[data-observe]", function () {
|
6
|
+
var element = $(this);
|
7
|
+
var interval = parseInt(element.data("observe"));
|
8
|
+
if (interval === null || interval === undefined) {
|
9
|
+
interval = 1000;
|
10
|
+
}
|
11
|
+
if (element.get(0).nodeName.toLowerCase() !== "input") {
|
12
|
+
alert("data-observe attribute must be only used with <input>s.");
|
13
|
+
return false;
|
14
|
+
}
|
15
|
+
element.previousObservedValue = element.val();
|
16
|
+
window.setInterval(function () {
|
17
|
+
if (element.val() !== element.previousObservedValue) {
|
18
|
+
element.trigger("emulated:change");
|
19
|
+
element.previousObservedValue = element.val();
|
20
|
+
}
|
21
|
+
}, interval);
|
22
|
+
return true;
|
23
|
+
});
|
24
|
+
})(jQuery);
|