From 34fc99271154ed1fd50b248778c82df80acce765 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Fri, 8 Nov 2013 11:56:17 +0100 Subject: [PATCH 01/20] removed some debug ouput --- app-base/application.js | 3 --- app-base/views/cell-types/cell-iframe-view.js | 5 ++--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app-base/application.js b/app-base/application.js index ed29111..f8700f6 100644 --- a/app-base/application.js +++ b/app-base/application.js @@ -46,9 +46,6 @@ var loadUserSets = function loadUserSets ( user_id, next ) { error: function loadUserSetsError (jqXHR, textStatus, errorThrown) { //next.apply(null,arguments); showError('Error loading sets' + (textStatus ? ': ' + textStatus + ' (' + jqXHR.status + ')' : '') ); - }, - complete: function() { - console.log(arguments); } }); } diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index cf218fa..990a63b 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -103,7 +103,7 @@ module.exports = CellDefaultView.extend({ activate : function () { if ( !this.active ) { - console.log("activate iframe: " + this.cid); + // console.log("activate iframe: " + this.cid); this.active = true; // needs to be before render(). why? don't know... @@ -129,8 +129,7 @@ module.exports = CellDefaultView.extend({ deactivate : function () { if ( this.active ) { if (!this.model.isSticky()) { - console.log("deactivate iframe: " + this.cid); - console.log(this); + // console.log("deactivate iframe: " + this.cid); //this.$el.empty(); // remove content and show info again $('.content', this.$el).remove(); From ac73a37346d955dd3ff9099eecb8850731cdb169 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Fri, 8 Nov 2013 11:57:52 +0100 Subject: [PATCH 02/20] added 10 second timeout for loading set data --- app-base/application.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app-base/application.js b/app-base/application.js index f8700f6..d2f0247 100644 --- a/app-base/application.js +++ b/app-base/application.js @@ -46,7 +46,8 @@ var loadUserSets = function loadUserSets ( user_id, next ) { error: function loadUserSetsError (jqXHR, textStatus, errorThrown) { //next.apply(null,arguments); showError('Error loading sets' + (textStatus ? ': ' + textStatus + ' (' + jqXHR.status + ')' : '') ); - } + }, + timeout: 10000 }); } From b58639274697b9008ebd5a421b062f249590e0b5 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Mon, 11 Nov 2013 17:00:29 +0100 Subject: [PATCH 03/20] handle empty iframe-src --- app-base/views/cell-types/cell-iframe-view.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index 990a63b..c0d4611 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -1,3 +1,4 @@ +/* cell-iframe-view.js */ var CellDefaultView = require('views/cell-view'), config = require('config/config'), pm = require('postmessenger'), @@ -71,11 +72,13 @@ module.exports = CellDefaultView.extend({ if ( Handlebars.compile && data['iframe-src'] ) { data['iframe-src'] = Handlebars.compile(data['iframe-src'])(config); } - var spl = data['iframe-src'].split('?'); - data['iframe-src'] = spl[0] + '?' + 'domain=http://' + config.host + '&' + (spl[1] || ''); - // if ( false === /^http[s]:\/\/.+/.test(data['iframe-src']) ) { - // data['iframe-src'] = 'http://' + config.host + config.baseUrl + data['iframe-src']; - // } + if ( data['iframe-src'] ) { + var spl = data['iframe-src'].split('?'); + data['iframe-src'] = spl[0] + '?' + 'domain=http://' + config.host + '&' + (spl[1] || ''); + // if ( false === /^http[s]:\/\/.+/.test(data['iframe-src']) ) { + // data['iframe-src'] = 'http://' + config.host + config.baseUrl + data['iframe-src']; + // } + } // collect attributes for +

{{{title}}}

{{description}}
-
-
-
\ No newline at end of file From b69770cb45bca531ca71df2cbe01ae1cad4ed584 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Tue, 12 Nov 2013 22:01:23 +0100 Subject: [PATCH 07/20] added loading animation for iframe/vimeo cells --- app-base/css/34-cell.css | 9 +++++++++ app-base/views/cell-types/cell-iframe-view.js | 14 ++++++++++++-- .../views/templates/cell-types/cell-iframe.hbs | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app-base/css/34-cell.css b/app-base/css/34-cell.css index b0d61ba..88543e8 100644 --- a/app-base/css/34-cell.css +++ b/app-base/css/34-cell.css @@ -228,3 +228,12 @@ .cell-collection .cell.type-text .info { display: none; }*/ +.loading { color:white; position:absolute; top:0;left:0;bottom:0;right:0; font-size:200%; text-align:center; vertical-align: middle; line-height:100%;} +.loading span { display:inline-block; margin-top:30%; } +.loading span:after { content:'•'; } +.loading .dot1 { -webkit-animation: fadeOut 0.7s 0.00s infinite alternate; animation: fadeOut 0.7s 0.00s infinite alternate; } +.loading .dot2 { -webkit-animation: fadeOut 0.7s 0.35s infinite alternate; animation: fadeOut 0.7s 0.35s infinite alternate; } +.loading .dot3 { -webkit-animation: fadeOut 0.7s 0.70s infinite alternate; animation: fadeOut 0.7s 0.70s infinite alternate; } +@-webkit-keyframes fadeOut { from {opacity:1;} to {opacity:0;} } +@keyframes fadeOut { from {opacity:1;} to {opacity:0;} } + diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index ca46dad..cfbf015 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -47,7 +47,7 @@ module.exports = CellDefaultView.extend({ render : function () { CellDefaultView.prototype.render.apply(this,arguments); - + return this; }, @@ -55,6 +55,9 @@ module.exports = CellDefaultView.extend({ open : function () { console.log("open " + this.cellInfo()); + // show loading animation + this.showLoadingAnimation(); + // load iframe from data-src var $iframe = $('iframe',this.$el); $iframe.attr( 'src', $iframe.data('src') ); @@ -69,7 +72,7 @@ module.exports = CellDefaultView.extend({ // remove content close : function () { console.log("close " + this.cellInfo()); - + var $iframe = $('iframe',this.$el); $iframe.attr( 'src', ''); @@ -95,4 +98,11 @@ module.exports = CellDefaultView.extend({ this.close(); } }, + + showLoadingAnimation : function() { + $('.loading', this.$el).show(0); + $('iframe', this.$el).off('load').on('load', function() { + $('.loading', this.$el).hide(0); + }); + } }); \ No newline at end of file diff --git a/app-base/views/templates/cell-types/cell-iframe.hbs b/app-base/views/templates/cell-types/cell-iframe.hbs index c8cdba8..11c9905 100644 --- a/app-base/views/templates/cell-types/cell-iframe.hbs +++ b/app-base/views/templates/cell-types/cell-iframe.hbs @@ -6,4 +6,5 @@

{{{title}}}

{{description}}
-
\ No newline at end of file + + \ No newline at end of file From aa025d24cca4caf4bb5a80c7fd8b2b3895e20afa Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Tue, 12 Nov 2013 22:09:19 +0100 Subject: [PATCH 08/20] add extra attribute fields to iframe cell --- app-base/views/cell-types/cell-iframe-view.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index cfbf015..7c39c97 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -45,9 +45,35 @@ module.exports = CellDefaultView.extend({ }); }, + getTemplateData : function () { + var data = CellDefaultView.prototype.getTemplateData.apply(this,arguments); + // TODO: check this again + if ( Handlebars.compile && data['iframe-src'] ) { + data['iframe-src'] = Handlebars.compile(data['iframe-src'])(config); + } + if ( data['iframe-src'] ) { + var spl = data['iframe-src'].split('?'); + data['iframe-src'] = spl[0] + '?' + 'domain=http://' + config.host + '&' + (spl[1] || ''); + // if ( false === /^http[s]:\/\/.+/.test(data['iframe-src']) ) { + // data['iframe-src'] = 'http://' + config.host + config.baseUrl + data['iframe-src']; + // } + } + + // collect extra attributes for -

{{{title}}}

{{description}}
+
+
+
\ No newline at end of file From d2f5519695882b1c9052d54bdde8d3b7b0e18cfc Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 01:13:57 +0100 Subject: [PATCH 14/20] Revert "Revert c15bfbb..09cedc8" This reverts commit 49e0b6598004e8aff47389f5a71034a56cbf87fa. --- app-base/css/34-cell.css | 10 + app-base/views/cell-collection-view.js | 2 + app-base/views/cell-types/cell-iframe-view.js | 255 ++++++++++-------- app-base/views/cell-types/cell-vimeo-view.js | 75 +++++- app-base/views/cell-view.js | 78 +++--- app-base/views/set-view.js | 120 ++++----- .../templates/cell-types/cell-iframe.hbs | 12 +- 7 files changed, 325 insertions(+), 227 deletions(-) diff --git a/app-base/css/34-cell.css b/app-base/css/34-cell.css index b0d61ba..1464e7b 100644 --- a/app-base/css/34-cell.css +++ b/app-base/css/34-cell.css @@ -228,3 +228,13 @@ .cell-collection .cell.type-text .info { display: none; }*/ +.loading { color:white; position:absolute; top:0;left:0;bottom:0;right:0; font-size:200%; text-align:center; vertical-align: middle; line-height:100%;} +.loading span { display:inline-block; margin-top:30%; } +.loading span:after { content:'•'; } +.loading .dot1 { -webkit-animation: fadeOut 0.7s 0.00s infinite alternate; animation: fadeOut 0.7s 0.00s infinite alternate; } +.loading .dot2 { -webkit-animation: fadeOut 0.7s 0.35s infinite alternate; animation: fadeOut 0.7s 0.35s infinite alternate; } +.loading .dot3 { -webkit-animation: fadeOut 0.7s 0.70s infinite alternate; animation: fadeOut 0.7s 0.70s infinite alternate; } +@-webkit-keyframes fadeOut { from {opacity:1;} to {opacity:0;} } +@keyframes fadeOut { from {opacity:1;} to {opacity:0;} } +.cell .content { position:relative; } /* so .loading doesn't overlay it */ + diff --git a/app-base/views/cell-collection-view.js b/app-base/views/cell-collection-view.js index 1c2e59f..1414122 100644 --- a/app-base/views/cell-collection-view.js +++ b/app-base/views/cell-collection-view.js @@ -1,3 +1,4 @@ +/* cell-collection-view.js */ var CellDefaultView = require('views/cell-view'), BaseCollectionView = require('views/base/collection-view'), mediator = require('mediator'), @@ -21,6 +22,7 @@ module.exports = BaseCollectionView.extend({ }, render : function () { + console.log("rendering cell collection"); BaseCollectionView.prototype.render.apply(this,arguments); // after rendring is finished attach scroll listener _(function(){ diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index d15d9e6..0c6d219 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -9,86 +9,47 @@ module.exports = CellDefaultView.extend({ // cell types have default values. can be overridden via fields // these are the defaults use by most cell types defaultViewAttributes : { - autoload : 1, // automatically open a cell on set load or scroll in? - sticky : 0, // close a cell on scroll out? - solo: 1 // close other cells on open? + autoload : 1, // open on scroll in? + sticky : 0, // don't close on scroll out? + solo: 0 // close other cells on open? }, - // events : { - // 'click' : function () { - // this.renderContent(); - // } - // }, - - // keep this in sync with cell-vimeo! - render : function () { - - CellDefaultView.prototype.render.apply(this,arguments); - - if ( this.model.attributes['autoload'] && - /^(1|true)$/i.test(this.model.attributes['autoload']) ) { - this.renderContent(); + events : { + 'click' : function () { + // console.log("click"); + if ( !this.isOpen ) { + this.open(); + } } - - return this; }, - renderContent : function () { - // load iframe from data-src - $('iframe',this.$el).attr('src',$('iframe',this.$el).data('src')); - - // connect to iframe with postmessenger - _(function(){ - - var view = this; - var iframe = $('iframe',this.$el); - - iframe.load(function() { - // show content, hide info - $('.element-hidden',view.$el).removeClass('element-hidden'); - $('.info',view.$el).addClass('element-hidden'); - - view.$iframe = $(this); - // if iframe on another domain add that to the accept list - var src = view.model.get('iframe-src'); - if ( /^http[s]?:\/\/.+/.test(src) ) { - var iframe_domain = (function(){ - var p = src.split('/'); - return p[0]+'//'+p[2]; - })(); - pm.accept(iframe_domain); - } - - // connect it - pm.send( - 'connect?', - { listener_id: hasher.generate(20) }, - this.contentWindow, - iframe_domain - ); - }); - - }).bind(this).defer(); - - this.$el.css({ - 'background-image' : 'none' + initialize : function () { + CellDefaultView.prototype.initialize.apply(this,arguments); + // fill in missing view attributs with defaults + _.defaults(this.model.attributes, this.defaultViewAttributes); + + // listen for solo event. close if in same solo group + this.subscribeEvent('!solo', function(args) { + // console.log("solo "); + // console.log(args); + // skip if we sent that event + if ( args.origin == this ) { return; } + if ( args.group == this.model.get('solo') ) { this.close(); } }); }, getTemplateData : function () { var data = CellDefaultView.prototype.getTemplateData.apply(this,arguments); + if ( Handlebars.compile && data['iframe-src'] ) { data['iframe-src'] = Handlebars.compile(data['iframe-src'])(config); } if ( data['iframe-src'] ) { var spl = data['iframe-src'].split('?'); data['iframe-src'] = spl[0] + '?' + 'domain=http://' + config.host + '&' + (spl[1] || ''); - // if ( false === /^http[s]:\/\/.+/.test(data['iframe-src']) ) { - // data['iframe-src'] = 'http://' + config.host + config.baseUrl + data['iframe-src']; - // } } - // collect attributes for +

{{{title}}}

{{description}}
-
-
-
\ No newline at end of file From ffcd8a88521ff06796d79031a011c3d35efd95b4 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 01:54:35 +0100 Subject: [PATCH 15/20] added smooth scrolling to vimeo on-finish trigger --- app-base/views/cell-types/cell-vimeo-view.js | 2 +- app-base/views/cell-view.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app-base/views/cell-types/cell-vimeo-view.js b/app-base/views/cell-types/cell-vimeo-view.js index 5d60aad..b1d364a 100644 --- a/app-base/views/cell-types/cell-vimeo-view.js +++ b/app-base/views/cell-types/cell-vimeo-view.js @@ -25,7 +25,7 @@ module.exports = CellIFrameView.extend({ this.subscribeEvent('!open', function(args) { if ( args.origin == this ) { return; } //console.log("open received for: " + args.cellid); - if ( args.cellid == this.model.get('connection_id') ) { this.open(); } + if ( args.cellid == this.model.get('connection_id') ) { this.scrollTo(); this.open(); } }); }, diff --git a/app-base/views/cell-view.js b/app-base/views/cell-view.js index 599da44..1909591 100644 --- a/app-base/views/cell-view.js +++ b/app-base/views/cell-view.js @@ -78,4 +78,18 @@ module.exports = BaseView.extend({ deactivate : function () { // console.log( "deactivate " + this.model.get('type') + this.model.get('connection_id') ); }, + + // smoothly scroll to this cell + scrollTo : function() { + console.log("scrolling to " + this.cellInfo()); + //$('#set .cell-collection-container').scrollLeft(this.$el.position().left); // jump + //$('#set .cell-collection-container').animate( {scrollLeft : this.$el.position().left}, 1500 ); // smoother + + var $viewport = $('#set .cell-collection-container'); + if ( this.$el.offset().left + this.$el.width() > $viewport.width() ) { // if not fully in view + var destLeft = this.$el.position().left - ($viewport.width() - this.$el.width()) / 2; + //$viewport.scrollLeft( destLeft ); //jump + $viewport.animate( {scrollLeft : destLeft}, 1500 ); // smooth + } + } }); \ No newline at end of file From f7af97c93fbab0736e72420d2a04d9f048040db1 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 02:16:21 +0100 Subject: [PATCH 16/20] added random choice syntax to on-finish trigger. updated lodash for _.sample(). (lazy, yes, but hey, it's 2.15 a.m.) --- app-base/views/cell-types/cell-vimeo-view.js | 3 ++- bower.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app-base/views/cell-types/cell-vimeo-view.js b/app-base/views/cell-types/cell-vimeo-view.js index b1d364a..1b87309 100644 --- a/app-base/views/cell-types/cell-vimeo-view.js +++ b/app-base/views/cell-types/cell-vimeo-view.js @@ -58,7 +58,8 @@ module.exports = CellIFrameView.extend({ //console.log(iframe); var onfinish = that.model.get('on-finish'); if (onfinish) { - that.publishEvent('!open', {cellid : onfinish, origin : that}); + var random = _.sample( onfinish.split('/') ); + that.publishEvent('!open', {cellid : random, origin : that}); } } }, diff --git a/bower.json b/bower.json index b934cfd..abfcb5f 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "dependencies": { "chaplin" : "~0.11.3", "console-polyfill" : "~0.1.0", - "lodash" : "~1.3.1", + "lodash" : "~2.3.0", "jquery" : "~2.0.2", "normalize-css" : "~2.1.2", "h5bp-helpers" : "~0.1.0", From f3050ee958e475947c8d22377200547081788801 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 13:14:46 +0100 Subject: [PATCH 17/20] proper load states for "media" cells --- app-base/views/cell-types/cell-iframe-view.js | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/app-base/views/cell-types/cell-iframe-view.js b/app-base/views/cell-types/cell-iframe-view.js index 0c6d219..852c1c4 100644 --- a/app-base/views/cell-types/cell-iframe-view.js +++ b/app-base/views/cell-types/cell-iframe-view.js @@ -17,12 +17,26 @@ module.exports = CellDefaultView.extend({ events : { 'click' : function () { // console.log("click"); - if ( !this.isOpen ) { + if ( !this.isOpen() ) { this.open(); } } }, + loadState : "closed", + + isOpen : function() { + return this.loadState.toLowerCase() == "open"; + }, + + isClosed : function() { + return this.loadState.toLowerCase() == "closed"; + }, + + isLoading : function() { + return this.loadState.toLowerCase() == "loading"; + }, + initialize : function () { CellDefaultView.prototype.initialize.apply(this,arguments); // fill in missing view attributs with defaults @@ -34,7 +48,10 @@ module.exports = CellDefaultView.extend({ // console.log(args); // skip if we sent that event if ( args.origin == this ) { return; } - if ( args.group == this.model.get('solo') ) { this.close(); } + if ( args.group == this.model.get('solo') ) { + // close if open or loading + if (!this.isClosed()) this.close(); + } }); }, @@ -73,6 +90,7 @@ module.exports = CellDefaultView.extend({ // render content open : function () { console.log("open " + this.cellInfo()); + this.loadState = "loading"; // show loading animation this.showLoadingAnimation(); @@ -80,7 +98,7 @@ module.exports = CellDefaultView.extend({ // load iframe from data-src var $iframe = $('iframe',this.$el); var that = this; - $iframe.one('load.open', function() { that.isOpen = true; }); // once loaded, set isOpen flag + $iframe.one('load.open', function() { that.loadState = "open"; }); // once loaded, set isOpen flag $iframe.attr( 'src', $iframe.data('src') ); $('.content',this.$el).removeClass('element-hidden'); @@ -99,26 +117,26 @@ module.exports = CellDefaultView.extend({ // remove content close : function () { console.log("close " + this.cellInfo()); + // debugger; + this.$el.css( 'background-image', 'url('+this.model.getPosterImageURL()+')' ); // show poster image + $('.info',this.$el).removeClass('element-hidden'); // show info + $('.content',this.$el).addClass('element-hidden'); // hide content var $iframe = $('iframe',this.$el); $iframe.off('.open'); // don't set isOpen anymore, if pending $iframe.attr( 'src', ''); - - $('.content',this.$el).addClass('element-hidden'); - $('.info',this.$el).removeClass('element-hidden'); - this.$el.css( 'background-image', 'url('+this.model.getPosterImageURL()+')' ); - this.isOpen = false; + this.loadState = "closed"; }, // called when scrolled into view activate : function () { // console.log( "activate " + this.model.get('type') + this.model.get('connection_id') ); - if ( this.model.getFlag('autoload') && !this.isOpen ) { + if ( this.model.getFlag('autoload') && !this.isOpen() ) { this.open(); } - if ( this.model.getFlag('sticky') && this.isOpen ) { + if ( this.model.getFlag('sticky') && this.isOpen() ) { // console.log("sending activate"); this.sendPM('activate!'); } @@ -131,7 +149,7 @@ module.exports = CellDefaultView.extend({ this.close(); } - if ( this.model.getFlag('sticky') && this.isOpen ) { + if ( this.model.getFlag('sticky') && this.isOpen() ) { // console.log("sending deactivate"); this.sendPM('deactivate!'); } @@ -181,7 +199,7 @@ module.exports = CellDefaultView.extend({ var iframe = $('iframe', this.$el)[0]; if (opts == undefined) { opts = {}; } - if (this.isOpen) { + if (this.isOpen()) { // console.log("sending " + msg); pm.send(msg, opts, iframe.contentWindow ); } else { // wait till iframe is loaded to send message From 633939c283cc824d360b52120699bfc1f83ad2ed Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 17:07:32 +0100 Subject: [PATCH 18/20] fix loading css --- app-base/css/34-cell.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app-base/css/34-cell.css b/app-base/css/34-cell.css index 1464e7b..7365e25 100644 --- a/app-base/css/34-cell.css +++ b/app-base/css/34-cell.css @@ -228,12 +228,12 @@ .cell-collection .cell.type-text .info { display: none; }*/ -.loading { color:white; position:absolute; top:0;left:0;bottom:0;right:0; font-size:200%; text-align:center; vertical-align: middle; line-height:100%;} -.loading span { display:inline-block; margin-top:30%; } -.loading span:after { content:'•'; } -.loading .dot1 { -webkit-animation: fadeOut 0.7s 0.00s infinite alternate; animation: fadeOut 0.7s 0.00s infinite alternate; } -.loading .dot2 { -webkit-animation: fadeOut 0.7s 0.35s infinite alternate; animation: fadeOut 0.7s 0.35s infinite alternate; } -.loading .dot3 { -webkit-animation: fadeOut 0.7s 0.70s infinite alternate; animation: fadeOut 0.7s 0.70s infinite alternate; } +.cell .loading { color:white; position:absolute; top:0;left:0;bottom:0;right:0; font-size:200%; text-align:center; vertical-align: middle; line-height:100%;} +.cell .loading span { display:inline-block; margin-top:30%; } +.cell .loading span:after { content:'•'; } +.cell .loading .dot1 { -webkit-animation: fadeOut 0.7s 0.00s infinite alternate; animation: fadeOut 0.7s 0.00s infinite alternate; } +.cell .loading .dot2 { -webkit-animation: fadeOut 0.7s 0.35s infinite alternate; animation: fadeOut 0.7s 0.35s infinite alternate; } +.cell .loading .dot3 { -webkit-animation: fadeOut 0.7s 0.70s infinite alternate; animation: fadeOut 0.7s 0.70s infinite alternate; } @-webkit-keyframes fadeOut { from {opacity:1;} to {opacity:0;} } @keyframes fadeOut { from {opacity:1;} to {opacity:0;} } .cell .content { position:relative; } /* so .loading doesn't overlay it */ From a67319e42635d485e6e0243ebb95233ee212a975 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 17:41:23 +0100 Subject: [PATCH 19/20] changed background gradient --- app-base/css/11-app.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app-base/css/11-app.css b/app-base/css/11-app.css index 1e50a06..b1de894 100644 --- a/app-base/css/11-app.css +++ b/app-base/css/11-app.css @@ -1,8 +1,8 @@ #app-background { /*background-image: url('http://motionbank-media.s3.amazonaws.com/dh/app/imgs/backs/background-1.jpg');*/ - background: -webkit-radial-gradient(45px 45px, cover, #666 0%, #222 100%); - background: -moz-radial-gradient(45px 45px, cover, #666 0%, #222 100%); - background: radial-gradient(45px 45px, cover, #666 0%, #222 100%); + background: -webkit-radial-gradient(45px 45px, cover, #3b4241 0%, #1d2121 100%); + background: -moz-radial-gradient(45px 45px, cover, #3b4241 0%, #1d2121 100%); + background: radial-gradient(45px 45px, cover, #3b4241 0%, #1d2121 100%); background-size: cover; -webkit-background-size: cover; -moz-background-size: cover; From e63a6e1801da835b94574f98d7737c58387c3fb7 Mon Sep 17 00:00:00 2001 From: Martin Leopold Date: Thu, 14 Nov 2013 18:09:53 +0100 Subject: [PATCH 20/20] implemented cell permalinks e.g. set/setid/cellid --- app-base/controllers/set-controller.js | 72 ++++++++++++++++++++------ app-base/routes.js | 8 +-- app-base/views/cell-collection-view.js | 9 ++++ app-base/views/cell-view.js | 9 ++-- 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/app-base/controllers/set-controller.js b/app-base/controllers/set-controller.js index d1c6307..bcde376 100644 --- a/app-base/controllers/set-controller.js +++ b/app-base/controllers/set-controller.js @@ -3,29 +3,71 @@ var Controller = require('controllers/base/controller'), SetModel = require('models/set-model'), ErrorView = require('views/error-view'); +var current_opts = prev_opts = {}; // hack this sh*t + module.exports = Controller.extend({ show : function ( opts ) { - - this.model = new SetModel(); + // console.log("set#show", opts.setid, opts.cellid); + + prev_opts = current_opts; + current_opts = opts; + + this.compose('set', { + compose : function() { + // console.log("composing"); + + // create set model + this.model = new SetModel(); + + // create set view + this.view = new SetView({ + region: 'content', + model: this.model + }); + + this.model.fetch({ + id : opts.setid, + + error : function(model, response, options) { + //Chaplin.helpers.redirectTo('error#show', {message: 'Error message'}); // use this to redirect to an error page (changes url) + new ErrorView( {message : 'Couldn\'t get the set you requested. (' + response.status + ')'} ); + } + }); + + this.model.synced(function(){ + this.view.render(); - this.model.fetch({ - id : opts.setid, + // scroll (jump) to cellid + _(function() { + if (current_opts.cellid) { + this.model.collectionView.scrollToCell(current_opts.cellid, 0); + } + }).bind(this).defer(); + }, this); + }, - error : function(model, response, options) { - //Chaplin.helpers.redirectTo('error#show', {message: 'Error message'}); // use this to redirect to an error page (changes url) - new ErrorView( {message : 'Couldn\'t get the set you requested. (' + response.status + ')'} ); + check : function() { + // differnet set -> reload + if ( current_opts.setid != prev_opts.setid ) { + return false; //rerun compose() + } + + // same set, but removed cell id -> reload + if ( current_opts.cellid == undefined && current_opts.setid == prev_opts.setid ) { + return false; //rerun compose() + } + + // same set, cell id given -> scroll to cell + if (current_opts.cellid) { + this.model.collectionView.scrollToCell(current_opts.cellid, 0); + } + + return true; // don't rerun compose() } - }); - this.model.synced(function(){ - setView.render(); - }); - - var setView = this.view = new SetView({ - region: 'content', - model: this.model }); + } }); diff --git a/app-base/routes.js b/app-base/routes.js index eb7a820..51cada8 100644 --- a/app-base/routes.js +++ b/app-base/routes.js @@ -1,8 +1,10 @@ module.exports = function(match) { + + match( 'set/:setid', 'set#show' ); + match( 'set/:setid/', 'set#show' ); + match( 'set/:setid/:cellid', 'set#show' ); + match( 'set/:setid/:cellid/', 'set#show' ); - match( 'set/:setid', 'set#show' - //,{ constraints: { setid: /^\d+$/ }} - ); match( '', 'cover#index' ); // match( 'error', 'error#show' ); // to test and error page (to redirect to) diff --git a/app-base/views/cell-collection-view.js b/app-base/views/cell-collection-view.js index 1414122..b4957f0 100644 --- a/app-base/views/cell-collection-view.js +++ b/app-base/views/cell-collection-view.js @@ -56,6 +56,15 @@ module.exports = BaseCollectionView.extend({ } return cellView; + }, + + // scroll to a cell + scrollToCell : function (cellid, time) { + if (cellid == undefined) return; + var cellView = _.find(this.subviews, function(cellView) { + return cellView.model.id == cellid; + }); + if (cellView) cellView.scrollTo(time); } }); \ No newline at end of file diff --git a/app-base/views/cell-view.js b/app-base/views/cell-view.js index 1909591..c558677 100644 --- a/app-base/views/cell-view.js +++ b/app-base/views/cell-view.js @@ -80,16 +80,19 @@ module.exports = BaseView.extend({ }, // smoothly scroll to this cell - scrollTo : function() { + scrollTo : function(time) { console.log("scrolling to " + this.cellInfo()); //$('#set .cell-collection-container').scrollLeft(this.$el.position().left); // jump //$('#set .cell-collection-container').animate( {scrollLeft : this.$el.position().left}, 1500 ); // smoother + if (time == undefined) time = 1500; + var $viewport = $('#set .cell-collection-container'); - if ( this.$el.offset().left + this.$el.width() > $viewport.width() ) { // if not fully in view + if ( this.$el.offset().left + this.$el.width() > $viewport.width() + || this.$el.offset().left < 0 ) { // if not fully in view var destLeft = this.$el.position().left - ($viewport.width() - this.$el.width()) / 2; //$viewport.scrollLeft( destLeft ); //jump - $viewport.animate( {scrollLeft : destLeft}, 1500 ); // smooth + $viewport.animate( {scrollLeft : destLeft}, time ); // smooth } } }); \ No newline at end of file