partystreusel 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
6
+ tmp/
7
+ log/
8
+ .sass-cache
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p448
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - "1.9.3-p448"
3
+ script: 'bundle exec guard-jasmine --server-timeout=60'
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # CHANGELOG
2
+
3
+ ## v1.0.0 - 2014-06-05
4
+
5
+ * Complete rework with jasmine testing
6
+ * Implemented modules:
7
+ * Read More
8
+ * Scroll To
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in partystreusel.gemspec
4
+ gemspec
5
+
6
+ group :assets do
7
+ gem 'coffee-script'
8
+ end
9
+
10
+ group :development, :test do
11
+ gem 'actionpack', '~> 3.2'
12
+ gem 'railties', '~> 3.2'
13
+ gem 'sass-rails', "~> 3.2"
14
+ gem 'tzinfo'
15
+
16
+ gem 'thin'
17
+
18
+ gem 'jasminerice'
19
+ gem 'jquery-rails'
20
+ gem 'i18n-js'
21
+ gem 'guard-jasmine'
22
+ end
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :jasmine, console: :always do
5
+ watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
6
+ watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
7
+ watch(%r{spec/javascripts/fixtures/.+$})
8
+ watch(%r{app/assets/stylesheets/.+$})
9
+ watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" }
10
+ end
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ [![Build Status](https://travis-ci.org/screenconcept/partystreusel.svg?branch=development)](https://travis-ci.org/screenconcept/partystreusel)
2
+ # Partystreusel
3
+
4
+ ## Installation
5
+
6
+ Add **partystreusel** to your Gemfile `gem 'partystreusel'` and bundle.
7
+
8
+ Partystreusel depends on i18n-js. Make sure you followed install
9
+ instructions on: https://github.com/fnando/i18n-js
10
+
11
+ Include in your application.js.coffee:
12
+
13
+ #= require partystreusel/<<modulename>>
14
+
15
+ $ ->
16
+ Streusel.<<Modulename>>.init()
17
+
18
+ For example for readmore:
19
+
20
+ #= require partystreusel/readmore
21
+
22
+ $ ->
23
+ Streusel.Readmore.init()
24
+
25
+ If you only want to initialize readmore for a part of the document:
26
+
27
+ Streusel.Readmore.init($('body article.loadedwithajax'))
28
+
29
+ # Module Usage
30
+
31
+ Available modules:
32
+ * Streusel.scrollTo
33
+ * Streusel.Readmore
34
+
35
+ ## Scroll To
36
+
37
+ This is just a function. Usage:
38
+
39
+ # scroll to a[name=linkname]
40
+ Streusel.scrollTo(link: 'linkname')
41
+
42
+ # scroll to selector
43
+ Streusel.scrollTo('selector')
44
+
45
+ # scroll to jquery element
46
+ Streusel.scrollTo($('selector'))
47
+
48
+ # you can scroll to element with a pixeloffset
49
+ # selector will be 12px below window top
50
+ Streusel.scrollTo('selector', offset: -12)
51
+
52
+ hint: If element to scroll to could not be found, the function returns
53
+ false. If element was found, return the found jquery element.
54
+
55
+ ## Read More
56
+
57
+ Use code below depending on environment you are in. If the content is
58
+ empty or contains only whitespaces, nothing will be displayed.
59
+
60
+ ### Rails
61
+
62
+ - readmore do
63
+ Your text....
64
+
65
+ You can use any haml tag option. E.g.
66
+
67
+ - readmore(class: 'mycustomclass') do
68
+ Your text....
69
+
70
+ ### Html
71
+
72
+ <div class='mycustomclass' data-streusel-readmore>
73
+ Your text....
74
+ </div>
75
+
76
+ Will be rendered to something like:
77
+
78
+ <div class='mycustomclass' data-streusel-readmore>
79
+ <div>Your text....</div>
80
+ <a ...>Read more</a>
81
+ </div>
82
+
83
+ ## Development
84
+
85
+ Test with
86
+
87
+ bundle exec guard
88
+
89
+ Or run the yasmine test directly with:
90
+
91
+ bundle exec guard-jasmine
92
+
93
+ Compare documentation on: https://github.com/netzpirat/guard-jasmine
94
+
95
+ Help for jasmine testing:
96
+ * http://jasmine.github.io/1.3/introduction.html
97
+
98
+ To help testing the following jasmine helpers are installed:
99
+ * https://github.com/searls/jasmine-fixture
100
+ * https://github.com/velesin/jasmine-jquery
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,2 @@
1
+ #= require partystreusel/translations
2
+ #= require partystreusel/all
@@ -0,0 +1,2 @@
1
+ #= require partystreusel/scroll_to
2
+ #= require partystreusel/readmore
@@ -0,0 +1,13 @@
1
+ #= require partystreusel/namespace
2
+ class Partystreusel.Base
3
+
4
+ @selector: ->
5
+ "[data-streusel-#{@prototype.constructor.name.toLowerCase()}]"
6
+
7
+ @init: (element = $('body')) ->
8
+ element.find(@selector()).map (i, el) =>
9
+ new @(el)
10
+
11
+ constructor: (el) ->
12
+ @$el = $(el)
13
+ @$el.data('object', @)
@@ -0,0 +1,2 @@
1
+ window.Partystreusel = {}
2
+ window.Streusel = Partystreusel
@@ -0,0 +1,42 @@
1
+ #= require partystreusel/base
2
+
3
+ class Readmore extends Partystreusel.Base
4
+
5
+ constructor: (el) ->
6
+ super
7
+
8
+ @contentDiv = $('<div/>')
9
+ .append(@$el.contents())
10
+ .addClass('hide')
11
+ @$el.append(@contentDiv)
12
+
13
+ @button = @renderButton('open')
14
+ $(@button).bind 'click', @toggle
15
+ @$el.append(@button)
16
+
17
+ toggle: (event) =>
18
+ @button.toggleClass('open close')
19
+ @button.text(@buttonText())
20
+ @contentDiv.slideToggle =>
21
+ @contentDiv.toggleClass('hide')
22
+ @contentDiv.css('display', "")
23
+ @contentDiv.removeAttr('style') if @contentDiv.attr('style') == ''
24
+ return false
25
+
26
+ buttonState: ->
27
+ classes = @button.attr('class').split(' ')
28
+ classes = classes.filter (v) -> v != 'button'
29
+ classes[0]
30
+
31
+ buttonText: (state = @buttonState()) ->
32
+ I18n.t("readmore.button_text.#{state}")
33
+
34
+ renderButton: (state) =>
35
+ text = @buttonText(state)
36
+
37
+ $('<a></a>')
38
+ .addClass(state + ' button')
39
+ .attr('href', '#')
40
+ .html(text)
41
+
42
+ Partystreusel.Readmore = Readmore
@@ -0,0 +1,15 @@
1
+ #= require partystreusel/namespace
2
+ Partystreusel.scrollTo = (x, relativeOffset = 0) ->
3
+ if typeof x == 'object' && !(x instanceof $)
4
+ # expect this is a hash and link is defined
5
+ x = $("a[name=#{JSON.stringify(x.link)}]")
6
+
7
+ if typeof x == 'string'
8
+ x = $(x)
9
+ if typeof x != 'number'
10
+ x = x.offset()?.top
11
+
12
+ return false unless x?
13
+
14
+ x = Math.round(x) + relativeOffset
15
+ $("html,body").animate({scrollTop: x}, 'slow')
@@ -0,0 +1,18 @@
1
+ I18n.translations ||=
2
+ en:
3
+ readmore:
4
+ button_text:
5
+ open: 'Read more'
6
+ close: 'Read less'
7
+
8
+ de:
9
+ readmore:
10
+ button_text:
11
+ open: 'Mehr lesen'
12
+ close: 'Weniger lesen'
13
+
14
+ fr:
15
+ readmore:
16
+ button_text:
17
+ open: 'Lire la suite'
18
+ close: 'Afficher moins'
@@ -0,0 +1,2 @@
1
+ .hide
2
+ display: none
data/config.ru ADDED
@@ -0,0 +1,21 @@
1
+ require 'action_controller/railtie'
2
+ require 'jasminerice'
3
+ require 'guard/jasmine'
4
+ require 'sprockets/railtie'
5
+ require 'jquery-rails'
6
+ require 'i18n-js'
7
+
8
+ class JasmineTest < Rails::Application
9
+ routes.append do
10
+ mount Jasminerice::Engine, at: '/jasmine'
11
+ end
12
+
13
+ config.cache_classes = true
14
+ config.active_support.deprecation = :log
15
+ config.assets.enabled = true
16
+ config.assets.version = '1.0'
17
+ config.secret_token = '9696be98e32a5f213730cb7ed6161c79'
18
+ end
19
+
20
+ JasmineTest.initialize!
21
+ run JasmineTest
@@ -0,0 +1,14 @@
1
+ module Partystreusel
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
7
+ require "partystreusel/version"
8
+ require "partystreusel/helpers"
9
+
10
+ if defined?(ActiveSupport)
11
+ ActiveSupport.on_load(:action_view) do
12
+ include Partystreusel::Helpers::ReadmoreHelper
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Partystreusel::Helpers
2
+ end
3
+
4
+ require 'partystreusel/helpers/readmore_helper'
@@ -0,0 +1,12 @@
1
+ module Partystreusel::Helpers::ReadmoreHelper
2
+
3
+ def readmore(*rest, &block)
4
+ attrs = {}
5
+ attrs = rest.shift if rest.last.is_a?(Hash)
6
+ attrs.symbolize_keys!
7
+ attrs[:data] ||= {}
8
+ attrs[:data]['streusel-readmore'] = true
9
+ haml_tag(:div, *rest, attrs, &block)
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ module Partystreusel
2
+ VERSION = "1.0.2"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "partystreusel/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "partystreusel"
7
+ s.version = Partystreusel::VERSION
8
+ s.authors = ["Flavio Pellanda"]
9
+ s.email = ["flavio.pellanda@screenconcetch"]
10
+ s.homepage = "http://www.screenconcept.ch"
11
+ s.summary = %q{A collection uf reusable javascript components by Screen Concept}
12
+ s.description = %q{Contains sliders, accordions, expandable contents and any other component we deem worthy of joining this collection of awesomeness.}
13
+
14
+ s.rubyforge_project = "partystreusel"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.add_runtime_dependency 'railties'
21
+ s.add_runtime_dependency 'i18n-js'
22
+ end
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.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -51,6 +51,28 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
+ - .gitignore
55
+ - .ruby-version
56
+ - .travis.yml
57
+ - CHANGELOG.md
58
+ - Gemfile
59
+ - Guardfile
60
+ - README.md
61
+ - Rakefile
62
+ - app/assets/javascripts/partystreusel.js.coffee
63
+ - app/assets/javascripts/partystreusel/all.js.coffee
64
+ - app/assets/javascripts/partystreusel/base.js.coffee
65
+ - app/assets/javascripts/partystreusel/namespace.js.coffee
66
+ - app/assets/javascripts/partystreusel/readmore.js.coffee
67
+ - app/assets/javascripts/partystreusel/scroll_to.js.coffee
68
+ - app/assets/javascripts/partystreusel/translations.js.coffee
69
+ - app/assets/stylesheets/partystreusel.css.sass
70
+ - config.ru
71
+ - lib/partystreusel.rb
72
+ - lib/partystreusel/helpers.rb
73
+ - lib/partystreusel/helpers/readmore_helper.rb
74
+ - lib/partystreusel/version.rb
75
+ - partystreusel.gemspec
54
76
  - spec/javascripts/helpers/.gitkeep
55
77
  - spec/javascripts/helpers/jasmine-fixture.js
56
78
  - spec/javascripts/helpers/jasmine-jquery.js
@@ -66,7 +88,6 @@ post_install_message:
66
88
  rdoc_options: []
67
89
  require_paths:
68
90
  - lib
69
- - app
70
91
  required_ruby_version: !ruby/object:Gem::Requirement
71
92
  none: false
72
93
  requirements: