corkboard 0.1.0 → 0.1.1
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.
- data/.env.template +1 -0
- data/.gitignore +15 -0
- data/.rspec.template +2 -0
- data/.rvmrc.template +4 -0
- data/.wiprc +0 -0
- data/.yardopts +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +223 -0
- data/app/assets/images/corkboard/.gitkeep +0 -0
- data/corkboard.gemspec +41 -0
- data/lib/corkboard/version.rb +1 -1
- data/script/rails +8 -0
- data/spec/controllers/corkboard/application_controller_spec.rb +7 -0
- data/spec/controllers/corkboard/authorizations_controller_spec.rb +26 -0
- data/spec/controllers/corkboard/board_controller_spec.rb +29 -0
- data/spec/controllers/corkboard/posts_controller_spec.rb +7 -0
- data/spec/corkboard/client_spec.rb +52 -0
- data/spec/corkboard/clients/instagram_spec.rb +30 -0
- data/spec/corkboard/engine_spec.rb +11 -0
- data/spec/corkboard/provider_spec.rb +28 -0
- data/spec/corkboard/providers/instagram_spec.rb +44 -0
- data/spec/corkboard/publishers/mock_spec.rb +12 -0
- data/spec/corkboard/publishers/pusher_spec.rb +12 -0
- data/spec/corkboard/service/config_spec.rb +12 -0
- data/spec/corkboard_spec.rb +136 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +65 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/corkboard.rb +45 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/jasmine.rb +5 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/db/migrate/20121212222912_create_corkboard_authorizations.corkboard.rb +18 -0
- data/spec/dummy/db/schema.rb +31 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/helpers/corkboard/application_helper_spec.rb +7 -0
- data/spec/javascripts/fixtures/board.html +3 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +340 -0
- data/spec/javascripts/spec.css +3 -0
- data/spec/javascripts/spec.js +5 -0
- data/spec/javascripts/spec_helper.js +41 -0
- data/spec/javascripts/specs/corkboard/app/board_spec.js +68 -0
- data/spec/javascripts/specs/corkboard/base_spec.js +17 -0
- data/spec/javascripts/specs/corkboard/lib/publisher_spec.js +101 -0
- data/spec/javascripts/specs/corkboard/lib/weighted_randomizer_spec.js +23 -0
- data/spec/javascripts/specs/corkboard_spec.js +45 -0
- data/spec/javascripts/support/jasmine.yml +75 -0
- data/spec/javascripts/support/jasmine_config.rb +1 -0
- data/spec/models/corkboard/authorization_spec.rb +7 -0
- data/spec/models/corkboard/post_spec.rb +7 -0
- data/spec/models/corkboard/subscription_spec.rb +7 -0
- data/spec/requests/authorizations_spec.rb +39 -0
- data/spec/requests/board_spec.rb +70 -0
- data/spec/routing/authorizations_routing_spec.rb +25 -0
- data/spec/routing/board_routing_spec.rb +7 -0
- data/spec/routing/posts_routing_spec.rb +15 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/helpers/config_helpers.rb +26 -0
- data/spec/support/helpers/controller_helpers.rb +12 -0
- data/spec/support/helpers/post_helpers.rb +119 -0
- data/vendor/assets/javascripts/jquery.masonry-extensions.js +203 -0
- data/vendor/assets/javascripts/jquery.masonry.js +499 -0
- data/vendor/assets/javascripts/modernizr.js +821 -0
- data/vendor/assets/javascripts/pusher.js +48 -0
- metadata +176 -11
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Board", :js => false do
|
4
|
+
before do
|
5
|
+
Corkboard.publish!([example_post(:instagram)])
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "GET corkboard/board#show" do
|
9
|
+
context "when the authentication requirement for 'board' is :disallow!" do
|
10
|
+
it "raises an exception" do
|
11
|
+
with_config(:authentication, { :board => :disallow! }) do
|
12
|
+
expect { visit corkboard.board_path }
|
13
|
+
.to raise_error(Corkboard::ActionForbidden)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when the authentication requirement for 'board' is nil" do
|
19
|
+
it "is successful" do
|
20
|
+
with_config(:authentication, { :board => nil }) do
|
21
|
+
visit corkboard.board_path
|
22
|
+
|
23
|
+
expect(page).to have_css('article#corkboard')
|
24
|
+
expect(page).to have_css('nav.corkboard.filters')
|
25
|
+
expect(page).to have_css('ul.corkboard.posts')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "given an authenticated User" do
|
31
|
+
before do
|
32
|
+
Corkboard::ApplicationController.any_instance
|
33
|
+
.stub(:authenticate!).and_return(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "is successful" do
|
37
|
+
with_config(:authentication, { :board => :authenticate! }) do
|
38
|
+
visit corkboard.board_path
|
39
|
+
|
40
|
+
expect(page).to have_css('article#corkboard')
|
41
|
+
expect(page).to have_css('nav.corkboard.filters')
|
42
|
+
expect(page).to have_css('ul.corkboard.posts')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when presentation framework is nil" do
|
48
|
+
it "renders with the default DOM" do
|
49
|
+
with_config(:presentation, { :framework => nil }) do
|
50
|
+
visit corkboard.board_path
|
51
|
+
|
52
|
+
expect(page).to have_css('nav.corkboard.filters > ul')
|
53
|
+
expect(page).to have_css('nav.corkboard.filters > ul > li:first-child.active')
|
54
|
+
expect(page).to_not have_css('nav.corkboard.filters > ul[class]')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when presentation framework is :bootstrap" do
|
60
|
+
it "renders with the Bootstrap-enabled DOM" do
|
61
|
+
with_config(:presentation, { :framework => :bootstrap }) do
|
62
|
+
visit corkboard.board_path
|
63
|
+
|
64
|
+
expect(page).to have_css('nav.corkboard.filters > ul.btn-group')
|
65
|
+
expect(page).to have_css('nav.corkboard.filters > ul > li.active.btn')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Routing for Authorizations" do
|
4
|
+
it "maps GET ':mount_point/auth' to #index" do
|
5
|
+
expect(:get => '/auth').to route_to('corkboard/authorizations#index')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "maps GET ':mount_point/auth/:provider/callback' to #create" do
|
9
|
+
expect(:get => '/auth/example/callback').to route_to('corkboard/authorizations#create', {
|
10
|
+
:provider => 'example'
|
11
|
+
})
|
12
|
+
end
|
13
|
+
|
14
|
+
it "maps POST ':mount_point/auth/:provider/callback' to #create" do
|
15
|
+
expect(:post => '/auth/example/callback').to route_to('corkboard/authorizations#create', {
|
16
|
+
:provider => 'example'
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
it "maps DELETE ':mount_point/auth/:provider' to #destroy" do
|
21
|
+
expect(:delete => '/auth/example').to route_to('corkboard/authorizations#destroy', {
|
22
|
+
:provider => 'example'
|
23
|
+
})
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Routing for Posts" do
|
4
|
+
it "maps GET ':mount_point/posts/:provider/callback' to #create" do
|
5
|
+
expect(:get => '/posts/example/callback').to route_to('corkboard/posts#create', {
|
6
|
+
:provider => 'example'
|
7
|
+
})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "maps POST ':mount_point/posts/:provider/callback' to #create" do
|
11
|
+
expect(:post => '/posts/example/callback').to route_to('corkboard/posts#create', {
|
12
|
+
:provider => 'example'
|
13
|
+
})
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'capybara/rspec'
|
7
|
+
require 'ffaker'
|
8
|
+
require 'mock_redis'
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[Rails.root.join("../support/**/*.rb")].each {|f| require f}
|
13
|
+
|
14
|
+
Capybara.register_driver :firefox do |app|
|
15
|
+
Capybara::Selenium::Driver.new(app, :browser => :firefox)
|
16
|
+
end
|
17
|
+
|
18
|
+
Capybara.javascript_driver = (ENV['CAPYBARA_JS'] || :webkit).intern
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include Capybara::RSpecMatchers
|
22
|
+
config.include Support::ConfigHelpers
|
23
|
+
config.include Support::ControllerHelpers
|
24
|
+
config.include Support::PostHelpers
|
25
|
+
|
26
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
27
|
+
# examples within a transaction, remove the following line or assign false
|
28
|
+
# instead of true.
|
29
|
+
config.use_transactional_fixtures = true
|
30
|
+
|
31
|
+
# If true, the base class of anonymous controllers will be inferred
|
32
|
+
# automatically. This will be the default behavior in future versions of
|
33
|
+
# rspec-rails.
|
34
|
+
config.infer_base_class_for_anonymous_controllers = false
|
35
|
+
|
36
|
+
# Run specs in random order to surface order dependencies. If you find an
|
37
|
+
# order dependency and want to debug it, you can fix the order by providing
|
38
|
+
# the seed, which is printed after each run.
|
39
|
+
# --seed 1234
|
40
|
+
config.order = "random"
|
41
|
+
|
42
|
+
config.before(:suite) do
|
43
|
+
Corkboard.publisher(:mock)
|
44
|
+
end
|
45
|
+
|
46
|
+
config.before(:each, :type => :controller) { @routes = Corkboard::Engine.routes }
|
47
|
+
config.before(:each, :type => :routing) { @routes = Corkboard::Engine.routes }
|
48
|
+
config.before(:each) do
|
49
|
+
Corkboard.redis = MockRedis.new
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Support
|
2
|
+
module ConfigHelpers
|
3
|
+
def with_config(method, value)
|
4
|
+
Corkboard.send(method, value)
|
5
|
+
yield
|
6
|
+
ensure
|
7
|
+
# NOTE: capturing and resetting-to the original (above) resulted in
|
8
|
+
# intermittent failures. Using defaults here is more stable, but
|
9
|
+
# will require maintenance (in the event that the defaults change).
|
10
|
+
Corkboard.send(method, send(:"defaults_for_#{method}"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def defaults_for_authentication
|
14
|
+
{ :admin => :disallow!, :board => nil }
|
15
|
+
end
|
16
|
+
|
17
|
+
def defaults_for_presentation
|
18
|
+
{
|
19
|
+
:title => 'Corkboard',
|
20
|
+
:description => 'Corkboard',
|
21
|
+
:framework => :bootstrap,
|
22
|
+
:weights => { :s => 10, :m => 3, :l => 1 }
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Support
|
2
|
+
module ControllerHelpers
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# Wrap `ActionController::TestCase::Behavior` actions with routing fixes
|
6
|
+
# for engine development.
|
7
|
+
def process(*args)
|
8
|
+
args[1] = (args[1] || {}).merge({ :use_route => :corkboard })
|
9
|
+
super(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module Support
|
2
|
+
module PostHelpers
|
3
|
+
def example_post(service)
|
4
|
+
send(:"example_post_for_#{service}")
|
5
|
+
end
|
6
|
+
|
7
|
+
def example_post_for_instagram
|
8
|
+
Instagram.new.to_mash
|
9
|
+
end
|
10
|
+
|
11
|
+
class Instagram
|
12
|
+
def to_hash
|
13
|
+
{
|
14
|
+
"id" => post_id,
|
15
|
+
"link" => post_url,
|
16
|
+
"tags" => tags,
|
17
|
+
"caption" => {
|
18
|
+
"created_time" => timestamp,
|
19
|
+
"text" => Faker::Lorem.sentence,
|
20
|
+
"from" => {
|
21
|
+
"id" => user_id,
|
22
|
+
"username" => user_name,
|
23
|
+
"full_name" => full_name,
|
24
|
+
"profile_picture" => image_url
|
25
|
+
},
|
26
|
+
"id"=>"340900468247837201"
|
27
|
+
},
|
28
|
+
"images" => {
|
29
|
+
"low_resolution" => {
|
30
|
+
"url" => image_url,
|
31
|
+
"width" => 306,
|
32
|
+
"height" => 306
|
33
|
+
},
|
34
|
+
"standard_resolution" => {
|
35
|
+
"url" => image_url,
|
36
|
+
"width" => 612,
|
37
|
+
"height" => 612
|
38
|
+
},
|
39
|
+
"thumbnail" => {
|
40
|
+
"url" => image_url,
|
41
|
+
"width" => 150,
|
42
|
+
"height" => 150
|
43
|
+
}
|
44
|
+
},
|
45
|
+
"location" => {
|
46
|
+
"id" => location_id,
|
47
|
+
"name" => location_name,
|
48
|
+
"latitude" => location_lat,
|
49
|
+
"longitude" => location_lng
|
50
|
+
},
|
51
|
+
"user" => {
|
52
|
+
"id" => user_id,
|
53
|
+
"username" => user_name,
|
54
|
+
"full_name" => full_name,
|
55
|
+
"bio" => "",
|
56
|
+
"website" => "",
|
57
|
+
"profile_picture" => image_url
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_json
|
63
|
+
JSON.dump(to_hash)
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_mash
|
67
|
+
Hashie::Mash.new(to_hash)
|
68
|
+
end
|
69
|
+
|
70
|
+
def image_url
|
71
|
+
@image_url ||= Faker::Internet.http_url
|
72
|
+
end
|
73
|
+
|
74
|
+
def location_id
|
75
|
+
@location_id ||= "1234567"
|
76
|
+
end
|
77
|
+
|
78
|
+
def location_name
|
79
|
+
@location_name ||= Faker::Address.city
|
80
|
+
end
|
81
|
+
|
82
|
+
def location_lat
|
83
|
+
@location_lat ||= Faker::Geolocation.lat
|
84
|
+
end
|
85
|
+
|
86
|
+
def location_lng
|
87
|
+
@location_lng ||= Faker::Geolocation.lng
|
88
|
+
end
|
89
|
+
|
90
|
+
def post_id
|
91
|
+
@post_id ||= "123456789123456789_12345678"
|
92
|
+
end
|
93
|
+
|
94
|
+
def post_url
|
95
|
+
@post_url ||= Faker::Internet.http_url
|
96
|
+
end
|
97
|
+
|
98
|
+
def tags
|
99
|
+
@tags ||= Faker::Lorem.words
|
100
|
+
end
|
101
|
+
|
102
|
+
def timestamp
|
103
|
+
@timestamp ||= 1.day.ago.to_i
|
104
|
+
end
|
105
|
+
|
106
|
+
def user_id
|
107
|
+
@user_id ||= "0987654321"
|
108
|
+
end
|
109
|
+
|
110
|
+
def user_name
|
111
|
+
@user_name ||= Faker::Internet.user_name
|
112
|
+
end
|
113
|
+
|
114
|
+
def full_name
|
115
|
+
@full_name ||= Faker::Name.name
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
(function($) {
|
2
|
+
var Modernizr = window.Modernizr;
|
3
|
+
|
4
|
+
// helper function
|
5
|
+
var capitalize = function( str ) {
|
6
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
7
|
+
};
|
8
|
+
|
9
|
+
// ========================= getStyleProperty by kangax ===============================
|
10
|
+
// http://perfectionkills.com/feature-testing-css-properties/
|
11
|
+
|
12
|
+
var prefixes = 'Moz Webkit O Ms'.split(' ');
|
13
|
+
|
14
|
+
var getStyleProperty = function( propName ) {
|
15
|
+
var style = document.documentElement.style,
|
16
|
+
prefixed;
|
17
|
+
|
18
|
+
// test standard property first
|
19
|
+
if ( typeof style[propName] === 'string' ) {
|
20
|
+
return propName;
|
21
|
+
}
|
22
|
+
|
23
|
+
// capitalize
|
24
|
+
propName = capitalize( propName );
|
25
|
+
|
26
|
+
// test vendor specific properties
|
27
|
+
for ( var i=0, len = prefixes.length; i < len; i++ ) {
|
28
|
+
prefixed = prefixes[i] + propName;
|
29
|
+
if ( typeof style[ prefixed ] === 'string' ) {
|
30
|
+
return prefixed;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
var transformProp = getStyleProperty('transform'),
|
36
|
+
transitionProp = getStyleProperty('transitionProperty');
|
37
|
+
|
38
|
+
// ========================= isoTransform ===============================
|
39
|
+
/**
|
40
|
+
* provides hooks for .css({ scale: value, translate: [x, y] })
|
41
|
+
* Progressively enhanced CSS transforms
|
42
|
+
* Uses hardware accelerated 3D transforms for Safari
|
43
|
+
* or falls back to 2D transforms.
|
44
|
+
*/
|
45
|
+
|
46
|
+
if ( Modernizr.csstransforms ) {
|
47
|
+
// i.e. transformFnNotations.scale(0.5) >> 'scale3d( 0.5, 0.5, 1)'
|
48
|
+
var transformFnNotations = Modernizr.csstransforms3d ?
|
49
|
+
{ // 3D transform functions
|
50
|
+
translate : function ( position ) {
|
51
|
+
return 'translate3d(' + position[0] + 'px, ' + position[1] + 'px, 0) ';
|
52
|
+
},
|
53
|
+
scale : function ( scale ) {
|
54
|
+
return 'scale3d(' + scale + ', ' + scale + ', 1) ';
|
55
|
+
}
|
56
|
+
} :
|
57
|
+
{ // 2D transform functions
|
58
|
+
translate : function ( position ) {
|
59
|
+
return 'translate(' + position[0] + 'px, ' + position[1] + 'px) ';
|
60
|
+
},
|
61
|
+
scale : function ( scale ) {
|
62
|
+
return 'scale(' + scale + ') ';
|
63
|
+
}
|
64
|
+
}
|
65
|
+
;
|
66
|
+
|
67
|
+
var setIsoTransform = function ( elem, name, value ) {
|
68
|
+
// unpack current transform data
|
69
|
+
var data = $.data( elem, 'isoTransform' ) || {},
|
70
|
+
newData = {},
|
71
|
+
fnName,
|
72
|
+
transformObj = {},
|
73
|
+
transformValue;
|
74
|
+
|
75
|
+
// i.e. newData.scale = 0.5
|
76
|
+
newData[ name ] = value;
|
77
|
+
// extend new value over current data
|
78
|
+
$.extend( data, newData );
|
79
|
+
|
80
|
+
for ( fnName in data ) {
|
81
|
+
transformValue = data[ fnName ];
|
82
|
+
transformObj[ fnName ] = transformFnNotations[ fnName ]( transformValue );
|
83
|
+
}
|
84
|
+
|
85
|
+
// get proper order
|
86
|
+
// ideally, we could loop through this give an array, but since we only have
|
87
|
+
// a couple transforms we're keeping track of, we'll do it like so
|
88
|
+
var translateFn = transformObj.translate || '',
|
89
|
+
scaleFn = transformObj.scale || '',
|
90
|
+
// sorting so translate always comes first
|
91
|
+
valueFns = translateFn + scaleFn;
|
92
|
+
|
93
|
+
// set data back in elem
|
94
|
+
$.data( elem, 'isoTransform', data );
|
95
|
+
|
96
|
+
// set name to vendor specific property
|
97
|
+
elem.style[ transformProp ] = valueFns;
|
98
|
+
};
|
99
|
+
|
100
|
+
// ==================== scale ===================
|
101
|
+
$.cssNumber.scale = true;
|
102
|
+
|
103
|
+
$.cssHooks.scale = {
|
104
|
+
set: function( elem, value ) {
|
105
|
+
// uncomment this bit if you want to properly parse strings
|
106
|
+
// if ( typeof value === 'string' ) {
|
107
|
+
// value = parseFloat( value );
|
108
|
+
// }
|
109
|
+
setIsoTransform( elem, 'scale', value );
|
110
|
+
},
|
111
|
+
get: function( elem, computed ) {
|
112
|
+
var transform = $.data( elem, 'isoTransform' );
|
113
|
+
return transform && transform.scale ? transform.scale : 1;
|
114
|
+
}
|
115
|
+
};
|
116
|
+
|
117
|
+
$.fx.step.scale = function( fx ) {
|
118
|
+
$.cssHooks.scale.set( fx.elem, fx.now+fx.unit );
|
119
|
+
};
|
120
|
+
|
121
|
+
// ==================== translate ===================
|
122
|
+
$.cssNumber.translate = true;
|
123
|
+
|
124
|
+
$.cssHooks.translate = {
|
125
|
+
set: function( elem, value ) {
|
126
|
+
|
127
|
+
// uncomment this bit if you want to properly parse strings
|
128
|
+
// if ( typeof value === 'string' ) {
|
129
|
+
// value = value.split(' ');
|
130
|
+
// }
|
131
|
+
//
|
132
|
+
// var i, val;
|
133
|
+
// for ( i = 0; i < 2; i++ ) {
|
134
|
+
// val = value[i];
|
135
|
+
// if ( typeof val === 'string' ) {
|
136
|
+
// val = parseInt( val );
|
137
|
+
// }
|
138
|
+
// }
|
139
|
+
|
140
|
+
setIsoTransform( elem, 'translate', value );
|
141
|
+
},
|
142
|
+
|
143
|
+
get: function( elem, computed ) {
|
144
|
+
var transform = $.data( elem, 'isoTransform' );
|
145
|
+
return transform && transform.translate ? transform.translate : [ 0, 0 ];
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
// ========================= get transition-end event ===============================
|
152
|
+
var transitionEndEvent, transitionDurProp;
|
153
|
+
|
154
|
+
if ( Modernizr.csstransitions ) {
|
155
|
+
transitionEndEvent = {
|
156
|
+
WebkitTransitionProperty: 'webkitTransitionEnd', // webkit
|
157
|
+
MozTransitionProperty: 'transitionend',
|
158
|
+
OTransitionProperty: 'oTransitionEnd otransitionend',
|
159
|
+
transitionProperty: 'transitionend'
|
160
|
+
}[ transitionProp ];
|
161
|
+
|
162
|
+
transitionDurProp = getStyleProperty('transitionDuration');
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
var hideStyle = { opacity: 0, zoom: 0.001 };
|
167
|
+
var showStyle = { opacity: 1, zoom: 1 };
|
168
|
+
|
169
|
+
if(Modernizr.csstransforms && Modernizr.csstransitions) {
|
170
|
+
hideStyle = { opacity: 0, scale: 0.001 };
|
171
|
+
showStyle = { opacity: 1, scale: 1 };
|
172
|
+
}
|
173
|
+
|
174
|
+
// ====================== Filtering ======================
|
175
|
+
$.Mason.prototype.filter = function(items, selector, callback) {
|
176
|
+
var filtered = items.filter(selector);
|
177
|
+
var hiddenClass = 'hidden',
|
178
|
+
hiddenSelector = '.' + hiddenClass,
|
179
|
+
$hiddenItems = items.filter(hiddenSelector),
|
180
|
+
$itemsToShow = $hiddenItems,
|
181
|
+
$itemsToHide;
|
182
|
+
|
183
|
+
if(selector !== '*') {
|
184
|
+
$itemsToShow = $hiddenItems.filter(selector);
|
185
|
+
$itemsToHide = items.not(hiddenSelector).not(selector).addClass(hiddenClass);
|
186
|
+
this.styleQueue.push({ $el: $itemsToHide, style: hideStyle });
|
187
|
+
|
188
|
+
$itemsToHide.each(function() {
|
189
|
+
var item = $(this);
|
190
|
+
item.data('_originalDimensions') || item.data('_originalDimensions', {
|
191
|
+
width : item.width(),
|
192
|
+
height : item.height()
|
193
|
+
});
|
194
|
+
});
|
195
|
+
}
|
196
|
+
|
197
|
+
this.styleQueue.push({ $el: $itemsToShow, style: showStyle });
|
198
|
+
$itemsToShow.removeClass(hiddenClass);
|
199
|
+
|
200
|
+
this.reload();
|
201
|
+
return filtered;
|
202
|
+
};
|
203
|
+
})(jQuery);
|