framework7-rails 0.7.4.0 → 0.9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +50 -45
  3. data/app/helpers/app_helper.rb +1 -1
  4. data/app/helpers/bar_helper.rb +45 -0
  5. data/app/helpers/bar_item_helper.rb +105 -0
  6. data/app/helpers/content_block_helper.rb +66 -0
  7. data/app/helpers/framework7_helper.rb +26 -0
  8. data/app/helpers/list_block_helper.rb +180 -0
  9. data/app/helpers/pages_helper.rb +66 -0
  10. data/app/helpers/panel_helper.rb +27 -0
  11. data/app/helpers/toolbar_helper.rb +52 -0
  12. data/app/helpers/views_helper.rb +36 -0
  13. data/app/presenters/framework7/base_presenter.rb +24 -0
  14. data/framework7-rails.gemspec +5 -1
  15. data/lib/framework7.rb +6 -0
  16. data/lib/framework7/rails/version.rb +1 -1
  17. data/lib/generators/f7/install/examples/examples_generator.rb +17 -0
  18. data/lib/generators/f7/install/examples/templates/app/controllers/examples_controller.rb +16 -0
  19. data/lib/generators/f7/install/examples/templates/app/views/examples/about.html.erb +27 -0
  20. data/lib/generators/f7/install/examples/templates/app/views/examples/form.html.erb +227 -0
  21. data/lib/generators/f7/install/examples/templates/app/views/examples/index.html.erb +80 -0
  22. data/lib/generators/f7/install/examples/templates/app/views/examples/services.html.erb +27 -0
  23. data/lib/generators/f7/install/install_generator.rb +1 -1
  24. data/lib/generators/f7/install/templates/application.css +1 -0
  25. data/lib/generators/f7/layout/layout_generator.rb +17 -3
  26. data/lib/generators/f7/layout/templates/layout.html.erb +9 -82
  27. data/lib/generators/f7/layout/templates/setup.coffee +10 -0
  28. data/lib/generators/f7/layout/templates/setup.js +12 -0
  29. data/vendor/assets/javascripts/framework7.js +5859 -1140
  30. data/vendor/assets/stylesheets/framework7.css +2569 -244
  31. data/vendor/assets/stylesheets/framework7.rtl.css +427 -0
  32. data/vendor/assets/stylesheets/framework7.themes.css +279 -0
  33. metadata +56 -15
  34. data/lib/generators/f7/layout/templates/app.js.coffee.erb +0 -77
  35. data/vendor/assets/images/i-form-checkbox-black.png +0 -0
  36. data/vendor/assets/images/i-form-checkbox-blue.png +0 -0
  37. data/vendor/assets/images/i-form-checkbox-white.png +0 -0
  38. data/vendor/assets/images/i-form-radio-black.png +0 -0
  39. data/vendor/assets/images/i-form-radio-blue.png +0 -0
  40. data/vendor/assets/images/i-form-radio-white.png +0 -0
  41. data/vendor/assets/javascripts/framework7.min.js +0 -16
  42. data/vendor/assets/stylesheets/framework7.min.css +0 -15
@@ -0,0 +1,66 @@
1
+ module PagesHelper
2
+ @pages = []
3
+
4
+ def f7_pages(options = {}, &block)
5
+ @pages = []
6
+ css_classes = ['pages']
7
+ css_classes << "navbar-#{options[:navbar]}" if options[:navbar]
8
+ css_classes << "toolbar-#{options[:toolbar]}" if options[:toolbar]
9
+ options[:class] = css_classes + ([options[:class]] || [])
10
+
11
+ options.reject! { |k, v| [:navbar, :toolbar].include? k }
12
+
13
+ content_tag :div, options do
14
+ yield if block_given?
15
+ end
16
+ end
17
+
18
+
19
+
20
+ def f7_page(name, options = {}, &block)
21
+ @pages << name
22
+ @no_bar = []
23
+ current_view = (@current_view).underscore
24
+ layout = options[:layout] || false
25
+ css_classes = ['page']
26
+
27
+ css_classes << bar_classes_for(options[:padding]) unless options[:padding].nil?
28
+ css_classes += [options[:class]] if options[:class]
29
+
30
+ options.reject! { |k, v| [:class, :layout, :padding].include? k }
31
+ options[:class] = css_classes.uniq
32
+
33
+ content_tag :div, options, 'data-page' => name do
34
+ if block_given?
35
+ yield
36
+ else
37
+ render :partial => "#{controller.controller_path}/#{current_view}/#{name}", :layout => layout
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def bar_classes_for(padding)
45
+ padding = [padding].flatten
46
+ classes = []
47
+ toolbar_pad = nil
48
+
49
+ if padding.include? :no_navbar
50
+ classes << 'no-navbar'
51
+ elsif padding.include? :navbar
52
+ classes << 'navbar'
53
+ end
54
+
55
+ if padding.include? :no_toolbar
56
+ classes << 'no-toolbar'
57
+ elsif padding.include? :tabbar_labels
58
+ classes << 'tabbar-labels-fixed'
59
+ elsif padding.include? :toolbar
60
+ classes << 'toolbar-fixed'
61
+ end
62
+
63
+ classes.join(' ')
64
+ end
65
+
66
+ end
@@ -0,0 +1,27 @@
1
+ module PanelHelper
2
+
3
+ def f7_panel(*args, &block)
4
+ options = args.first || {}
5
+
6
+ panel_div(options)
7
+ end
8
+
9
+ private
10
+
11
+ def panel_div(options = {}, &block)
12
+ output = []
13
+ css_classes = ['panel']
14
+ css_classes << "panel-#{options[:side]}" if options[:side]
15
+ css_classes << "panel-#{options[:show]}" if options[:show]
16
+ css_classes += options[:class] if options[:class]
17
+ css_classes.uniq!
18
+
19
+ opts = { :class => css_classes }
20
+ opts[:id] = options[:id] if options[:id]
21
+
22
+ content_tag :div, opts do
23
+ output << capture(&block) if block_given?
24
+ output.join("\n").html_safe
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,52 @@
1
+ module ToolbarHelper
2
+
3
+ def f7_toolbar_item(title_or_options, options=nil, &block)
4
+ output = []
5
+ if title_or_options.class == Hash
6
+ options = title_or_options if options.nil?
7
+ title = options[:title]
8
+ else
9
+ title = title_or_options
10
+ end
11
+ title ||= capture(&block) if block_given?
12
+
13
+ href = options[:href] || '#'
14
+
15
+ css_classes = []
16
+ css_classes << (@is_tabbar ? 'tab-link' : 'link')
17
+ css_classes += [options[:class]] if options[:class]
18
+
19
+ if @is_tabbar
20
+ if options.has_key? :icon
21
+ content_tag :a, :href => href, :class => css_classes do
22
+ if options[:badge]
23
+ if options[:badge].kind_of? Hash
24
+ badge_data = options[:badge]
25
+ badge_classes = [:badge]
26
+ badge_classes << badge_data[:class]
27
+ badge = content_tag :span, badge_data[:text], :class => badge_classes
28
+ else
29
+ badge = content_tag :span, options[:badge], :class => [:badge, 'badge-red']
30
+ end
31
+ link = link_icon_i(options[:icon], badge)
32
+ else
33
+ link = link_icon_i(options[:icon])
34
+ end
35
+ output << link
36
+ output << content_tag(:span, title, :class => 'tabbar-label') if @has_labels && !title.blank?
37
+ output.join("\n").html_safe
38
+ end
39
+ else
40
+ content_tag :a, title, :href => href, :class => css_classes
41
+ end
42
+ else
43
+ content_tag :a, title, :href => href, :class => css_classes
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def link_icon_i(icon, badge = '')
50
+ content_tag :i, badge, :class => ['icon', icon]
51
+ end
52
+ end
@@ -0,0 +1,36 @@
1
+ module ViewsHelper
2
+ @current_view = nil
3
+ @views_defined = false
4
+
5
+ def f7_views(*args, &block)
6
+ return if @views_defined
7
+ @views_defined = true
8
+ @current_view = nil
9
+
10
+ content_tag :div, :class => ['views'] do
11
+ yield if block_given?
12
+ end
13
+ end
14
+
15
+
16
+
17
+ def f7_view(name, html_options = {}, &block)
18
+ name = name.to_s.gsub(/view-/,'')
19
+ @current_view = name
20
+
21
+ view_name = "view-#{name}"
22
+
23
+ css_classes = ['view']
24
+ css_classes << view_name
25
+ html_options[:class] = css_classes + ([html_options[:class]] || [])
26
+
27
+ content_tag :div, html_options do
28
+ if block_given?
29
+ yield
30
+ else
31
+ render :partial => "#{controller.controller_path}/#{name}/#{name}", :layout => false
32
+ end
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,24 @@
1
+ class Framework7::BasePresenter
2
+ def initialize(object, template)
3
+ @object = object
4
+ @template = template
5
+ end
6
+
7
+ def self.presents(name)
8
+ define_method(name) do
9
+ @object
10
+ end
11
+ end
12
+
13
+ def h
14
+ @template
15
+ end
16
+
17
+ def method_missing(*args, &block)
18
+ if @template.respond_to? args.first
19
+ @template.send(*args, &block)
20
+ else
21
+ @object.send(*args, &block)
22
+ end
23
+ end
24
+ end
@@ -2,6 +2,7 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'framework7/rails/version'
5
+ require 'framework7'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "framework7-rails"
@@ -14,11 +15,14 @@ Gem::Specification.new do |spec|
14
15
  spec.license = "MIT"
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
18
+ # spec.files = `git ls-files --stage`.gsub(/^([0-9]{6}\s[0-9a-f]*\s[0-9]\s)/, '').split("\n") # For development
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
21
  spec.require_paths = ["lib"]
20
22
 
21
- spec.add_dependency "railties", "~> 4.0"
23
+ spec.add_dependency "railties", "> 3.1"
24
+ spec.add_dependency "coffee-script", "> 2.1"
25
+ spec.add_dependency "coffee-rails", "> 3.2.1"
22
26
 
23
27
  spec.add_development_dependency "bundler", "~> 1.5"
24
28
  spec.add_development_dependency "rake", "~> 0"
@@ -0,0 +1,6 @@
1
+ module Framework7
2
+ end
3
+
4
+ if defined?(Rails)
5
+ ActionController::Base.send(:helper, Framework7Helper)
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Framework7
2
2
  module Rails
3
- VERSION = "0.7.4.0"
3
+ VERSION = "0.9.6.0"
4
4
  end
5
5
  end
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+
3
+ module F7
4
+ module Generators
5
+ class LayoutGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ desc 'This generator creates an example application.'
8
+
9
+ empty_directory "app/assets/javascripts/views"
10
+ create_file "app/assets/javascripts/views/.gitkeep"
11
+
12
+ directory "app"
13
+
14
+ route "get 'examples(/:action)' => 'examples#index', :as => 'examples'"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ class ExamplesController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def about
6
+ render :layout => false
7
+ end
8
+
9
+ def form
10
+ render :layout => false
11
+ end
12
+
13
+ def services
14
+ render :layout => false
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ <!-- We don't need full layout here, because this page will be parsed with Ajax-->
2
+ <!-- Top Navbar-->
3
+ <div class="navbar">
4
+ <div class="navbar-inner">
5
+ <div class="left"><a href="#" class="back link"><i class="icon icon-back-blue"></i><span>Back</span></a></div>
6
+ <div class="center sliding">About</div>
7
+ <div class="right">
8
+ <!-- Right link contains only icon - additional "icon-only" class--><a href="#" class="link icon-only open-panel"><i class="icon icon-bars-blue"></i></a>
9
+ </div>
10
+ </div>
11
+ </div>
12
+ <div class="pages">
13
+ <!-- Page, data-page contains page name-->
14
+ <div data-page="about" class="page">
15
+ <!-- Scrollable page content-->
16
+ <div class="page-content">
17
+ <div class="content-block">
18
+ <div class="content-block-inner">
19
+ <p>Here is About page!</p>
20
+ <p>Go <a href="#" class="back">back</a> or click <a href="#" class="create-page">here </a>to create dynamic page.</p>
21
+ <p>Mauris posuere sit amet metus id venenatis. Ut ante dolor, tempor nec commodo rutrum, varius at sem. Nullam ac nisi non neque ornare pretium. Nulla mauris mauris, consequat et elementum sit amet, egestas sed orci. In hac habitasse platea dictumst.</p>
22
+ <p>Fusce eros lectus, accumsan eget mi vel, iaculis tincidunt felis. Nulla tincidunt pharetra sagittis. Fusce in felis eros. Nulla sit amet aliquam lorem, et gravida ipsum. Mauris consectetur nisl non sollicitudin tristique. Praesent vitae metus ac quam rhoncus mattis vel et nisi. Aenean aliquet, felis quis dignissim iaculis, lectus quam tincidunt ligula, et venenatis turpis risus sed lorem. Morbi eu metus elit. Ut vel diam dolor.</p>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
@@ -0,0 +1,227 @@
1
+ <!-- We don't need full layout here, because this page will be parsed with Ajax-->
2
+ <!-- Top Navbar-->
3
+ <div class="navbar">
4
+ <div class="navbar-inner">
5
+ <div class="left"><a href="#" class="back link"><i class="icon icon-back-blue"></i><span>Back</span></a></div>
6
+ <div class="center sliding">Form</div>
7
+ <div class="right">
8
+ <!-- Right link contains only icon - additional "icon-only" class--><a href="#" class="link icon-only open-panel"><i class="icon icon-bars-blue"></i></a>
9
+ </div>
10
+ </div>
11
+ </div>
12
+ <div class="pages">
13
+ <!-- Page, data-page contains page name-->
14
+ <div data-page="form" class="page">
15
+ <!-- Scrollable page content-->
16
+ <div class="page-content">
17
+ <div class="content-block-title">Form Example</div>
18
+ <div class="list-block">
19
+ <ul>
20
+ <li>
21
+ <div class="item-content">
22
+ <div class="item-media"><i class="icon icon-form-name"></i></div>
23
+ <div class="item-inner">
24
+ <div class="item-title label">Name</div>
25
+ <div class="item-input">
26
+ <input type="text" placeholder="Your name"/>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </li>
31
+ <li>
32
+ <div class="item-content">
33
+ <div class="item-media"><i class="icon icon-form-email"></i></div>
34
+ <div class="item-inner">
35
+ <div class="item-title label">E-mail</div>
36
+ <div class="item-input">
37
+ <input type="email" placeholder="E-mail"/>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </li>
42
+ <li>
43
+ <div class="item-content">
44
+ <div class="item-media"><i class="icon icon-form-url"></i></div>
45
+ <div class="item-inner">
46
+ <div class="item-title label">URL</div>
47
+ <div class="item-input">
48
+ <input type="url" placeholder="URL"/>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </li>
53
+ <li>
54
+ <div class="item-content">
55
+ <div class="item-media"><i class="icon icon-form-password"></i></div>
56
+ <div class="item-inner">
57
+ <div class="item-title label">Password</div>
58
+ <div class="item-input">
59
+ <input type="password" placeholder="Password"/>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </li>
64
+ <li>
65
+ <div class="item-content">
66
+ <div class="item-media"><i class="icon icon-form-tel"></i></div>
67
+ <div class="item-inner">
68
+ <div class="item-title label">Phone</div>
69
+ <div class="item-input">
70
+ <input type="tel" placeholder="Phone"/>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </li>
75
+ <li>
76
+ <div class="item-content">
77
+ <div class="item-media"><i class="icon icon-form-gender"></i></div>
78
+ <div class="item-inner">
79
+ <div class="item-title label">Gender</div>
80
+ <div class="item-input">
81
+ <select>
82
+ <option>Male</option>
83
+ <option>Female</option>
84
+ </select>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </li>
89
+ <li>
90
+ <div class="item-content">
91
+ <div class="item-media"><i class="icon icon-form-calendar"></i></div>
92
+ <div class="item-inner">
93
+ <div class="item-title label">Birth date</div>
94
+ <div class="item-input">
95
+ <input type="date" placeholder="Birth day" value="2014-04-30"/>
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </li>
100
+ <li>
101
+ <div class="item-content">
102
+ <div class="item-media"><i class="icon icon-form-toggle"></i></div>
103
+ <div class="item-inner">
104
+ <div class="item-title label">Switch</div>
105
+ <div class="item-input">
106
+ <label class="label-switch">
107
+ <input type="checkbox"/>
108
+ </label>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </li>
113
+ <li>
114
+ <div class="item-content">
115
+ <div class="item-media"><i class="icon icon-form-settings"></i></div>
116
+ <div class="item-inner">
117
+ <div class="item-title label">Slider</div>
118
+ <div class="item-input">
119
+ <div class="range-slider">
120
+ <input type="range" min="0" max="100" value="50" step="0.1"/>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </li>
126
+ <li class="align-top">
127
+ <div class="item-content">
128
+ <div class="item-media"><i class="icon icon-form-comment"></i></div>
129
+ <div class="item-inner">
130
+ <div class="item-title label">Textarea</div>
131
+ <div class="item-input">
132
+ <textarea></textarea>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </li>
137
+ </ul>
138
+ </div>
139
+ <div class="content-block">
140
+ <div class="row">
141
+ <div class="col-50"><a href="#" class="button button-big button-cancel">Cancel</a></div>
142
+ <div class="col-50">
143
+ <input type="submit" value="Submit" class="button button-big button-submit"/>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ <div class="content-block-title">Checkbox group</div>
148
+ <div class="list-block">
149
+ <ul>
150
+ <li>
151
+ <label class="label-checkbox item-content">
152
+ <input type="checkbox" name="ks-checkbox" value="Books" checked="checked"/>
153
+ <div class="item-media"><i class="icon icon-form-checkbox"></i></div>
154
+ <div class="item-inner">
155
+ <div class="item-title">Books</div>
156
+ </div>
157
+ </label>
158
+ </li>
159
+ <li>
160
+ <label class="label-checkbox item-content">
161
+ <input type="checkbox" name="ks-checkbox" value="Movies"/>
162
+ <div class="item-media"><i class="icon icon-form-checkbox"></i></div>
163
+ <div class="item-inner">
164
+ <div class="item-title">Movies</div>
165
+ </div>
166
+ </label>
167
+ </li>
168
+ <li>
169
+ <label class="label-checkbox item-content">
170
+ <input type="checkbox" name="ks-checkbox" value="Food"/>
171
+ <div class="item-media"><i class="icon icon-form-checkbox"></i></div>
172
+ <div class="item-inner">
173
+ <div class="item-title">Food</div>
174
+ </div>
175
+ </label>
176
+ </li>
177
+ <li>
178
+ <label class="label-checkbox item-content">
179
+ <input type="checkbox" name="ks-checkbox" value="Drinks"/>
180
+ <div class="item-media"><i class="icon icon-form-checkbox"></i></div>
181
+ <div class="item-inner">
182
+ <div class="item-title">Drinks</div>
183
+ </div>
184
+ </label>
185
+ </li>
186
+ </ul>
187
+ </div>
188
+ <div class="content-block-title">Radio buttons group</div>
189
+ <div class="list-block">
190
+ <ul>
191
+ <li>
192
+ <label class="label-radio item-content">
193
+ <input type="radio" name="ks-radio" value="Books" checked="checked"/>
194
+ <div class="item-inner">
195
+ <div class="item-title">Books</div>
196
+ </div>
197
+ </label>
198
+ </li>
199
+ <li>
200
+ <label class="label-radio item-content">
201
+ <input type="radio" name="ks-radio" value="Movies"/>
202
+ <div class="item-inner">
203
+ <div class="item-title">Movies</div>
204
+ </div>
205
+ </label>
206
+ </li>
207
+ <li>
208
+ <label class="label-radio item-content">
209
+ <input type="radio" name="ks-radio" value="Food"/>
210
+ <div class="item-inner">
211
+ <div class="item-title">Food</div>
212
+ </div>
213
+ </label>
214
+ </li>
215
+ <li>
216
+ <label class="label-radio item-content">
217
+ <input type="radio" name="ks-radio" value="Drinks"/>
218
+ <div class="item-inner">
219
+ <div class="item-title">Drinks</div>
220
+ </div>
221
+ </label>
222
+ </li>
223
+ </ul>
224
+ </div>
225
+ </div>
226
+ </div>
227
+ </div>