newton-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 20b47623eb9aa82d76ea878f1736d87cefa7c54d
4
+ data.tar.gz: f8118e2185072fe3f04e70ee9991fb06ea0b6d2e
5
+ SHA512:
6
+ metadata.gz: bd52f076163f7e3554df6f8f57c0b7e5b4edc40215ef515854d926c9fe029fb0103d7372b6257e95862c7def87cf97cf0acb6ec56554d70efd449717ac138cbc
7
+ data.tar.gz: d7abc7d01d42fae7a3c1e6c67cf4f6e7cad58bcd92644050a6f86fbf1d75b6480b55c9c6e390197c2001d69e1c4a828fbc2b78b2e029b4a0bf864058b4fc38eb
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/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "bootstrap"]
2
+ path = newton
3
+ url = https://github.com/jpsilvashy/newton.git
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrap-rails.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Newton for Rails
2
+ You can install from latest build just for testing right now;
3
+
4
+ ``` ruby
5
+ gem 'newton-rails', github: 'jpsilvashy/newton'
6
+ ```
7
+
8
+ and run bundle install.
9
+
10
+ ## Stylesheets
11
+
12
+ Add necessary stylesheet file to app/assets/stylesheets/application.css
13
+
14
+ ``` css
15
+ *= require newton/newton
16
+ ```
17
+
18
+ ## Javascripts
19
+
20
+ Add necessary javascript(s) files to app/assets/javascripts/application.js
21
+
22
+ ``` javascript
23
+ // Include all Newton's javascripts
24
+ //= require newton/newton
25
+
26
+ // Or peek any of them yourself
27
+ //= require newton/newton/modal
28
+ //= require newton/newton/alert
29
+ ```
30
+
31
+ ## Extending
32
+
33
+
34
+ ## Thanks
35
+
36
+
37
+ ## License
38
+ Copyright (c) 2013 Joseph Silvashy
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
41
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+
5
+ namespace :newton do
6
+
7
+ desc "Pulls Newton Scss"
8
+ task :pull do
9
+ if !system "cd newton && git pull"
10
+ abort "...."
11
+ end
12
+ end
13
+
14
+ NEWTON_JS = FileList["newton/js/*.*"]
15
+ ASSETS_JS = NEWTON_JS.pathmap("app/assets/javascripts/newton/newton/%f")
16
+ ASSETS_JS.zip(NEWTON_JS).each do |target, source|
17
+ file target => [source] { cp source, target, verbose: true }
18
+ end
19
+
20
+ NEWTON_SCSS = FileList["newton/scss/*.*"]
21
+ ASSETS_SCSS = NEWTON_SCSS.pathmap("app/assets/stylesheets/newton/newton/_%f")
22
+ ASSETS_SCSS.zip(NEWTON_SCSS).each do |target, source|
23
+ target.gsub!(/__/, '_')
24
+ file target => [source] { cp source, target, verbose: true }
25
+ end
26
+
27
+ desc "Update Newton JS"
28
+ task :js => ASSETS_JS do
29
+ js = {}
30
+ ASSETS_JS.pathmap("%f").each { |f| js[f] = 1 }
31
+
32
+ # dependencies
33
+ order = %w{base.js}
34
+ order.each_with_index {|o, i| js[o] = i }
35
+
36
+ list = js.to_a.sort {|a,b| a[1] <=> b[1]}.map{|p| p[0]}
37
+ File.write "app/assets/javascripts/newton/newton.js", list.map {|f| "//= require newton/newton/#{f}"}.join("\n")
38
+ end
39
+
40
+ desc "Update Newton SCSS"
41
+ task :scss => ASSETS_SCSS do
42
+ File.write "app/assets/stylesheets/newton/newton.scss", '@import "newton/newton/newton";'
43
+ end
44
+
45
+ desc "Clean gem assets files"
46
+ task :clean do
47
+ FileUtils.rm_rf 'app/assets'
48
+ FileUtils.mkpath 'app/assets/javascripts/newton/newton'
49
+ FileUtils.mkpath 'app/assets/stylesheets/newton/newton'
50
+ end
51
+
52
+ desc "Update Newton Assets"
53
+ task :assets => [:pull, :clean, :scss, :js]
54
+
55
+ end
56
+
57
+ Rake::TestTask.new do |t|
58
+ t.libs << "test"
59
+ t.test_files = FileList['test/*_test.rb']
60
+ t.verbose = true
61
+ end
@@ -0,0 +1,12 @@
1
+ //= require twitter/bootstrap/transition.js
2
+ //= require twitter/bootstrap/alert.js
3
+ //= require twitter/bootstrap/button.js
4
+ //= require twitter/bootstrap/carousel.js
5
+ //= require twitter/bootstrap/collapse.js
6
+ //= require twitter/bootstrap/dropdown.js
7
+ //= require twitter/bootstrap/modal.js
8
+ //= require twitter/bootstrap/tooltip.js
9
+ //= require twitter/bootstrap/popover.js
10
+ //= require twitter/bootstrap/scrollspy.js
11
+ //= require twitter/bootstrap/tab.js
12
+ //= require twitter/bootstrap/affix.js
@@ -0,0 +1,120 @@
1
+ /* ========================================================================
2
+ * Bootstrap: affix.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#affix
4
+ * ========================================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ======================================================================== */
19
+
20
+
21
+ +function ($) { "use strict";
22
+
23
+ // AFFIX CLASS DEFINITION
24
+ // ======================
25
+
26
+ var Affix = function (element, options) {
27
+ this.options = $.extend({}, Affix.DEFAULTS, options)
28
+ this.$window = $(window)
29
+ .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
30
+ .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
31
+
32
+ this.$element = $(element)
33
+ this.affixed =
34
+ this.unpin = null
35
+
36
+ this.checkPosition()
37
+ }
38
+
39
+ Affix.DEFAULTS = {
40
+ offset: 0
41
+ }
42
+
43
+ Affix.prototype.checkPositionWithEventLoop = function () {
44
+ setTimeout($.proxy(this.checkPosition, this), 1)
45
+ }
46
+
47
+ Affix.prototype.checkPosition = function () {
48
+ if (!this.$element.is(':visible')) return
49
+
50
+ var scrollHeight = $(document).height()
51
+ var scrollTop = this.$window.scrollTop()
52
+ var position = this.$element.offset()
53
+ var offset = this.options.offset
54
+ var offsetTop = offset.top
55
+ var offsetBottom = offset.bottom
56
+ var reset = 'affix affix-top affix-bottom'
57
+
58
+ if (typeof offset != 'object') offsetBottom = offsetTop = offset
59
+ if (typeof offsetTop == 'function') offsetTop = offset.top()
60
+ if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
61
+
62
+ var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
63
+ offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
64
+ offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
65
+
66
+ if (this.affixed === affix) return
67
+
68
+ this.affixed = affix
69
+ this.unpin = affix == 'bottom' ? position.top - scrollTop : null
70
+
71
+ this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
72
+ }
73
+
74
+
75
+ // AFFIX PLUGIN DEFINITION
76
+ // =======================
77
+
78
+ var old = $.fn.affix
79
+
80
+ $.fn.affix = function (option) {
81
+ return this.each(function () {
82
+ var $this = $(this)
83
+ var data = $this.data('bs.affix')
84
+ var options = typeof option == 'object' && option
85
+
86
+ if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
87
+ if (typeof option == 'string') data[option]()
88
+ })
89
+ }
90
+
91
+ $.fn.affix.Constructor = Affix
92
+
93
+
94
+ // AFFIX NO CONFLICT
95
+ // =================
96
+
97
+ $.fn.affix.noConflict = function () {
98
+ $.fn.affix = old
99
+ return this
100
+ }
101
+
102
+
103
+ // AFFIX DATA-API
104
+ // ==============
105
+
106
+ $(window).on('load', function () {
107
+ $('[data-spy="affix"]').each(function () {
108
+ var $spy = $(this)
109
+ var data = $spy.data()
110
+
111
+ data.offset = data.offset || {}
112
+
113
+ if (data.offsetBottom) data.offset.bottom = data.offsetBottom
114
+ if (data.offsetTop) data.offset.top = data.offsetTop
115
+
116
+ $spy.affix(data)
117
+ })
118
+ })
119
+
120
+ }(window.jQuery);
@@ -0,0 +1,96 @@
1
+ /* ========================================================================
2
+ * Bootstrap: alert.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
4
+ * ========================================================================
5
+ * Copyright 2013 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ======================================================================== */
19
+
20
+
21
+ +function ($) { "use strict";
22
+
23
+ // ALERT CLASS DEFINITION
24
+ // ======================
25
+
26
+ var dismiss = '[data-dismiss="alert"]'
27
+ var Alert = function (el) {
28
+ $(el).on('click', dismiss, this.close)
29
+ }
30
+
31
+ Alert.prototype.close = function (e) {
32
+ var $this = $(this)
33
+ var selector = $this.attr('data-target')
34
+
35
+ if (!selector) {
36
+ selector = $this.attr('href')
37
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
38
+ }
39
+
40
+ var $parent = $(selector)
41
+
42
+ if (e) e.preventDefault()
43
+
44
+ if (!$parent.length) {
45
+ $parent = $this.hasClass('alert') ? $this : $this.parent()
46
+ }
47
+
48
+ $parent.trigger(e = $.Event('close.bs.alert'))
49
+
50
+ if (e.isDefaultPrevented()) return
51
+
52
+ $parent.removeClass('in')
53
+
54
+ function removeElement() {
55
+ $parent.trigger('closed.bs.alert').remove()
56
+ }
57
+
58
+ $.support.transition && $parent.hasClass('fade') ?
59
+ $parent.on($.support.transition.end, removeElement) :
60
+ removeElement()
61
+ }
62
+
63
+
64
+ // ALERT PLUGIN DEFINITION
65
+ // =======================
66
+
67
+ var old = $.fn.alert
68
+
69
+ $.fn.alert = function (option) {
70
+ return this.each(function () {
71
+ var $this = $(this)
72
+ var data = $this.data('bs.alert')
73
+
74
+ if (!data) $this.data('bs.alert', (data = new Alert(this)))
75
+ if (typeof option == 'string') data[option].call($this)
76
+ })
77
+ }
78
+
79
+ $.fn.alert.Constructor = Alert
80
+
81
+
82
+ // ALERT NO CONFLICT
83
+ // =================
84
+
85
+ $.fn.alert.noConflict = function () {
86
+ $.fn.alert = old
87
+ return this
88
+ }
89
+
90
+
91
+ // ALERT DATA-API
92
+ // ==============
93
+
94
+ $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
95
+
96
+ }(window.jQuery);
@@ -0,0 +1,105 @@
1
+ /* ========================================================================
2
+ * Bootstrap: button.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#buttons
4
+ * ========================================================================
5
+ * Copyright 2013 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ======================================================================== */
19
+
20
+
21
+ +function ($) { "use strict";
22
+
23
+ // BUTTON PUBLIC CLASS DEFINITION
24
+ // ==============================
25
+
26
+ var Button = function (element, options) {
27
+ this.$element = $(element)
28
+ this.options = $.extend({}, Button.DEFAULTS, options)
29
+ }
30
+
31
+ Button.DEFAULTS = {
32
+ loadingText: 'loading...'
33
+ }
34
+
35
+ Button.prototype.setState = function (state) {
36
+ var d = 'disabled'
37
+ var $el = this.$element
38
+ var val = $el.is('input') ? 'val' : 'html'
39
+ var data = $el.data()
40
+
41
+ state = state + 'Text'
42
+
43
+ if (!data.resetText) $el.data('resetText', $el[val]())
44
+
45
+ $el[val](data[state] || this.options[state])
46
+
47
+ // push to event loop to allow forms to submit
48
+ setTimeout(function () {
49
+ state == 'loadingText' ?
50
+ $el.addClass(d).attr(d, d) :
51
+ $el.removeClass(d).removeAttr(d);
52
+ }, 0)
53
+ }
54
+
55
+ Button.prototype.toggle = function () {
56
+ var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
57
+
58
+ if ($parent) {
59
+ $parent.find('.active').removeClass('active')
60
+ }
61
+
62
+ this.$element.toggleClass('active')
63
+ }
64
+
65
+
66
+ // BUTTON PLUGIN DEFINITION
67
+ // ========================
68
+
69
+ var old = $.fn.button
70
+
71
+ $.fn.button = function (option) {
72
+ return this.each(function () {
73
+ var $this = $(this)
74
+ var data = $this.data('button')
75
+ var options = typeof option == 'object' && option
76
+
77
+ if (!data) $this.data('bs.button', (data = new Button(this, options)))
78
+
79
+ if (option == 'toggle') data.toggle()
80
+ else if (option) data.setState(option)
81
+ })
82
+ }
83
+
84
+ $.fn.button.Constructor = Button
85
+
86
+
87
+ // BUTTON NO CONFLICT
88
+ // ==================
89
+
90
+ $.fn.button.noConflict = function () {
91
+ $.fn.button = old
92
+ return this
93
+ }
94
+
95
+
96
+ // BUTTON DATA-API
97
+ // ===============
98
+
99
+ $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
100
+ var $btn = $(e.target)
101
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
102
+ $btn.button('toggle')
103
+ })
104
+
105
+ }(window.jQuery);