blob: c93d24963afa979e3fd575e62e82a23ceac00e05 [file] [log] [blame]
webpackJsonp([0,2],[function(t,e,i){"use strict";function o(t,e){return(e||document).querySelector(t)}function n(t,e){return(e||document).querySelectorAll(t)}function r(t,e,i,o){t.addEventListener(e,i,!!o)}function c(t,e,i,o){function c(i){var r=i.target,c=n(e,t),l=Array.prototype.indexOf.call(c,r)>=0;l&&o.call(r,i)}var l="blur"===i||"focus"===i;r(t,i,c,l)}function l(t,e){if(t.parentNode)return t.parentNode.tagName.toLowerCase()===e.toLowerCase()?t.parentNode:l(t.parentNode,e)}function a(t,e){var i=t.indexOf(e);return i===-1?t:void t.splice(i,1)}i.d(e,"a",function(){return o}),i.d(e,"b",function(){return n}),i.d(e,"d",function(){return r}),i.d(e,"c",function(){return c}),i.d(e,"e",function(){return l}),i.d(e,"f",function(){return a}),NodeList.prototype.forEach=Array.prototype.forEach},,function(t,e,i){"use strict";function o(){i.i(c.a)()}var n=i(1),r=(i.n(n),i(10)),c=(i.n(r),i(0),i(8));e.a=o},function(t,e,i){"use strict";function o(t,e){var i=this;i.model=t,i.view=e,i.view.bind("newTodo",function(t){i.addItem(t)}),i.view.bind("itemEdit",function(t){i.editItem(t.id)}),i.view.bind("itemEditDone",function(t){i.editItemSave(t.id,t.title)}),i.view.bind("itemEditCancel",function(t){i.editItemCancel(t.id)}),i.view.bind("itemRemove",function(t){i.removeItem(t.id)}),i.view.bind("itemToggle",function(t){i.toggleComplete(t.id,t.completed)}),i.view.bind("removeCompleted",function(){i.removeCompletedItems()}),i.view.bind("toggleAll",function(t){i.toggleAll(t.completed)})}e.a=o,o.prototype.setView=function(t){var e=t.split("/")[1],i=e||"";this._updateFilterState(i)},o.prototype.showAll=function(){var t=this;t.model.read(function(e){t.view.render("showEntries",e)})},o.prototype.showActive=function(){var t=this;t.model.read({completed:!1},function(e){t.view.render("showEntries",e)})},o.prototype.showCompleted=function(){var t=this;t.model.read({completed:!0},function(e){t.view.render("showEntries",e)})},o.prototype.addItem=function(t){var e=this;""!==t.trim()&&e.model.create(t,function(){e.view.render("clearNewTodo"),e._filter(!0)})},o.prototype.editItem=function(t){var e=this;e.model.read(t,function(i){e.view.render("editItem",{id:t,title:i[0].title})})},o.prototype.editItemSave=function(t,e){var i=this;e.trim()?i.model.update(t,{title:e},function(){i.view.render("editItemDone",{id:t,title:e})}):i.removeItem(t)},o.prototype.editItemCancel=function(t){var e=this;e.model.read(t,function(i){e.view.render("editItemDone",{id:t,title:i[0].title})})},o.prototype.removeItem=function(t){var e=this;e.model.remove(t,function(){e.view.render("removeItem",t)}),e._filter()},o.prototype.removeCompletedItems=function(){var t=this;t.model.read({completed:!0},function(e){e.forEach(function(e){t.removeItem(e.id)})}),t._filter()},o.prototype.toggleComplete=function(t,e,i){var o=this;o.model.update(t,{completed:e},function(){o.view.render("elementComplete",{id:t,completed:e})}),i||o._filter()},o.prototype.toggleAll=function(t){var e=this;e.model.read({completed:!t},function(i){i.forEach(function(i){e.toggleComplete(i.id,t,!0)})}),e._filter()},o.prototype._updateCount=function(){var t=this;t.model.getCount(function(e){t.view.render("updateElementCount",e.active),t.view.render("clearCompletedButton",{completed:e.completed,visible:e.completed>0}),t.view.render("toggleAll",{checked:e.completed===e.total}),t.view.render("contentBlockVisibility",{visible:e.total>0})})},o.prototype._filter=function(t){var e=this._activeRoute.charAt(0).toUpperCase()+this._activeRoute.substr(1);this._updateCount(),(t||"All"!==this._lastActiveRoute||this._lastActiveRoute!==e)&&this["show"+e](),this._lastActiveRoute=e},o.prototype._updateFilterState=function(t){t=t.split("?")[0],this._activeRoute=t,""===t&&(this._activeRoute="All"),this._filter(),this.view.render("setFilter",t)}},function(t,e,i){var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(i){var n={},r={};n.length=0,n.getItem=function(t){return r[t]||null},n.setItem=function(t,e){"undefined"==typeof e?n.removeItem(t):(r.hasOwnProperty(t)||n.length++,r[t]=""+e)},n.removeItem=function(t){r.hasOwnProperty(t)&&(delete r[t],n.length--)},n.key=function(t){return Object.keys(r)[t]||null},n.clear=function(){r={},n.length=0},"object"===o(e)?t.exports=n:i.localStorageMemory=n}(this)},function(t,e,i){"use strict";function o(t){this.storage=t}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.a=o,o.prototype.create=function(t,e){t=t||"",e=e||function(){};var i={title:t.trim(),completed:!1};this.storage.save(i,e)},o.prototype.read=function(t,e){var i="undefined"==typeof t?"undefined":n(t);return e=e||function(){},"function"===i?(e=t,this.storage.findAll(e)):void("string"===i||"number"===i?(t=parseInt(t,10),this.storage.find({id:t},e)):this.storage.find(t,e))},o.prototype.update=function(t,e,i){this.storage.save(e,i,t)},o.prototype.remove=function(t,e){this.storage.remove(t,e)},o.prototype.removeAll=function(t){this.storage.drop(t)},o.prototype.getCount=function(t){var e={active:0,completed:0,total:0};this.storage.findAll(function(i){i.forEach(function(t){t.completed?e.completed++:e.active++,e.total++}),t(e)})}},function(t,e,i){"use strict";function o(t,e){if(e=e||function(){},this._dbName=t,!r[t]){var i={todos:[]};r[t]=JSON.stringify(i)}e.call(this,JSON.parse(r[t])),this.subscribers=[]}var n=i(0),r=i(4);i.n(r);e.a=o;var c=1;o.prototype.subscribe=function(t){var e=this;return this.subscribers.push(t),function(){return i.i(n.f)(e.subscribers,t)}},o.prototype._notify=function(){this.subscribers.forEach(function(t){return t()})},o.prototype.find=function(t,e){if(e){var i=JSON.parse(r[this._dbName]).todos;e.call(this,i.filter(function(e){for(var i in t)if(t[i]!==e[i])return!1;return!0}))}},o.prototype.findAll=function(t){t=t||function(){},t.call(this,JSON.parse(r[this._dbName]).todos)},o.prototype.save=function(t,e,i){var o=JSON.parse(r[this._dbName]),n=o.todos;if(e=e||function(){},i){for(var l=0;l<n.length;l++)if(n[l].id===i){for(var a in t)n[l][a]=t[a];break}r[this._dbName]=JSON.stringify(o),e.call(this,JSON.parse(r[this._dbName]).todos)}else t.id=c++,n.push(t),r[this._dbName]=JSON.stringify(o),e.call(this,[t]);this._notify()},o.prototype.remove=function(t,e){for(var i=JSON.parse(r[this._dbName]),o=i.todos,n=0;n<o.length;n++)if(o[n].id===t){o.splice(n,1);break}r[this._dbName]=JSON.stringify(i),e.call(this,JSON.parse(r[this._dbName]).todos),this._notify()},o.prototype.drop=function(t){r[this._dbName]=JSON.stringify({todos:[]}),t.call(this,JSON.parse(r[this._dbName]).todos),this._notify()}},function(t,e,i){"use strict";function o(){this.defaultTemplate='\n <li data-id="{{id}}" class="{{completed}}">\n <div class="view">\n <input class="toggle" type="checkbox" {{checked}} />\n <label>{{title}}</label>\n <button class="destroy"></button>\n </div>\n </li>\n '}e.a=o;var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},r=function(t){return n[t]},c=/[&<>"'`]/g,l=new RegExp(c.source),a=function(t){return t&&l.test(t)?t.replace(c,r):t};o.prototype.show=function(t){var e,i,o="";for(e=0,i=t.length;e<i;e++){var n=this.defaultTemplate,r="",c="";t[e].completed&&(r="completed",c="checked"),n=n.replace("{{id}}",t[e].id),n=n.replace("{{title}}",a(t[e].title)),n=n.replace("{{completed}}",r),n=n.replace("{{checked}}",c),o+=n}return o},o.prototype.itemCounter=function(t){var e=1===t?"":"s";return"<strong>"+t+"</strong> item"+e+" left"},o.prototype.clearCompletedButton=function(t){return t>0?"Clear completed":""}},function(t,e,i){"use strict";function o(t){this.storage=new a.a(t),this.model=new l.a(this.storage),this.template=new d.a,this.view=new r.a(this.template),this.controller=new c.a(this.model,this.view)}function n(){s=new o("todos-vanillajs"),s.controller.setView(document.location.hash),u.forEach(function(t){return t()})}var r=i(9),c=i(3),l=i(5),a=i(6),d=i(7);i(0);i.d(e,"a",function(){return n});var s=void 0,u=[]},function(t,e,i){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t){i.i(a.a)(".filters .selected").className="",i.i(a.a)('.filters [href="#/'+t+'"]').className="selected"}function r(t,e){var o=i.i(a.a)('[data-id="'+t+'"]');o&&(o.className=e?"completed":"",i.i(a.a)("input",o).checked=e)}function c(t,e){var o=i.i(a.a)('[data-id="'+t+'"]');if(o){o.className=o.className+" editing";var n=document.createElement("input");n.className="edit",o.appendChild(n),n.focus(),n.value=e}}function l(t){var e=i.i(a.e)(t,"li");return parseInt(e.dataset.id,10)}var a=i(0),d=function(){function t(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,i,o){return i&&t(e.prototype,i),o&&t(e,o),e}}(),s=function(){function t(e){o(this,t),this.template=e,this.ENTER_KEY=13,this.ESCAPE_KEY=27,this.$todoList=i.i(a.a)(".todo-list"),this.$todoItemCounter=i.i(a.a)(".todo-count"),this.$clearCompleted=i.i(a.a)(".clear-completed"),this.$main=i.i(a.a)(".main"),this.$footer=i.i(a.a)(".footer"),this.$toggleAll=i.i(a.a)(".toggle-all"),this.$newTodo=i.i(a.a)(".new-todo")}return d(t,[{key:"_removeItem",value:function(t){var e=i.i(a.a)('[data-id="'+t+'"]');e&&this.$todoList.removeChild(e)}},{key:"_clearCompletedButton",value:function(t,e){this.$clearCompleted.innerHTML=this.template.clearCompletedButton(t),this.$clearCompleted.style.display=e?"block":"none"}},{key:"_editItemDone",value:function(t,e){var o=i.i(a.a)('[data-id="'+t+'"]');if(o){var n=i.i(a.a)("input.edit",o);o.removeChild(n),o.className=o.className.replace("editing",""),i.i(a.b)("label",o).forEach(function(t){t.textContent=e})}}},{key:"render",value:function(t,e){var i=this,o={showEntries:function(){i.$todoList.innerHTML=i.template.show(e)},removeItem:function(){i._removeItem(e)},updateElementCount:function(){i.$todoItemCounter.innerHTML=i.template.itemCounter(e)},clearCompletedButton:function(){i._clearCompletedButton(e.completed,e.visible)},contentBlockVisibility:function(){i.$main.style.display=i.$footer.style.display=e.visible?"block":"none"},toggleAll:function(){i.$toggleAll.checked=e.checked},setFilter:function(){n(e)},clearNewTodo:function(){i.$newTodo.value=""},elementComplete:function(){r(e.id,e.completed)},editItem:function(){c(e.id,e.title)},editItemDone:function(){i._editItemDone(e.id,e.title)}};o[t]()}},{key:"_bindItemEditDone",value:function(t){var e=this;i.i(a.c)(e.$todoList,"li .edit","blur",function(){this.dataset.iscanceled||t({id:l(this),title:this.value})}),i.i(a.c)(e.$todoList,"li .edit","keypress",function(t){t.keyCode===e.ENTER_KEY&&this.blur()})}},{key:"_bindItemEditCancel",value:function(t){var e=this;i.i(a.c)(e.$todoList,"li .edit","keyup",function(i){i.keyCode===e.ESCAPE_KEY&&(this.dataset.iscanceled=!0,this.blur(),t({id:l(this)}))})}},{key:"bind",value:function(t,e){var o=this;"newTodo"===t?i.i(a.d)(o.$newTodo,"change",function(){e(o.$newTodo.value)}):"removeCompleted"===t?i.i(a.d)(o.$clearCompleted,"click",function(){e()}):"toggleAll"===t?i.i(a.d)(o.$toggleAll,"click",function(){e({completed:this.checked})}):"itemEdit"===t?i.i(a.c)(o.$todoList,"li label","dblclick",function(){e({id:l(this)})}):"itemRemove"===t?i.i(a.c)(o.$todoList,".destroy","click",function(){e({id:l(this)})}):"itemToggle"===t?i.i(a.c)(o.$todoList,".toggle","click",function(){e({id:l(this),completed:this.checked})}):"itemEditDone"===t?o._bindItemEditDone(e):"itemEditCancel"===t&&o._bindItemEditCancel(e)}}]),t}();e.a=s},function(t,e){},function(t,e,i){"use strict";function o(){i.i(r.d)(window,"load",n.a),i.i(r.d)(window,"hashchange",n.a)}var n=i(2),r=i(0);"complete"===document.readyState;o()}],[11]);
//# sourceMappingURL=bundle.app.930ad8b83126862d7445.js.map