Skip to content

Commit

Permalink
Assets work
Browse files Browse the repository at this point in the history
* ES6 all the things !

* ESLint checks everything

* CSS fixes (use stylelint)

* Fix #2231
  • Loading branch information
tcitworld committed Sep 28, 2016
1 parent 5534533 commit c146f69
Show file tree
Hide file tree
Showing 23 changed files with 445 additions and 417 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
@@ -1,4 +1,4 @@
{
"extends": "airbnb",
"installedESLint": true,
"parser": "babel-eslint"
}
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -49,3 +49,7 @@ app/Resources/static/lib/*
/bin
!/src/Wallabag/CoreBundle/Resources/public
/src/Wallabag/CoreBundle/Resources/public/*

# PHPStorm
.idea/

3 changes: 3 additions & 0 deletions .stylelintrc
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-standard"
}
46 changes: 22 additions & 24 deletions Gruntfile.js
Expand Up @@ -41,27 +41,6 @@ module.exports = function (grunt) {
options: {
separator: ';',
},
jsMaterial: {
src: [
'<%= appDir %>/themes/material/js/init.js',
'<%= appDir %>/themes/_global/js/restoreScroll.js',
'node_modules/jquery.tinydot/src/jquery.tinydot.js',
],
dest: '<%= buildDir %>/material.js',
},
jsBaggy: {
src: [
'<%= appDir %>/themes/baggy/js/init.js',
'<%= appDir %>/themes/_global/js/restoreScroll.js',
'<%= appDir %>/themes/baggy/js/autoClose.js',
'<%= appDir %>/themes/baggy/js/autoCompleteTags.js',
'<%= appDir %>/themes/baggy/js/closeMessage.js',
'<%= appDir %>/themes/baggy/js/popupForm.js',
// Save link is no more used for now
// '<%= appDir %>/themes/baggy/js/saveLink.js',
],
dest: '<%= buildDir %>/baggy.js',
},
cssMaterial: {
src: [
'node_modules/materialize-css/bin/materialize.css',
Expand All @@ -77,8 +56,27 @@ module.exports = function (grunt) {
},
},
browserify: {
'<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'],
'<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'],
dist: {
files: {
'<%= buildDir %>/material.browser.js': ['<%= appDir %>/themes/material/js/init.js'],
'<%= buildDir %>/baggy.browser.js': ['<%= appDir %>/themes/baggy/js/init.js']
}
},
options: {
sourceType: "module",
transform: [
["babelify", {
presets: ["es2015"]
}], "browserify-shim"
],
browserifyOptions: {
browser: {
"jQuery": "./node_modules/jquery/dist/jquery.js",
"jquery.tinydot": "./nodes_modules/jquery.tinydot/src/jquery.tinydot.js"
}
}
}

},
uglify: {
material: {
Expand Down Expand Up @@ -199,7 +197,7 @@ module.exports = function (grunt) {
grunt.registerTask(
'js',
'Build and install js files',
['clean:js', 'copy:pickerjs', 'concat:jsMaterial', 'concat:jsBaggy', 'browserify', 'uglify']
['clean:js', 'copy:pickerjs', 'browserify', 'uglify']
);

grunt.registerTask(
Expand Down
6 changes: 5 additions & 1 deletion app/Resources/static/themes/_global/js/bookmarklet.js
@@ -1,2 +1,6 @@

top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
top['bookmarklet-url@wallabag.org'] =
'<!DOCTYPE html><html><head><title>bag it!</title>' +
'<link rel="icon" href="tpl/img/favicon.ico" />' +
'</head><body><script>window.onload=function(){window.setTimeout' +
'(function(){history.back();},250);};</script></body></html>';
25 changes: 0 additions & 25 deletions app/Resources/static/themes/_global/js/restoreScroll.js

This file was deleted.

50 changes: 50 additions & 0 deletions app/Resources/static/themes/_global/js/tools.js
@@ -0,0 +1,50 @@
const $ = require('jquery');

function supportsLocalStorage() {
try {
return 'localStorage' in window && window.localStorage !== null;
} catch (e) {
return false;
}
}

function savePercent(id, percent) {
if (!supportsLocalStorage()) { return false; }
localStorage[`wallabag.article.${id}.percent`] = percent;
return true;
}

function retrievePercent(id) {
if (!supportsLocalStorage()) { return false; }

const bheight = $(document).height();
const percent = localStorage[`wallabag.article.${id}.percent`];
const scroll = bheight * percent;

$('html,body').animate({ scrollTop: scroll }, 'fast');

return true;
}

function initFilters() {
// no display if filters not available
if ($('div').is('#filters')) {
$('#button_filters').show();
$('.button-collapse-right').sideNav({ edge: 'right' });
$('#clear_form_filters').on('click', () => {
$('#filters input').val('');
$('#filters :checked').removeAttr('checked');
return false;
});
}
}

function initExport() {
// no display if export not available
if ($('div').is('#export')) {
$('#button_export').show();
$('.button-collapse-right').sideNav({ edge: 'right' });
}
}

export { savePercent, retrievePercent, initFilters, initExport };
13 changes: 7 additions & 6 deletions app/Resources/static/themes/baggy/css/main.css
Expand Up @@ -481,9 +481,6 @@ footer a {
text-transform: none;
margin-bottom: 0;
line-height: 1.2;
text-align: justify;
-moz-text-align-last: center;
text-align-last: center;
}

.entry h2::after {
Expand Down Expand Up @@ -1071,7 +1068,7 @@ pre code {
font-family: "Courier New", Courier, monospace;
}

#filter-form {
#filters {
position: fixed;
width: 20%;
height: 100%;
Expand All @@ -1086,7 +1083,7 @@ pre code {
min-width: 300px;
}

#filter-form form .filter-group {
#filters form .filter-group {
margin: 5px;
}

Expand Down Expand Up @@ -1125,9 +1122,11 @@ pre code {
.entry {
width: 49%;
}

.entry:nth-child(3n+1) {
margin-left: 1.5%;
}

.entry:nth-child(2n+1) {
margin-left: 0;
}
Expand All @@ -1137,6 +1136,7 @@ pre code {
#article {
width: 80%;
}

.topPosF {
right: 2.5em;
}
Expand All @@ -1147,6 +1147,7 @@ pre code {
width: 100%;
margin-left: 0;
}

#display-mode {
display: none;
}
Expand Down Expand Up @@ -1197,7 +1198,6 @@ pre code {
height: auto;
top: 0.5em;
width: 75px;
height: 75px;
margin-left: -37.5px;
}

Expand All @@ -1214,6 +1214,7 @@ pre code {
background-color: #999;
font-size: 1.2em;
}

.desktopHide:hover,
.desktopHide:focus {
background-color: #fff;
Expand Down
4 changes: 3 additions & 1 deletion app/Resources/static/themes/baggy/css/ratatouille.css
Expand Up @@ -63,7 +63,9 @@ pre {
max-width: 61.25em; /* 980px */
}

table, img, figure {
table,
img,
figure {
max-width: 100%;
height: auto;
}
Expand Down
8 changes: 0 additions & 8 deletions app/Resources/static/themes/baggy/js/autoClose.js

This file was deleted.

52 changes: 7 additions & 45 deletions app/Resources/static/themes/baggy/js/autoCompleteTags.js
@@ -1,46 +1,8 @@
var $ = global.jquery = require('jquery');
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}

jQuery(function ($) {
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}


$('#value').bind('keydown', function (event) {
if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
event.preventDefault();
}
}).autocomplete({
source: function (request, response) {
$.getJSON('./?view=tags', {
term: extractLast(request.term),
//id: $(':hidden#entry_id').val()
}, response);
},
search: function () {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
return false;
}
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push('');
this.value = terms.join(', ');
return false;
},
});
});
export { split, extractLast };
19 changes: 0 additions & 19 deletions app/Resources/static/themes/baggy/js/closeMessage.js

This file was deleted.

0 comments on commit c146f69

Please sign in to comment.