ember-layout 0.0.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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ember-layout.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Hedtek Ltd. and Gordon L. Hempton
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.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Ember Layout asset pipeline
2
+
3
+ Ember layout library packaged for the rails asset pipeline.
4
+
5
+ Original package came from https://github.com/ghempton/ember-layout
6
+
7
+ Commit 678e1b5137ec1962b6e00eefad261631ca5b8c09
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'ember-layout'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ember-layout
22
+
23
+ ## Usage
24
+
25
+ Add the gem to your project and add the line
26
+ //= require ember-layout
27
+ to your application's javascript manifest file
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/ember-layout/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["David Workman", "Hedtek Ltd."]
6
+ gem.email = ["gems@hedtek.com"]
7
+ gem.description = %q{Ember layout packaged for asset pipeline}
8
+ gem.summary = %q{Ember layout packaged for asset pipeline}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "ember-layout"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Ember::Layout::VERSION
17
+ end
@@ -0,0 +1,6 @@
1
+ require "ember-layout/version"
2
+
3
+ module EmberLayout
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Ember
2
+ module Layout
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,204 @@
1
+
2
+ (function(exports) {
3
+ var get = Ember.get, set = Ember.set, meta = Ember.meta;
4
+
5
+ /**
6
+ @class
7
+ This is an extension of Ember.ContainerView who's content
8
+ is restricted to a single child dicated by a property
9
+ on another view.
10
+ */
11
+ Ember.Handlebars.FrameView = Ember.ContainerView.extend({
12
+ /**
13
+ The view corresponding to the containing template
14
+ */
15
+ blockContainer: null,
16
+
17
+ /**
18
+ The property on the blockContainer which dictates the
19
+ contents of this container.
20
+ */
21
+ childPath: 'content',
22
+
23
+ /**
24
+ Set up the listener on the view corresponding to the
25
+ containing template
26
+ */
27
+ init: function() {
28
+ this._super();
29
+ var blockContainer = get(this, 'blockContainer');
30
+ blockContainer.addObserver(get(this, 'childPath'), this, 'contentDidUpdate');
31
+ this.contentDidUpdate();
32
+ },
33
+
34
+ /** @private
35
+ Fired when the property specified by contentPath changes on
36
+ the blockContainer
37
+ */
38
+ contentDidUpdate: function() {
39
+ var blockContainer = this.get('blockContainer');
40
+ var view = blockContainer.getPath(get(this, 'childPath'));
41
+ ember_assert(view instanceof Ember.View, "dynamicView's content must be set to a subclass of Ember.View'");
42
+ var childViews = this.get('_childViews');
43
+ var len = childViews.get('length');
44
+ var views = view ? [view] : [];
45
+ childViews.replace(0, len, views);
46
+ },
47
+
48
+ destroy: function() {
49
+ this._super();
50
+ var blockContainer = get(this, 'blockContainer');
51
+ blockContainer.removeObserver(get(this, 'childPath'), this, 'contentDidUpdate');
52
+ }
53
+ });
54
+
55
+ Ember.Handlebars.dynamicViewHelper = Ember.Object.create({
56
+
57
+ findContainingBlock: function(view) {
58
+ if (!view) {
59
+ return view;
60
+ }
61
+ // We are using _parentView here, because we need to go through the virtual YieldViews, so we can treat them differently.
62
+ else if (view instanceof Ember.Handlebars.FrameView) {
63
+ var blockContainer = Ember.get(view, 'blockContainer');
64
+ return this.findContainingBlock(Ember.get(blockContainer, '_parentView'));
65
+ }
66
+ else if (view.isVirtual) {
67
+ return this.findContainingBlock(Ember.get(view, '_parentView'));
68
+ }
69
+ return view;
70
+ },
71
+
72
+ helper: function(name, options) {
73
+ // If no name is provided, use default and swap parameters
74
+ if (name && name.data && name.data.isRenderData) {
75
+ options = name;
76
+ name = false;
77
+ }
78
+
79
+ var blockContainer = Ember.Handlebars.dynamicViewHelper.findContainingBlock(options.data.view);
80
+
81
+ if(name) {
82
+ options.hash.childPath = name;
83
+ }
84
+ options.hash.blockContainer = blockContainer;
85
+ return Ember.Handlebars.helpers.view.call(this, 'Ember.Handlebars.FrameView', options);
86
+ }
87
+
88
+ });
89
+
90
+ Ember.Handlebars.registerHelper('dynamicView', Ember.Handlebars.dynamicViewHelper.helper);
91
+
92
+
93
+
94
+ })({});
95
+
96
+
97
+ (function(exports) {
98
+ var get = Ember.get, set = Ember.set;
99
+
100
+ /**
101
+ @class
102
+ A convenient extension of Ember.State which makes it easy
103
+ to swap out dynamic content during state transitions.
104
+ */
105
+ Ember.LayoutState = Ember.State.extend({
106
+ /**
107
+ Convenience property to bind to.
108
+ */
109
+ active: false,
110
+
111
+ isViewState: true,
112
+
113
+ /**
114
+ The property to set in the nearest parent view
115
+ when this state is entered.
116
+ */
117
+ contentPath: 'content',
118
+
119
+ init: function() {
120
+ // This is currently experimental. We allow
121
+ // the view itself to define it's substates
122
+ // for better encapsulation. To do this, set
123
+ // the layoutStates property.
124
+ var viewClass = get(this, 'viewClass');
125
+ if(viewClass) {
126
+ var layoutStates = get(viewClass, 'proto').layoutStates;
127
+ set(this, 'states', layoutStates);
128
+ }
129
+
130
+ this._super();
131
+ },
132
+
133
+ enter: function(stateManager, transition) {
134
+ this._super(stateManager, transition);
135
+
136
+ set(this, 'active', true);
137
+
138
+ var viewClass = get(this, 'viewClass'), view;
139
+ ember_assert('view cannot be set directly, use viewClass instead', !this.get('view'));
140
+ view = this.createView(stateManager, transition);
141
+ this.set('view', view);
142
+
143
+ if (view) {
144
+ ember_assert('view must be an Ember.View', view instanceof Ember.View);
145
+
146
+
147
+ // if there is another view in the hierarchy then
148
+ // set its content
149
+ var parentView = get(this, 'parentView') || get(stateManager, 'rootView');
150
+ if(parentView) {
151
+ Ember.setPath(parentView, get(this, 'contentPath'), view);
152
+ }
153
+ // otherwise we just append to the rootElement on the
154
+ // state manager
155
+ else {
156
+ var root = stateManager.get('rootElement') || 'body';
157
+ view.appendTo(root);
158
+ }
159
+ }
160
+ },
161
+
162
+ exit: function(stateManager, transition) {
163
+ var view = get(this, 'view');
164
+
165
+ var parentView = get(this, 'parentView') || get(stateManager, 'rootView');
166
+ if(parentView) {
167
+ Ember.setPath(parentView, get(this, 'contentPath'), null);
168
+ }
169
+ else {
170
+ view.remove();
171
+ }
172
+ set(this, 'view', null);
173
+ set(this, 'active', false);
174
+ this._super(stateManager, transition);
175
+ },
176
+
177
+ /**
178
+ Instantiates viewClass. This method can be
179
+ overridden.
180
+ */
181
+ createView: function(stateManager, transition) {
182
+ var viewClass = get(this, 'viewClass');
183
+ ember_assert('viewClass must extend Ember.View', Ember.View.detect(viewClass));
184
+ return viewClass.create();
185
+ },
186
+
187
+ /**
188
+ Recursively find the nearest parent view
189
+ in the state hierarchy
190
+ */
191
+ parentView: Ember.computed(function() {
192
+ var state = this.get('parentState');
193
+ while(state && !state.get('view')) {
194
+ state = state.get('parentState');
195
+ }
196
+ return state && state.get('view');
197
+ }).property()
198
+ });
199
+
200
+ })({});
201
+
202
+
203
+ (function(exports) {
204
+ })({});
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-layout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Workman
9
+ - Hedtek Ltd.
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-03-26 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Ember layout packaged for asset pipeline
16
+ email:
17
+ - gems@hedtek.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - ember-layout.gemspec
28
+ - lib/ember-layout.rb
29
+ - lib/ember-layout/version.rb
30
+ - vendor/assets/javascripts/ember-layout.js
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.16
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Ember layout packaged for asset pipeline
55
+ test_files: []