phantom_forms 0.1.8 → 0.2.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71a329aebb0122805bb05d1692cfebe526d73b06
4
- data.tar.gz: b4c45424135a294668dabe75c5d59e1ffa7b39f7
3
+ metadata.gz: fee862caffd78e920cb2b09495e9278d55bf2647
4
+ data.tar.gz: e2c8b34bfe8e47765806b2728147704d3277c955
5
5
  SHA512:
6
- metadata.gz: 5bca0db0f898420705da46c066440049b4a776f42fb38a5e242ae0a1f30d26f8827d8005d98d2816073f4ae2d4ac1d7ea5d0e63541f1d73c6ce4052014756374
7
- data.tar.gz: 1a41b583ea510fcbea08943bfc8a40d13558d5fa5616fbcf76b5a9480ab8a3d07ab5364f3b933772c14afb41bd09214d6938f38bf22b43973d902293cf3bba6e
6
+ metadata.gz: a345c10e0c43a4b62abac55e9d3aced9b64d623107ee01961d1e1ca67b26244d830a4e2a97c389e15bf658dcfd950520567f62aac1a5adb4c0c868851e9feb62
7
+ data.tar.gz: 546aeabcb6ddd3b37f8431e5d293133d51fe513adf8c36535f435b2713ebc27fb67195436bef56b096751830f28082ef69cb59b38852ce214b30590ed9e3fb1f
@@ -6,33 +6,14 @@ module PhantomForms
6
6
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
7
7
  options[:remote] = true
8
8
  options[:html] = {:class => 'remote-form form'}
9
- content_tag :div, class: "col-md-12" do
10
- content_tag :div, class: "well" do
11
- form_for(object, options, &block)
12
- end
13
- end
14
- end
15
9
 
16
- def remote_form_panel_for(object, panel_title = nil, options = {}, &block)
17
- options[:validate] = true
18
- options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
19
- options[:remote] = true
20
- options[:html] = {:class => 'remote-form form'}
21
- content_tag :div, class: "col-md-12" do
22
- content_tag :div, class: "panel panel-primary" do
23
- [
24
- if panel_title
25
- content_tag :div, class: "panel-heading" do
26
- content_tag :h3, class: "panel-title" do
27
- panel_title
28
- end
29
- end
30
- end,
31
- content_tag(:div, class: "panel-body") do
32
- form_for(object, options, &block)
33
- end
34
- ].join.html_safe
35
- end
10
+ object_name = get_class(extract_object(object))
11
+ object_class = options[:resource] || object_name
12
+ label = options[:label] || t("#{object_name.underscore}.singular")
13
+
14
+ content_tag :div, class: "panel panel-primary" do
15
+ concat(panel_title(label, slide_form_close_button(object_class)))
16
+ concat(content_tag(:div, class: "panel-body") { form_for(object, options, &block) })
36
17
  end
37
18
  end
38
19
 
@@ -40,64 +21,66 @@ module PhantomForms
40
21
  options[:validate] = true
41
22
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
42
23
  options[:html] = {:class => 'normal-form form'}
43
- content_tag :div, class: "row" do
44
- content_tag :div, class: "col-md-12" do
45
- form_for(object, options, &block)
46
- end
24
+
25
+ object_name = get_class(extract_object(object))
26
+ object_class = options[:resource] || object_name
27
+ label = options[:label] || t("#{object_name.underscore}.singular")
28
+
29
+ content_tag :div, class: "panel panel-primary" do
30
+ concat(panel_title(label, slide_form_close_button(object_class))) unless label == 'nil'
31
+ concat(content_tag(:div, class: "panel-body") { form_for(object, options, &block) })
47
32
  end
48
33
  end
49
34
 
35
+
50
36
  def modal_form_for(object, options = {}, &block)
51
37
  options[:validate] = true
52
38
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
53
39
  options[:html] = {:'data-type' => 'script', :class => 'remote-form'}
54
40
  options[:remote] = true
55
- form_for(object, options, &block)
41
+
42
+ object_name = get_class(extract_object(object))
43
+ object_class = options[:resource] || object_name
44
+ label = options[:label] || t("#{object_name.underscore}.singular")
45
+
46
+ content_tag :div, class: "col-md-12 alert-dismissable" do
47
+ content_tag :div, class: "panel panel-primary" do
48
+ concat(panel_title(label, modal_close_button))
49
+ concat(content_tag(:div, class: "panel-body") { form_for(object, options, &block) })
50
+ end
51
+ end
56
52
  end
57
53
 
58
54
  def normal_modal_form_for(object, options = {}, &block)
59
55
  options[:validate] = true
60
56
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
61
57
  options[:html] = {:'data-type' => 'script', :class => 'normal-form'}
62
- form_for(object, options, &block)
63
- end
64
58
 
65
- def buttons_for(object, options = {})
66
- object_name = get_class(object)
67
- object_class = options[:nested_id] || object_name
68
-
69
- locale_name = object_name.underscore
70
- locale = options[:label] || t("#{locale_name}.save")
59
+ object_name = get_class(extract_object(object))
60
+ object_class = options[:resource] || object_name
61
+ label = options[:label] || t("#{object_name.underscore}.singular")
71
62
 
72
- content_tag :div, :class => 'row' do
73
- [
74
- content_tag(:div, :class => 'col-md-9') do
75
- concat submit_button( locale , :id => "submit-#{object_class}-button")
76
- end,
77
- content_tag(:div, :class => 'col-md-3') do
78
- concat link_to_cancel( :id => "cancel-#{object_class}-link")
79
- end
80
- ].join.html_safe
63
+ content_tag :div, class: "panel panel-primary" do
64
+ concat(panel_title(label, modal_close_button))
65
+ concat(content_tag(:div, class: "panel-body") { form_for(object, options, &block) })
81
66
  end
82
67
  end
83
68
 
84
- def modal_buttons_for(object, options = {})
69
+ def buttons_for(object, options = {})
85
70
  object_name = get_class(object)
86
- object_class = options[:nested_id] || object_name
71
+ object_class = options[:resource] || object_name
87
72
 
88
73
  locale_name = object_name.underscore
89
74
  locale = options[:label] || t("#{locale_name}.save")
90
-
91
- content_tag :div, :class => 'row' do
92
- content_tag :div, :class => 'col-md-12' do
93
- concat submit_button( locale , :id => "submit-#{object_class}-button")
94
- concat link_to_modal_cancel( :id => "cancel-#{object_class}-link")
95
- end
75
+ content_tag :div, class: "panel-footer" do
76
+ submit_button(locale, :id => "submit-#{object_class}-button")
96
77
  end
97
78
  end
98
79
 
99
80
 
100
- private
81
+ def modal_form_error(id)
82
+ content_tag :div, nil, :id => id
83
+ end
101
84
 
102
85
  def get_class(object)
103
86
  object_class_name = object.class.to_s.underscore.dasherize.split('/').last
@@ -108,5 +91,21 @@ module PhantomForms
108
91
  end
109
92
  end
110
93
 
94
+ private
95
+
96
+ def extract_object(object)
97
+ if object.kind_of?(Array)
98
+ object.last
99
+ else
100
+ object
101
+ end
102
+ end
103
+
104
+ def slide_form_close_button(object_class)
105
+ content_tag :button, id: "close-#{object_class}-button", :class => 'close-form' do
106
+ "&times".html_safe
107
+ end
108
+ end
109
+
111
110
  end
112
111
  end
@@ -15,10 +15,42 @@ formBuilder =
15
15
 
16
16
  window.Rails4ClientSideValidations.formBuilders["PhantomForms::FormBuilders::ValidateFormBuilder"] = formBuilder
17
17
 
18
- $ ->
18
+ manage_form_hiding = (resource) ->
19
+ console.log resource
20
+ resource_new_link = "#new-" + resource + "-link"
21
+ resource_form = "#new-" + resource
22
+ console.log 'resource_new_link: ' + resource_new_link
23
+ console.log 'resource_form: ' + resource_form
24
+ $(resource_new_link).show()
25
+ $(resource_form).slide()
26
+
27
+
28
+ ready = ->
19
29
 
20
30
  window.Rails4ClientSideValidations.callbacks.element.fail = (element, message, callback) ->
21
31
  callback()
22
32
  if element.data("valid") isnt false
23
33
  element.parent().parent().addClass "error"
24
34
  element.parent().find(".message").addClass "error help-inline"
35
+
36
+
37
+ $(document).off('click', '.cancel-link').on "click",".cancel-link", (e) ->
38
+ e.preventDefault()
39
+ if $(e.target).parents('.modal-body').length is 0
40
+ resource = $(this).attr("id").replace("cancel-", "").replace("-link", "")
41
+ manage_form_hiding(resource)
42
+
43
+ $(document).off('click', '.close').on "click",".close", (e) ->
44
+ e.preventDefault()
45
+ if $(e.target).parents('.modal').length is 0
46
+ resource = $(this).attr("id").replace("close-", "").replace("-button", "")
47
+ manage_form_hiding(resource)
48
+
49
+ $(document).off('click', '.close-form').on "click",".close-form", (e) ->
50
+ console.log 'close-form click'
51
+ e.preventDefault()
52
+ resource = $(this).attr("id").replace("close-", "").replace("-button", "")
53
+ manage_form_hiding(resource)
54
+
55
+ $(document).ready(ready)
56
+ $(window).bind('page:change', ready)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantom_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vassil Kalkov
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-16 00:00:00.000000000 Z
13
+ date: 2013-10-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails4_client_side_validations
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 0.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 0.0.3
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -44,16 +44,16 @@ dependencies:
44
44
  name: phantom_helpers
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: 0.11.0.alpha1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: '0'
56
+ version: 0.11.0.alpha1
57
57
  description: rails helpers for bootstrap 3
58
58
  email: info@genshin.org
59
59
  executables: []
@@ -83,9 +83,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: 1.8.7
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - '>'
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: 1.3.1
89
89
  requirements:
90
90
  - none
91
91
  rubyforge_project: