uikit-on-rails 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/README.md +37 -0
  4. data/Rakefile +1 -0
  5. data/lib/uikit-on-rails.rb +1 -0
  6. data/lib/uikit/sass/rails.rb +2 -0
  7. data/lib/uikit/sass/rails/engine.rb +12 -0
  8. data/lib/uikit/sass/rails/version.rb +7 -0
  9. data/uikit-on-rails.gemspec +23 -0
  10. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  11. data/vendor/assets/fonts/fontawesome-webfont.otf +0 -0
  12. data/vendor/assets/fonts/fontawesome-webfont.svg +565 -0
  13. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  14. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  15. data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
  16. data/vendor/assets/javascripts/uikit.js +19 -0
  17. data/vendor/assets/javascripts/uikit/components/accordion.js +180 -0
  18. data/vendor/assets/javascripts/uikit/components/autocomplete.js +340 -0
  19. data/vendor/assets/javascripts/uikit/components/datepicker.js +3167 -0
  20. data/vendor/assets/javascripts/uikit/components/form-password.js +67 -0
  21. data/vendor/assets/javascripts/uikit/components/form-select.js +85 -0
  22. data/vendor/assets/javascripts/uikit/components/grid-parallax.js +168 -0
  23. data/vendor/assets/javascripts/uikit/components/grid.js +540 -0
  24. data/vendor/assets/javascripts/uikit/components/htmleditor.js +679 -0
  25. data/vendor/assets/javascripts/uikit/components/lightbox.js +591 -0
  26. data/vendor/assets/javascripts/uikit/components/nestable.js +653 -0
  27. data/vendor/assets/javascripts/uikit/components/notify.js +189 -0
  28. data/vendor/assets/javascripts/uikit/components/pagination.js +147 -0
  29. data/vendor/assets/javascripts/uikit/components/parallax.js +462 -0
  30. data/vendor/assets/javascripts/uikit/components/search.js +92 -0
  31. data/vendor/assets/javascripts/uikit/components/slider.js +552 -0
  32. data/vendor/assets/javascripts/uikit/components/slideset.js +523 -0
  33. data/vendor/assets/javascripts/uikit/components/slideshow-fx.js +383 -0
  34. data/vendor/assets/javascripts/uikit/components/slideshow.js +596 -0
  35. data/vendor/assets/javascripts/uikit/components/sortable.js +688 -0
  36. data/vendor/assets/javascripts/uikit/components/sticky.js +364 -0
  37. data/vendor/assets/javascripts/uikit/components/timepicker.js +192 -0
  38. data/vendor/assets/javascripts/uikit/components/tooltip.js +234 -0
  39. data/vendor/assets/javascripts/uikit/components/upload.js +262 -0
  40. data/vendor/assets/javascripts/uikit/core/alert.js +66 -0
  41. data/vendor/assets/javascripts/uikit/core/button.js +156 -0
  42. data/vendor/assets/javascripts/uikit/core/core.js +820 -0
  43. data/vendor/assets/javascripts/uikit/core/cover.js +95 -0
  44. data/vendor/assets/javascripts/uikit/core/dropdown.js +529 -0
  45. data/vendor/assets/javascripts/uikit/core/grid.js +117 -0
  46. data/vendor/assets/javascripts/uikit/core/modal.js +389 -0
  47. data/vendor/assets/javascripts/uikit/core/nav.js +152 -0
  48. data/vendor/assets/javascripts/uikit/core/offcanvas.js +197 -0
  49. data/vendor/assets/javascripts/uikit/core/scrollspy.js +209 -0
  50. data/vendor/assets/javascripts/uikit/core/smooth-scroll.js +62 -0
  51. data/vendor/assets/javascripts/uikit/core/switcher.js +309 -0
  52. data/vendor/assets/javascripts/uikit/core/tab.js +167 -0
  53. data/vendor/assets/javascripts/uikit/core/toggle.js +124 -0
  54. data/vendor/assets/javascripts/uikit/core/touch.js +175 -0
  55. data/vendor/assets/javascripts/uikit/core/utility.js +338 -0
  56. data/vendor/assets/javascripts/uikit/uikit.js +3905 -0
  57. data/vendor/assets/stylesheets/extra/font-awesome.scss +14 -0
  58. data/vendor/assets/stylesheets/uikit.scss +7 -0
  59. data/vendor/assets/stylesheets/uikit/components/accordion.scss +94 -0
  60. data/vendor/assets/stylesheets/uikit/components/autocomplete.scss +107 -0
  61. data/vendor/assets/stylesheets/uikit/components/datepicker.scss +197 -0
  62. data/vendor/assets/stylesheets/uikit/components/dotnav.scss +212 -0
  63. data/vendor/assets/stylesheets/uikit/components/form-advanced.scss +128 -0
  64. data/vendor/assets/stylesheets/uikit/components/form-file.scss +63 -0
  65. data/vendor/assets/stylesheets/uikit/components/form-password.scss +74 -0
  66. data/vendor/assets/stylesheets/uikit/components/form-select.scss +66 -0
  67. data/vendor/assets/stylesheets/uikit/components/htmleditor.scss +269 -0
  68. data/vendor/assets/stylesheets/uikit/components/nestable.scss +231 -0
  69. data/vendor/assets/stylesheets/uikit/components/notify.scss +190 -0
  70. data/vendor/assets/stylesheets/uikit/components/placeholder.scss +66 -0
  71. data/vendor/assets/stylesheets/uikit/components/progress.scss +173 -0
  72. data/vendor/assets/stylesheets/uikit/components/search.scss +309 -0
  73. data/vendor/assets/stylesheets/uikit/components/slidenav.scss +183 -0
  74. data/vendor/assets/stylesheets/uikit/components/slider.scss +139 -0
  75. data/vendor/assets/stylesheets/uikit/components/slideshow.scss +208 -0
  76. data/vendor/assets/stylesheets/uikit/components/sortable.scss +124 -0
  77. data/vendor/assets/stylesheets/uikit/components/sticky.scss +57 -0
  78. data/vendor/assets/stylesheets/uikit/components/tooltip.scss +177 -0
  79. data/vendor/assets/stylesheets/uikit/components/upload.scss +34 -0
  80. data/vendor/assets/stylesheets/uikit/core/alert.scss +141 -0
  81. data/vendor/assets/stylesheets/uikit/core/animation.scss +599 -0
  82. data/vendor/assets/stylesheets/uikit/core/article.scss +139 -0
  83. data/vendor/assets/stylesheets/uikit/core/badge.scss +110 -0
  84. data/vendor/assets/stylesheets/uikit/core/base.scss +563 -0
  85. data/vendor/assets/stylesheets/uikit/core/block.scss +155 -0
  86. data/vendor/assets/stylesheets/uikit/core/breadcrumb.scss +86 -0
  87. data/vendor/assets/stylesheets/uikit/core/button.scss +406 -0
  88. data/vendor/assets/stylesheets/uikit/core/close.scss +132 -0
  89. data/vendor/assets/stylesheets/uikit/core/column.scss +209 -0
  90. data/vendor/assets/stylesheets/uikit/core/comment.scss +172 -0
  91. data/vendor/assets/stylesheets/uikit/core/contrast.scss +493 -0
  92. data/vendor/assets/stylesheets/uikit/core/cover.scss +70 -0
  93. data/vendor/assets/stylesheets/uikit/core/description-list.scss +71 -0
  94. data/vendor/assets/stylesheets/uikit/core/dropdown.scss +280 -0
  95. data/vendor/assets/stylesheets/uikit/core/flex.scss +320 -0
  96. data/vendor/assets/stylesheets/uikit/core/form.scss +629 -0
  97. data/vendor/assets/stylesheets/uikit/core/grid.scss +731 -0
  98. data/vendor/assets/stylesheets/uikit/core/icon.scss +930 -0
  99. data/vendor/assets/stylesheets/uikit/core/list.scss +102 -0
  100. data/vendor/assets/stylesheets/uikit/core/modal.scss +343 -0
  101. data/vendor/assets/stylesheets/uikit/core/nav.scss +468 -0
  102. data/vendor/assets/stylesheets/uikit/core/navbar.scss +325 -0
  103. data/vendor/assets/stylesheets/uikit/core/offcanvas.scss +203 -0
  104. data/vendor/assets/stylesheets/uikit/core/overlay.scss +534 -0
  105. data/vendor/assets/stylesheets/uikit/core/pagination.scss +197 -0
  106. data/vendor/assets/stylesheets/uikit/core/panel.scss +332 -0
  107. data/vendor/assets/stylesheets/uikit/core/print.scss +61 -0
  108. data/vendor/assets/stylesheets/uikit/core/subnav.scss +213 -0
  109. data/vendor/assets/stylesheets/uikit/core/switcher.scss +38 -0
  110. data/vendor/assets/stylesheets/uikit/core/tab.scss +368 -0
  111. data/vendor/assets/stylesheets/uikit/core/table.scss +147 -0
  112. data/vendor/assets/stylesheets/uikit/core/text.scss +136 -0
  113. data/vendor/assets/stylesheets/uikit/core/thumbnail.scss +122 -0
  114. data/vendor/assets/stylesheets/uikit/core/thumbnav.scss +122 -0
  115. data/vendor/assets/stylesheets/uikit/core/utility.scss +610 -0
  116. data/vendor/assets/stylesheets/uikit/core/variables.scss +23 -0
  117. data/vendor/assets/stylesheets/uikit/uikit-mixins.scss +327 -0
  118. data/vendor/assets/stylesheets/uikit/uikit-variables.scss +819 -0
  119. data/vendor/assets/stylesheets/uikit/uikit.scss +52 -0
  120. metadata +177 -0
@@ -0,0 +1,189 @@
1
+ /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ (function(addon) {
3
+
4
+ var component;
5
+
6
+ if (window.UIkit) {
7
+ component = addon(UIkit);
8
+ }
9
+
10
+ if (typeof define == "function" && define.amd) {
11
+ define("uikit-notify", ["uikit"], function(){
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI){
17
+
18
+ "use strict";
19
+
20
+ var containers = {},
21
+ messages = {},
22
+
23
+ notify = function(options){
24
+
25
+ if (UI.$.type(options) == 'string') {
26
+ options = { message: options };
27
+ }
28
+
29
+ if (arguments[1]) {
30
+ options = UI.$.extend(options, UI.$.type(arguments[1]) == 'string' ? {status:arguments[1]} : arguments[1]);
31
+ }
32
+
33
+ return (new Message(options)).show();
34
+ },
35
+ closeAll = function(group, instantly){
36
+
37
+ var id;
38
+
39
+ if (group) {
40
+ for(id in messages) { if(group===messages[id].group) messages[id].close(instantly); }
41
+ } else {
42
+ for(id in messages) { messages[id].close(instantly); }
43
+ }
44
+ };
45
+
46
+ var Message = function(options){
47
+
48
+ this.options = UI.$.extend({}, Message.defaults, options);
49
+
50
+ this.uuid = UI.Utils.uid("notifymsg");
51
+ this.element = UI.$([
52
+
53
+ '<div class="uk-notify-message">',
54
+ '<a class="uk-close"></a>',
55
+ '<div></div>',
56
+ '</div>'
57
+
58
+ ].join('')).data("notifyMessage", this);
59
+
60
+ this.content(this.options.message);
61
+
62
+ // status
63
+ if (this.options.status) {
64
+ this.element.addClass('uk-notify-message-'+this.options.status);
65
+ this.currentstatus = this.options.status;
66
+ }
67
+
68
+ this.group = this.options.group;
69
+
70
+ messages[this.uuid] = this;
71
+
72
+ if(!containers[this.options.pos]) {
73
+ containers[this.options.pos] = UI.$('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo('body').on("click", ".uk-notify-message", function(){
74
+
75
+ var message = UI.$(this).data("notifyMessage");
76
+
77
+ message.element.trigger('manualclose.uk.notify', [message]);
78
+ message.close();
79
+ });
80
+ }
81
+ };
82
+
83
+
84
+ UI.$.extend(Message.prototype, {
85
+
86
+ uuid: false,
87
+ element: false,
88
+ timout: false,
89
+ currentstatus: "",
90
+ group: false,
91
+
92
+ show: function() {
93
+
94
+ if (this.element.is(":visible")) return;
95
+
96
+ var $this = this;
97
+
98
+ containers[this.options.pos].show().prepend(this.element);
99
+
100
+ var marginbottom = parseInt(this.element.css("margin-bottom"), 10);
101
+
102
+ this.element.css({"opacity":0, "margin-top": -1*this.element.outerHeight(), "margin-bottom":0}).animate({"opacity":1, "margin-top": 0, "margin-bottom":marginbottom}, function(){
103
+
104
+ if ($this.options.timeout) {
105
+
106
+ var closefn = function(){ $this.close(); };
107
+
108
+ $this.timeout = setTimeout(closefn, $this.options.timeout);
109
+
110
+ $this.element.hover(
111
+ function() { clearTimeout($this.timeout); },
112
+ function() { $this.timeout = setTimeout(closefn, $this.options.timeout); }
113
+ );
114
+ }
115
+
116
+ });
117
+
118
+ return this;
119
+ },
120
+
121
+ close: function(instantly) {
122
+
123
+ var $this = this,
124
+ finalize = function(){
125
+ $this.element.remove();
126
+
127
+ if (!containers[$this.options.pos].children().length) {
128
+ containers[$this.options.pos].hide();
129
+ }
130
+
131
+ $this.options.onClose.apply($this, []);
132
+ $this.element.trigger('close.uk.notify', [$this]);
133
+
134
+ delete messages[$this.uuid];
135
+ };
136
+
137
+ if (this.timeout) clearTimeout(this.timeout);
138
+
139
+ if (instantly) {
140
+ finalize();
141
+ } else {
142
+ this.element.animate({"opacity":0, "margin-top": -1* this.element.outerHeight(), "margin-bottom":0}, function(){
143
+ finalize();
144
+ });
145
+ }
146
+ },
147
+
148
+ content: function(html){
149
+
150
+ var container = this.element.find(">div");
151
+
152
+ if(!html) {
153
+ return container.html();
154
+ }
155
+
156
+ container.html(html);
157
+
158
+ return this;
159
+ },
160
+
161
+ status: function(status) {
162
+
163
+ if (!status) {
164
+ return this.currentstatus;
165
+ }
166
+
167
+ this.element.removeClass('uk-notify-message-'+this.currentstatus).addClass('uk-notify-message-'+status);
168
+
169
+ this.currentstatus = status;
170
+
171
+ return this;
172
+ }
173
+ });
174
+
175
+ Message.defaults = {
176
+ message: "",
177
+ status: "",
178
+ timeout: 5000,
179
+ group: null,
180
+ pos: 'top-center',
181
+ onClose: function() {}
182
+ };
183
+
184
+ UI.notify = notify;
185
+ UI.notify.message = Message;
186
+ UI.notify.closeAll = closeAll;
187
+
188
+ return notify;
189
+ });
@@ -0,0 +1,147 @@
1
+ /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ /*
3
+ * Based on simplePagination - Copyright (c) 2012 Flavius Matis - http://flaviusmatis.github.com/simplePagination.js/ (MIT)
4
+ */
5
+ (function(addon) {
6
+
7
+ var component;
8
+
9
+ if (window.UIkit) {
10
+ component = addon(UIkit);
11
+ }
12
+
13
+ if (typeof define == "function" && define.amd) {
14
+ define("uikit-pagination", ["uikit"], function(){
15
+ return component || addon(UIkit);
16
+ });
17
+ }
18
+
19
+ })(function(UI){
20
+
21
+ "use strict";
22
+
23
+ UI.component('pagination', {
24
+
25
+ defaults: {
26
+ items : 1,
27
+ itemsOnPage : 1,
28
+ pages : 0,
29
+ displayedPages : 7,
30
+ edges : 1,
31
+ currentPage : 0,
32
+ lblPrev : false,
33
+ lblNext : false,
34
+ onSelectPage : function() {}
35
+ },
36
+
37
+ boot: function() {
38
+
39
+ // init code
40
+ UI.ready(function(context) {
41
+
42
+ UI.$("[data-uk-pagination]", context).each(function(){
43
+ var ele = UI.$(this);
44
+
45
+ if (!ele.data("pagination")) {
46
+ UI.pagination(ele, UI.Utils.options(ele.attr("data-uk-pagination")));
47
+ }
48
+ });
49
+ });
50
+ },
51
+
52
+ init: function() {
53
+
54
+ var $this = this;
55
+
56
+ this.pages = this.options.pages ? this.options.pages : Math.ceil(this.options.items / this.options.itemsOnPage) ? Math.ceil(this.options.items / this.options.itemsOnPage) : 1;
57
+ this.currentPage = this.options.currentPage;
58
+ this.halfDisplayed = this.options.displayedPages / 2;
59
+
60
+ this.on("click", "a[data-page]", function(e){
61
+ e.preventDefault();
62
+ $this.selectPage(UI.$(this).data("page"));
63
+ });
64
+
65
+ this._render();
66
+ },
67
+
68
+ _getInterval: function() {
69
+
70
+ return {
71
+ start: Math.ceil(this.currentPage > this.halfDisplayed ? Math.max(Math.min(this.currentPage - this.halfDisplayed, (this.pages - this.options.displayedPages)), 0) : 0),
72
+ end : Math.ceil(this.currentPage > this.halfDisplayed ? Math.min(this.currentPage + this.halfDisplayed, this.pages) : Math.min(this.options.displayedPages, this.pages))
73
+ };
74
+ },
75
+
76
+ render: function(pages) {
77
+ this.pages = pages ? pages : this.pages;
78
+ this._render();
79
+ },
80
+
81
+ selectPage: function(pageIndex, pages) {
82
+ this.currentPage = pageIndex;
83
+ this.render(pages);
84
+
85
+ this.options.onSelectPage.apply(this, [pageIndex]);
86
+ this.trigger('select.uk.pagination', [pageIndex, this]);
87
+ },
88
+
89
+ _render: function() {
90
+
91
+ var o = this.options, interval = this._getInterval(), i;
92
+
93
+ this.element.empty();
94
+
95
+ // Generate Prev link
96
+ if (o.lblPrev) this._append(this.currentPage - 1, {text: o.lblPrev});
97
+
98
+ // Generate start edges
99
+ if (interval.start > 0 && o.edges > 0) {
100
+
101
+ var end = Math.min(o.edges, interval.start);
102
+
103
+ for (i = 0; i < end; i++) this._append(i);
104
+
105
+ if (o.edges < interval.start && (interval.start - o.edges != 1)) {
106
+ this.element.append('<li><span>...</span></li>');
107
+ } else if (interval.start - o.edges == 1) {
108
+ this._append(o.edges);
109
+ }
110
+ }
111
+
112
+ // Generate interval links
113
+ for (i = interval.start; i < interval.end; i++) this._append(i);
114
+
115
+ // Generate end edges
116
+ if (interval.end < this.pages && o.edges > 0) {
117
+
118
+ if (this.pages - o.edges > interval.end && (this.pages - o.edges - interval.end != 1)) {
119
+ this.element.append('<li><span>...</span></li>');
120
+ } else if (this.pages - o.edges - interval.end == 1) {
121
+ this._append(interval.end++);
122
+ }
123
+
124
+ var begin = Math.max(this.pages - o.edges, interval.end);
125
+
126
+ for (i = begin; i < this.pages; i++) this._append(i);
127
+ }
128
+
129
+ // Generate Next link (unless option is set for at front)
130
+ if (o.lblNext) this._append(this.currentPage + 1, {text: o.lblNext});
131
+ },
132
+
133
+ _append: function(pageIndex, opts) {
134
+
135
+ var item, options;
136
+
137
+ pageIndex = pageIndex < 0 ? 0 : (pageIndex < this.pages ? pageIndex : this.pages - 1);
138
+ options = UI.$.extend({ text: pageIndex + 1 }, opts);
139
+
140
+ item = (pageIndex == this.currentPage) ? '<li class="uk-active"><span>' + (options.text) + '</span></li>' : '<li><a href="#page-'+(pageIndex+1)+'" data-page="'+pageIndex+'">'+options.text+'</a></li>';
141
+
142
+ this.element.append(item);
143
+ }
144
+ });
145
+
146
+ return UI.pagination;
147
+ });
@@ -0,0 +1,462 @@
1
+ /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ (function(addon) {
3
+
4
+ var component;
5
+
6
+ if (window.UIkit) {
7
+ component = addon(UIkit);
8
+ }
9
+
10
+ if (typeof define == "function" && define.amd) {
11
+ define("uikit-parallax", ["uikit"], function(){
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI){
17
+
18
+ "use strict";
19
+
20
+ var parallaxes = [],
21
+ supports3d = false,
22
+ scrolltop = 0,
23
+ wh = window.innerHeight,
24
+ checkParallaxes = function() {
25
+
26
+ scrolltop = UI.$win.scrollTop();
27
+
28
+ window.requestAnimationFrame(function(){
29
+ for (var i=0; i < parallaxes.length; i++) {
30
+ parallaxes[i].process();
31
+ }
32
+ });
33
+ };
34
+
35
+
36
+ UI.component('parallax', {
37
+
38
+ defaults: {
39
+ velocity : 0.5,
40
+ target : false,
41
+ viewport : false,
42
+ media : false
43
+ },
44
+
45
+ boot: function() {
46
+
47
+ supports3d = (function(){
48
+
49
+ var el = document.createElement('div'),
50
+ has3d,
51
+ transforms = {
52
+ 'WebkitTransform':'-webkit-transform',
53
+ 'MSTransform':'-ms-transform',
54
+ 'MozTransform':'-moz-transform',
55
+ 'Transform':'transform'
56
+ };
57
+
58
+ // Add it to the body to get the computed style.
59
+ document.body.insertBefore(el, null);
60
+
61
+ for (var t in transforms) {
62
+ if (el.style[t] !== undefined) {
63
+ el.style[t] = "translate3d(1px,1px,1px)";
64
+ has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
65
+ }
66
+ }
67
+
68
+ document.body.removeChild(el);
69
+
70
+ return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
71
+ })();
72
+
73
+ // listen to scroll and resize
74
+ UI.$doc.on("scrolling.uk.document", checkParallaxes);
75
+ UI.$win.on("load resize orientationchange", UI.Utils.debounce(function(){
76
+ wh = window.innerHeight;
77
+ checkParallaxes();
78
+ }, 50));
79
+
80
+ // init code
81
+ UI.ready(function(context) {
82
+
83
+ UI.$('[data-uk-parallax]', context).each(function() {
84
+
85
+ var parallax = UI.$(this);
86
+
87
+ if (!parallax.data("parallax")) {
88
+ UI.parallax(parallax, UI.Utils.options(parallax.attr("data-uk-parallax")));
89
+ }
90
+ });
91
+ });
92
+ },
93
+
94
+ init: function() {
95
+
96
+ this.base = this.options.target ? UI.$(this.options.target) : this.element;
97
+ this.props = {};
98
+ this.velocity = (this.options.velocity || 1);
99
+
100
+ var reserved = ['target','velocity','viewport','plugins','media'];
101
+
102
+ Object.keys(this.options).forEach(function(prop){
103
+
104
+ if (reserved.indexOf(prop) !== -1) {
105
+ return;
106
+ }
107
+
108
+ var start, end, dir, diff, startend = String(this.options[prop]).split(',');
109
+
110
+ if (prop.match(/color/i)) {
111
+ start = startend[1] ? startend[0] : this._getStartValue(prop),
112
+ end = startend[1] ? startend[1] : startend[0];
113
+
114
+ if (!start) {
115
+ start = 'rgba(255,255,255,0)';
116
+ }
117
+
118
+ } else {
119
+ start = parseFloat(startend[1] ? startend[0] : this._getStartValue(prop)),
120
+ end = parseFloat(startend[1] ? startend[1] : startend[0]);
121
+ diff = (start < end ? (end-start):(start-end));
122
+ dir = (start < end ? 1:-1);
123
+ }
124
+
125
+ this.props[prop] = { 'start': start, 'end': end, 'dir': dir, 'diff': diff };
126
+
127
+ }.bind(this));
128
+
129
+ parallaxes.push(this);
130
+ },
131
+
132
+ process: function() {
133
+
134
+ if (this.options.media) {
135
+
136
+ switch(typeof(this.options.media)) {
137
+ case 'number':
138
+ if (window.innerWidth < this.options.media) {
139
+ return false;
140
+ }
141
+ break;
142
+ case 'string':
143
+ if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
144
+ return false;
145
+ }
146
+ break;
147
+ }
148
+ }
149
+
150
+ var percent = this.percentageInViewport();
151
+
152
+ if (this.options.viewport !== false) {
153
+ percent = (this.options.viewport === 0) ? 1 : percent / this.options.viewport;
154
+ }
155
+
156
+ this.update(percent);
157
+ },
158
+
159
+ percentageInViewport: function() {
160
+
161
+ var top = this.base.offset().top,
162
+ height = this.base.outerHeight(),
163
+ distance, percentage, percent;
164
+
165
+ if (top > (scrolltop + wh)) {
166
+ percent = 0;
167
+ } else if ((top + height) < scrolltop) {
168
+ percent = 1;
169
+ } else {
170
+
171
+ if ((top + height) < wh) {
172
+
173
+ percent = (scrolltop < wh ? scrolltop : scrolltop - wh) / (top+height);
174
+
175
+ } else {
176
+
177
+ distance = (scrolltop + wh) - top;
178
+ percentage = Math.round(distance / ((wh + height) / 100));
179
+ percent = percentage/100;
180
+ }
181
+ }
182
+
183
+ return percent;
184
+ },
185
+
186
+ update: function(percent) {
187
+
188
+ var $this = this,
189
+ css = {transform:'', filter:''},
190
+ compercent = percent * (1 - (this.velocity - (this.velocity * percent))),
191
+ opts, val;
192
+
193
+ if (compercent < 0) compercent = 0;
194
+ if (compercent > 1) compercent = 1;
195
+
196
+ if (this._percent !== undefined && this._percent == compercent) {
197
+ return;
198
+ }
199
+
200
+ Object.keys(this.props).forEach(function(prop) {
201
+
202
+ opts = this.props[prop];
203
+
204
+ if (percent === 0) {
205
+ val = opts.start;
206
+ } else if(percent === 1) {
207
+ val = opts.end;
208
+ } else if(opts.diff !== undefined) {
209
+ val = opts.start + (opts.diff * compercent * opts.dir);
210
+ }
211
+
212
+ if ((prop == 'bg' || prop == 'bgp') && !this._bgcover) {
213
+ this._bgcover = initBgImageParallax(this, prop, opts);
214
+ }
215
+
216
+ switch(prop) {
217
+
218
+ // transforms
219
+ case 'x':
220
+ css.transform += supports3d ? ' translate3d('+val+'px, 0, 0)':' translateX('+val+'px)';
221
+ break;
222
+ case 'xp':
223
+ css.transform += supports3d ? ' translate3d('+val+'%, 0, 0)':' translateX('+val+'%)';
224
+ break;
225
+ case 'y':
226
+ css.transform += supports3d ? ' translate3d(0, '+val+'px, 0)':' translateY('+val+'px)';
227
+ break;
228
+ case 'yp':
229
+ css.transform += supports3d ? ' translate3d(0, '+val+'%, 0)':' translateY('+val+'%)';
230
+ break;
231
+ case 'rotate':
232
+ css.transform += ' rotate('+val+'deg)';
233
+ break;
234
+ case 'scale':
235
+ css.transform += ' scale('+val+')';
236
+ break;
237
+
238
+ // bg image
239
+ case 'bg':
240
+
241
+ // don't move if image height is too small
242
+ // if ($this.element.data('bgsize') && ($this.element.data('bgsize').h + val - window.innerHeight) < 0) {
243
+ // break;
244
+ // }
245
+
246
+ css['background-position'] = '50% '+val+'px';
247
+ break;
248
+ case 'bgp':
249
+ css['background-position'] = '50% '+val+'%';
250
+ break;
251
+
252
+ // color
253
+ case 'color':
254
+ case 'background-color':
255
+ case 'border-color':
256
+ css[prop] = calcColor(opts.start, opts.end, compercent);
257
+ break;
258
+
259
+ // CSS Filter
260
+ case 'blur':
261
+ css.filter += ' blur('+val+'px)';
262
+ break;
263
+ case 'hue':
264
+ css.filter += ' hue-rotate('+val+'deg)';
265
+ break;
266
+ case 'grayscale':
267
+ css.filter += ' grayscale('+val+'%)';
268
+ break;
269
+ case 'invert':
270
+ css.filter += ' invert('+val+'%)';
271
+ break;
272
+ case 'fopacity':
273
+ css.filter += ' opacity('+val+'%)';
274
+ break;
275
+ case 'saturate':
276
+ css.filter += ' saturate('+val+'%)';
277
+ break;
278
+ case 'sepia':
279
+ css.filter += ' sepia('+val+'%)';
280
+ break;
281
+
282
+ default:
283
+ css[prop] = val;
284
+ break;
285
+ }
286
+
287
+ }.bind(this));
288
+
289
+ if (css.filter) {
290
+ css['-webkit-filter'] = css.filter;
291
+ }
292
+
293
+ this.element.css(css);
294
+
295
+ this._percent = compercent;
296
+ },
297
+
298
+ _getStartValue: function(prop) {
299
+
300
+ var value = 0;
301
+
302
+ switch(prop) {
303
+ case 'scale':
304
+ value = 1;
305
+ break;
306
+ default:
307
+ value = this.element.css(prop);
308
+ }
309
+
310
+ return (value || 0);
311
+ }
312
+
313
+ });
314
+
315
+
316
+ // helper
317
+
318
+ function initBgImageParallax(obj, prop, opts) {
319
+
320
+ var img = new Image(), url, element, size, check, ratio, width, height;
321
+
322
+ element = obj.element.css({'background-size': 'cover', 'background-repeat': 'no-repeat'});
323
+ url = element.css('background-image').replace(/^url\(/g, '').replace(/\)$/g, '').replace(/("|')/g, '');
324
+ check = function() {
325
+
326
+ var w = element.innerWidth(), h = element.innerHeight(), extra = (prop=='bg') ? opts.diff : (opts.diff/100) * h;
327
+
328
+ h += extra;
329
+ w += Math.ceil(extra * ratio);
330
+
331
+ if (w-extra < size.w && h < size.h) {
332
+ return obj.element.css({'background-size': 'auto'});
333
+ }
334
+
335
+ // if element height < parent height (gap underneath)
336
+ if ((w / ratio) < h) {
337
+
338
+ width = Math.ceil(h * ratio);
339
+ height = h;
340
+
341
+ if (h > window.innerHeight) {
342
+ width = width * 1.2;
343
+ height = height * 1.2;
344
+ }
345
+
346
+ // element width < parent width (gap to right)
347
+ } else {
348
+
349
+ width = w;
350
+ height = Math.ceil(w / ratio);
351
+ }
352
+
353
+ element.css({'background-size': (width+'px '+height+'px')}).data('bgsize', {w:width,h:height});
354
+ };
355
+
356
+ img.onerror = function(){
357
+ // image url doesn't exist
358
+ };
359
+
360
+ img.onload = function(){
361
+ size = {w:img.width, h:img.height};
362
+ ratio = img.width / img.height;
363
+
364
+ UI.$win.on("load resize orientationchange", UI.Utils.debounce(function(){
365
+ check();
366
+ }, 50));
367
+
368
+ check();
369
+ };
370
+
371
+ img.src = url;
372
+
373
+ return true;
374
+ }
375
+
376
+
377
+ // Some named colors to work with, added by Bradley Ayers
378
+ // From Interface by Stefan Petre
379
+ // http://interface.eyecon.ro/
380
+ var colors = {
381
+ 'black': [0,0,0,1],
382
+ 'blue': [0,0,255,1],
383
+ 'brown': [165,42,42,1],
384
+ 'cyan': [0,255,255,1],
385
+ 'fuchsia': [255,0,255,1],
386
+ 'gold': [255,215,0,1],
387
+ 'green': [0,128,0,1],
388
+ 'indigo': [75,0,130,1],
389
+ 'khaki': [240,230,140,1],
390
+ 'lime': [0,255,0,1],
391
+ 'magenta': [255,0,255,1],
392
+ 'maroon': [128,0,0,1],
393
+ 'navy': [0,0,128,1],
394
+ 'olive': [128,128,0,1],
395
+ 'orange': [255,165,0,1],
396
+ 'pink': [255,192,203,1],
397
+ 'purple': [128,0,128,1],
398
+ 'violet': [128,0,128,1],
399
+ 'red': [255,0,0,1],
400
+ 'silver': [192,192,192,1],
401
+ 'white': [255,255,255,1],
402
+ 'yellow': [255,255,0,1],
403
+ 'transparent': [255,255,255,0]
404
+ };
405
+
406
+ function calcColor(start, end, pos) {
407
+
408
+ start = parseColor(start);
409
+ end = parseColor(end);
410
+ pos = pos || 0;
411
+
412
+ return calculateColor(start, end, pos);
413
+ }
414
+
415
+ /**!
416
+ * @preserve Color animation 1.6.0
417
+ * http://www.bitstorm.org/jquery/color-animation/
418
+ * Copyright 2011, 2013 Edwin Martin <edwin@bitstorm.org>
419
+ * Released under the MIT and GPL licenses.
420
+ */
421
+
422
+ // Calculate an in-between color. Returns "#aabbcc"-like string.
423
+ function calculateColor(begin, end, pos) {
424
+ var color = 'rgba('
425
+ + parseInt((begin[0] + pos * (end[0] - begin[0])), 10) + ','
426
+ + parseInt((begin[1] + pos * (end[1] - begin[1])), 10) + ','
427
+ + parseInt((begin[2] + pos * (end[2] - begin[2])), 10) + ','
428
+ + (begin && end ? parseFloat(begin[3] + pos * (end[3] - begin[3])) : 1);
429
+
430
+ color += ')';
431
+ return color;
432
+ }
433
+
434
+ // Parse an CSS-syntax color. Outputs an array [r, g, b]
435
+ function parseColor(color) {
436
+
437
+ var match, quadruplet;
438
+
439
+ // Match #aabbcc
440
+ if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) {
441
+ quadruplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1];
442
+
443
+ // Match #abc
444
+ } else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) {
445
+ quadruplet = [parseInt(match[1], 16) * 17, parseInt(match[2], 16) * 17, parseInt(match[3], 16) * 17, 1];
446
+
447
+ // Match rgb(n, n, n)
448
+ } else if (match = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
449
+ quadruplet = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3]), 1];
450
+
451
+ } else if (match = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(color)) {
452
+ quadruplet = [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10),parseFloat(match[4])];
453
+
454
+ // No browser returns rgb(n%, n%, n%), so little reason to support this format.
455
+ } else {
456
+ quadruplet = colors[color] || [255,255,255,0];
457
+ }
458
+ return quadruplet;
459
+ }
460
+
461
+ return UI.parallax;
462
+ });