uikit-sass-rails 1.3.0 → 1.4.0

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