light_mobile 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +69 -0
- data/app/assets/images/light_mobile/buttons/button_dark_bg.png +0 -0
- data/app/assets/images/light_mobile/buttons/menu_icon.png +0 -0
- data/app/assets/images/light_mobile/layout/header_bar_bg.png +0 -0
- data/app/assets/javascripts/light_mobile/tabs.js.coffee +43 -0
- data/app/assets/stylesheets/light_mobile/{application.css → application.css.scss} +1 -1
- data/app/assets/stylesheets/light_mobile/buttons.css.scss +4 -2
- data/app/assets/stylesheets/light_mobile/menu.css.scss +2 -2
- data/app/assets/stylesheets/light_mobile/tables.css.scss +5 -0
- data/app/assets/stylesheets/light_mobile/tabs.css.scss +47 -0
- data/app/helpers/light_mobile/tabs_helper.rb +7 -0
- data/lib/light_mobile.rb +11 -0
- data/lib/light_mobile/dynamic_renderer.rb +22 -0
- data/lib/light_mobile/mime_types.rb +1 -0
- data/lib/light_mobile/tabs.rb +24 -0
- data/lib/light_mobile/version.rb +1 -1
- metadata +27 -4
- data/README.rdoc +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fccd16ca88cb142929c239c8337d9155be9bc53a
|
4
|
+
data.tar.gz: 003903363eb21e6c0b9148472a90665cd7265ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4c17a8d4614bee9ac566fd6a0c9bd3d2fe6b300f474d41f39bb7f1f3ffd2e572f5b23f66f5425a0eba90ae6d42b4269c5ba76444870713ba536c49eb801371
|
7
|
+
data.tar.gz: ca123691596a97685cc2b2b74eaa2699770dcb44d3fac4a7db52525827602059a6aeb89819ff024020dc1176815eb8abcb362a8836a0d8e9414631503ebf1ec5
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# LightMobile
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
|
6
|
+
### Gemfile
|
7
|
+
|
8
|
+
Add to your Gemfile and bundle.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "light_mobile"
|
12
|
+
```
|
13
|
+
|
14
|
+
### ApplicationController
|
15
|
+
|
16
|
+
Add this include to your ApplicationController.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class ApplicationController < ActionController::Base
|
20
|
+
include LightMobile::DynamicRenderer
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
### MimeTypes
|
25
|
+
|
26
|
+
Add this to "config/initializers/mime_types.rb":
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require "light_mobile/mime_types"
|
30
|
+
```
|
31
|
+
|
32
|
+
### CSS
|
33
|
+
|
34
|
+
Add a new file "app/assets/stylesheets/application_mobile.css.scss":
|
35
|
+
|
36
|
+
```scss
|
37
|
+
/*
|
38
|
+
*= require light_mobile/buttons
|
39
|
+
*= require light_mobile/menu
|
40
|
+
*= require light_mobile/simple_form
|
41
|
+
*= require light_mobile/tables
|
42
|
+
*/
|
43
|
+
```
|
44
|
+
|
45
|
+
### JavaScript
|
46
|
+
|
47
|
+
Add a new file "app/assets/javascripts/application_mobile.js.coffee":
|
48
|
+
```coffee
|
49
|
+
#= require light_mobile/menu
|
50
|
+
```
|
51
|
+
|
52
|
+
## Usage
|
53
|
+
|
54
|
+
### Tabs
|
55
|
+
|
56
|
+
```haml
|
57
|
+
= mobile_tabs do |tabs|
|
58
|
+
- tabs.tab label: "Details", id: "tab-details", active: true
|
59
|
+
- tabs.tab label: "Comments", id: "tab-comments"
|
60
|
+
- tabs.tab label: "Assigned Users", id: "tab-assigned-users"
|
61
|
+
|
62
|
+
#tab-details This is the details
|
63
|
+
#tab-comments This is the comments
|
64
|
+
#tab-assigned-users This is the assigned users
|
65
|
+
```
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
This project rocks and uses MIT-LICENSE.
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$ ->
|
2
|
+
$("table.mobile-tabs").each ->
|
3
|
+
lightMobileInitTabs($(this))
|
4
|
+
|
5
|
+
lightMobileInitTabs = (tabs) ->
|
6
|
+
tds = $("tbody > tr > td", tabs)
|
7
|
+
|
8
|
+
tds.click (e) ->
|
9
|
+
lightMobileActivateTab(tabs, $(this))
|
10
|
+
|
11
|
+
if match = location.hash.match(/^#mobile-tab-(.+)$/)
|
12
|
+
mobile_tab_active = match[1]
|
13
|
+
|
14
|
+
tds.each ->
|
15
|
+
tab = $(this)
|
16
|
+
active_tab = false
|
17
|
+
|
18
|
+
container = $("#" + tab.data("tab"))
|
19
|
+
container.addClass("mobile-tabs-container")
|
20
|
+
|
21
|
+
if mobile_tab_active
|
22
|
+
active_tab = true if mobile_tab_active == tab.data("tab")
|
23
|
+
else if tab.hasClass("mobile-tab-active")
|
24
|
+
active_tab = true
|
25
|
+
|
26
|
+
if active_tab
|
27
|
+
tab.addClass("mobile-tab-active")
|
28
|
+
container.addClass("mobile-tabs-container-active")
|
29
|
+
else
|
30
|
+
tab.removeClass("mobile-tab-active")
|
31
|
+
|
32
|
+
lightMobileActivateTab = (tabs, tab) ->
|
33
|
+
active_tab = $("> tbody > tr > td.mobile-tab-active", tabs)
|
34
|
+
active_tab.removeClass("mobile-tab-active")
|
35
|
+
tab.addClass("mobile-tab-active")
|
36
|
+
|
37
|
+
active_container = $("#" + active_tab.data("tab"))
|
38
|
+
active_container.removeClass("mobile-tabs-container-active")
|
39
|
+
|
40
|
+
new_container = $("#" + tab.data("tab"))
|
41
|
+
new_container.addClass("mobile-tabs-container-active")
|
42
|
+
|
43
|
+
location.hash = "mobile-tab-" + tab.data("tab")
|
@@ -4,7 +4,6 @@ a.mobile-button:link, a.mobile-button:visited, a.mobile-button:hover, a.mobile-b
|
|
4
4
|
text-decoration: none;
|
5
5
|
display: block;
|
6
6
|
color: #000000;
|
7
|
-
cursor: default;
|
8
7
|
}
|
9
8
|
|
10
9
|
.mobile-button {
|
@@ -16,6 +15,8 @@ a.mobile-button:link, a.mobile-button:visited, a.mobile-button:hover, a.mobile-b
|
|
16
15
|
text-align: center;
|
17
16
|
height: 41px;
|
18
17
|
white-space: nowrap;
|
18
|
+
cursor: pointer;
|
19
|
+
margin-bottom: 10px;
|
19
20
|
|
20
21
|
&.mobile-button-primary {
|
21
22
|
border-color: #006486;
|
@@ -25,13 +26,14 @@ a.mobile-button:link, a.mobile-button:visited, a.mobile-button:hover, a.mobile-b
|
|
25
26
|
|
26
27
|
&.mobile-button-dark {
|
27
28
|
border-color: #7c7c7c;
|
28
|
-
background-image: url("/
|
29
|
+
background-image: url("/assets/light_mobile/buttons/button_dark_bg.png");
|
29
30
|
color: #ffffff !important;
|
30
31
|
}
|
31
32
|
|
32
33
|
&.mobile-button-danger {
|
33
34
|
border-color: #761c18;
|
34
35
|
background: linear-gradient(#aa363b, #8d1f23);
|
36
|
+
color: #ffffff !important;
|
35
37
|
}
|
36
38
|
|
37
39
|
&.mobile-button-small {
|
@@ -3,14 +3,14 @@
|
|
3
3
|
top: 8px;
|
4
4
|
left: 8px;
|
5
5
|
border: 1px solid #7c7c7c;
|
6
|
-
background-image: url("/
|
6
|
+
background-image: url("/assets/light_mobile/buttons/button_dark_bg.png");
|
7
7
|
border-radius: 3px;
|
8
8
|
width: 24px;
|
9
9
|
height: 24px;
|
10
10
|
cursor: pointer;
|
11
11
|
|
12
12
|
.mobile-menu-button-icon {
|
13
|
-
background-image: url("/
|
13
|
+
background-image: url("/assets/light_mobile/buttons/menu_icon.png");
|
14
14
|
background-size: 19px 19px;
|
15
15
|
background-repeat: no-repeat;
|
16
16
|
background-position: 2px 2px;
|
@@ -47,6 +47,11 @@
|
|
47
47
|
td:not(:first-child):not(:last-child) {
|
48
48
|
border-top: 1px solid #ababab;
|
49
49
|
}
|
50
|
+
|
51
|
+
/* If there is only one row, then the top border should still be shown */
|
52
|
+
td:first-child:last-child {
|
53
|
+
border-top: 1px solid #ababab;
|
54
|
+
}
|
50
55
|
}
|
51
56
|
|
52
57
|
/* If a thead is present, the border of the first td row should not have radius. */
|
@@ -0,0 +1,47 @@
|
|
1
|
+
table.mobile-tabs {
|
2
|
+
width: 100%;
|
3
|
+
border-spacing: 0px;
|
4
|
+
border-collapse: separate;
|
5
|
+
margin-bottom: 15px;
|
6
|
+
table-layout: fixed;
|
7
|
+
|
8
|
+
> tbody {
|
9
|
+
> tr {
|
10
|
+
> td {
|
11
|
+
border: 1px solid #ababab;
|
12
|
+
border-right: none;
|
13
|
+
background-color: #f6f6f6;
|
14
|
+
list-style-type: none;
|
15
|
+
padding: 10px;
|
16
|
+
text-align: center;
|
17
|
+
cursor: pointer;
|
18
|
+
width: auto;
|
19
|
+
}
|
20
|
+
|
21
|
+
> td.mobile-tab-active {
|
22
|
+
font-weight: bold;
|
23
|
+
background-color: #5595bf;
|
24
|
+
color: #ffffff;
|
25
|
+
}
|
26
|
+
|
27
|
+
> td:first-child {
|
28
|
+
border-top-left-radius: 10px;
|
29
|
+
border-bottom-left-radius: 10px;
|
30
|
+
}
|
31
|
+
|
32
|
+
> td:last-child {
|
33
|
+
border-top-right-radius: 10px;
|
34
|
+
border-bottom-right-radius: 10px;
|
35
|
+
border-right: 1px solid #ababab;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
.mobile-tabs-container {
|
42
|
+
display: none;
|
43
|
+
|
44
|
+
&.mobile-tabs-container-active {
|
45
|
+
display: block;
|
46
|
+
}
|
47
|
+
}
|
data/lib/light_mobile.rb
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
require "light_mobile/engine"
|
2
|
+
require "html_gen"
|
2
3
|
|
3
4
|
module LightMobile
|
5
|
+
def self.const_missing(name)
|
6
|
+
file_name = "#{::File.dirname(__FILE__)}/light_mobile/#{::StringCases.camel_to_snake(name)}.rb"
|
7
|
+
|
8
|
+
if ::File.exists?(file_name)
|
9
|
+
require file_name
|
10
|
+
return ::LightMobile.const_get(name) if ::LightMobile.const_defined?(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
super
|
14
|
+
end
|
4
15
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module LightMobile::DynamicRenderer
|
2
|
+
# In order to only render mobile views if they exist.
|
3
|
+
def render(*args, &blk)
|
4
|
+
if request.user_agent && view_context.agent_mobile? && (session[:light_mobile_version].to_s == "mobile" || !session[:light_mobile_version].present?)
|
5
|
+
name = args[0]
|
6
|
+
name = action_name.to_sym if !name.is_a?(Symbol) && !name.is_a?(String)
|
7
|
+
|
8
|
+
if name.is_a? Symbol
|
9
|
+
view_paths.each do |view_path|
|
10
|
+
ActionView::Template::Handlers.extensions.each do |handler|
|
11
|
+
full_path = "#{view_path}/#{controller_path}/#{name}.mobile.#{handler}"
|
12
|
+
next unless File.exists? full_path
|
13
|
+
request.format = :mobile
|
14
|
+
self.formats = [:mobile, :html]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Mime::Type.register "text/html", :mobile
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class LightMobile::Tabs
|
2
|
+
def initialize(args)
|
3
|
+
@tabs = []
|
4
|
+
end
|
5
|
+
|
6
|
+
def tab(args)
|
7
|
+
@tabs << args
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_html
|
11
|
+
table = ::HtmlGen::Element.new(:table, classes: ["mobile-tabs"])
|
12
|
+
tr = table.add_ele(:tbody).add_ele(:tr)
|
13
|
+
|
14
|
+
@tabs.each do |tab|
|
15
|
+
td = tr.add_ele(:td)
|
16
|
+
|
17
|
+
td.classes << "mobile-tab-active" if tab[:active]
|
18
|
+
td.data[:tab] = tab[:id]
|
19
|
+
td.add_str tab[:label]
|
20
|
+
end
|
21
|
+
|
22
|
+
table.html.html_safe
|
23
|
+
end
|
24
|
+
end
|
data/lib/light_mobile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light_mobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: html_gen
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.6
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sqlite3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,21 +60,30 @@ extensions: []
|
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- MIT-LICENSE
|
49
|
-
- README.
|
63
|
+
- README.md
|
50
64
|
- Rakefile
|
65
|
+
- app/assets/images/light_mobile/buttons/button_dark_bg.png
|
66
|
+
- app/assets/images/light_mobile/buttons/menu_icon.png
|
67
|
+
- app/assets/images/light_mobile/layout/header_bar_bg.png
|
51
68
|
- app/assets/javascripts/light_mobile/application.js
|
52
69
|
- app/assets/javascripts/light_mobile/menu.js.coffee
|
53
|
-
- app/assets/
|
70
|
+
- app/assets/javascripts/light_mobile/tabs.js.coffee
|
71
|
+
- app/assets/stylesheets/light_mobile/application.css.scss
|
54
72
|
- app/assets/stylesheets/light_mobile/buttons.css.scss
|
55
73
|
- app/assets/stylesheets/light_mobile/menu.css.scss
|
56
74
|
- app/assets/stylesheets/light_mobile/simple_form.css.scss
|
57
75
|
- app/assets/stylesheets/light_mobile/tables.css.scss
|
76
|
+
- app/assets/stylesheets/light_mobile/tabs.css.scss
|
58
77
|
- app/controllers/light_mobile/application_controller.rb
|
59
78
|
- app/helpers/light_mobile/application_helper.rb
|
79
|
+
- app/helpers/light_mobile/tabs_helper.rb
|
60
80
|
- app/views/layouts/light_mobile/application.html.erb
|
61
81
|
- config/routes.rb
|
62
82
|
- lib/light_mobile.rb
|
83
|
+
- lib/light_mobile/dynamic_renderer.rb
|
63
84
|
- lib/light_mobile/engine.rb
|
85
|
+
- lib/light_mobile/mime_types.rb
|
86
|
+
- lib/light_mobile/tabs.rb
|
64
87
|
- lib/light_mobile/version.rb
|
65
88
|
- lib/tasks/light_mobile_tasks.rake
|
66
89
|
- test/dummy/README.rdoc
|
data/README.rdoc
DELETED