summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-04-27 14:24:20 -0400
committerJules Laplace <jules@okfoc.us>2015-04-27 14:24:20 -0400
commit3e2d7e98230990ad954b33203e0611358c1fa915 (patch)
tree5581c71544de94c736ac7fbabf86dd9ebcdc25a5
parenta69d9410c42ad312283fe5a25ed7ca8d7c6b42e2 (diff)
stubbing in videos
-rw-r--r--app/node_modules/okadminview/index.js1
-rw-r--r--site/index.js3
-rw-r--r--site/templates/project.liquid5
-rw-r--r--themes/okadmin/public/css/main.css17
-rw-r--r--themes/okadmin/public/js/app.js58
-rw-r--r--themes/okadmin/public/js/upload.js15
-rw-r--r--themes/okadmin/templates/partials/inputs.liquid55
7 files changed, 130 insertions, 24 deletions
diff --git a/app/node_modules/okadminview/index.js b/app/node_modules/okadminview/index.js
index 82f364d..2a0fcd5 100644
--- a/app/node_modules/okadminview/index.js
+++ b/app/node_modules/okadminview/index.js
@@ -157,6 +157,7 @@ function OKAdminView(options) {
resourceMissingHandler(req, res)()
} else {
view.renderResource(req, res, assign(data, {
+ JSON: JSON,
success: req.flash('success'),
errors: req.flash('errors')
}));
diff --git a/site/index.js b/site/index.js
index 8bb4b4d..a7b207a 100644
--- a/site/index.js
+++ b/site/index.js
@@ -5,8 +5,7 @@ var projectSchema = {
title: {type: 'string'},
menu: {type: 'string'},
description: {type: 'text'},
- video: {type: 'video'},
- images: {type: 'captioned-image-list'},
+ images: {type: 'media-list'},
thumbnail: {type: 'image'},
}
diff --git a/site/templates/project.liquid b/site/templates/project.liquid
index b54722d..3d32c0d 100644
--- a/site/templates/project.liquid
+++ b/site/templates/project.liquid
@@ -1,7 +1,10 @@
<div class="entry">
<span>
<span class="postname">{{project.title}}</span>
-
+ <div class="galnav">
+ <span class="prevbutton">PREVIOUS ASSET</span>
+ <span class="nextbutton">NEXT ASSET</span>
+ </div>
<div class="gallery" id="okgallery">
{% if project.video.token %}
<div class="cell video" style="background-image:url({{ project.video.thumb }})" data-video="https://player.vimeo.com/video/{{ project.video.token }}" data-caption="{{ project.video.title }}"></div>
diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css
index 747ec34..5dbd910 100644
--- a/themes/okadmin/public/css/main.css
+++ b/themes/okadmin/public/css/main.css
@@ -283,11 +283,11 @@ button, input[type=submit] {
list-style-type: none;
display: block;
clear: both;
- height: 10em;
+ height: 7em;
}
.main.resource form img {
width: 10em;
- max-height: 10em;
+ max-height: 6em;
border: 0;
}
.main.resource form .images img {
@@ -296,7 +296,10 @@ button, input[type=submit] {
}
.main.resource form textarea.caption {
width: 15em;
- height: 9em;
+ height: 6em;
+}
+.main.resource form .video-element input[type=text] {
+ width: 15em;
}
.add-image-button {
background: #ddd;
@@ -324,13 +327,15 @@ button, input[type=submit] {
margin: 0; padding: 0;
cursor: pointer;
}
-.image-element:hover .remove-image {
+.video-element:hover .remove,
+.image-element:hover .remove {
display: block;
}
-.image-element .remove-image:hover {
+.video-element .remove:hover,
+.image-element .remove:hover {
color: red;
}
-.remove-image {
+.remove {
display: none;
}
diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js
index e981223..c46cea8 100644
--- a/themes/okadmin/public/js/app.js
+++ b/themes/okadmin/public/js/app.js
@@ -2,23 +2,56 @@ var OKAdmin = function(){
// initialize our multi-image uploader with an element and a template
$(".group.image-list").each(function(){
+ var parent = this
var uploader = new OKUpload ()
uploader.bind( this )
uploader.add = function(url){
- var imageTemplate = $("#captioned-image-template").html()
+ var imageTemplate = $(".image-template", parent).html()
var $el = $(imageTemplate)
$el.find(".uri").val(url)
$el.find("img").attr("src", url)
- $(".captioned-image-list ol").append($el)
+ $("ol", parent).append($el)
}
})
// delete image from gallery
- $(document).on("mousedown", ".image-list .remove-image", function(){
+ $(document).on("mousedown", ".image-list .remove", function(){
if (confirm("Remove this image?")) {
$(this).parent().remove()
}
})
+ // initialize our multimedia uploader with an element and a template
+ $(".group.media-list").each(function(){
+ var parent = this
+ var uploader = new OKUpload ()
+ uploader.bind( this )
+ uploader.add = function(url){
+ var imageTemplate = $(".image-template", parent).html()
+ var $el = $(imageTemplate)
+ $el.find(".uri").val(url)
+ $el.find("img").attr("src", url)
+ $("ol", parent).append($el)
+ }
+ uploader.addVideo = function(media){
+ console.log(media)
+ var videoTemplate = $(".video-template", parent).html()
+ var $el = $(videoTemplate)
+ $el.addClass("loaded")
+ $el.find(".video-type").val( media.type )
+ $el.find(".video-token").val( media.token )
+ $el.find(".video-title").val( media.title )
+ $el.find(".video-thumb").val( media.thumbnail )
+ $el.find("img").attr("src", media.thumbnail )
+ $("ol", parent).append($el)
+ }
+ })
+ // delete image from gallery
+ $(document).on("mousedown", ".media-list .remove", function(){
+ if (confirm("Remove this media?")) {
+ $(this).parent().remove()
+ }
+ })
+
// initialize our single image uploader with existing DOM
$(".group.image").each(function(){
var $el = $(this)
@@ -35,7 +68,7 @@ var OKAdmin = function(){
}
})
// delete image from single image entry
- $(document).on("mousedown", ".image .remove-image", function(){
+ $(document).on("mousedown", ".image .remove", function(){
if (confirm("Remove this image?")) {
var $el = $(this).closest(".image")
$el.removeClass('loaded')
@@ -46,8 +79,8 @@ var OKAdmin = function(){
})
// make the region sortable with drag-and-drop
- $(".captioned-image-list ol").sortable()
- $(".captioned-image-list ol").disableSelection()
+ $(".media-list ol, .image-list ol").sortable()
+ $(".media-list ol, .image-list ol").disableSelection()
// populate a video field with info from our url parser
var last_url
@@ -94,14 +127,17 @@ var OKAdmin = function(){
$id.val( slug )
}
- $(".image-element").each(function(index){
- $(this).find("input,textarea").each(function(){
- var field = $(this).attr("name").replace(/\[[0-9]*\]/, "[" + index + "]")
- $(this).attr("name", field)
+ $("ol").each(function(){
+ $("li", this).each(function(index){
+ $(this).find("input,textarea").each(function(){
+ var field = $(this).attr("name").replace(/\[[0-9]*\]/, "[" + index + "]")
+ $(this).attr("name", field)
+ })
})
})
})
+ // delete individual records
$("#delete_form").submit(function(e){
if (confirm("Are you sure you want to delete this record?")) {
return
@@ -111,6 +147,7 @@ var OKAdmin = function(){
}
})
+ // reorder items in categories
$(".resource-category").on("click", ".edit-btn", function(e) {
e.preventDefault();
var $parent = $(e.delegateTarget);
@@ -142,6 +179,7 @@ var OKAdmin = function(){
}
});
+ // save new category order
$(".resource-category").on("submit", "form", function(e) {
var $parent = $(e.delegateTarget);
$parent.find(".resource-input").each(function(index) {
diff --git a/themes/okadmin/public/js/upload.js b/themes/okadmin/public/js/upload.js
index b4a0dfc..8d73dd5 100644
--- a/themes/okadmin/public/js/upload.js
+++ b/themes/okadmin/public/js/upload.js
@@ -5,11 +5,19 @@ var OKUpload = function(){
OKUpload.prototype.bind = function(rapper){
var uploader = this
$(".add-image-button input", rapper).change( uploader.handleFileSelect.bind(uploader) )
- $(".add-image-url", rapper).on("keydown blur", pressEnter( function(e){
+ $(".add-url", rapper).on("keydown blur", pressEnter( function(e){
var url = $(this).val()
$(this).val("")
if (! url) return
- uploader.add(url)
+ Parser.parse( url, function(media){
+ console.log(url, media)
+ if (media.type == "image") {
+ uploader.add(url)
+ }
+ else {
+ uploader.addVideo(media)
+ }
+ })
}))
}
OKUpload.prototype.handleFileSelect = function(e) {
@@ -50,6 +58,9 @@ OKUpload.prototype.success = function(data){
OKUpload.prototype.add = function(media){
console.log(media)
}
+OKUpload.prototype.addVideo = function(media){
+ console.log(media)
+}
OKUpload.prototype.error = function(error){
throw error
}
diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid
index 4d31413..d5d8b66 100644
--- a/themes/okadmin/templates/partials/inputs.liquid
+++ b/themes/okadmin/templates/partials/inputs.liquid
@@ -40,7 +40,7 @@
<input type="file" accept="image/*">
<button>+ Add image</button>
</div>
- <input class="add-image-url" type="text" placeholder="+ Add URL">
+ <input class="add-url" type="text" placeholder="+ Add URL">
</div>
<div class="image-element">
<input class="uri" type="hidden" name="{{name}}[uri]" value="{{spec.value.uri}}">
@@ -49,6 +49,55 @@
<button class="remove-image">x</button>
</div>
</div>
+ {% elsif type == 'media-list' %}
+ <div class="media-list group loaded">
+ <div class="fields">
+ <div class="add-image-button">
+ <input type="file" accept="image/*" multiple>
+ <button>+ Add images</button>
+ </div>
+ <input class="add-url" type="text" placeholder="+ Add Image/Video URL">
+ </div>
+
+ <script type="text/html" class="image-template">
+ <li class="image-element">
+ <input class="uri" type="hidden" name="{{name}}[][uri]" value="">
+ <textarea class="caption" name="{{name}}[][caption]"></textarea>
+ <img>
+ <button class="remove">x</button>
+ </li>
+ </script>
+
+ <script type="text/html" class="video-template">
+ <li class="video-element">
+ <input name="{{name}}[][type]" type="hidden" class="video-type" hidden>
+ <input name="{{name}}[][token]" type="hidden" class="video-token" hidden>
+ <label>Caption</label>
+ <input name="{{name}}[][title]" type="text" class="video-title">
+ <label>Thumbnail</label>
+ <input name="{{name}}[][thumb]" type="text" class="video-thumb">
+ <img>
+ <button class="remove">x</button>
+ </li>
+ </script>
+
+ <ol>
+ {% for image in spec.value %}
+ {% if image.token %}
+ <li class="video">
+ {{ JSON.stringify(spec.value) }}
+ </li>
+ {% else %}
+ <li class="image-element">
+ <input type="hidden" name="{{name}}[{{forloop.index0}}][uri]" value="{{image.uri}}">
+ <textarea class="caption" name="{{name}}[{{forloop.index0}}][caption]">{{image.caption}}</textarea>
+ <img src="{{image.uri}}" alt="{{image.caption}}">
+ <button class="remove-image">x</button>
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ol>
+ </div>
{% elsif type == 'captioned-image-list' %}
<div class="image-list group loaded">
<div class="fields">
@@ -56,10 +105,10 @@
<input type="file" accept="image/*" multiple>
<button>+ Add images</button>
</div>
- <input class="add-image-url" type="text" placeholder="+ Add URL">
+ <input class="add-url" type="text" placeholder="+ Add URL">
</div>
- <script type="text/html" id="captioned-image-template">
+ <script type="text/html" class="image-template">
<li class="image-element">
<input class="uri" type="hidden" name="{{name}}[][uri]" value="">
<textarea class="caption" name="{{name}}[][caption]"></textarea>