Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNSメンバーのタイムライン(PC版のみ/コメントは未実装)に文字数カウント機能を追加 #28

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion apps/pc_frontend/modules/timeline/templates/_timelineAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@


<?php use_javascript('/opTimelinePlugin/js/timeline-loader.api.js') ?>
<?php use_javascript('/opTimelinePlugin/js/counter.js') ?>
<?php use_stylesheet('/opTimelinePlugin/css/bootstrap.css', 'last') ?>
<?php use_stylesheet('/opTimelinePlugin/css/timeline.css', 'last') ?>
<?php use_stylesheet('/opTimelinePlugin/css/counter.css', 'last') ?>

<script type="text/javascript">
$(function(){
Expand All @@ -31,10 +33,11 @@

<div class="timeline">
<div class="timeline-postform well">
<textarea id="timeline-textarea" class="input-xlarge" rows="1" placeholder="今何してる?"></textarea>
<textarea id="timeline-textarea" class="input-xlarge" rows="1" placeholder="今何してる?" onkeypress="return (this.value.length < 1139)"></textarea>
<div id="timeline-submit-loader"><?php echo op_image_tag('ajax-loader.gif', array()) ?></div>
<div id="timeline-submit-error"></div>
<div id="timeline-submit-area">
<span id="counter"></span>
<button id="timeline-submit-button" class="btn btn-primary timeline-submit">投稿</button>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions web/css/counter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#counter{
position: absolute;
top: 75px;
left: 340px;
font-size: 18px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
46 changes: 46 additions & 0 deletions web/js/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* OpenPNE - opTimelinePlugin Character Count Script 1.00
* Createed by Yudai Sonoda
* http://net-top.jp/
*
* The author is completely abandoned the right of this script.
* (It is also possible diversion to other projects)
*
* Built for jQuery library
* http://jquery.com/
* and opTimelinePlugin
* https://github.com/kashiwasan/
*
*/

$(function ()
{

// Configuration
var allowed = 140;
var warning = 25;
var textarea = $('#timeline-textarea');
var counter = $('#counter');

counter.text(allowed);
textarea.keyup(function ()
{
count = (allowed - $(this).val().length);
counter.text(count);
if (count <= warning && count >= 0) {
counter.css({
color : '#FFA500'
})
}
else if (count < 0) {
counter.css({
color : '#FF0000'
})
}
else {
counter.css({
color : '#000000'
})
}
});
});