From dfb1198143aa459b548ce1aa55290e3b05c2f665 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 13 Sep 2014 16:11:58 +0200 Subject: [PATCH] Worked on post uploads (#11) - added GUI --- public_html/css/core.css | 9 + public_html/css/forms.css | 50 ++ public_html/css/post-upload.css | 167 ++++++ public_html/index.html | 3 + public_html/js/Controls/TagInput.js | 140 +++++ .../js/Presenters/PostUploadPresenter.js | 536 +++++++++++++++++- public_html/js/Util.js | 12 + public_html/templates/post-upload.tpl | 134 +++++ 8 files changed, 1047 insertions(+), 4 deletions(-) create mode 100644 public_html/css/post-upload.css create mode 100644 public_html/js/Controls/TagInput.js create mode 100644 public_html/templates/post-upload.tpl diff --git a/public_html/css/core.css b/public_html/css/core.css index bbb32489..9338e46b 100644 --- a/public_html/css/core.css +++ b/public_html/css/core.css @@ -32,3 +32,12 @@ a { a:hover { color: #7b3; } + +hr { + margin: 1.5em auto; + height: 1px; + border: 0; + border-bottom: 1px solid #eee; + border-top: 1px solid #eee; + box-sizing: content-box; +} diff --git a/public_html/css/forms.css b/public_html/css/forms.css index be463dac..17f5ad80 100644 --- a/public_html/css/forms.css +++ b/public_html/css/forms.css @@ -8,6 +8,11 @@ display: table-row; } +.form-label { + width: 1%; + white-space: pre; +} + .form-label, .form-input { display: table-cell; @@ -25,6 +30,7 @@ text-align: right; } +.tag-input, textarea, input[type=text], input[type=password] { @@ -45,7 +51,22 @@ input[type=button] { background: #eee; font-family: 'Droid Sans', sans-serif; font-size: 17px; + cursor: pointer; } +button:hover, +input[type=button]:hover { + background: #f5f5f5; +} + +button.highlight, +input[type=button].highlight { + background: #ad5; +} +button:hover.highlight, +input[type=button]:hover.highlight { + background: #dfa; +} + .file-handler { border: 3px dashed #eee; @@ -58,3 +79,32 @@ input[type=button] { border-color: #6a2; background-color: #eeffcc; } + +.tag-input { + padding: 1px; + line-height: normal !important; + cursor: text; +} +.tag-input ul { + list-style-type: none; + display: inline; + margin: 0; + padding: 0; +} +.tag-input li { + background: #ddd; + display: inline-block; + margin: 1px; + padding: 2px 4px; + font-size: 15px; +} +.tag-input input { + border: none; + width: auto; +} +.tag-input li a { + color: black; + font-size: 14px; + margin-left: 0.5em; + cursor: pointer; +} diff --git a/public_html/css/post-upload.css b/public_html/css/post-upload.css new file mode 100644 index 00000000..01001710 --- /dev/null +++ b/public_html/css/post-upload.css @@ -0,0 +1,167 @@ +#post-upload-step1 { + display: table; + width: 30em; + margin: 0 auto; +} + +#post-upload-step1 .file-handler { + padding: 3.5em; +} + +#post-upload-step1 .url-handler { + margin-top: 0.5em; + position: relative; +} +#post-upload-step1 .url-handler .input-wrapper { + margin-right: 8.5em; +} +#post-upload-step1 .url-handler button { + position: absolute; + top: 0; + right: 0; + width: 8em; +} + +#post-upload-step2 .hybrid-view { + text-align: center; +} +@media all and (min-width: 62.5em) { + #post-upload-step2 .hybrid-window:first-child { + width: 40%; + margin-right: 1em; + float: left; + } + #post-upload-step2 .hybrid-window:last-child { + display: inline-block; + width: 57.5%; + } +} + +#post-upload-step2 .thumbnail img { + border: 1px solid black; + vertical-align: middle; + display: block; +} + +#post-upload-step2 table { + border-spacing: 0; + table-layout: fixed; + width: 100%; +} +#post-upload-step2 table td, +#post-upload-step2 table th { + padding: 0.2em 0.5em; + text-align: center; +} +#post-upload-step2 table th { + font-weight: normal; +} +#post-upload-step2 table tr.selected { + background: #faffca; +} +#post-upload-step2 table .checkbox { + width: 30px; + padding: 0.2em 0; +} +#post-upload-step2 table .checkbox input { + margin: 0 auto; +} +#post-upload-step2 table .thumbnail { + width: 40px; + padding: 0.2em 0; +} +#post-upload-step2 table .safety { + width: 60px; + padding: 0.2em 0; +} +#post-upload-step2 table .tags { + text-align: left; + overflow: hidden; + text-overflow: ellipsis; +} +#post-upload-step2 table .safety { + text-align: center; +} +#post-upload-step2 table .safety [class^=safety-] { + box-shadow: inset 0 0 0 3px rgba(0,0,0,0.1); + width: 25px; + height: 25px; + margin: 0 auto; +} +#post-upload-step2 table .safety-safe { background: #b2efa2; } +#post-upload-step2 table .safety-sketchy { background: #f0e4a8; } +#post-upload-step2 table .safety-unsafe { background: #fbc6b6; } +#post-upload-step2 table .thumbnail img { + width: 30px; + height: 30px; + display: inline-block; + background-size: 30px 30px; +} +#post-upload-step2 .operations { + list-style-type: none; + margin: 0; + padding: 0; +} +#post-upload-step2 .operations li { + display: inline-block; + margin: 0.3em 0.3em 0 0; +} + +#post-upload-step2 form { + width: 100%; + margin: 0 auto; + overflow: hidden; + text-align: left; +} +#post-upload-step2 .messages { + margin-bottom: 1em; +} +#post-upload-step2 .form-slider { + text-align: center; +} +#post-upload-step2 .form-slider .thumbnail img { + max-width: 100%; + max-height: 300px; + margin: 0 auto 1em auto; +} + + + +#post-upload-step2, +.template { + display: none; +} + +#lightbox { + display: none; + position: absolute; + pointer-events: none; + position: absolute; + margin-left: 10px; +} +#lightbox img { + max-width: 400px; + max-height: 400px; + background: white; + border: 0.5em solid white; + box-shadow: 0 0 0 1px #eee; + position: relative; +} +#lightbox:after { + content: ''; + position: absolute; + left: -8px; + top: 50%; + margin-top: -8px; + width: 12px; + height: 12px; + background: white; + border-left: 1px solid #eee; + border-bottom: 1px solid #eee; + transform: rotate(45deg); +} + +#uploading-alert { + display: none; + text-align: left; +} diff --git a/public_html/index.html b/public_html/index.html index 0827fa28..44a3766d 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -13,6 +13,7 @@ + @@ -25,6 +26,7 @@ + @@ -59,6 +61,7 @@ + diff --git a/public_html/js/Controls/TagInput.js b/public_html/js/Controls/TagInput.js new file mode 100644 index 00000000..b794d687 --- /dev/null +++ b/public_html/js/Controls/TagInput.js @@ -0,0 +1,140 @@ +var App = App || {}; +App.Controls = App.Controls || {}; + +//todo: autocomplete + +App.Controls.TagInput = function( + $underlyingInput, + _, + jQuery) { + + var KEY_RETURN = 13; + var KEY_SPACE = 32; + var KEY_BACKSPACE = 8; + + var tags = []; + var options = { + beforeTagAdded: null, + beforeTagRemoved: null, + }; + + if ($underlyingInput.length !== 1) { + throw new Error('Cannot set tag input to more than one elements at once'); + } + if ($underlyingInput.attr('data-tagged')) { + throw new Error('Tag input was already initialized for this element'); + } + $underlyingInput.attr('data-tagged', true); + $underlyingInput.hide(); + + var $wrapper = jQuery('
'); + var $tagList = jQuery('