From d8e9b4d5334db049feec81b0083c3adcedaf7e12 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 28 Mar 2016 19:10:26 -0400 Subject: allow generic urls in media field --- themes/okadmin/public/js/app.js | 38 ++++++++++++++++------- themes/okadmin/public/js/parser.js | 4 +-- themes/okadmin/templates/partials/inputs.liquid | 41 ++++++++++++++++++++----- 3 files changed, 62 insertions(+), 21 deletions(-) (limited to 'themes/okadmin') diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index da398eb..61fc8c8 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -47,17 +47,33 @@ var OKAdmin = function(){ $("ol", parent).prepend($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).prepend($el) - } + switch (media.type) { + case 'youtube': + case 'vimeo': + case 'video': + 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(".video-width").val( media.width ) + $el.find(".video-height").val( media.height ) + $el.find("img").attr("src", media.thumbnail ) + $("ol", parent).prepend($el) + break + case 'link': + var linkTemplate = $(".link-template", parent).html() + var $el = $(linkTemplate) + $el.addClass("loaded") + $el.find(".uri").val( media.url ) + $("ol", parent).prepend($el) + break + default: + alert("Unsupported link type!") + } + } }) // delete image from gallery $(document).on("mousedown", ".media-list .remove", function(){ diff --git a/themes/okadmin/public/js/parser.js b/themes/okadmin/public/js/parser.js index 411f425..95b391c 100644 --- a/themes/okadmin/public/js/parser.js +++ b/themes/okadmin/public/js/parser.js @@ -145,7 +145,6 @@ var Parser = { '&color=ff6600&auto_play=false&show_artwork=true">' } }, - /* { type: 'link', regex: /^http.+/i, @@ -163,8 +162,7 @@ var Parser = { tag: function (media) { return '' + media.url + '' } - } - */ + }, ], tumblr: function(url, cb){ diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 4acb435..77ee7a4 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -29,6 +29,8 @@ + + @@ -143,11 +145,12 @@ - + + +
    {% for image in spec.value %} - {% if image.token %} + {% if image.type and (image.type == "vimeo" or image.type == "youtube" or image.type == "video") %}
  1. + + @@ -185,11 +201,22 @@
  2. + {% elsif image.type and image.type == "link" %} + {% else %}
  3. + - {{image.caption}} + + {{image.caption | strip_html}}
  4. {% endif %} @@ -210,7 +237,7 @@
  5. - {{image.caption}} +
  6. @@ -220,7 +247,7 @@
  7. - {{image.caption}} + {{image.caption | strip_html}}
  8. {% endfor %} @@ -238,7 +265,7 @@