On Github Bolza / webapp-like-lego
Created by Stefano Sergio / @StefanoSergio
Refuel.define('TVSApp',{require: ['GenericModule', 'DataSource']}, function TVSApp() { var app = Refuel.newModule('GenericModule', { root: document.querySelector("body"), autoload: true, modules: { top: { data: Refuel.newModule('DataSource', { url: 'http://...' }), rowStyle: ['series-row-A', 'series-row-B'] } } }); }});
<ul class="series" data="PLEASE_TAKE_DATA_FROM_THIS_API"> <li data="HEY_THIS_IS_THE_ITEM_TEMPLATE"> <div class="view"> <img class="left" src="MY_SHOW_IMAGE"> <div class="title left">TITLE OF MY FAVOURITE SHOW</div> <button class="series-action plan">[ADD TO PLANNED SHOWS]</button> </div> </li> </ul>
<ul data-rf-list="top.results"> <li data-rf-action="showZoom" class="{{user.status}}"> <div class="view"> <img class="left" data-src="{{thumb}}"> <div class="title left">{{title}}</div> <button class="series-action plan" data-rf-action="plan"></button> </div> </li> </ul>
function planShow(e) { var id = e.module.data.tvdb_id; var paramBody = {'tvdb_id': [id]}; Refuel.ajax.post(url, JSON.stringify(paramBody), { successCallback: function(ev) { setLoadingState(ev.target, false); } }); };
top.defineAction('plan', function(e) { planShow.call(this, e); });
<header id="saytbox" data-rf-sayt="searchSayt"> <input type="search" autocomplete="on" placeholder="search shows"> <span class="clear-search" data-rf-action="clearSayt"></span> </header>
app = Refuel.newModule('GenericModule', { //...blablabla previous slides, searchSayt: { url: 'http://app.tvshowmark.it/api/v1/tvshow/jsearch/', dataPath: 'results', delay: 200, minChars: 2 } });
<header id="saytbox" data-rf-sayt="searchSayt"> <!-- INPUT BOX IS HERE --> <ul data-rf-list="results" class="sayt-results"> <li data-rf-template="show" data-rf-action-mousedown="showZoom"> <div class="view"> <div class="title">{{title}}</div> </div> </li> </ul> </header>