Draw a diagram of the result of following code.
var businessName = "Trader Joe's";
var location = "Austin";| (function () { | |
| // | |
| // Global ajax loaders | |
| // | |
| // This is useful for showing a loading animation, yet still taking | |
| // advantage of the default behavior of m.request, which is to wait | |
| // for all requests to complete before rendering the view. | |
| // | |
| // The loader is assumed to already be on the page | |
| var loader = document.querySelector('.ajax-loader') |
| @mixin li-hover { | |
| background: #3875d7; | |
| color: #fff; | |
| } | |
| .autocomplete-input--select-drop { | |
| background: white; | |
| border: 1px solid #aaa; | |
| margin-top: -1px; | |
| position: absolute; |
| // Taken from http://loading.io/ | |
| uiload { | |
| display: inline-block; | |
| position: relative; | |
| & > div { | |
| position: relative; | |
| } | |
| } | |
| @-webkit-keyframes ajax-loader { |
| var Comment = {} | |
| Comment.store = Store('Comment') | |
| Comment.fetchForPost = function (postId) { | |
| return m.request({ method: 'GET', url: '/api/post/' + postId + '/comments' }) | |
| .then(Comment.store.syncAll) | |
| } |
| // m.prop is a great pattern, but Plain-old JavaScript Objects (POJO) are | |
| // much more pleasant to work with. | |
| // Here's an example of using POJOs with one- and two-way data binding. | |
| // First, the helper methods | |
| m.setValue = function (obj, prop) { | |
| return m.withAttr('value', function(value) { obj[prop] = value }) | |
| } |
| var Comment = {] | |
| Comment.create = function (attrs) { | |
| return m.request({ method: 'POST', url: '/comments', data: attrs }) | |
| } | |
| // A view-model is basically a temporary, disposable copy of a model. | |
| // It allows the user can either commit or cancel the changes they make. | |
| Comment.vm = function (attrs) { | |
| attrs = attrs || {} |
| var BlogComments = {} | |
| BlogComments.controller = function (options) { | |
| App.state.fetch('blogComments', `/api/blog-post/${ options.blog_id }/comments`) | |
| } | |
| BlogComments.view = function (ctrl, options) { | |
| var comments = App.state.blogComments | |
| return m('.blog-comments-component', [ |
| <!DOCTYPE html> | |
| <head> | |
| <link rel="stylesheet" type="text/css" href="line-numbers.css"> | |
| </head> | |
| <body> | |
| <pre><code>function add (a, b) { | |
| return a + b; | |
| }</code></pre> |
| var animateHeight = { | |
| oncreate: function (vnode) { | |
| var height = vnode.dom.clientHeight | |
| vnode.dom.style.maxHeight = 0 | |
| vnode.dom.offsetHeight // Trick to recalc layout | |
| window.requestAnimationFrame( ()=> (vnode.dom.style.maxHeight = height+1+"px") ) | |
| }, | |
| onbeforeremove: function (vnode, done) { | |
| vnode.dom.addEventListener('transitionend', done) | |
| vnode.dom.style.maxHeight = 0 |