Skip to content

Commit

Permalink
popover, dropdown, accordion, tabs, sass #1 #2 #3 #4 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
herereadthis committed Aug 2, 2014
1 parent a85d01d commit 3b639f9
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 95 deletions.
2 changes: 1 addition & 1 deletion build/css/greeneyes.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[data-module=parallax_scroll]{background-attachment:fixed}
[data-module=parallax_scroll]{background-position:center 0;background-attachment:fixed}
2 changes: 1 addition & 1 deletion build/js/main.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/js/accordion_content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Content Tabs

(function() {
define(['jquery'], function($) {
var exports, makeItHappen, moduleName;
exports = {};
moduleName = "accordion_content";

makeItHappen = function($this) {
console.log($this.html());
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
});
}
};
return exports;
});
}).call(this);
26 changes: 26 additions & 0 deletions src/js/content_tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Content Tabs

(function() {
define(['jquery'], function($) {
var exports, makeItHappen, moduleName;
exports = {};
moduleName = "content_tabs";

makeItHappen = function($this) {
console.log($this.html());
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
});
}
};
return exports;
});
}).call(this);
26 changes: 26 additions & 0 deletions src/js/dropdown_menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Drop Down Menu

(function() {
define(['jquery'], function($) {
var exports, makeItHappen, moduleName;
exports = {};
moduleName = "dropdown_menu";

makeItHappen = function($this) {
console.log($this.html());
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
});
}
};
return exports;
});
}).call(this);
4 changes: 4 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
paths: {
// google analytics
"Analytics": "analytics",
"Popover": "popover",
"ContentTabs": "content_tabs",
"AccordionContent": "accordion_content",
"DropdownMenu": "dropdown_menu",
// jQuery
"jquery": '../components/jquery/dist/jquery.min',
}
Expand Down
184 changes: 91 additions & 93 deletions src/js/parallax_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,114 @@
// takes your background and allows it scroll relative to window scroll

// Your container must contain data attribute
// [data-module="parallax_scroll"]
// [data-module="parallax_scroll"]
// You can set the relative scrolling with attribute
// [data-parallax-speed="NUMBER"]
// Where number is expressed between '0' to '100'
// [data-parallax-speed="NUMBER"]
// Where number is expressed as a percentage
// Note that negativ numbers are allowed and create an awesome dizzying effect.
// 0 = fixed to window, and 100 = fixed to scroll

(function() {
define(['jquery'], function($) {
var exports, gVars, makeItHappen, moduleName, bgSettings, scroller, $window;
exports = {};
$window = $(window);
moduleName = "parallax_scroll";
// options
var defaultParallaxSpeed;
defaultParallaxSpeed = 50;

define(function(require) {
var $, exports, gVars , makeItHappen, moduleName, bgSettings, scroller, $window;
$ = require("jquery");
exports = {};
$window = $(window);
moduleName = "parallax_scroll";
// options
var defaultParallaxSpeed;
defaultParallaxSpeed = 50;
bgSettings = function($this) {

bgSettings = function($this) {
var bgParam,
bgPosition, bgRepeat, bgSize, bgImage,
parallaxSpeed,
_i;

var bgParam,
bgPosition, bgRepeat, bgSize, bgImage,
parallaxSpeed,
_i;
// bgImage = $this.css('background-image');
// bgSize = $this.css('background-size').split(' ');
// bgRepeat = $this.css('background-repeat');

// bgImage = $this.css('background-image');
// bgSize = $this.css('background-size').split(' ');
// bgRepeat = $this.css('background-repeat');

bgPosition = $this.css('background-position').split(' ');
// you can state background position as one value that doubles for x/y.
// if so, make both values equal.
if (bgPosition.length === 1) {
bgPosition[1] = bgPosition[0];
}
// it should grab top|center|etc as percentages, but we'll force it.
for (_i = 0; _i < 2; _i++) {
if (bgPosition[_i] === "center") {
bgPosition[_i] = '50%';
}
else if (bgPosition[_i] === "top" || bgPosition[_i] === "left") {
bgPosition[_i] = '0%';
bgPosition = $this.css('background-position').split(' ');
// you can state background position as one value that doubles for x/y.
// if so, make both values equal.
if (bgPosition.length === 1) {
bgPosition[1] = bgPosition[0];
}
else if (bgPosition[_i] === "bottom" || bgPosition[_i] === "right") {
bgPosition[_i] = '100%';
}
if ( /%/.test(bgPosition[_i]) ) {
if (parseInt(bgPosition[_i], 10) === 0) {
bgPosition[_i] = 0;
// it should grab top|center|etc as percentages, but we'll force it.
for (_i = 0; _i < 2; _i++) {
if (bgPosition[_i] === "center") {
bgPosition[_i] = '50%';
}
else if (bgPosition[_i] === "top" || bgPosition[_i] === "left") {
bgPosition[_i] = '0%';
}
else if (bgPosition[_i] === "bottom" || bgPosition[_i] === "right") {
bgPosition[_i] = '100%';
}
if ( /%/.test(bgPosition[_i]) ) {
if (parseInt(bgPosition[_i], 10) === 0) {
bgPosition[_i] = 0;
}
}
}
}

// bunch of measures to make sure there is a data attribute for parallax-speed
// if not, default to 50%
if ($this.data('parallax-speed') === undefined || $this.data('parallax-speed') === '') {
parallaxSpeed = defaultParallaxSpeed;
}
else {
parallaxSpeed = $this.data('parallax-speed');
}
// bunch of measures to make sure there is a data attribute for parallax-speed
// if not, default to 50%
if ($this.data('parallax-speed') === undefined || $this.data('parallax-speed') === '') {
parallaxSpeed = defaultParallaxSpeed;
}
else {
parallaxSpeed = $this.data('parallax-speed');
}

bgParam = {
bgPosition: bgPosition,
parallaxSpeed: parallaxSpeed
}
return bgParam;
};
scroller = function(bgParam, $this) {
var offsetCoords, topOffset, scrollSpeed, yPosition, newBgPosition;
bgParam = {
bgPosition: bgPosition,
parallaxSpeed: parallaxSpeed
}
return bgParam;
};
scroller = function(bgParam, $this) {
var offsetCoords, topOffset, scrollSpeed, yPosition, newBgPosition;

// we only want the y-offset
offsetCoords = $this.offset(),
topOffset = offsetCoords.top;
// we only want the y-offset
offsetCoords = $this.offset(),
topOffset = offsetCoords.top;

$window.scroll(function() {
// If this section is in view
if ( ($window.scrollTop() + $window.height()) > (topOffset) &&
( (topOffset + $this.height()) > $window.scrollTop() ) ) {
$window.scroll(function() {
// If this section is in view
if ( ($window.scrollTop() + $window.height()) > (topOffset) &&
( (topOffset + $this.height()) > $window.scrollTop() ) ) {

// scroll speed is a percentage of the actual scrolling
scrollSpeed = bgParam.parallaxSpeed / 100;
// y-position of background position
yPosition = -1 * Math.round($window.scrollTop() * scrollSpeed);
// scroll speed is a percentage of the actual scrolling
scrollSpeed = bgParam.parallaxSpeed / 100;
// y-position of background position
yPosition = -1 * Math.round($window.scrollTop() * scrollSpeed);

// combine exising x-position and y-position of background-position
newBgPosition = bgParam.bgPosition[0] + ' ' + yPosition + 'px';
// console.log(bgParam.parallaxSpeed, $window.scrollTop(), yPosition);
// set it as css
$this.css('background-position', newBgPosition);
}
});
};
makeItHappen = function($this) {
var bgParam = bgSettings($this);
scroller(bgParam, $this);
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
// combine exising x-position and y-position of background-position
newBgPosition = bgParam.bgPosition[0] + ' ' + yPosition + 'px';
// console.log(bgParam.parallaxSpeed, $window.scrollTop(), yPosition);
// set it as css
$this.css('background-position', newBgPosition);
}
});
}
};
return exports;
};
makeItHappen = function($this) {
var bgParam = bgSettings($this);
scroller(bgParam, $this);
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
});
}
};
return exports;
});

}).call(this);
26 changes: 26 additions & 0 deletions src/js/popover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Content Tabs

(function() {
define(['jquery'], function($) {
var exports, makeItHappen, moduleName;
exports = {};
moduleName = "popover";

makeItHappen = function($this) {
console.log($this.html());
};
exports.init = function($this) {
var element;
if ($this !== void 0) {
return makeItHappen($this);
}
else {
element = $('[data-module="' + moduleName + '"]');
return element.each(function() {
return makeItHappen($(this));
});
}
};
return exports;
});
}).call(this);
1 change: 1 addition & 0 deletions src/less/parallax_scroll.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Parallax Scroll
[data-module="parallax_scroll"] {
background-position: center 0;
background-attachment: fixed;
}
1 change: 1 addition & 0 deletions src/sass/greeneyes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "parallax_scroll";
4 changes: 4 additions & 0 deletions src/sass/parallax_scroll.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Parallax Scroll
[data-module="parallax_scroll"] {
background-attachment: fixed;
}

0 comments on commit 3b639f9

Please sign in to comment.