partystreusel 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -0
- data/app/assets/javascripts/partystreusel/base.js.coffee +3 -2
- data/app/assets/javascripts/partystreusel/foundation_helpers.js.coffee +15 -0
- data/app/assets/javascripts/partystreusel/readmore.js.coffee +2 -0
- data/lib/partystreusel/version.rb +1 -1
- data/spec/javascripts/partystreusel/base_spec.js.coffee +17 -0
- data/spec/javascripts/partystreusel/readmore_spec.js.coffee +12 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -17,6 +17,8 @@ Include in your application.js.coffee:
|
|
17
17
|
|
18
18
|
For example for readmore:
|
19
19
|
|
20
|
+
#= require i18n
|
21
|
+
#= require partystreusel/translations
|
20
22
|
#= require partystreusel/readmore
|
21
23
|
|
22
24
|
$ ->
|
@@ -34,6 +36,10 @@ Available modules:
|
|
34
36
|
|
35
37
|
## Scroll To
|
36
38
|
|
39
|
+
Add to applicaiton.js.coffee:
|
40
|
+
|
41
|
+
#= require partystreusel/scroll_to
|
42
|
+
|
37
43
|
This is just a function. Usage:
|
38
44
|
|
39
45
|
# scroll to a[name=linkname]
|
@@ -57,6 +63,16 @@ false. If element was found, return the found jquery element.
|
|
57
63
|
Use code below depending on environment you are in. If the content is
|
58
64
|
empty or contains only whitespaces, nothing will be displayed.
|
59
65
|
|
66
|
+
Readmore depends on translations and i18n js, add this to your
|
67
|
+
application.js.coffee
|
68
|
+
|
69
|
+
#= require i18n
|
70
|
+
#= require partystreusel/translations
|
71
|
+
#= require partystreusel/readmore
|
72
|
+
|
73
|
+
$ ->
|
74
|
+
Streusel.Readmore.init()
|
75
|
+
|
60
76
|
### Rails
|
61
77
|
|
62
78
|
- readmore do
|
@@ -80,6 +96,18 @@ Will be rendered to something like:
|
|
80
96
|
<a ...>Read more</a>
|
81
97
|
</div>
|
82
98
|
|
99
|
+
## Foundation Helpers
|
100
|
+
|
101
|
+
Add to applicaiton.js.coffee:
|
102
|
+
|
103
|
+
#= require partystreusel/foundation_helpers
|
104
|
+
|
105
|
+
Available Functions:
|
106
|
+
|
107
|
+
Streusel.FoundationHelpers.isLarge()
|
108
|
+
Streusel.FoundationHelpers.isMedium()
|
109
|
+
Streusel.FoundationHelpers.isSmall()
|
110
|
+
|
83
111
|
## Development
|
84
112
|
|
85
113
|
Test with
|
@@ -6,8 +6,9 @@ class Partystreusel.Base
|
|
6
6
|
"[data-streusel-#{@prototype.constructor.name.toLowerCase()}]"
|
7
7
|
|
8
8
|
@init: (element = $('body')) ->
|
9
|
-
element.find(@selector())
|
10
|
-
|
9
|
+
element.find(@selector())
|
10
|
+
.filter (i, el) -> !($(el).data('object')?)
|
11
|
+
.map (i, el) => new @(el)
|
11
12
|
|
12
13
|
constructor: (el) ->
|
13
14
|
@$el = $(el)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#= require partystreusel/namespace
|
2
|
+
|
3
|
+
class FoundationHelpers
|
4
|
+
|
5
|
+
@isSmall = ->
|
6
|
+
!matchMedia(Foundation.media_queries['medium']).matches
|
7
|
+
|
8
|
+
@isMedium = ->
|
9
|
+
matchMedia(Foundation.media_queries['medium']).matches &&
|
10
|
+
!@isLarge()
|
11
|
+
|
12
|
+
@isLarge = ->
|
13
|
+
matchMedia(Foundation.media_queries['large']).matches
|
14
|
+
|
15
|
+
Partystreusel.FoundationHelpers = FoundationHelpers
|
@@ -3,7 +3,13 @@ describe 'Base', ->
|
|
3
3
|
describe 'class functions', ->
|
4
4
|
|
5
5
|
beforeEach ->
|
6
|
+
initSpy = jasmine.createSpy('initSpy')
|
7
|
+
@initSpy = initSpy
|
8
|
+
|
6
9
|
class MyClass extends Streusel.Base
|
10
|
+
constructor: (el) ->
|
11
|
+
initSpy()
|
12
|
+
super(el)
|
7
13
|
|
8
14
|
@subject = MyClass
|
9
15
|
|
@@ -24,3 +30,14 @@ describe 'Base', ->
|
|
24
30
|
expect(tag2.data('object')).toBeDefined()
|
25
31
|
expect(tag2.data('object')).toEqual(objects[1])
|
26
32
|
|
33
|
+
it 'does not double initialize objects', ->
|
34
|
+
tag1 = affix('#c1[data-streusel-myclass]')
|
35
|
+
objects = @subject.init()
|
36
|
+
expect(objects.length).toEqual(1)
|
37
|
+
expect(@initSpy).toHaveBeenCalled()
|
38
|
+
|
39
|
+
@initSpy.reset()
|
40
|
+
spyOn(Streusel, 'Base')
|
41
|
+
objects = @subject.init()
|
42
|
+
expect(objects.length).toEqual(0)
|
43
|
+
expect(@initSpy).not.toHaveBeenCalled()
|
@@ -58,3 +58,15 @@ describe 'Readmore', ->
|
|
58
58
|
expect(@subject.find('div')).toHaveClass('hide')
|
59
59
|
expect(@subject.find('div')).not.toHaveAttr('style')
|
60
60
|
expect(@subject.find('div')).toBeHidden()
|
61
|
+
|
62
|
+
describe 'without content', ->
|
63
|
+
|
64
|
+
beforeEach ->
|
65
|
+
@subject = affix('[data-streusel-readmore]')
|
66
|
+
@subject.html(' \n ')
|
67
|
+
Partystreusel.Readmore.init()
|
68
|
+
|
69
|
+
it 'removes element when no content available', ->
|
70
|
+
expect(@subject).not.toContain('a.button')
|
71
|
+
|
72
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partystreusel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- app/assets/javascripts/partystreusel.js.coffee
|
63
63
|
- app/assets/javascripts/partystreusel/all.js.coffee
|
64
64
|
- app/assets/javascripts/partystreusel/base.js.coffee
|
65
|
+
- app/assets/javascripts/partystreusel/foundation_helpers.js.coffee
|
65
66
|
- app/assets/javascripts/partystreusel/ie_fixes.js.coffee
|
66
67
|
- app/assets/javascripts/partystreusel/namespace.js.coffee
|
67
68
|
- app/assets/javascripts/partystreusel/readmore.js.coffee
|