forked from TechDocs/TechDocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
2 lines (2 loc) · 11.7 KB
/
app.js
1
2
!function t(e,n,o){function i(a,u){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var s=n[a]={exports:{}};e[a][0].call(s.exports,function(t){var n=e[a][1][t];return i(n?n:t)},s,s.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t){var e=t("riot"),n=t("./lib/ajax-get");t("../components/app.tag"),t("../components/logo.tag"),t("../components/item.tag"),t("../components/footnote.tag"),URL="/index.json",n(URL,function(t){e.mount("app",{title:"TechDocs",items:JSON.parse(t),urls:{github:"https://github.com/TechDocs/TechDocs"}})})},{"../components/app.tag":3,"../components/footnote.tag":4,"../components/item.tag":5,"../components/logo.tag":6,"./lib/ajax-get":7,riot:2}],2:[function(t,e,n){!function(){function t(t){var e={val:t},n=t.split(/\s+in\s+/);return n[1]&&(e.val=x(0)+n[1],n=n[0].slice(x(0).length).trim().split(/,\s*/),e.key=n[0],e.pos=n[1]),e}function o(t,e,n){var o={};return o[t.key]=e,t.pos&&(o[t.pos]=n),o}function i(e,n,i){function r(t,e,n){d.splice(t,0,e),g.splice(t,0,n)}p(e,"each");var a,c=e.outerHTML,l=e.previousSibling,s=e.parentNode,d=[],g=[];i=t(i),n.one("update",function(){s.removeChild(e)}).one("premount",function(){s.stub&&(s=n.root)}).on("update",function(){var t=C(i.val,n);if(t){if(!Array.isArray(t)){var e=JSON.stringify(t);if(e==a)return;a=e,f(g,function(t){t.unmount()}),d=[],g=[],t=Object.keys(t).map(function(e){return o(i,e,t[e])})}f(m(d,t),function(t){var e=d.indexOf(t),n=g[e];n&&(n.unmount(),d.splice(e,1),g.splice(e,1))});var p=s.childNodes,h=[].indexOf.call(p,l);f(t,function(e,l){var f=t.indexOf(e,l),m=d.indexOf(e,l);if(0>f&&(f=t.lastIndexOf(e,l)),0>m&&(m=d.lastIndexOf(e,l)),0>m){!a&&i.key&&(e=o(i,e,f));var v=new u({tmpl:c},{before:p[h+1+f],parent:n,root:s,item:e});return v.mount(),r(f,e,v)}return i.pos&&g[m][i.pos]!=f&&(g[m].one("update",function(t){t[i.pos]=f}),g[m].update()),f!=m?(s.insertBefore(p[h+m+1],p[h+f+1]),r(f,d.splice(m,1)[0],g.splice(m,1)[0])):void 0}),d=t.slice()}})}function r(t,e,n){h(t,function(t){if(1==t.nodeType){var o=b(t);if(o&&!t.getAttribute("each")){var i=new u(o,{root:t,parent:e});e.tags[t.getAttribute("name")||o.name]=i,n.push(i)}f(t.attributes,function(n){/^(name|id)$/.test(n.name)&&(e[n.value]=t)})}})}function a(t,e,n){function o(t,e,o){if(e.indexOf(x(0))>=0){var i={dom:t,expr:e};n.push(d(i,o))}}h(t,function(t){var n=t.nodeType;if(3==n&&"STYLE"!=t.parentNode.tagName&&o(t,t.nodeValue),1==n){var r=t.getAttribute("each");return r?(i(t,e,r),!1):(f(t.attributes,function(e){var n=e.name,i=n.split("__")[1];return o(t,e.value,{attr:i||n,bool:i}),i?(p(t,n),!1):void 0}),b(t)?!1:void 0)}})}function u(t,e){function n(){f(Object.keys(x),function(t){c[t]=C(x[t],p||u)})}function o(t){if(f(m,function(e){e[t?"mount":"unmount"]()}),p){var e=t?"on":"off";p[e]("update",u.update)[e]("unmount",u.unmount)}}var i,u=k.observable(this),c=v(e.opts)||{},l=g(t.tmpl),p=e.parent,h=[],m=[],b=e.root,y=e.item,w=t.fn,x={};w&&b.riot||(b.riot=!0,d(this,{parent:p,root:b,opts:c,tags:{}},y),f(b.attributes,function(t){x[t.name]=t.value}),this.update=function(t){d(u,t,y),n(),u.trigger("update",y),s(h,u,y),u.trigger("updated")},this.mount=function(){if(n(),w&&w.call(u,c),o(!0),a(l,u,h),u.update(),u.trigger("premount"),w)for(;l.firstChild;)b.appendChild(l.firstChild);else i=l.firstChild,b.insertBefore(i,e.before||null);b.stub&&(u.root=b=p.root),u.trigger("mount")},this.unmount=function(){var t=w?b:i,e=t.parentNode;if(e){if(p)e.removeChild(t);else for(;b.firstChild;)b.removeChild(b.firstChild);o(),u.trigger("unmount"),u.off("*"),delete b.riot}},r(l,this,m))}function c(t,e,n,o,i){n[t]=function(t){t=t||window.event,t.which=t.which||t.charCode||t.keyCode,t.target=t.target||t.srcElement,t.currentTarget=n,t.item=i,e.call(o,t)!==!0&&(t.preventDefault&&t.preventDefault(),t.returnValue=!1);var r=i?o.parent:o;r.update()}}function l(t,e,n){t&&(t.insertBefore(n,e),t.removeChild(e))}function s(t,e,n){f(t,function(t){var o=t.dom,i=t.attr,r=C(t.expr,e),a=t.dom.parentNode;if(null==r&&(r=""),a&&"TEXTAREA"==a.tagName&&(r=r.replace(/riot-/g,"")),t.value!==r){if(t.value=r,!i)return o.nodeValue=r;if(p(o,i),"function"==typeof r)c(i,r,o,e,n);else if("if"==i){var u=t.stub;r?u&&l(u.parentNode,u,o):(u=t.stub=u||document.createTextNode(""),l(o.parentNode,o,u))}else if(/^(show|hide)$/.test(i))"hide"==i&&(r=!r),o.style.display=r?"":"none";else if("value"==i)o.value=r;else if("riot-"==i.slice(0,5))i=i.slice(5),r?o.setAttribute(i,r):p(o,i);else{if(t.bool){if(o[i]=r,!r)return;r=i}"object"!=typeof r&&o.setAttribute(i,r)}}})}function f(t,e){for(var n,o=0,i=(t||[]).length;i>o;o++)n=t[o],null!=n&&e(n,o)===!1&&o--;return t}function p(t,e){t.removeAttribute(e)}function d(t,e,n){return e&&f(Object.keys(e),function(n){t[n]=e[n]}),n?d(t,n):t}function g(t){var e=t.trim().slice(1,3).toLowerCase(),n=/td|th/.test(e)?"tr":"tr"==e?"tbody":"div",o=document.createElement(n);return o.stub=!0,o.innerHTML=t,o}function h(t,e){if(t)if(e(t)===!1)h(t.nextSibling,e);else for(t=t.firstChild;t;)h(t,e),t=t.nextSibling}function m(t,e){return t.filter(function(t){return e.indexOf(t)<0})}function v(t){function e(){}return e.prototype=t,new e}function b(t){return T[t.tagName.toLowerCase()]}function y(t){var e=document.createElement("style");e.innerHTML=t,document.head.appendChild(e)}function w(t,e,n){var o=T[e];return o&&t&&(o=new u(o,{root:t,opts:n})),o&&o.mount?(o.mount(),O.push(o),o.on("unmount",function(){O.splice(O.indexOf(o),1)})):void 0}var k={version:"v2.0.12",settings:{}};k.observable=function(t){t=t||{};var e={},n=0;return t.on=function(o,i){return"function"==typeof i&&(i._id="undefined"==typeof i._id?n++:i._id,o.replace(/\S+/g,function(t,n){(e[t]=e[t]||[]).push(i),i.typed=n>0})),t},t.off=function(n,o){return"*"==n?e={}:n.replace(/\S+/g,function(t){if(o)for(var n,i=e[t],r=0;n=i&&i[r];++r)n._id==o._id&&(i.splice(r,1),r--);else e[t]=[]}),t},t.one=function(e,n){return n&&(n.one=1),t.on(e,n)},t.trigger=function(n){for(var o,i=[].slice.call(arguments,1),r=e[n]||[],a=0;o=r[a];++a)o.busy||(o.busy=1,o.apply(t,o.typed?[n].concat(i):i),o.one?(r.splice(a,1),a--):r[a]!==o&&a--,o.busy=0);return t},t},function(t,e){function n(){return a.hash.slice(1)}function o(t){return t.split("/")}function i(t){t.type&&(t=n()),t!=r&&(u.trigger.apply(null,["H"].concat(o(t))),r=t)}if(this.top){var r,a=location,u=t.observable(),c=window,l=t.route=function(t){t[0]?(a.hash=t,i(t)):u.on("H",t)};l.exec=function(t){t.apply(null,o(n()))},l.parser=function(t){o=t},c.addEventListener?c.addEventListener(e,i,!1):c.attachEvent("on"+e,i)}}(k,"hashchange");var x=function(t,e,n){return function(o){return e=k.settings.brackets||t,n!=e&&(n=e.split(" ")),o&&o.test?e==t?o:RegExp(o.source.replace(/\{/g,n[0].replace(/(?=.)/g,"\\")).replace(/\}/g,n[1].replace(/(?=.)/g,"\\")),o.global?"g":""):n[o]}}("{ }"),C=function(){function t(t,n){return t=(t||x(0)+x(1)).replace(x(/\\{/g),"").replace(x(/\\}/g),""),n=o(t,x(/{[\s\S]*?}/g)),new Function("d","return "+(n[0]||n[2]||n[3]?"["+n.map(function(t,n){return n%2?e(t,!0):'"'+t.replace(/\n/g,"\\n").replace(/"/g,'\\"')+'"'}).join(",")+'].join("")':e(n[1])).replace(/\uFFF0/g,x(0)).replace(/\uFFF1/g,x(1))+";")}function e(t,e){return t=t.replace(/\n/g," ").replace(x(/^[{ ]+|[ }]+$|\/\*.+?\*\//g),""),/^\s*[\w- "']+ *:/.test(t)?"["+t.replace(/\W*([\w- ]+)\W*:([^,]+)/g,function(t,e,o){return o.replace(/[^&|=!><]+/g,n)+'?"'+e.trim()+'":"",'})+'].join(" ").trim()':n(t,e)}function n(t,e){return t=t.trim(),t?"(function(v){try{v="+(t.replace(r,function(t,e,n){return n?"(d."+n+"===undefined?window."+n+":d."+n+")":t})||"x")+"}finally{return "+(e===!0?'!v&&v!==0?"":v':"v")+"}}).call(d)":""}function o(t,e){var n=[],o=0;return t.replace(e,function(e,i){n.push(t.slice(o,i),e),o=i+e.length}),n.concat(t.slice(o))}var i={},r=/(['"\/]).*?[^\\]\1|\.\w*|\w*:|\b(?:(?:new|typeof|in|instanceof) |(?:this|true|false|null|undefined)\b|function *\()|([a-z_$]\w*)/gi;return function(e,n){return e&&(i[e]=i[e]||t(e))(n)}}(),O=[],T={};k.tag=function(t,e,n,o){"function"==typeof n?o=n:n&&y(n),T[t]={name:t,tmpl:e,fn:o}},k.mount=function(t,e,n){function o(t){var o=e||t.tagName.toLowerCase(),r=w(t,o,n);r&&i.push(r)}"*"==t&&(t=Object.keys(T).join(", ")),"object"==typeof e&&(n=e,e=0);var i=[];return t.tagName?(o(t),i[0]):(f(document.querySelectorAll(t),o),i)},k.update=function(){return f(O,function(t){t.update()})},k.mountTo=k.mount,k.util={brackets:x,tmpl:C},"object"==typeof n?e.exports=k:"function"==typeof define&&define.amd?define(function(){return k}):this.riot=k}()},{}],3:[function(t){var e=t("riot");e.tag("app",'<logo title="{ opts.title }"></logo> <form> <input type="search" value="{ keyword }" onkeyup="{ keyup }" placeholder="search"> </form> <item each="{ filtered }" url="{ url }" language="{ language }" title="{ title }"></item> <p if="{ more }">and { count - MAX } more documents</p> <footnote urls="{ opts.urls }"></footnote>',"app { display: block; text-align: center; color: #666; } app form { background: #72A7EE; padding: 0 2em 2em; margin-bottom: 1em; } app input[type=search] { width: 100%; font-size: 2em; padding: .5em 0; text-align: center; outline: none; border: 0; border-radius: .2em; background-color: rgba(255,255,255,.7); transition: all .5s; } app input[type=search]:hover,app input[type=search]:focus { background-color: rgba(255,255,255,1); box-shadow: 0 1px 5px rgba(0,0,0,.3); } app p { color: #ccc; }",function(t){MAX=20,this.init=function(){this.keyword="",this.items=t.items,this.filtered=[],this.count=0,this.more=!1,this.search()}.bind(this),this.keyup=function(t){this.keyword=t.target.value.trim().toLowerCase(),this.search()}.bind(this),this.search=function(){filtered=this.items.filter(this.filter),this.count=filtered.length,this.more=filtered.length>MAX,this.filtered=filtered.slice(0,MAX)}.bind(this),this.filter=function(t){return!this.keyword.length||t.id.replace(/\-\w\w$/,"").match(this.keyword)}.bind(this),this.init()})},{riot:2}],4:[function(t){var e=t("riot");e.tag("footnote",'<ul> <li><a href="http://www.deego.co.jp/"><img src="images/deego.svg" alt="Deego.co.,ltd."></a></li> <li><a href="http://www.osscafe.net/"><img src="images/osscafe.svg" alt="Open Source Cafe, Shimokitazawa"></a></li> </ul> <p>TechDocs Project - <a href="{ opts.urls.github }">GitHub</a></p>',"footnote { color: #999; } footnote ul { padding: 0; list-style: none; } footnote li { display: inline-block; } footnote li a { display: block; opacity: .3; padding: 0 .5em; transition: all .5s; } footnote li a:hover { opacity: .8; } footnote p { line-height: 4em; }",function(){})},{riot:2}],5:[function(t){var e=t("riot");e.tag("item",'<a href="{ opts.url }"> <span class="language">{ opts.language }</span> { opts.title } </a>',"item { display: block; text-align: left; border-bottom: 1px dotted #ddd; background: white; } item .language { background: #FB1C1C; color: white; text-align: center; width: 2em; line-height: 1.4em; border-radius: .6em; margin-right: .4em; display: inline-block; font-size: 80%; } item a { text-decoration: none; display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; line-height: 2em; padding: .3em 5%; color: inherit; } item a:hover { background: #f7f7f7; color: #333; }",function(){})},{riot:2}],6:[function(t){var e=t("riot");e.tag("logo","<h1>{ opts.title }</h1>","logo { display: block; background-color: #72A7EE; color: #fff; padding: 5em 0; } logo h1 { background-image: url('images/logo.svg'); background-size: contain; background-position: center; background-repeat: no-repeat; color: transparent; margin: 0; padding: .5em; font-size: 3em; white-space: nowrap; overflow: hidden; }",function(){})},{riot:2}],7:[function(t,e){e.exports=function(t,e){var n=new XMLHttpRequest;n.onreadystatechange=function(){4==n.readyState&&200==n.status&&e(n.responseText)},n.open("GET",t,!0),n.send("")}},{}]},{},[1]);
//# sourceMappingURL=app.js.map