Skip to content

Commit

Permalink
Merge branch 'v1.9.1' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
berbaquero committed Feb 15, 2015
2 parents 6113e78 + e99212d commit 31fcf63
Show file tree
Hide file tree
Showing 45 changed files with 795 additions and 358 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
node_modules

.sass-cache
*.sublime-project
*.sublime-workspace

scripts/modules.js
39 changes: 33 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var gulp = require('gulp'),
rename = require('gulp-rename'),
concat = require('gulp-concat-util'),
prefix = require('gulp-autoprefixer'),
groupMQ = require('gulp-group-css-media-queries');
groupMQ = require('gulp-group-css-media-queries'),
jade = require('gulp-jade');

var paths = {
styles: 'styles/**/*.scss',
Expand All @@ -19,11 +20,20 @@ var paths = {
'scripts/functions.js',
'scripts/actions.js',
'scripts/listeners.js',
'scripts/init.js'
'scripts/init.js',
'scripts/modules.js'
],
scriptModules: {
root: 'scripts/modules/**/*.js',
dest: 'scripts'
},
templates: {
root: 'templates/index.jade'
},
watch: {
scripts: 'scripts/**/*.js',
styles: 'styles/**/*.scss'
scripts: ['scripts/**/*.js', '!scripts/modules.js'],
styles: 'styles/**/*.scss',
templates: 'templates/**/*.jade'
},
root: './',
distribution: 'dist/'
Expand All @@ -45,7 +55,15 @@ gulp.task('styles', function() {
.pipe(gulp.dest(paths.distribution));
});

gulp.task('scripts', function() {
gulp.task('scripts-modules', function() {
return gulp.src(paths.scriptModules.root)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('modules.js'))
.pipe(gulp.dest(paths.scriptModules.dest));
});

gulp.task('scripts', ['scripts-modules'], function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'))
Expand All @@ -61,9 +79,18 @@ gulp.task('scripts', function() {
.pipe(gulp.dest(paths.distribution));
});

gulp.task('default', ['styles', 'scripts']);
gulp.task('templates', function() {
return gulp.src(paths.templates.root)
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest(paths.root));
});

gulp.task('default', ['styles', 'scripts', 'templates']);

gulp.task('dev', function() {
gulp.watch(paths.watch.styles, ['styles']);
gulp.watch(paths.watch.scripts, ['scripts']);
gulp.watch(paths.watch.templates, ['templates']);
});
Binary file removed img/cancel.png
Binary file not shown.
Binary file removed img/close.png
Binary file not shown.
24 changes: 13 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,41 @@
<span id="btn-new-sub" class="btn-side-menu-add">+</span>
</div>
<ul id="subs"></ul>

<div class="menu-desc">
Channels
<span id="btn-new-channel" class="btn-side-menu-add">+</span>
</div>
<ul id="channels"></ul>
<div class="menu-desc">Sorting</div>
<div id="sorting">
<p class="sorting-choice">hot</p>
<p>new</p>
<p>controversial</p>
<p>top</p>
</div>
<div class="menu-desc">Options</div>
<div class="option" id="about">About</div>
<div class="option" id="exp-data">Export Data</div>
<div class="option" id="imp-data">Import Data</div>
<div class="option" id="mnml">Mnml</div>
<div class="option" id="mnml">Theme</div>
</div>
</div>
</nav>

<section class="view main-view show-view">
<section class="wrapper" id="main-wrap"></section>
<div class="view-footer" id="main-footer">
<p id="footer-sub"></p>
<div class="sorter-wrap">
<div class="sorter-container js-sort-container sorter--hot">
<span class="sorter-label sorter-label--hot">Hot</span>
<span class="sorter-icon"></span>
<span class="sorter-label sorter-label--new">New</span>
</div>
</div>
<p id="footer-sub" class="footer-sub-title"></p>
<div class="btn-footer footer-refresh btn-refresh" data-origin="footer-main"></div>
</div>
</section>

<section class="view detail-view">
<section class="wrapper wrapper--detail" id="detail-wrap"></section>
<div class="view-footer" id="detail-footer">
<div class="btn-footer hide btn-to-main" id="detail-close"></div>
<p id="footer-post"></p>
<div class="btn-footer hide btn-to-main" id="detail-close">&times;</div>
<p id="footer-post" class="footer-post-title"></p>
<div class="btn-footer footer-refresh btn-refresh hide" data-origin="footer-detail"></div>
</div>
</section>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"gulp-jshint": "~1.6.3",
"gulp-watch": "^0.6.8",
"gulp-concat-util": "~0.5.1",
"gulp-group-css-media-queries": "~1.0.1"
"gulp-group-css-media-queries": "~1.0.1",
"gulp-jade": "~0.11.0"
},
"scripts": {
"start": "gulp dev"
Expand Down
2 changes: 0 additions & 2 deletions reeddit.appcache
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ dist/app.min.css
# images
/img/add.png
/img/alienHead.png
/img/cancel.png
/img/close.png
/img/comment_24.png
/img/darkdenim3.png
/img/delete.png
Expand Down
59 changes: 33 additions & 26 deletions scripts/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ tappable("#wide-refresh", {

tappable("#sub-title", {
onTap: function() {
if ((!isDesktop && loadingLinks) || isLargeScreen) return;
if ((!isDesktop && loadingLinks)) return;
V.Actions.moveMenu(showingMenu ? move.left : move.right);
}
});
Expand All @@ -208,8 +208,11 @@ tappable("#more-links", {
onTap: function() {
doByCurrentSelection(function() {
var url;
if (M.currentSelection.name.toUpperCase() === 'frontPage'.toUpperCase()) url = urlInit + "r/" + M.Subreddits.getAllString() + "/";
else url = urlInit + "r/" + M.currentSelection.name + "/";
if (M.currentSelection.name.toLowerCase() === 'frontpage') {
url = urlInit + "r/" + M.Subreddits.getAllSubsString() + "/";
} else {
url = urlInit + "r/" + M.currentSelection.name + "/";
}
C.Posts.load(url, '&after=' + M.Posts.idLast);
}, function() {
var channel = M.Channels.getByName(M.currentSelection.name);
Expand Down Expand Up @@ -262,7 +265,7 @@ tappable('.btn-add-sub', {
subTitle = $(".subreddit-title", parent);
subTitle.css("color", "#2b9900"); // 'adding sub' little UI feedback
var newSub = subTitle.text();
V.Subreddits.insert(newSub);
C.Subreddits.add(newSub);
},
activeClass: 'button-active'
});
Expand Down Expand Up @@ -373,25 +376,29 @@ V.detailWrap.on('click', '#comments-container a, #selftext a', function(ev) {
});

// Swipes
V.detailView.swipeRight(function() {
if (isWideScreen) return;
location.hash = "#";
});

V.mainView.swipeRight(function() {
if ((!isDesktop && loadingLinks) || isLargeScreen) return;
if (currentView === view.main) V.Actions.moveMenu(move.right);
});

V.mainView.swipeLeft(function() {
if ((!isDesktop && loadingLinks) || isLargeScreen) return;
if (showingMenu) V.Actions.moveMenu(move.left);
});

V.mainView.on("swipeLeft", ".link", function() {
if (isWideScreen) return;
if (!showingMenu) {
var id = $(this).data("id");
goToComments(id);
}
});
if (isMobile) {
if (!(isiPhone && isiOS7)) {
V.detailView.swipeRight(function() {
if (isWideScreen) return;
location.hash = "#";
});
}

V.mainView.swipeRight(function() {
if ((!isDesktop && loadingLinks) || isLargeScreen) return;
if (currentView === view.main) V.Actions.moveMenu(move.right);
});

V.mainView.swipeLeft(function() {
if ((!isDesktop && loadingLinks) || isLargeScreen) return;
if (showingMenu) V.Actions.moveMenu(move.left);
});

V.mainView.on("swipeLeft", ".link", function() {
if (isWideScreen) return;
if (!showingMenu) {
var id = $(this).data("id");
goToComments(id);
}
});
}
39 changes: 32 additions & 7 deletions scripts/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ var C = { // "Controller"

V.Posts.show(links, paging);
M.Posts.setList(links);
if (isWideScreen) {
var id = getCommentHash();
if (id) {
V.Actions.setSelectedLink(id);
}
}
}
},
Comments: {
Expand Down Expand Up @@ -171,18 +177,31 @@ var C = { // "Controller"
loadPosts: function(sub) {
if (sub !== M.currentSelection.name || editingSubs) {
var url;
if (sub.toUpperCase() === 'frontPage'.toUpperCase()) url = urlInit + "r/" + M.Subreddits.getAllString() + "/";
else url = urlInit + "r/" + sub + "/";
if (sub.toLowerCase() === 'frontpage') {
url = urlInit + "r/" + M.Subreddits.getAllSubsString() + "/";
} else {
url = urlInit + "r/" + sub + "/";
}
C.Posts.load(url);
C.currentSelection.setSubreddit(sub);
}
V.Actions.setSubTitle(sub);
},
remove: function(sub) {
M.Subreddits.remove(sub);
V.Subreddits.remove(sub);
if (M.currentSelection.type === selection.sub && M.currentSelection.name === sub) C.currentSelection.setSubreddit('frontPage'); // If it was the current selection
},
remove: function(sub) {
M.Subreddits.remove(sub);
V.Subreddits.remove(sub);
if (M.currentSelection.type === selection.sub &&
M.currentSelection.name === sub) { // If it was the current selection
C.currentSelection.setSubreddit('frontPage');
}
},
add: function(newSub) {
if (M.Subreddits.listHasSub(newSub)) {
return;
}
M.Subreddits.add(newSub);
V.Subreddits.insert(newSub);
},
addFromNewForm: function() {
var txtSub = $id("txt-new-sub"),
subName = txtSub.value;
Expand All @@ -191,6 +210,12 @@ var C = { // "Controller"
V.Anims.shakeForm();
return;
}
if (M.Subreddits.listHasSub(subName)) {
txtSub.value = "";
txtSub.setAttribute("placeholder", subName + " already added!");
V.Anims.shakeForm();
return;
}

subName = subName.trim();

Expand Down
36 changes: 17 additions & 19 deletions scripts/functions.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
function checkWideScreen() {
return win.matchMedia("(min-width: 1000px)").matches;
}

function checkLargeScreen() {
return win.matchMedia("(min-width: 490px)").matches;
}

function triggerClick(url) {
var a = doc.createElement('a');
a.setAttribute("href", url);
a.setAttribute("target", "_blank");

//var dispatch = doc.createEvent("HTMLEvents");
//dispatch.initEvent("click", true, true);
//a.dispatchEvent(dispatch);

var clickEvent = new MouseEvent("click", {
"view": window,
"bubbles": true,
Expand All @@ -33,12 +21,19 @@ function openPost(url, id) {
}
}

function getCommentHash() {
var match = location.hash.match(/(#comments:)((?:[a-zA-Z0-9]*))/);
if (match && match[2]) {
return match[2];
}
}

function goToCommentFromHash() {
var match = location.hash.match(/(#comments:)((?:[a-zA-Z0-9]*))/);
if (match && match[2]) {
var id = match[2];
C.Comments.show(id);
}
var id = getCommentHash();
C.Comments.show(id);
if (isWideScreen) {
V.Actions.setSelectedLink(id);
}
}

function checkImageLink(url) {
Expand Down Expand Up @@ -101,8 +96,11 @@ function goToComments(id) {
function refreshCurrentStream() {
if (editingSubs) return;
doByCurrentSelection(function() { // if it's subreddit
if (M.currentSelection.name.toUpperCase() === 'frontPage'.toUpperCase()) C.Posts.load(urlInit + "r/" + M.Subreddits.getAllString() + "/");
else C.Posts.load(urlInit + "r/" + M.currentSelection.name + "/");
if (M.currentSelection.name.toLowerCase() === 'frontpage') {
C.Posts.load(urlInit + "r/" + M.Subreddits.getAllSubsString() + "/");
} else {
C.Posts.load(urlInit + "r/" + M.currentSelection.name + "/");
}
}, function() { // if it's channel
C.Channels.loadPosts(M.Channels.getByName(M.currentSelection.name));
});
Expand Down
21 changes: 16 additions & 5 deletions scripts/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ var editingSubs = false,
loadingComments = false,
loadingLinks = false,
currentThread,
isWideScreen = checkWideScreen(),
isLargeScreen = checkLargeScreen(),
isiPad,
scrollFix,
iPadScrollFix,
currentSortingChoice = 'hot',
mnml = false,
updateBackup = 1,
Expand Down Expand Up @@ -55,9 +52,23 @@ var editingSubs = false,
},
currentView = view.main;

var defaultSubs = ["frontPage", "pics", "IAmA", "AskReddit", "worldNews", "todayilearned", "tech", "science", "reactiongifs", "books", "explainLikeImFive", "videos", "AdviceAnimals", "funny", "aww", "earthporn"];
var defaultSubs = ["frontPage", "all", "pics", "IAmA", "AskReddit", "worldNews", "todayilearned", "tech", "science", "reactiongifs", "books", "explainLikeImFive", "videos", "AdviceAnimals", "funny", "aww", "earthporn"];

var defaultChannel = {
name: "Media",
subs: ["movies", "television", "music", "games"]
};

// Breakpoints
var wideScreenBP = win.matchMedia("(min-width: 1000px)"),
largeScreenBP = win.matchMedia("(min-width: 490px)"),
isWideScreen = wideScreenBP.matches,
isLargeScreen = largeScreenBP.matches;

// Browser Detection
var UA = win.navigator.userAgent,
isMobile = !isDesktop,
isiPhone = /iP(hone|od)/.test(UA),
isiPad = /iPad/.test(UA),
isiOS = isiPad || isiPhone,
isiOS7 = isiOS && parseInt(UA.match(/ OS (\d+)_/i)[1], 10) >= 7;
Loading

0 comments on commit 31fcf63

Please sign in to comment.