{"_id":"567856b9e5da8d0d00591c66","category":{"_id":"5666dac5d784a70d00397bcb","__v":8,"pages":["5666dda06819320d000c2e19","567856b9e5da8d0d00591c66","567861b8e5da8d0d00591c7c","568bdbf9e3e30f0d0021e07c","568be56983d2061900d86ce9","5697f7a60b09a41900b245d7","56abb8b49327b30d00f7c234","56d088977c2e100b000af8f0"],"project":"564de2dbfe07a81700b5c3a5","version":"564de2dbfe07a81700b5c3a8","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-08T13:27:33.662Z","from_sync":false,"order":4,"slug":"tutorials","title":"Tutorials"},"parentDoc":null,"user":"564de2b4fe07a81700b5c3a4","version":{"_id":"564de2dbfe07a81700b5c3a8","project":"564de2dbfe07a81700b5c3a5","__v":10,"createdAt":"2015-11-19T14:55:23.838Z","releaseDate":"2015-11-19T14:55:23.837Z","categories":["564de2ddfe07a81700b5c3a9","564df317826645210097a890","564df3217c8f372b00b934df","564e5227c3553e0d003e53ba","5666dac5d784a70d00397bcb","56cd08ddd98d851d00c0c3bd","56e9a50946bfd60e008840a7","5718e37bf8f7de1900683fad","58c3308dfedf070f0043b72c","58ce99c75457d02300560c0a"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":2,"project":"564de2dbfe07a81700b5c3a5","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-21T19:44:57.167Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Modals are a really easy way to show embeds when you don't have the real estate on the page to display them inline. Here we are going to show a super easy modal a couple of ways.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"On Demand\"\n}\n[/block]\nInstead of prefetching all the data associated with the links on the page, only make an API call when the user has initiated an event. In this case, it's click to watch the video.\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fc5uubz68%2F1%2F%3Fheight%3D600%26tabs%3Dresult%2Cjs%2Chtml%2Ccss&src=https%3A%2F%2Fjsfiddle.net%2Fc5uubz68%2F1%2Fembedded%2Fresult%2Cjs%2Chtml%2Ccss%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\\\" width=\\\"600\\\" height=\\\"600\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://jsfiddle.net/c5uubz68/1/?height=600&tabs=result,js,html,css\",\n  \"title\": \"Edit fiddle - JSFiddle\",\n  \"favicon\": \"https://jsfiddle.net/favicon.png\"\n}\n[/block]\nIn this case, when the button is clicked, we fetch the embed code and place it in the model. Here's the Javascript.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$('.button').on('click', function(e) {\\n  \\n  // Show the Foundation modal.\\n  var elem = new Foundation.Reveal($('#videoModal'), {\\n    vOffset: 0\\n  });\\n  elem.open();\\n\\n  // Get the URL.\\n  var url = $(this).attr('href');\\n\\n  // Call embedly\\n  $.embedly.oembed(url, {\\n      key: 'Your Embed Key'\\n    })\\n    .progress(function(obj) {\\n      $('#videoModal h2').text(obj.title);\\n      $('#videoModal div').html('<div class=\\\"flex-video\\\">' + obj.html + '</div>');\\n    });\\n\\n  // So the link isn't followed.\\n  return false;\\n});\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Pre Fetch\"\n}\n[/block]\nIn this case we will grab the data before the user clicks on the link. The modal will render a little faster because we already have the data.\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fshnv1L87%2F1%2F%3Fheight%3D600%26tabs%3Dresult%2Cjs%2Chtml%2Ccss&src=https%3A%2F%2Fjsfiddle.net%2Fshnv1L87%2F1%2Fembedded%2Fresult%2Cjs%2Chtml%2Ccss%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\\\" width=\\\"600\\\" height=\\\"400\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://jsfiddle.net/shnv1L87/1/?height=600&tabs=result,js,html,css\",\n  \"title\": \"Edit fiddle - JSFiddle\",\n  \"favicon\": \"https://jsfiddle.net/favicon.png\"\n}\n[/block]\nIn this case we use the default Embedly jQuery process to grab the URL data on load then display that data when the button is clicked.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$('.button')\\n  .embedly({\\n    display: $.noop,\\n    key:'Your Embedly Key'\\n  })\\n  .on('click', function() {\\n    // Get the data that embedly stored on the attr.\\n    var obj = $(this).data('embedly');\\n    $('#videoModal h2').text(obj.title);\\n    $('#videoModal div').html('<div class=\\\"flex-video\\\">' + obj.html + '</div>');\\n\\n    var elem = new Foundation.Reveal($('#videoModal'), {\\n      vOffset: 0\\n    });\\n\\n    // open the model.\\n    elem.open();\\n    return false;\\n  });\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"modal","type":"basic","title":"Modal"}
Modals are a really easy way to show embeds when you don't have the real estate on the page to display them inline. Here we are going to show a super easy modal a couple of ways. [block:api-header] { "type": "basic", "title": "On Demand" } [/block] Instead of prefetching all the data associated with the links on the page, only make an API call when the user has initiated an event. In this case, it's click to watch the video. [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fc5uubz68%2F1%2F%3Fheight%3D600%26tabs%3Dresult%2Cjs%2Chtml%2Ccss&src=https%3A%2F%2Fjsfiddle.net%2Fc5uubz68%2F1%2Fembedded%2Fresult%2Cjs%2Chtml%2Ccss%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\" width=\"600\" height=\"600\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://jsfiddle.net/c5uubz68/1/?height=600&tabs=result,js,html,css", "title": "Edit fiddle - JSFiddle", "favicon": "https://jsfiddle.net/favicon.png" } [/block] In this case, when the button is clicked, we fetch the embed code and place it in the model. Here's the Javascript. [block:code] { "codes": [ { "code": "$('.button').on('click', function(e) {\n \n // Show the Foundation modal.\n var elem = new Foundation.Reveal($('#videoModal'), {\n vOffset: 0\n });\n elem.open();\n\n // Get the URL.\n var url = $(this).attr('href');\n\n // Call embedly\n $.embedly.oembed(url, {\n key: 'Your Embed Key'\n })\n .progress(function(obj) {\n $('#videoModal h2').text(obj.title);\n $('#videoModal div').html('<div class=\"flex-video\">' + obj.html + '</div>');\n });\n\n // So the link isn't followed.\n return false;\n});", "language": "text" } ] } [/block] [block:api-header] { "type": "basic", "title": "Pre Fetch" } [/block] In this case we will grab the data before the user clicks on the link. The modal will render a little faster because we already have the data. [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fjsfiddle.net%2Fshnv1L87%2F1%2F%3Fheight%3D600%26tabs%3Dresult%2Cjs%2Chtml%2Ccss&src=https%3A%2F%2Fjsfiddle.net%2Fshnv1L87%2F1%2Fembedded%2Fresult%2Cjs%2Chtml%2Ccss%2F&type=text%2Fhtml&key=02466f963b9b4bb8845a05b53d3235d7&schema=jsfiddle\" width=\"600\" height=\"400\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://jsfiddle.net/shnv1L87/1/?height=600&tabs=result,js,html,css", "title": "Edit fiddle - JSFiddle", "favicon": "https://jsfiddle.net/favicon.png" } [/block] In this case we use the default Embedly jQuery process to grab the URL data on load then display that data when the button is clicked. [block:code] { "codes": [ { "code": "$('.button')\n .embedly({\n display: $.noop,\n key:'Your Embedly Key'\n })\n .on('click', function() {\n // Get the data that embedly stored on the attr.\n var obj = $(this).data('embedly');\n $('#videoModal h2').text(obj.title);\n $('#videoModal div').html('<div class=\"flex-video\">' + obj.html + '</div>');\n\n var elem = new Foundation.Reveal($('#videoModal'), {\n vOffset: 0\n });\n\n // open the model.\n elem.open();\n return false;\n });", "language": "javascript" } ] } [/block]