From: Jeanie Chung Date: Fri, 23 Jan 2015 21:34:51 +0000 (-0800) Subject: Changes to gulpfile so that work can be done on the html parser. Basic syntax layout... X-Git-Tag: v2.0.0-rc.1~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1883fb7fa7779128b063b596a337333c2af34647;p=thirdparty%2Ffoundation%2Ffoundation-emails.git Changes to gulpfile so that work can be done on the html parser. Basic syntax layout for main table, row, and columns. --- diff --git a/gulpfile.js b/gulpfile.js index 118aa0cc..d862bf5d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -51,6 +51,11 @@ gulp.task('clean:html', function(cb) { rimraf('./build/html', cb); }); +// Clean the JS directory +gulp.task('clean:js', function(cb) { + rimraf('./build/js', cb); +}) + // 4. STYLESHEETS // - - - - - - - - - - - - - - - @@ -114,19 +119,22 @@ gulp.task('jquery', function() { .pipe(gulp.dest(dirs.build + '/js/')); }); -// Concat all js files -gulp.task('js', ['jquery'], function() { - gulp.src(dirs.js) - .pipe(concat('main.js')) +gulp.task('inky-prime', function() { + return gulp.src(dirs.js) + .pipe(concat('inky-prime.js')) .pipe(gulp.dest(dirs.build + '/js/')) - .pipe(connect.reload()); + .pipe(connect.reload()); +}) + +gulp.task('js', ['clean:js', 'jquery'], function() { + gulp.start('inky-prime'); }); // 7. GO FORTH AND BUILD // - - - - - - - - - - - - - - - // Wipes build folder, then compiles SASS, then minifies and copies HTML -gulp.task('build', ['clean', 'sass'], function() { +gulp.task('build', ['clean', 'sass', 'js'], function() { gulp.start('minify-html'); }); diff --git a/html/index.html b/html/index.html index 73448f56..c3b431c5 100644 --- a/html/index.html +++ b/html/index.html @@ -2,7 +2,7 @@ - + @@ -11,16 +11,30 @@

This is an email.

+ + + + four col +
+ bloop +
+
+ eight col +
+
+ + + + two col + + + eight col + two col + + - - - - -
- -
- - + empty container + empty row \ No newline at end of file diff --git a/js/components/col.js b/js/components/col.js new file mode 100644 index 00000000..0d11fc86 --- /dev/null +++ b/js/components/col.js @@ -0,0 +1,29 @@ +// Columns + +// TODO: Make private function + +var createCol = function(obj) { + var output = ''; + + $.each(obj, function(v,k) { + var temp = '' + var contents = $(this).html(); + var colClass = 'columns ' + $(this).attr('class'); + + if (v !== obj.length - 1) { + temp = '' + +'' + +'
' + + contents +'
'; + } else { + temp = '' + +'' + +'
' + + contents +'
'; + } + + output += temp; + }); + + return output; +}; diff --git a/js/components/row.js b/js/components/row.js new file mode 100644 index 00000000..6f8f35ef --- /dev/null +++ b/js/components/row.js @@ -0,0 +1,23 @@ +// Rows + +$(document).on('ready', function() { + $('row').each(function() { + var contents = $(this).html(); + var html = $.parseHTML( contents ); + + // find a better way to detect empty row + // or will we ever have an empty row? + if (html[0].nodeName !== '#text') { + contents = createCol(html); + } + + $(this).empty().html('' + contents + ''); + $(this).replaceWith(function() { + return $('', { + class: 'row', + html: this.innerHTML + }); + }); + + }); +}); diff --git a/js/components/row/row.html b/js/components/row/row.html deleted file mode 100644 index 2f62b385..00000000 --- a/js/components/row/row.html +++ /dev/null @@ -1 +0,0 @@ -row \ No newline at end of file diff --git a/js/components/row/row.js b/js/components/row/row.js deleted file mode 100644 index e69de29b..00000000 diff --git a/js/components/table.js b/js/components/table.js new file mode 100644 index 00000000..1c26570f --- /dev/null +++ b/js/components/table.js @@ -0,0 +1,17 @@ +// Table Main Body + +$(document).on('ready', function() { + + $('container').each(function() { + var contents = $(this).html(); + $(this).empty().html(''); + + $(this).replaceWith(function() { + return $('
' + contents + '
', { + class: 'container', + html: this.innerHTML + }); + }); + + }); +});