summaryrefslogtreecommitdiff
path: root/views/new-post.php
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-01-15 11:11:18 -0800
committerAaron Parecki <aaron@parecki.com>2017-01-15 11:11:18 -0800
commit3bdcd009c8817df5275041d5c4d72c716d660456 (patch)
tree9ae64b8a88a6142d29134374218854a9fe158679 /views/new-post.php
parent8aa73596e81208a97ba7442833ab94aebed66338 (diff)
add tokenfield for tags
Diffstat (limited to 'views/new-post.php')
-rw-r--r--views/new-post.php39
1 files changed, 25 insertions, 14 deletions
diff --git a/views/new-post.php b/views/new-post.php
index 434f54e..7059c5e 100644
--- a/views/new-post.php
+++ b/views/new-post.php
@@ -32,7 +32,7 @@
</div>
<div class="form-group" id="form_tags">
- <label for="note_category">Tags (comma-separated list)</label>
+ <label for="note_category">Tags</label>
<input type="text" id="note_category" value="" class="form-control" placeholder="e.g. web, personal">
</div>
@@ -180,6 +180,7 @@ function saveNoteState() {
$("#syndication-container button.btn-info").each(function(i,btn){
state.syndications[$(btn).data('syndicate-to')] = 'selected';
});
+ console.log("saving",state);
localforage.setItem('current-note', state);
}
@@ -202,6 +203,9 @@ function restoreNoteState() {
}
});
$("#note_content").change();
+ activateTokenField();
+ } else {
+ activateTokenField();
}
});
}
@@ -238,6 +242,13 @@ function expandReplySection() {
$("#note_in_reply_to").change();
}
+function activateTokenField() {
+ $("#note_category").tokenfield({
+ createTokensOnBlur: true,
+ beautify: true
+ });
+}
+
$(function(){
var userHasSetCategory = false;
@@ -314,12 +325,12 @@ $(function(){
$("#note_content_remaining").addClass("pcheck"+tweet_check);
// If the user didn't enter any categories, add them from the post
- if(!userHasSetCategory) {
- var tags = $("#note_content").val().match(/#[a-z][a-z0-9]+/ig);
- if(tags) {
- $("#note_category").val(tags.map(function(tag){ return tag.replace('#',''); }).join(", "));
- }
- }
+ // if(!userHasSetCategory) {
+ // var tags = $("#note_content").val().match(/#[a-z][a-z0-9]+/ig);
+ // if(tags) {
+ // $("#note_category").val(tags.map(function(tag){ return tag.replace('#',''); }).join(", "));
+ // }
+ // }
});
$("#note_in_reply_to").on('change', function(){
@@ -338,13 +349,13 @@ $(function(){
if(data.canonical_reply_url != reply_to) {
$("#note_in_reply_to").val(data.canonical_reply_url);
}
- var category = csv_to_array($("#note_category").val());
- for(var i in data.entry.category) {
- if($.inArray(data.entry.category[i], category) == -1) {
- category.push(data.entry.category[i]);
- }
- }
- $("#note_category").val(category.join(", "));
+ // var category = csv_to_array($("#note_category").val());
+ // for(var i in data.entry.category) {
+ // if($.inArray(data.entry.category[i], category) == -1) {
+ // category.push(data.entry.category[i]);
+ // }
+ // }
+ // $("#note_category").val(category.join(", "));
if($("#note_content").val() == "" && data.mentions) {
var mentions = '';