angular-masonry-rails 0.11.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a8408b4ff8405cbb973fac7f4cf62c76443798fb
4
+ data.tar.gz: 65bb61e2ac58682478cba692b0118b5e347fee21
5
+ SHA512:
6
+ metadata.gz: 57e0f6d0b780a81ae7a0d9e96e02e1f7f266ed5573b785c46a3c99ed251bc1e3e15978467775a5e3b200fe0ba769fc5cfeb4e1fee127c4f6aaab3f6885d51df7
7
+ data.tar.gz: ddaffaa0facf53adba7d756cd0f1657ace78f8bd97420413a647ffc55fcc14917ee5999fa8af5a9478efd7ffc564f8f56dfa3ce5fc5a221d4adf2f783370112d
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Andrew H. Yi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # angular-masonry-rails
2
+
3
+ angular-masonry-rails wraps the [Angular Masonry](https://github.com/passy/angular-masonry) library for use in Rails 4.0 and above. Assets will minify automatically during production.
4
+
5
+ ## Usage
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'angular-masonry-rails'
11
+ ```
12
+
13
+ Add the following directive to your JavaScript manifest file (application.js):
14
+
15
+ //= require angular-masonry
16
+
17
+ ## Contributing
18
+
19
+ Bug reports and pull requests are welcome on GitHub at https://github.com/AndrewHYi/angular-masonry-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
20
+
21
+
22
+ ## License
23
+
24
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ require "angular-masonry-rails/version"
2
+
3
+ module AngularMasonry
4
+ module Rails
5
+ if defined? ::Rails::Engine
6
+ require "angular-masonry-rails/engine"
7
+ elsif defined? Sprockets
8
+ require "angular-masonry-rails/sprockets"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module AngularMasonry
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ require 'sprockets'
2
+
3
+ Sprockets.append_path File.expand_path("../../../vendor/assets/javascripts", __FILE__)
@@ -0,0 +1,5 @@
1
+ module AngularMasonry
2
+ module Rails
3
+ VERSION = "0.11.0"
4
+ end
5
+ end
@@ -0,0 +1,139 @@
1
+ /*!
2
+ * angular-masonry 0.11.0
3
+ * Pascal Hartig, weluse GmbH, http://weluse.de/
4
+ * License: MIT
5
+ */
6
+ (function () {
7
+ 'use strict';
8
+ angular.module('wu.masonry', []).controller('MasonryCtrl', [
9
+ '$scope',
10
+ '$element',
11
+ '$timeout',
12
+ function controller($scope, $element, $timeout) {
13
+ var bricks = {};
14
+ var destroyed = false;
15
+ var self = this;
16
+ var timeout = null;
17
+ this.preserveOrder = false;
18
+ this.loadImages = true;
19
+
20
+ this.scheduleMasonry = function scheduleMasonry() {
21
+ $element.masonry('layout')
22
+ }
23
+
24
+ function defaultLoaded($element) {
25
+ $element.addClass('loaded');
26
+ }
27
+ this.appendBrick = function appendBrick(element, id) {
28
+ if (destroyed) {
29
+ return;
30
+ }
31
+ function _append() {
32
+ if (Object.keys(bricks).length === 0) {
33
+ $element.masonry('resize');
34
+ }
35
+ if (bricks[id] === undefined) {
36
+ // Keep track of added elements.
37
+ bricks[id] = true;
38
+ defaultLoaded(element);
39
+ $element.masonry('appended', element, true);
40
+ }
41
+ }
42
+ function _layout() {
43
+ self.scheduleMasonry('layout');
44
+ }
45
+ if (!self.loadImages) {
46
+ _append();
47
+ _layout();
48
+ } else if (self.preserveOrder) {
49
+ _append();
50
+ element.imagesLoaded(_layout);
51
+ } else {
52
+ element.imagesLoaded(function imagesLoaded() {
53
+ _append();
54
+ _layout();
55
+ });
56
+ }
57
+ };
58
+ this.removeBrick = function removeBrick(id, element) {
59
+ if (destroyed) {
60
+ return;
61
+ }
62
+ delete bricks[id];
63
+ $element.masonry('remove', element);
64
+ this.scheduleMasonry('layout');
65
+ };
66
+ this.destroy = function destroy() {
67
+ destroyed = true;
68
+ if ($element.data('masonry')) {
69
+ // Gently uninitialize if still present
70
+ $element.masonry('destroy');
71
+ }
72
+ $scope.$emit('masonry.destroyed');
73
+ bricks = [];
74
+ };
75
+ this.reload = function reload() {
76
+ $element.masonry();
77
+ $scope.$emit('masonry.reloaded');
78
+ };
79
+ }
80
+ ]).directive('masonry', function masonryDirective() {
81
+ return {
82
+ restrict: 'AE',
83
+ controller: 'MasonryCtrl',
84
+ link: {
85
+ pre: function preLink(scope, element, attrs, ctrl) {
86
+ var $element = angular.element(element)
87
+ var attrOptions = scope.$eval(attrs.masonry || attrs.masonryOptions);
88
+ var options = angular.extend({
89
+ itemSelector: attrs.itemSelector || '.masonry-brick',
90
+ columnWidth: parseInt(attrs.columnWidth, 10) || attrs.columnWidth
91
+ }, attrOptions || {});
92
+ element.masonry(options);
93
+ var loadImages = scope.$eval(attrs.loadImages);
94
+ ctrl.loadImages = loadImages !== false;
95
+ var preserveOrder = scope.$eval(attrs.preserveOrder);
96
+ ctrl.preserveOrder = preserveOrder !== false && attrs.preserveOrder !== undefined;
97
+ var reloadOnShow = scope.$eval(attrs.reloadOnShow);
98
+ if (reloadOnShow !== false && attrs.reloadOnShow !== undefined) {
99
+ scope.$watch(function () {
100
+ return element.prop('offsetParent');
101
+ }, function (isVisible, wasVisible) {
102
+ if (isVisible && !wasVisible) {
103
+ ctrl.reload();
104
+ }
105
+ });
106
+ }
107
+ scope.$emit('masonry.created', element);
108
+ scope.$on('$destroy', ctrl.destroy);
109
+ }
110
+ }
111
+ };
112
+ }).directive('masonryBrick', function masonryBrickDirective() {
113
+ return {
114
+ restrict: 'AC',
115
+ require: '^masonry',
116
+ scope: true,
117
+ link: {
118
+ pre: function preLink(scope, element, attrs, ctrl) {
119
+ var id = scope.$id, index;
120
+ ctrl.appendBrick(element, id);
121
+ element.on('$destroy', function () {
122
+ ctrl.removeBrick(id, element);
123
+ });
124
+ scope.$on('masonry.reload', function () {
125
+ ctrl.scheduleMasonry('reloadItems');
126
+ ctrl.scheduleMasonry('layout');
127
+ });
128
+ scope.$watch('$index', function () {
129
+ if (index !== undefined && index !== scope.$index) {
130
+ ctrl.scheduleMasonry('reloadItems');
131
+ ctrl.scheduleMasonry('layout');
132
+ }
133
+ index = scope.$index;
134
+ });
135
+ }
136
+ }
137
+ };
138
+ });
139
+ }());
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angular-masonry-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew H Yi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Rails wrapper for AngularJS Masonry directive
14
+ email:
15
+ - andrew.yi50@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - lib/angular-masonry-rails.rb
23
+ - lib/angular-masonry-rails/engine.rb
24
+ - lib/angular-masonry-rails/sprockets.rb
25
+ - lib/angular-masonry-rails/version.rb
26
+ - vendor/assets/javascripts/angular-masonry.js
27
+ homepage: https://github.com/AndrewHYi/angular-masonry-rails
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.4.5.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Rails wrapper for AngularJS Masonry directive
51
+ test_files: []