summaryrefslogtreecommitdiff
path: root/themes/okadmin/public/js/app.js
blob: 7a5eb60d51f239019e8ce225f9008fd4379055c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var OKAdmin = function(){
  
  OKUpload.bind()
  OKUpload.add = function(data){
    var url = data[0].extra.location
    var imageTemplate = $("#image-template").html()
    var $el = $(imageTemplate)
    $el.find("url").val(url)
    $(".images").append($el)
    console.log(data)
  }

  $(".video .url").change(function(){
    var $el = $(this)
    var url = $el.val()
    Parser.parse( url, function(media){
      console.log(url,media)
      $el.parent().addClass("loaded")
      $el.parent().find(".video-type").val( media.type )
      $el.parent().find(".video-token").val( media.token )
      $el.parent().find(".video-title").val( media.title )
      $el.parent().find(".video-thumb").val( media.thumbnail )
    })
  })
  
  $(document).on("click", ".remove-image", function(){
    if (confirm("Delete this image?")) {
      $(this).parent().remove()
    }
  })
  
  $("form").submit(function(){
    $(".template").remove()
  })
}

$(function(){
  window.app = new OKAdmin ()
})