Skip to content

Commit

Permalink
unclear. Uncommitted changes from last I worked on this
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdmejias committed Sep 8, 2015
1 parent 794b91d commit 1f608ba
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 165 deletions.
Binary file removed .DS_Store
Binary file not shown.
75 changes: 40 additions & 35 deletions assets/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/styles.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions assets/js/app.js
@@ -1,5 +1,5 @@
define(['svg', 'colors', 'header', 'eventsManager'],
function (SVG, colors, header, EvtsMgr) {
define(['svg', 'colors', 'header', 'eventsManager', 'modal'],
function (SVG, Colors, Header, EvtsMgr, Modal) {
'use strict';

var App = {
Expand All @@ -15,7 +15,7 @@ define(['svg', 'colors', 'header', 'eventsManager'],
defaultAnimation: 'Six',
animations: {},
viewportSize: {},
numOfColorSchemes: colors.length,
numOfColorSchemes: Colors.length,
debug: true,
// modal: modal,

Expand All @@ -26,7 +26,7 @@ define(['svg', 'colors', 'header', 'eventsManager'],
App.sel.container.style.width = App.viewportSize.width + 'px';
App.sel.container.style.height = App.viewportSize.height - App.sel.header.clientHeight - 4 + 'px';

App.colorScheme = colors[Math.floor(Math.random() * App.numOfColorSchemes)];
App.colorScheme = Colors[Math.floor(Math.random() * App.numOfColorSchemes)];

// App.draw = SVG('container').fixSubPixelOffset();
App.draw = SVG('container');
Expand Down Expand Up @@ -58,11 +58,16 @@ define(['svg', 'colors', 'header', 'eventsManager'],
App.animations[module].init();
});
}

ga('send', 'event', 'category', 'demoSwitch', App.currentAnimation);

},

resetPrior: function() {
if(App.debug) console.log('App: resetting', App.priorAnimation);
if(App.debug) console.log('App: sending reset command to', App.priorAnimation);

var type = 'soft';

if (App.priorAnimation !== App.currentAnimation) {
type = 'hard';
}
Expand All @@ -88,7 +93,8 @@ define(['svg', 'colors', 'header', 'eventsManager'],
appinit: function () {
App.bindEvents(window);
App.setup();
header.init();
Header.init();
Modal.init();
EvtsMgr.subscribe('app/demoSwitch', App.demoSwitch);
App.demoSwitch({selectedDemo: App.defaultAnimation})
}
Expand Down
1 change: 0 additions & 1 deletion assets/js/demos/demoThree.js
Expand Up @@ -29,7 +29,6 @@ define(['../helpers'], function (h) {
app.parentGroup.clear();
h.stopTimer(globalTimer);
if (type === 'hard') {
console.warn('Three: hard reset');
}
}

Expand Down
191 changes: 106 additions & 85 deletions assets/js/events.js
@@ -1,102 +1,123 @@
define([], function () {
'use strict';
function events(app) {

return function (app) {
return {
onResize: function () {
},
/* function demoSwitch() {
var self = this;
getViewportSize: function () {
app.viewportSize = {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
};
},
app.sel.demoButtons.addEventListener('click', function (e) {
if (e.target.tagName === 'BUTTON') {
demoSwitch: function () {
var self = this;
var currentDemo = e.target.getAttribute('data-demo');
app.demoButtons.addEventListener('click', function (e) {
if (e.target.tagName === 'BUTTON') {
app.priorAnimation = app.currentAnimation;
app.currentAnimation = currentDemo;
var currentDemo = e.target.getAttribute('data-demo');
self.loadDemo(currentDemo);
app.priorAnimation = app.currentAnimation;
app.currentAnimation = currentDemo;
ga('send', 'event', 'category', 'switchDemo', currentDemo);
self.resetDemo();
document.getElementsByTagName('body')[0].className = currentDemo;
ga('send', 'event', 'category', 'switchDemo', currentDemo);
}
});
}*/

document.getElementsByTagName('body')[0].className = currentDemo;
/* function loadDemo(demo) {
var module;
if (module === 'loading') {
return;
}
}
if (module === undefined) {
module = 'loading';
require(['demos/demo' + demo], function (ModuleObject) {
console.log('loading a new module', 'demos/demo'+demo);
module = new ModuleObject();
});
},
resetDemo: function () {
if (app.animations[app.priorAnimation].hasOwnProperty('reset')) {
app.animations[app.priorAnimation].reset();
} else {
app.animations.demo.reset();
}
} else {
module.init();
}
}
app.animations[app.currentAnimation].init();

ga('send', 'event', 'category', 'resetDemo', app.currentAnimation);
},

saveDemo: function () {
app.modal.show('save-image');
var content = btoa(app.container.innerHTML),
innerModal = document.getElementsByClassName('modalForeground')[0],
image = innerModal.getElementsByTagName('img')[0];

image.setAttribute('src', 'data:image/svg+xml;base64,' + content);
ga('send', 'event', 'category', 'saveDemo', currentDemo);

},

showControls: function () {
app.modal.show('more-controls');
},

controls: function () {
var self = this;
app.controlButtons.addEventListener('click', function (e) {
if (e.target.tagName === 'BUTTON') {
var action = e.target.getAttribute('data-action');

switch (action) {
case 'controls':
console.log('will show controls at some point');
self.showControls();
break;
case 'save':
console.log('saving demo');
self.saveDemo();
break;
default:
self.resetDemo();
}
}
});
},

moreInfo: function () {
var infoButton = document.getElementsByClassName('moreInfo')[0];
infoButton.addEventListener('click', function (e) {
e.preventDefault();
app.modal.show('more-info');
}, true);
},

init : function () {
this.getViewportSize();
this.demoSwitch();
this.controls();
this.moreInfo();
function resetDemo() {
if (app.animations[app.priorAnimation].hasOwnProperty('reset')) {
app.animations[app.priorAnimation].reset();
} else {
app.animations.demo.reset();
}
};
};
app.animations[app.currentAnimation].init();
ga('send', 'event', 'category', 'resetDemo', app.currentAnimation);
}*/

function saveDemo() {
app.modal.show('save-image');
var content = btoa(app.container.innerHTML),
innerModal = document.getElementsByClassName('modalForeground')[0],
image = innerModal.getElementsByTagName('img')[0];

image.setAttribute('src', 'data:image/svg+xml;base64,' + content);
ga('send', 'event', 'category', 'saveDemo', currentDemo);

}

function showControls() {
app.modal.show('more-controls');
}

function controls() {
var self = this;
app.sel.controlButtons.addEventListener('click', function (e) {
if (e.target.tagName === 'BUTTON') {
var action = e.target.getAttribute('data-action');

switch (action) {
case 'controls':
console.log('will show controls at some point');
self.showControls();
break;
case 'save':
console.log('saving demo');
self.saveDemo();
break;
default:
self.resetDemo();
}
}
});
}

/* function moreInfo() {
var infoButton = document.getElementsByClassName('moreInfo')[0];
infoButton.addEventListener('click', function (e) {
e.preventDefault();
app.modal.show('more-info');
}, true);
}*/

function bindEvents() {
console.log('wasd');
window.addEventListener('resize', function(event){
console.log('wasd');
});
}

function init () {
// this.getViewportSize();
// this.demoSwitch();
// this.controls();
// this.moreInfo();
this.bindEvents();
// this.loadDemo(app.defaultAnimation)
}

return {
init: init
}
}

return events;
});

0 comments on commit 1f608ba

Please sign in to comment.