Skip to content

Commit

Permalink
Merge pull request #40 from TelaSocial/manual-sync
Browse files Browse the repository at this point in the history
Manual sync - this is already useful as is, considering this 0.4.1 and merging, renaming tuesday milestone to 0.4.2
  • Loading branch information
fczuardi committed Apr 26, 2014
2 parents ebf067f + 28ce697 commit f19cd84
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"glob": "^3.2.9",
"gulp": "^3.6.0",
"gulp-assemble": "git://github.com/assemble/gulp-assemble.git",
"gulp-autoprefixer": "0.0.6",
"gulp-sass": "^0.7.1",
"gulp-util": "^2.2.14",
"handlebars": "~2.0.0-alpha.2",
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/gulp-tasks/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var gulp = require('gulp'),
glob = require('glob'),
_ = require ('lodash'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
through = require('through2'),
browserify = require('browserify'),
hbsfy = require('hbsfy').configure({
Expand Down Expand Up @@ -92,8 +93,10 @@ module.exports = function(paths){
gulp.src(['**/*.scss'], {cwd: paths.sources.styles + '**'})
.pipe(gulp.dest(paths.build.scss));
}

return gulp.src(paths.sources.styles + '**/*.scss')
.pipe(sass(options))
.pipe(prefix('last 2 versions'))
.pipe(gulp.dest(paths.build.css));
};

Expand Down
44 changes: 31 additions & 13 deletions src/scripts/lib/companion/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ module.exports = function($, FISLParser, templates){
feedData,
bookmarkedSessions;

var populateSchedule = function(data, viewArg){
var template = templates.app,
destinationElement = $('#app'),
view = viewArg ? viewArg : defaultView,
var populateSchedule = function(data, isRefresh){
var template = isRefresh ? templates.schedule : templates.app,
destinationElement = isRefresh ? $('#schedule-view') : $('#app'),
view = $('#list-view-toggle').length > 0 ?
($('#list-view-toggle .active').hasClass('list-view-button') ? 'list' : 'table') :
defaultView,
templateData = {
schedule_type: view,
title: 'Companion App',
Expand Down Expand Up @@ -276,8 +278,17 @@ module.exports = function($, FISLParser, templates){
applyBookmarksFilter();
};

var manualFetchClicked = function(){
var buttonElement = $(this);
buttonElement.addClass('loading');
loadFeed();
};

var setupAppHeaderBar = function(){

//refresh button
$('#refresh-feed').click(manualFetchClicked);

//toggle bookmarks-only filter
$('#filter-bookmarks').click(toggleBookmarksFilter);
//list view toggle (lists vs tables)
Expand Down Expand Up @@ -311,8 +322,10 @@ module.exports = function($, FISLParser, templates){
};

var feedLoaded = function(data, textStatus, xhr, fromCache) {
var scheduleData = parser.parse(data);
var scheduleData = parser.parse(data),
isRefresh = $('#schedule-view').length > 0;
feedData = data;

console.log('XML size='+data.length);
if (xhr !== null){
console.log('XML all headers='+xhr.getAllResponseHeaders());
Expand All @@ -322,21 +335,23 @@ module.exports = function($, FISLParser, templates){
updateLocalFeed();
}
//3. render schedule
populateSchedule(scheduleData);
populateSchedule(scheduleData, isRefresh);
//4. start framework - example: $(document).foundation()
if (defaultView === 'list'){
initListView();
}else{
initTableView();
}
//setup App main bar buttons
setupAppHeaderBar();
if (!isRefresh){
setupAppHeaderBar();
}
//bind session element events
initSessions();
};

var firstLoad = function(){
console.log('firstLoad');
var loadFeed = function(){
console.log('loadFeed');
var appElement = $('#app'),
feedURL = appElement.data('feed-url'),
localFeed = appElement.data('local-feed-url');
Expand All @@ -350,7 +365,8 @@ module.exports = function($, FISLParser, templates){
//download everything
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
var xhr = new window.XMLHttpRequest(),
progressbar = document.getElementById('progressMeter');
xhr.addEventListener('progress', function(evt) {
var percentComplete,
total,
Expand All @@ -365,7 +381,9 @@ module.exports = function($, FISLParser, templates){
}
percentComplete = Math.min((evt.loaded / total), 1);
percentString = (Math.round(percentComplete * 100)+'%');
document.getElementById('progressMeter').setAttribute('style', 'width:' + percentString +';');
if (progressbar){
progressbar.setAttribute('style', 'width:' + percentString +';');
}
}, false);
return xhr;
},
Expand All @@ -377,7 +395,7 @@ module.exports = function($, FISLParser, templates){
.fail(function() {
console.log('error');
}).always(function() {
console.log('finished');
$('#refresh-feed').removeClass('loading');
});
};

Expand All @@ -396,7 +414,7 @@ module.exports = function($, FISLParser, templates){
companionStore.getLastFetchInfo(function(info){
if (info === null){
//no feed information was found, this is the first run
firstLoad();
loadFeed();
}else{
//load the stored xml
companionStore.cachedXML(loadCached);
Expand Down
11 changes: 11 additions & 0 deletions src/styles/lib/companion/_tweaks_bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ body {
padding-top: 50px; //space for the app top menu
}

#refresh-feed .icon,
.filter-bookmarks-toggle .icon,
.bookmark-button .icon,
.clear-cache-button .icon,
Expand Down Expand Up @@ -45,3 +46,13 @@ body {
.favorite .bookmark-button .icon{
@extend .glyphicon-star;
}
#refresh-feed .icon{
@extend .glyphicon-refresh;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
#refresh-feed.loading .icon{
animation: spin 1s infinite linear;
}
15 changes: 11 additions & 4 deletions src/templates/partials/app_menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
<li><a id="erase-all" href="#">Erase all local data</a></li>
</ul>
<button
id="filter-bookmarks"
id="refresh-feed"
class="
filter-bookmarks-toggle
btn btn-default navbar-btn"
>
<span class="icon"></span>
</button>
</div>

<form class="navbar-form navbar-right">
<div class="navbar-right">
<button
id="filter-bookmarks"
class="
filter-bookmarks-toggle
btn btn-default navbar-btn"
>
<span class="icon"></span>
</button>
<div
id="list-view-toggle"
class="btn-group"
Expand Down Expand Up @@ -59,5 +66,5 @@
<span class="icon"></span>
</button>
</div>
</form>
</div>
</nav>

0 comments on commit f19cd84

Please sign in to comment.