From 1b5100e8e42fba786767aa0cd78250d6db819aca Mon Sep 17 00:00:00 2001 From: George Michael Brower Date: Fri, 15 Aug 2014 12:32:49 -0400 Subject: [PATCH] gulp --- .gitignore | 2 + elements/base-controller.html | 67 +---------- elements/base-controller.js | 87 ++++++++++++++ elements/gui-panel.css | 6 + elements/gui-panel.html | 23 +--- elements/gui-panel.js | 7 ++ elements/gui-panel.styl | 6 + elements/gui-row.css | 18 +++ elements/gui-row.html | 30 +---- elements/gui-row.js | 7 ++ elements/gui-row.styl | 20 ++++ elements/number-controller.css | 160 ++++++++++++------------- elements/number-controller.html | 202 ++++---------------------------- elements/number-controller.js | 136 +++++++++++++++++++++ elements/number-controller.styl | 98 ++++++++++++++++ elements/shared.css | 0 elements/shared.styl | 9 ++ gulpfile.js | 33 ++++++ index.html | 48 ++++---- package.json | 11 ++ 20 files changed, 575 insertions(+), 395 deletions(-) create mode 100644 .gitignore create mode 100644 elements/base-controller.js create mode 100644 elements/gui-panel.css create mode 100644 elements/gui-panel.js create mode 100644 elements/gui-panel.styl create mode 100644 elements/gui-row.css create mode 100644 elements/gui-row.js create mode 100644 elements/gui-row.styl create mode 100644 elements/number-controller.js create mode 100644 elements/number-controller.styl create mode 100644 elements/shared.css create mode 100644 elements/shared.styl create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e501e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bower_components +node_modules \ No newline at end of file diff --git a/elements/base-controller.html b/elements/base-controller.html index 3dd2fc5..13d18e0 100644 --- a/elements/base-controller.html +++ b/elements/base-controller.html @@ -1,66 +1,3 @@ - - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/elements/base-controller.js b/elements/base-controller.js new file mode 100644 index 0000000..8f7bc15 --- /dev/null +++ b/elements/base-controller.js @@ -0,0 +1,87 @@ +Polymer('base-controller', { + + value: null, + object: null, + property: null, + + ready: function() { + + var _this = this; + this._observer = function( changes ) { + + changes.forEach( function( c ) { + + if ( c.name == _this.property ) { + _this.value = _this.object[ _this.property ]; + } + + } ); + + }; + + this.update(); + + }, + + + // Observers + // ------------------------------- + + objectChanged: function( oldObject, newObject ) { + + if ( oldObject && this.property ) { + this.unbind( oldObject ); + } + + if ( newObject && this.property ) { + this.bind(); + } + + }, + + propertyChanged: function( oldProperty, newProperty ) { + + if ( oldProperty && this.object ) { + this.unbind( this.object ); + } + + if ( newProperty && this.object ) { + this.bind(); + } + + }, + + valueChanged: function() { + + if ( this.object && this.property ) { + this.object[ this.property ] = this.value; + } + + this.update(); + + }, + + bind: function() { + + Object.observe( this.object, this._observer ); + this.value = this.object[ this.property ]; + + }, + + unbind: function( object ) { + + Object.unobserve( object, this._observer ); + + }, + + update: function() {}, + + + // Helpers + // ------------------------------- + + map: function( x, a, b, c, d ) { + return ( x - a ) / ( b - a ) * ( d - c ) + c; + } + +}); \ No newline at end of file diff --git a/elements/gui-panel.css b/elements/gui-panel.css new file mode 100644 index 0000000..022e7de --- /dev/null +++ b/elements/gui-panel.css @@ -0,0 +1,6 @@ +:host { + position: absolute; + top: 0; + right: 20px; + width: 300px; +} diff --git a/elements/gui-panel.html b/elements/gui-panel.html index cfd4527..ce86945 100644 --- a/elements/gui-panel.html +++ b/elements/gui-panel.html @@ -1,17 +1,12 @@ - +