Removed fitty.js, using manual font-size setting instead. Fixed valid/expired posts check.
This commit is contained in:
parent
d06921fcc8
commit
6cb980051c
@ -24,49 +24,60 @@ class Posts
|
||||
$date = new \DateTime();
|
||||
$now = $date->format("Y-m-d");
|
||||
|
||||
$valid = $this->model->showAll([
|
||||
['valid_at', '<=', $now],
|
||||
['status', '!=', 0]
|
||||
$data = [];
|
||||
|
||||
$valid_data = $this->model->showAll([
|
||||
['valid_at', '<=', $now]
|
||||
]);
|
||||
if ($valid) {
|
||||
foreach ($valid as $fields) {
|
||||
if (is_array($fields)) {
|
||||
$id = $fields['id'];
|
||||
} else {
|
||||
$id = $valid['id'];
|
||||
}
|
||||
$this->model->update(['status' => 1], $id);
|
||||
if ($valid_data != false) {
|
||||
if (array_key_exists(0, $valid_data)) {
|
||||
$data = $valid_data;
|
||||
} else {
|
||||
$data[] = $valid_data;
|
||||
}
|
||||
|
||||
foreach ($data as $fields) {
|
||||
$id = $fields['id'];
|
||||
}
|
||||
|
||||
$this->model->update(['status' => 1], $id);
|
||||
$data = [];
|
||||
}
|
||||
|
||||
$not_valid = $this->model->showAll([
|
||||
['valid_at', '>', $now],
|
||||
['status', '!=', 0]
|
||||
$notvalid_data = $this->model->showAll([
|
||||
['valid_at', '>', $now]
|
||||
]);
|
||||
if ($not_valid) {
|
||||
foreach ($not_valid as $fields) {
|
||||
if (is_array($fields)) {
|
||||
$id = $fields['id'];
|
||||
} else {
|
||||
$id = $not_valid['id'];
|
||||
}
|
||||
$this->model->update(['status' => 2], $id);
|
||||
if ($notvalid_data != false) {
|
||||
if (array_key_exists(0, $notvalid_data)) {
|
||||
$data = $notvalid_data;
|
||||
} else {
|
||||
$data[] = $notvalid_data;
|
||||
}
|
||||
|
||||
foreach ($data as $fields) {
|
||||
$id = $fields['id'];
|
||||
}
|
||||
|
||||
$this->model->update(['status' => 2], $id);
|
||||
$data = [];
|
||||
}
|
||||
|
||||
$expired = $this->model->showAll([
|
||||
['expired_at', '<', $now],
|
||||
['status', '!=', 0]
|
||||
$expired_data = $this->model->showAll([
|
||||
['expired_at', '<', $now]
|
||||
]);
|
||||
if ($expired) {
|
||||
foreach ($expired as $fields) {
|
||||
if (is_array($fields)) {
|
||||
$id = $fields['id'];
|
||||
} else {
|
||||
$id = $expired['id'];
|
||||
}
|
||||
$this->model->update(['status' => 0], $id);
|
||||
if ($expired_data != false) {
|
||||
if (array_key_exists(0, $expired_data)) {
|
||||
$data = $expired_data;
|
||||
} else {
|
||||
$data[] = $expired_data;
|
||||
}
|
||||
|
||||
foreach ($data as $fields) {
|
||||
$id = $fields['id'];
|
||||
}
|
||||
|
||||
$this->model->update(['status' => 0], $id);
|
||||
$data = [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,13 +329,10 @@ class Posts
|
||||
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('/');
|
||||
|
@ -10,8 +10,8 @@ class Post extends \Core\Model
|
||||
[
|
||||
'id int(3) NOT NULL AUTO_INCREMENT',
|
||||
'category int(3) NOT NULL',
|
||||
'created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
'valid_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||
'created_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"',
|
||||
'valid_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"',
|
||||
'expired_at timestamp NOT NULL',
|
||||
'creator int(3) NOT NULL',
|
||||
'edited_at timestamp',
|
||||
@ -92,6 +92,7 @@ class Post extends \Core\Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = $db->prepare($sql);
|
||||
|
||||
if (count($conditions)) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
{% block body %}
|
||||
<main class="documentation">
|
||||
<section>
|
||||
<h1>Pengumuman {{ post.id }}</h1>
|
||||
<h1>Ubah Pengumuman</h1>
|
||||
|
||||
<form method="post">
|
||||
<div class="flex five grow">
|
||||
|
@ -13,7 +13,7 @@
|
||||
{% endif %}
|
||||
<a href="/logout" class="navy button" data-tooltip="Keluar"><i class="fa fa-sign-out" aria-hidden="true"></i> Keluar</a>
|
||||
{% else %}
|
||||
<a href="/login" class="navy hidden-hover" data-tooltip="Masuk">
|
||||
<a href="/login" class="navy hidden-hover button" data-tooltip="Masuk">
|
||||
<i class="fa fa-sign-in" aria-hidden="true"></i> Masuk
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -26,14 +26,14 @@
|
||||
|
||||
{% if privilege == "" %}
|
||||
{% if not posts %}
|
||||
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
|
||||
<h1 class="fitty">Tidak ada pengumuman</h1>
|
||||
<div style="background:#fff;text-align:left;max-width:100vw;padding:10vh 0 0;">
|
||||
<h1 class="fitty pengumuman">Tidak ada pengumuman</h1>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="slidr-div">
|
||||
{% for post in posts %}
|
||||
<div data-slidr="{{ post.id }}" style="color:{{ post.foreground }};background-color:{{ post.background }};width:100%;height:100vh;padding:15vh 0;">
|
||||
<div class="fitty" style="padding:0 5rem">
|
||||
<div data-slidr="{{ post.id }}" style="color:{{ post.foreground }};background-color:{{ post.background }};width:100vw;height:100vh;">
|
||||
<div style="padding:15vh 0">
|
||||
{{ post.content|rendermd }}
|
||||
</div>
|
||||
</div>
|
||||
@ -45,10 +45,10 @@
|
||||
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
|
||||
<div class="filter flex six-600 four grow">
|
||||
<div class="sixth-600 none"></div>
|
||||
<a href="/" class="navy noFitty">Semua</a>
|
||||
<a href="/?status=1" class="navy noFitty">Aktif</a>
|
||||
<a href="/?status=2" class="navy noFitty">Belum Aktif</a>
|
||||
<a href="/?status=0" class="navy noFitty">Nonaktif</a>
|
||||
<a href="/" class="navy" style="font-size:smaller;">Semua</a>
|
||||
<a href="/?status=1" class="navy" style="font-size:smaller;">Aktif</a>
|
||||
<a href="/?status=2" class="navy" style="font-size:smaller;">Belum Aktif</a>
|
||||
<a href="/?status=0" class="navy" style="font-size:smaller;">Nonaktif</a>
|
||||
<div class="sixth-600 none"></div>
|
||||
</div>
|
||||
<div class="flex four-900 full card-wrapper" style="padding: 0 .6em;">
|
||||
@ -91,6 +91,7 @@
|
||||
<div class="half-900">
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<input type="hidden" name="valid_at" value="##date##">
|
||||
<input type="hidden" name="status" value="1">
|
||||
<!-- Method -->
|
||||
<input type="hidden" name="_method" value="put">
|
||||
<!-- Token -->
|
||||
@ -112,16 +113,6 @@
|
||||
</main>
|
||||
|
||||
<script>
|
||||
fitty('.fitty', {
|
||||
minSize: 120,
|
||||
maxSize: 700
|
||||
});
|
||||
|
||||
fitty('.noFitty', {
|
||||
minSize: 15,
|
||||
maxSize: 15
|
||||
});
|
||||
|
||||
slidr.create('slidr-div', {
|
||||
controls: false,
|
||||
timing: {'linear': '0.5s ease-in'},
|
||||
|
@ -64,12 +64,28 @@
|
||||
|
||||
.fitty {
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
white-space: normal;
|
||||
line-height: 1em;
|
||||
padding-bottom: .1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#slidr-div p {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
}
|
||||
@media screen and (orientation: landscape) {
|
||||
#slidr-div p {
|
||||
font-size: 8vw;
|
||||
}
|
||||
}
|
||||
@media screen and (orientation: portrait) {
|
||||
#slidr-div p {
|
||||
font-size: 10vh;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: 'Lobster', cursive;
|
||||
font-size: x-large;
|
||||
@ -139,6 +155,14 @@
|
||||
.fitty > p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
nav {
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
.pengumuman {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -149,7 +173,6 @@
|
||||
{% block nav %}{% endblock %}
|
||||
</nav>
|
||||
<script src="/js/rome.js"></script>
|
||||
<script src="/js/fitty.min.js"></script>
|
||||
<script src="/js/slidr.min.js"></script>
|
||||
<script src="/js/simplemde.min.js"></script>
|
||||
{% block body %}
|
||||
@ -170,6 +193,5 @@
|
||||
}, 50);
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
5
public/js/fitty.min.js
vendored
5
public/js/fitty.min.js
vendored
@ -1,5 +0,0 @@
|
||||
/*
|
||||
* fitty v2.2.3 - Snugly resizes text to fit its parent container
|
||||
* Copyright (c) 2017 Rik Schennink <hello@rikschennink.nl> (http://rikschennink.nl/)
|
||||
*/
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.fitty=n.exports}}(this,function(e,t){"use strict";function n(e,t){var n=r({},E,t),i=e.map(function(e){var t=r({},n,{element:e});return z(t),F(t),{element:e,fit:w(t,a.DIRTY),unsubscribe:T(t)}});return s(),i}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e?n(o(document.querySelectorAll(e)),t):n([e],t)[0]}Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},o=function(e){return[].slice.call(e)},u=window,a={IDLE:0,DIRTY_CONTENT:1,DIRTY_LAYOUT:2,DIRTY:3},c=[],l=null,s="requestAnimationFrame"in u?function(){u.cancelAnimationFrame(l),l=u.requestAnimationFrame(function(){d(c.filter(function(e){return e.dirty}))})}:function(){},f=function(e){return function(){c.forEach(function(t){t.dirty=e}),s()}},d=function(e){e.filter(function(e){return!e.styleComputed}).forEach(function(e){e.styleComputed=v(e)}),e.filter(h).forEach(b),e.filter(m).forEach(p),e.forEach(y),e.forEach(S)},p=function(e){e.availableWidth=e.element.parentNode.clientWidth,e.currentWidth=e.element.scrollWidth,e.previousFontSize=e.currentFontSize,e.currentFontSize=Math.min(Math.max(e.minSize,e.availableWidth/e.currentWidth*e.previousFontSize),e.maxSize),e.whiteSpace=e.multiLine&&e.currentFontSize===e.minSize?"normal":"nowrap"},m=function(e){return e.dirty!==a.DIRTY_LAYOUT||e.dirty===a.DIRTY_LAYOUT&&e.element.parentNode.clientWidth!==e.availableWidth},v=function(e){var t=u.getComputedStyle(e.element,null);e.currentFontSize=parseInt(t.getPropertyValue("font-size"),10),e.display=t.getPropertyValue("display"),e.whiteSpace=t.getPropertyValue("white-space")},h=function(e){var t=!1;return/inline-/.test(e.display)||(t=!0,e.display="inline-block"),"nowrap"!==e.whiteSpace&&(t=!0,e.whiteSpace="nowrap"),t},y=function(e){b(e),e.dirty=a.IDLE},b=function(e){e.element.style.cssText="white-space:"+e.whiteSpace+";display:"+e.display+";font-size:"+e.currentFontSize+"px"},S=function(e){e.element.dispatchEvent(new CustomEvent("fit",{detail:{oldValue:e.previousFontSize,newValue:e.currentFontSize,scaleFactor:e.currentFontSize/e.previousFontSize}}))},w=function(e,t){return function(){e.dirty=t,s()}},z=function(e){e.newbie=!0,e.dirty=!0,c.push(e)},T=function(e){return function(){c=c.filter(function(t){return t.element!==e.element}),e.observeMutations&&e.observer.disconnect(),e.element.style.removeProperty("font-size")}},F=function(e){e.observeMutations&&(e.observer=new MutationObserver(w(e,a.DIRTY_CONTENT)),e.observer.observe(e.element,e.observeMutations))},D={subtree:!0,childList:!0,characterData:!0},E={minSize:16,maxSize:512,multiLine:!0,observeMutations:"MutationObserver"in u&&D},O=null,Y=function(){u.clearTimeout(O),O=u.setTimeout(f(a.DIRTY_LAYOUT),i.observeWindowDelay)},x=["resize","orientationchange"];Object.defineProperty(i,"observeWindow",{set:function(e){var t=(e?"add":"remove")+"EventListener";x.forEach(function(e){u[t](e,Y)})}}),i.observeWindow=!0,i.observeWindowDelay=100,i.fitAll=f(a.DIRTY),t.default=i,e.exports=t.default});
|
Loading…
Reference in New Issue
Block a user