From 00c5aba77d7d9bd0ec602399b7b84b0ff1f25d80 Mon Sep 17 00:00:00 2001 From: Gregorio Chiko Putra Date: Thu, 14 Sep 2017 16:39:53 +0700 Subject: [PATCH] Huge updates: 1. Redesigned the web 2. Fixed logging in redirect issue 3. Added new route 4. Fixed sql issue on entry 5. Fixed typos --- App/Controllers/Home.php | 20 ++--- App/Controllers/Posts.php | 79 +++++++++++-------- App/Models/Access.php | 2 +- App/Models/Post.php | 31 +++----- App/Views/Access/login.html | 4 +- App/Views/Data/kategori.html | 8 +- App/Views/Data/pengumuman.html | 139 ++++++++++++++++++++++++--------- App/Views/base.html | 95 +++++++++++++++++++++- Core/Router.php | 7 ++ _tests/unit/RouterTest.php | 28 ++++--- public/index.php | 3 +- public/js/slidr.min.js | 48 ++++++++++++ 12 files changed, 348 insertions(+), 116 deletions(-) create mode 100644 public/js/slidr.min.js diff --git a/App/Controllers/Home.php b/App/Controllers/Home.php index a243dc2..02736d0 100644 --- a/App/Controllers/Home.php +++ b/App/Controllers/Home.php @@ -31,10 +31,6 @@ class Home Session::flash('info', 'Anda telah masuk'); Redirect::to('/'); die(); - } else { - View::render('Access/login.html', [ - 'token' => Token::generate() - ]); } // Login @@ -69,17 +65,21 @@ class Home Session::put('userid', $user['id']); Session::put('username', $user['username']); Session::put('full_name', $user['full_name']); - Session::put('privilage', $user['privilage']); + Session::put('privilege', $user['privilege']); $info = "Berhasil masuk"; + Session::flash('info', $info); + Redirect::to('/'); + die(); } } } } } - Session::flash('info', $info); - Redirect::to('/'); - die(); + } else { + View::render('Access/login.html', [ + 'token' => Token::generate() + ]); } } @@ -90,7 +90,7 @@ class Home Session::delete('userid'); Session::delete('username'); Session::delete('full_name'); - Session::delete('privilage'); + Session::delete('privilege'); $info = "Berhasil keluar"; } @@ -100,7 +100,7 @@ class Home public function register() { - if (Session::exists('userid') && Session::get('privilage') == 1) { + if (Session::exists('userid') && Session::get('privilege') == 1) { View::render('Access/registrasi.html', [ 'token' => Token::generate() ]); diff --git a/App/Controllers/Posts.php b/App/Controllers/Posts.php index 71fbd00..d099c7c 100644 --- a/App/Controllers/Posts.php +++ b/App/Controllers/Posts.php @@ -25,7 +25,7 @@ class Posts $valid = $this->model->showAll([ ['valid_at', '<=', $now], - ['status', '!=', 3] + ['status', '!=', 0] ]); if ($valid) { foreach ($valid as $fields) { @@ -40,7 +40,7 @@ class Posts $not_valid = $this->model->showAll([ ['valid_at', '>', $now], - ['status', '!=', 3] + ['status', '!=', 0] ]); if ($not_valid) { foreach ($not_valid as $fields) { @@ -55,7 +55,7 @@ class Posts $expired = $this->model->showAll([ ['expired_at', '<', $now], - ['status', '!=', 3] + ['status', '!=', 0] ]); if ($expired) { foreach ($expired as $fields) { @@ -70,7 +70,7 @@ class Posts } /* Routes */ - public function index() + public function index($args = '') { $this->checkValid(); @@ -83,11 +83,16 @@ class Posts $url = 'Data/pengumuman.html'; $status = ''; - $privilage = ''; + $privilege = ''; if (Session::exists('userid')) { $post = $this->model->showAll(); - $privilage = Session::get('privilage'); + if ($args != '') { + $post = $this->model->showAll([ + ['status', '=', $args] + ]); + } + $privilege = Session::get('privilege'); $status = 'loggedin'; } @@ -106,7 +111,8 @@ class Posts View::render($url, [ 'posts' => $posts, 'status' => $status, - 'privilage' => $privilage + 'privilege' => $privilege, + 'token' => Token::generate() ]); } @@ -204,7 +210,7 @@ class Posts public function category() { if (Session::exists('userid')) { - if (Session::get('privilage') != 1) { + if (Session::get('privilege') != 1) { Session::flash('info', 'Hanya admin yang bisa mengatur kategori'); Redirect::to('/'); die(); @@ -266,12 +272,13 @@ class Posts die(); } - public function put($args = []) + public function put($args) { if (isset($args['_addon'])) { $table = $args['_addon']; + unset($args['_addon']); - $this->model->update(['status' => 1], $args['id'], $table); + $this->model->update($args, $args['id'], $table); Session::flash('info', 'Data berhasil diaktifkan'); Redirect::to('/posts/category'); @@ -285,32 +292,37 @@ class Posts unset($args['id']); // Check if data same with old data - $old_data = [ - $args['old_category'], - $args['old_content'], - $args['old_valid_at'], - $args['old_expired_at'] - ]; - $new_data = [ - $args['category'], - $args['content'], - $args['valid_at'], - $args['expired_at'] - ]; - - if ($old_data == $new_data) { - Session::flash('info', 'Tidak ada data yang diubah'); - Redirect::to("./$id"); - die(); - } - $keys = array_keys($args); + $old_data = []; + if ($matches = preg_grep('/^old_/', $keys)) { foreach ($matches as $match) { + $old_data[] = $args[$match]; unset($args[$match]); } + $new_data = [ + $args['category'], + $args['content'], + $args['valid_at'], + $args['expired_at'] + ]; + if ($old_data == $new_data) { + Session::flash('info', 'Tidak ada data yang diubah'); + Redirect::to("./$id"); + die(); + } } + foreach ($args as $key => $val) { + if (strpos($val, "##date##") !== false) { + $date = new \DateTime(); + $now = $date->format("Y-m-d"); + $args[$key] = $now; + } + } + + var_dump($args); + if ($this->model->update($args, $id)) { Session::flash('info', 'Data berhasil diperbarui'); Redirect::to('/'); @@ -329,11 +341,12 @@ class Posts } $id = $args['id']; + unset($args['id']); - if ($table) { - $delete = $this->model->delete($id, 0, $table); + if (isset($table)) { + $delete = $this->model->update($args, $id, $table); } else { - $delete = $this->model->delete($id); + $delete = $this->model->update($args, $id); } if ($delete == true) { @@ -344,7 +357,7 @@ class Posts Session::flash('info', $info); - if ($table) { + if (isset($table)) { Redirect::to("/posts/category"); } else { Redirect::to('/'); diff --git a/App/Models/Access.php b/App/Models/Access.php index a1c90fd..a5dcb74 100644 --- a/App/Models/Access.php +++ b/App/Models/Access.php @@ -13,7 +13,7 @@ class Access extends \Core\Model 'salt char(23) NOT NULL', 'full_name varchar(50) NOT NULL', 'registered_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', - 'privilage tinyint(1) NOT NULL DEFAULT 0', + 'privilege tinyint(1) NOT NULL DEFAULT 0', 'status tinyint(1) NOT NULL DEFAULT 0', 'max_user int(1) NOT NULL DEFAULT 5', 'PRIMARY KEY (id)' diff --git a/App/Models/Post.php b/App/Models/Post.php index 2836ceb..b4d6e59 100644 --- a/App/Models/Post.php +++ b/App/Models/Post.php @@ -130,31 +130,22 @@ class Post extends \Core\Model $x = 1; foreach ($args as $field) { - // Setting the query for multiple rows - if (is_array($field)) { - foreach ($field as $fields) { - $values .= '(?)'; - if ($x < count($field)) { - $values .= ', '; - } - $x++; - } - } else { - if ($x === 1) { - $values .= '('; - } - $values .= '?'; - if ($x < count($args)) { - $values .= ', '; - } else { - $values .= ')'; - } - $x++; + if ($x === 1) { + $values .= '('; } + $values .= '?'; + if ($x < count($args)) { + $values .= ', '; + } else { + $values .= ')'; + } + $x++; } try { $sql = "INSERT INTO {$table} ({$keys}) VALUES {$values}"; + var_dump($sql); + var_dump($args); $db = static::connectDB(); diff --git a/App/Views/Access/login.html b/App/Views/Access/login.html index 2e7bb21..20c65c0 100644 --- a/App/Views/Access/login.html +++ b/App/Views/Access/login.html @@ -19,7 +19,9 @@
- +
diff --git a/App/Views/Data/kategori.html b/App/Views/Data/kategori.html index ad4ac5e..9b58d02 100644 --- a/App/Views/Data/kategori.html +++ b/App/Views/Data/kategori.html @@ -13,19 +13,21 @@
{% if cat.status == 1 %} + {% elseif cat.status == 0 %} + {% endif %} -
diff --git a/App/Views/Data/pengumuman.html b/App/Views/Data/pengumuman.html index b46b236..e224ce5 100644 --- a/App/Views/Data/pengumuman.html +++ b/App/Views/Data/pengumuman.html @@ -6,15 +6,15 @@ + {% endblock %} diff --git a/App/Views/base.html b/App/Views/base.html index 7fd2c53..d5193de 100644 --- a/App/Views/base.html +++ b/App/Views/base.html @@ -6,6 +6,7 @@ + {% block title %}{% endblock %} + + {% block body %} {% endblock %} + + diff --git a/Core/Router.php b/Core/Router.php index 633af89..74f5f79 100644 --- a/Core/Router.php +++ b/Core/Router.php @@ -22,6 +22,7 @@ class Router $route = preg_replace('/\//', '\/', $route); $route = preg_replace('/\{([a-z]+)\}/', '(?P<\1>[a-z-]+)', $route); $route = preg_replace('/\{([a-z]+):([^\}]+)\}/', '(?P<\1>\2)', $route); + $route = preg_replace('/\{\?([a-z]+):([^\}]+)\}/', '\?(?P<\1>[a-z]+=\2)', $route); $route = '/^'.$route.'$/'; $this->routes[$route] = $params; @@ -77,12 +78,18 @@ class Router } unset($var['_token']); unset($var['_method']); + } elseif (Input::exists('get')) { + $get_var = $_GET; } if (array_key_exists('id', $this->params)) { $var['id'] = $this->params['id']; + } elseif (array_key_exists('status', $this->params)) { + $get_var = preg_replace('/^[a-z]+=/', '', $get_var['status']); } if (isset($var)) { return $object->$action($var); + } elseif (isset($get_var)) { + return $object->$action($get_var); } else { return $object->$action(); } diff --git a/_tests/unit/RouterTest.php b/_tests/unit/RouterTest.php index fe9d192..a59323b 100644 --- a/_tests/unit/RouterTest.php +++ b/_tests/unit/RouterTest.php @@ -35,7 +35,13 @@ class RouterTest extends \PHPUnit\Framework\TestCase '{action}', ['controller' => 'home'], '/login', - ['controller' => 'home'] + ['controller' => 'home', 'action' => 'login'] + ], + [ + '{?status:\d+}', + ['controller' => 'posts', 'action' => 'index'], + '/?status=1', + ['controller' => 'posts', 'action' => 'index', 'status' => '1'] ] ]; } @@ -51,9 +57,13 @@ class RouterTest extends \PHPUnit\Framework\TestCase $router->add($route, $params); + // echo "$route\n$url\n"; + // var_dump($router->getRoutes()); + $this->assertTrue($router->match($url)); - // $this->assertEquals($expected_param, $router->getParams()); + $this->assertEquals($expected_param, $router->getParams()); + var_dump($router->getParams()); } /** @@ -61,11 +71,11 @@ class RouterTest extends \PHPUnit\Framework\TestCase * @test * @dataProvider routeProvider */ - public function dispatchingRouteSuccess($route, $params, $url) - { - $router = new Router(); - $router->add($route, $params); - - $this->assertTrue($router->dispatch($url)); - } + // public function dispatchingRouteSuccess($route, $params, $url) + // { + // $router = new Router(); + // $router->add($route, $params); + // + // $this->assertTrue($router->dispatch($url)); + // } } diff --git a/public/index.php b/public/index.php index cee0ad8..f53a3ea 100644 --- a/public/index.php +++ b/public/index.php @@ -12,7 +12,7 @@ set_error_handler("Core\Error::errorHandler"); set_exception_handler("Core\Error::exceptionHandler"); if (Core\Session::exists('info')) { - echo '

'; + echo '

'; echo Core\Session::flash('info'); echo '

'; } @@ -23,6 +23,7 @@ $router->add('', ['controller' => 'posts', 'action' => 'index']); $router->add('{controller}/{action}'); $router->add('{controller}/{action}/{id:\d+}'); $router->add('{action}', ['controller' => 'home']); +$router->add('{?status:\d+}', ['controller' => 'posts', 'action' => 'index']); $url = $_SERVER['REQUEST_URI']; $router->dispatch($url); diff --git a/public/js/slidr.min.js b/public/js/slidr.min.js new file mode 100644 index 0000000..e689a56 --- /dev/null +++ b/public/js/slidr.min.js @@ -0,0 +1,48 @@ +/*! + * slidr v0.5.0 - A Javascript library for adding slide effects. + * bchanx.com/slidr + * MIT licensed + * + * Copyright (c) 2014 Brian Chan (bchanx.com) + */ +function E(){function H(){}function K(a,b,c){var d={id:a,a:b,h:null,controls:null,d:c,u:!1,v:!1,start:null,c:null,j:{id:null,ga:5E3,direction:"right"},W:{},K:{},D:{},i:{up:null,down:null,left:null,right:null}};return{start:function(a){q.start(d,a);return this},canSlide:function(a){return q.N(d,a)},slide:function(a){q.s(d,a);return this},add:function(a,b,c,e){q.add(d,a,b,c,e);return this},auto:function(a,b,c){q.start(d,c);q.j(d,a||d.j.ga,b||d.j.direction);return this},stop:function(){q.stop(d);return this}, +timing:function(a,b){a&&a.constructor===Object?d.d.timing=A(d.d.timing,a):"string"===typeof a&&"string"===typeof b&&(d.d.timing[a]=b);return this},breadcrumbs:function(){q.h(d);return this},controls:function(a){q.controls(d,a);return this}}}function G(a,b){var c=a,d;for(d in b){if(!c||!c.hasOwnProperty(b[d]))return null;c=c[b[d]]}return c===a?null:c}function A(){for(var a={},b=0,c;c=arguments[b];b++)for(var d in c)a[d]=c[d];return a}function I(a,b){return a.contains?a.contains(b):a.compareDocumentPosition? +a.compareDocumentPosition(b)&16:0}function x(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;cf&&c.push(g),"rm"===b&&0<=f&&c.splice(f,1);a.className=c.join(" ");return a}function C(a){return a.replace(/[\s'"]/gi, +"").split("").sort().join("")}function D(a,b){return a&&a.getAttribute?a.getAttribute(b):null}function h(a,b){if("string"===typeof b){var c=document.defaultView?document.defaultView.getComputedStyle(a):a.currentStyle,d=c[e.q(b)];d||"opacity"!==b||(d=c.filter?c.filter.split("=")[1].replace(")",""):"1");return d?(c=d.slice(0,-2),"px"===d.slice(-2)&&!isNaN(parseInt(c))&&0>=c.search("px")?parseInt(c):d):"none"}for(d in b)e.q(d)&&(a.style[e.q(d)]=b[d]);return a}function w(a,b,c,d){"string"===typeof b&& +(b=[b]);for(var g=0,f,F;f=b[g];g++)F=0x(t.Z,b)||!u.ka[b]?"none":b},get:function(a,b,c,d){return G(a.K,[b,"in"===c?l.I(d):d])},set:function(a,b,c,d){d=t.L(a,d);a.K[b]||(a.K[b]={});return a.K[b][c]= +d},apply:function(a,b,c,d,g){p.update(a,b,c);u.B(a,b,g,c,d)}},r={e:{},hash:function(a){return[a.id,a["in"].slidr,a["in"].trans,a["in"].dir,a.out.slidr,a.out.trans,a.out.dir].join("-")},ua:function(a,b,c,d,g,f,e){return{id:a.id,"in":{el:l.get(a,c).m,slidr:c,trans:e,dir:g},out:{el:l.get(a,b).m,slidr:b,trans:f,dir:l.I(d)}}},C:function(a,b){var c=r.hash(b);r.e[c]||(r.e[c]={});r.e[c].C||(r.e[c].C=!0,c=a.d.before,"function"===typeof c&&c(b))},A:function(a,b){var c=r.hash(b);r.e[c].A||(r.e[c].A=!0,c=a.d.after, +"function"===typeof c&&r.na(c,b))},na:function(a,b){if(e.supports("animation")&&"none"!==b["in"].trans){var c=function(d){e.T[d.animationName]&&(a(b),w(b["in"].el,e.M,c,!0),r.reset(b))};w(b["in"].el,e.M,c)}else a(b),r.reset(b)},reset:function(a){a=r.hash(a);r.e[a].C=!1;r.e[a].A=!1}},l={F:"left up top right down bottom".split(" "),H:function(a){return 0<=x(l.F,a)},I:function(a){var b=l.F.length;return l.H(a)?l.F[(x(l.F,a)+b/2)%b]:null},get:function(a){for(var b=[],c=1,d;void 0!==(d=arguments[c++]);b.push(d)); +return G(a.W,b)},display:function(a){!a.v&&l.get(a,a.start)&&(a.c=a.start,p.create(a),m.create(a),u.G(a,a.c,"fade"),u.B(a,a.c,"fade","in"),a.v=!0,q.controls(a,a.d.controls),a.d.breadcrumbs&&q.h(a))},s:function(a,b){return l.H(b)?l.go(a,l.get(a,a.c,b),b,b):l.ta(a,b)},ta:function(a,b){if(b&&b!==a.c&&l.get(a,b)){var c=a.D[a.c],d=a.D[b],g=c.xd.x?"left":null,d=c.yd.y?"down":null,c=t.get(a,a.c,"out",g)?g:t.get(a,a.c,"out",d)?d:null,g=t.get(a,b,"in",g)?g:t.get(a,b,"in",d)? +d:null;l.go(a,b,c,g,c?null:"fade",g?null:"fade")}},go:function(a,b,c,d,g,f){if(a.c&&b){f=f||t.get(a,b,"in",d);g=g||t.get(a,a.c,"out",c);var e=r.ua(a,a.c,b,c,d,g,f);r.C(a,e);t.apply(a,b,"in",d,f);t.apply(a,a.c,"out",c,g);r.A(a,e);a.c=b;m.update(a);return!0}return!1},find:function(a,b){for(var c=b?[]:{},d=0,g,f;g=a.a.childNodes[d];d++)(f=D(g,"data-slidr"))&&(b&&0>x(c,f)?c.push(f):f in c||(c[f]=g));return c},L:function(a,b,c,d,g,f){if(!b||b.constructor!==Array)return!1;for(var e=0,n,h,k,m,p,q,r,s;n= +b[e];e++)if(!(n in d)||l.get(a,n)&&(h=b[e-1]||null,k=b[e+1]||null,m=l.get(a,n,g),p=l.get(a,n,f),q=l.get(a,k,g),r=t.get(a,n,"out",g),s=t.get(a,n,"out",f),p&&k&&p!=k||m&&h&&m!=h||q&&q!=n||h&&r&&r!=c||k&&s&&s!=c))return!1;return!0},add:function(a,b,c,d,g,e){for(var h=0,n;n=b[h];h++){a.W[n]=a.W[n]||{};var k=l.get(a,n);k.m=d[n];b[h-1]&&(k[g]=b[h-1],t.set(a,n,g,c));b[h+1]&&(k[e]=b[h+1],t.set(a,n,e,c));u.G(a,n,c);a.start=a.start?a.start:n}a.u&&(a.v?p.create(a):l.display(a));return!0}},m={b:e.$("control"), +types:["border","corner","none"],valid:function(a){return 0<=x(m.types,a)},create:function(a){if(a.a&&!a.controls){a.controls=h(v(y("aside",{id:m.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)","z-index":"0",visibility:"hidden","pointer-events":"none"});for(var b in a.i){var c=a.i,d=b,g=v(y("div"),"add",m.b.i,b);g&&g.setAttribute&&g.setAttribute(m.b.data,b);c[d]=g;a.controls.appendChild(a.i[b])}m.t(a);a.a.appendChild(a.controls);w(a.controls,"click",m.onclick(a))}},t:function(a){e.f(m.b.r, +{position:"absolute",bottom:h(a.a,"padding-bottom")+"px",right:h(a.a,"padding-right")+"px",padding:"10px","box-sizing":"border-box",width:"75px",height:"75px",transform:"translateZ(9998px)"},!0);e.f(m.b.r+".disabled",{transform:"translateZ(0px) !important"},!0);e.f(m.b.r+".breadcrumbs",{left:h(a.a,"padding-left")+"px",right:"auto"},!0);e.f(m.b.r+".border",{bottom:"0",right:"0",left:"0",width:"100%",height:"100%"},!0);e.f(m.b.w,{position:"absolute","pointer-events":"auto",cursor:"pointer",transition:"opacity 0.2s linear"}, +!0);var b={opacity:"0.05",cursor:"auto"};e.k()&&(b.display="none");e.f(m.b.w+".disabled",b,!0);var c,d,g,f;for(c in a.i)d="left"===c||"right"===c,b="up"===c?"top":"down"===c?"bottom":c,g=d?"top":"left",f={width:d?"22px":"16px",height:d?"16px":"22px","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none","user-select":"none"},f[b]="0",f[g]="50%",f["margin-"+g]="-8px",e.f(m.b.w+"."+c,f,!0),f={width:"0",height:"0",content:'""',position:"absolute",border:"8px solid transparent"},f["border-"+ +l.I(b)+"-width"]="12px",f["border-"+b+"-width"]="10px",f["border-"+l.I(b)+"-color"]=a.d.theme,f[b]="0",f[g]="50%",f["margin-"+g]="-8px",e.f(m.b.id(a,!0)+" ."+m.b.i+"."+c+":after",f,!0),f={},f[d?"height":"width"]="100%",f[g]="0",f["margin-"+g]="0",e.f(m.b.r+".border ."+m.b.i+"."+c,f,!0),d={},d[b]=h(a.a,"padding-"+b)+"px",e.f(m.b.id(a,!0)+".border ."+m.b.i+"."+c,d,!0)},onclick:function(a){return function(b){q.s(a,D(e.o(b).target,m.b.data))}},update:function(a){for(var b in a.i)v(a.i[b],q.N(a,b)?"rm": +"add","disabled")}},p={b:e.$("breadcrumbs"),G:function(a){a.a&&!a.h&&(a.h=h(v(y("aside",{id:p.b.id(a)}),"add","disabled"),{opacity:"0",filter:"alpha(opacity=0)","z-index":"0","pointer-events":"none",visibility:"hidden"}),p.t(a),a.a.appendChild(a.h),w(a.h,"click",p.onclick(a)))},t:function(a){e.f(p.b.r,{position:"absolute",bottom:h(a.a,"padding-bottom")+"px",right:h(a.a,"padding-right")+"px",padding:"10px","box-sizing":"border-box",transform:"translateZ(9999px)"},!0);e.f(p.b.r+".disabled",{transform:"translateZ(0px) !important"}, +!0);e.f(p.b.w,{padding:"0","font-size":"0","line-height":"0"},!0);e.f(p.b.w+" li",{width:"10px",height:"10px",display:"inline-block",margin:"3px","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none","user-select":"none"},!0);e.f(p.b.id(a,!0)+" ."+p.b.i+" li.normal",{"border-radius":"100%",border:"1px "+a.d.theme+" solid",cursor:"pointer","pointer-events":"auto"},!0);e.f(p.b.id(a,!0)+" ."+p.b.i+" li.active",{width:"12px",height:"12px",margin:"2px","background-color":a.d.theme},!0)},onclick:function(a){return function(b){q.s(a, +D(e.o(b).target,p.b.data))}},V:{right:{x:1,y:0},up:{x:0,y:1},left:{x:-1,y:0},down:{x:0,y:-1}},find:function(a,b,c,d,g,e){if(d){b[d]||(b[d]={x:g,y:e},gc.x.max&&(c.x.max=g),ec.y.max&&(c.y.max=e));d=l.get(a,d);for(var h in p.V)d[h]&&!b[d[h]]&&p.find(a,b,c,d[h],g+p.V[h].x,e+p.V[h].y)}},update:function(a,b,c){v(a.D[b].m,"in"===c?"add":"rm","active")},create:function(a){p.G(a);if(a.h){var b={},c={x:{min:0,max:0},y:{min:0,max:0}};p.find(a,b,c,a.start,0,0); +c.x.U=0-c.x.min;c.y.U=0-c.y.min;var d={},e;for(e in b)b[e].x+=c.x.U,b[e].y+=c.y.U,d[b[e].x+","+b[e].y]=e;for(var f=c.y.max-c.y.min+1,c=c.x.max-c.x.min+1;a.h.firstChild;)a.h.removeChild(a.h.firstChild);e=v(y("ul"),"add",p.b.i);for(var h=y("li"),f=f-1,n;0<=f;f--){n=e.cloneNode(!1);for(var k=0,l,m;k=a.which&&37<=a.which){var b=B[s.g.c()],c=null;40===a.which&&b.canSlide("down")?c="down":39===a.which&&b.canSlide("right")?c="right":38===a.which&&b.canSlide("up")?c="up":37===a.which&&b.canSlide("left")&&(c="left");c&& +b.slide(c)&&e.stop(a)}})}(),va:function(a){var b,c,d,g,f,h;w(a.a,"touchstart",function(a){a=e.o(a);b=a.touches[0].pageX;c=a.touches[0].pageY;d=+new Date;h=f=g=0});w(a.a,"touchmove",function(a){a=e.o(a);1(Math.abs(g)+Math.abs(f))/h||e.stop(a))});w(a.a,"touchend",function(b){b=e.o(b);if(250>Number(+new Date-d)){var c=Math.abs(g),h=Math.abs(f),k=20g?"right":"left",p=0>f?"down": +"up";(c=k&&l?c>h?m:p:k?m:l?p:null)&&q.s(a,c);e.stop(b)}})}},q={start:function(a,b){if(!a.u&&a.a){var c=h(a.a,"display"),d=h(a.a,"position"),e=h(a.a,"opacity");h(a.a,{visibility:"visible",opacity:e,filter:"alpha(opacity="+100*e+")",display:"inline-block"===c||"inline"===c?"inline-block":"block",position:"static"===d?"relative":d,overflow:a.d.overflow?h(a.a,"overflow"):"hidden",transition:"height 0.05s ease-out, width 0.05s ease-out","tap-highlight-color":"rgba(0, 0, 0, 0)","touch-callout":"none"}); +a.start||q.add(a,a.d.direction,l.find(a,!0),a.d.transition);l.get(a,b)&&(a.start=b);l.display(a);k.ma(a);u.da(a,a.a);a.d.keyboard&&s.g.wa(a.a);a.d.touch&&s.va(a);a.u=!0;m.update(a)}},N:function(a,b){return a.u&&b&&(l.H(b)?!!l.get(a,a.c,b):!!l.get(a,b))},s:function(a,b){q.N(a,b)&&l.s(a,b)},add:function(a,b,c,d,e){if(a.a){d=t.L(a,d);var f=l.find(a),h="horizontal"===b||"h"===b?"left":"up",k="horizontal"===b||"h"===b?"right":"down";l.L(a,c,d,f,h,k)||e?l.add(a,c,d,f,h,k):console.warn("[Slidr] Error adding ["+ +b+"] slides for ["+a.id+"].")}},j:function(a,b,c){a.u&&l.H(c)&&(q.stop(a),a.j.ga=b,a.j.direction=c,a.j.id=setInterval(function(){a.d.pause&&s.g.S(a.id)||l.s(a,c)},b))},stop:function(a){a.u&&a.j.id&&(clearInterval(a.j.id),a.j.id=null)},h:function(a){if(a.h&&a.v){var b="0"===h(a.h,"opacity")?"in":"out";u.B(a,null,"fade",b,null,a.h,"3","none");a.controls&&v(a.controls,"in"===b?"add":"rm","breadcrumbs")}},controls:function(a,b){if(a.controls&&a.v){m.valid(b)||(b=null);var c="hidden"===h(a.controls,"visibility"), +d=b&&"none"!==b?"in":"out";"out"===d&&c||("border"===b?v(a.controls,"add","border"):"corner"===b&&v(a.controls,"rm","border"),u.B(a,null,"fade",d,null,a.controls,"2","none"))}}};setInterval(function b(){var c,d,g,f,m;for(g in k.l)(d=k.l[g],c=d.src,e.k()||I(document,c.a))?"hidden"===h(c.a,"visibility")?(k.l[g].X=k.ia(c.a,0),k.l[g].R=k.ha(c.a,0)):l.get(c,c.c)&&(f=l.get(c,c.c).m,m=k.fa(f),f=k.ea(f),d.ba.width&&d.X!=m&&(k.l[g].X=k.ia(c.a,m)),d.ba.height&&d.R!=f&&(k.l[g].R=k.ha(c.a,f))):(delete k.l[g], +delete B[c.id]);return b}(),250);var B={},M={after:H,before:H,breadcrumbs:!1,controls:"border",direction:"horizontal",fade:!0,keyboard:!1,overflow:!1,pause:!1,theme:"#fff",timing:{},touch:!1,transition:"linear"},N={none:"none",fade:"0.4s ease-out",linear:"0.6s ease-out",cube:"1s cubic-bezier(0.15, 0.9, 0.25, 1)"};return{version:function(){return"0.5.0"},transitions:function(){return t.Z.slice(0)},create:function(b,c){var d=document.getElementById(b);if(d){var e=A(M,c||{});e.timing=A(N,e.timing);B[b]= +B[b]||new K(b,d,e);return B[b]}console.warn("[Slidr] Could not find element with id ["+b+"].")}}}"object"===typeof exports?module.exports=E():"function"===typeof define&&define.amd?define(E):this.slidr=E();