mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-01-19 15:52:10 +01:00
Almost working in inline bookmark edit/add.
This commit is contained in:
parent
18372c5220
commit
19925df098
@ -34,10 +34,10 @@ if(isset($_POST['url'])) {
|
|||||||
|
|
||||||
if(isset($_POST['record_id']) && is_numeric($_POST['record_id']) ) { //EDIT
|
if(isset($_POST['record_id']) && is_numeric($_POST['record_id']) ) { //EDIT
|
||||||
$bm = $_POST['record_id'];
|
$bm = $_POST['record_id'];
|
||||||
OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['desc'], $pub);
|
OC_Bookmarks_Bookmarks::editBookmark($bm, $_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $_POST['title'], $tags, $_POST['desc'], $pub);
|
$bm = OC_Bookmarks_Bookmarks::addBookmark($_POST['url'], $_POST['title'], $tags, $_POST['description'], $pub);
|
||||||
}
|
}
|
||||||
OCP\JSON::success(array('id'=>$bm));
|
OCP\JSON::success(array('id'=>$bm));
|
||||||
exit();
|
exit();
|
||||||
|
@ -316,6 +316,12 @@ li:hover em { display : none; }
|
|||||||
width: 80%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bookmark_single_form {
|
||||||
|
padding-top: 1em;
|
||||||
|
border-bottom: 1px solid #DDD;
|
||||||
|
padding-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
.bookmark_single_form .tagit{
|
.bookmark_single_form .tagit{
|
||||||
width: 80%;
|
width: 80%;
|
||||||
box-shadow: 0 1px 1px #FFFFFF, 0 1px 0 #BBBBBB inset;
|
box-shadow: 0 1px 1px #FFFFFF, 0 1px 0 #BBBBBB inset;
|
||||||
|
@ -193,16 +193,17 @@ function createEditDialog(record){
|
|||||||
|
|
||||||
function addBookmark(event) {
|
function addBookmark(event) {
|
||||||
url = $('#add_url').val();
|
url = $('#add_url').val();
|
||||||
createEditDialog({ url: url});
|
|
||||||
$('#add_url').val('');
|
$('#add_url').val('');
|
||||||
|
bookmark = { url: url, description:'', title:''};
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'POST',
|
||||||
url: OC.filePath('bookmarks', 'ajax', 'getInfos.php'),
|
url: OC.filePath('bookmarks', 'ajax', 'editBookmark.php'),
|
||||||
data: { type: 'url_info', url: url},
|
data: bookmark,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if (data.status == 'success') {
|
if (data.status == 'success') {
|
||||||
$('.ui-dialog').data('bookmark_dialog').setTitle(data.title);
|
bookmark.id = data.id;
|
||||||
|
bookmark.added_date = new Date();
|
||||||
|
updateBookmarksList(bookmark, 'prepend');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -213,7 +214,7 @@ function delBookmark(event) {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'),
|
url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'),
|
||||||
data: 'id=' + record.data('id'),
|
data: { id: record.data('id') },
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if (data.status == 'success') {
|
if (data.status == 'success') {
|
||||||
record.remove();
|
record.remove();
|
||||||
@ -228,14 +229,12 @@ function delBookmark(event) {
|
|||||||
function editBookmark(event) {
|
function editBookmark(event) {
|
||||||
var record = $(this).parent().parent();
|
var record = $(this).parent().parent();
|
||||||
bookmark = record.data('record');
|
bookmark = record.data('record');
|
||||||
console.log(bookmark);
|
|
||||||
//createEditDialog(bookmark);
|
//createEditDialog(bookmark);
|
||||||
html = tmpl("item_form_tmpl", bookmark);
|
html = tmpl("item_form_tmpl", bookmark);
|
||||||
|
|
||||||
record.after(html);
|
record.after(html);
|
||||||
record.hide();
|
record.hide();
|
||||||
rec_form = record.next().find('form');
|
rec_form = record.next().find('form');
|
||||||
console.log(rec_form);
|
|
||||||
rec_form.find('.bookmark_form_tags ul').tagit({
|
rec_form.find('.bookmark_form_tags ul').tagit({
|
||||||
allowSpaces: true,
|
allowSpaces: true,
|
||||||
availableTags: fullTags,
|
availableTags: fullTags,
|
||||||
@ -251,6 +250,7 @@ function cancelBookmark(event) {
|
|||||||
rec_form.prev().show();
|
rec_form.prev().show();
|
||||||
rec_form.remove();
|
rec_form.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitBookmark(event) {
|
function submitBookmark(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
form_values = $(this).serialize();
|
form_values = $(this).serialize();
|
||||||
@ -268,8 +268,10 @@ function submitBookmark(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function updateBookmarksList(bookmark) {
|
|
||||||
var tags = bookmark.tags;
|
function updateBookmarksList(bookmark, position='append') {
|
||||||
|
bookmark = $.extend({title:'', description:'', added_date: new Date('now'), tags:[] }, bookmark);
|
||||||
|
tags = bookmark.tags;
|
||||||
var taglist = '';
|
var taglist = '';
|
||||||
for ( var i=0, len=tags.length; i<len; ++i ){
|
for ( var i=0, len=tags.length; i<len; ++i ){
|
||||||
if(tags[i] != '')
|
if(tags[i] != '')
|
||||||
@ -278,10 +280,11 @@ function updateBookmarksList(bookmark) {
|
|||||||
if(!hasProtocol(bookmark.url)) {
|
if(!hasProtocol(bookmark.url)) {
|
||||||
bookmark.url = 'http://' + bookmark.url;
|
bookmark.url = 'http://' + bookmark.url;
|
||||||
}
|
}
|
||||||
if(bookmark.title == '') bookmark.title = bookmark.url;
|
|
||||||
|
|
||||||
bookmark.added_date = new Date();
|
if(bookmark.added) {
|
||||||
bookmark.added_date.setTime(parseInt(bookmark.added)*1000);
|
bookmark.added_date.setTime(parseInt(bookmark.added)*1000);
|
||||||
|
}
|
||||||
|
|
||||||
if(bookmark_view == 'image') { //View in images
|
if(bookmark_view == 'image') { //View in images
|
||||||
service_url = formatString(shot_provider, {url: encodeEntities(bookmark.url), title: bookmark.title, width: 200});
|
service_url = formatString(shot_provider, {url: encodeEntities(bookmark.url), title: bookmark.title, width: 200});
|
||||||
$('.bookmarks_list').append(
|
$('.bookmarks_list').append(
|
||||||
@ -308,30 +311,22 @@ function updateBookmarksList(bookmark) {
|
|||||||
}
|
}
|
||||||
$('div[data-id="'+ bookmark.id +'"] a.bookmark_tag').bind('click', addFilterTag);
|
$('div[data-id="'+ bookmark.id +'"] a.bookmark_tag').bind('click', addFilterTag);
|
||||||
}
|
}
|
||||||
else { // View in text
|
else {
|
||||||
$('.bookmarks_list').append(
|
html = tmpl("item_tmpl", bookmark);
|
||||||
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
|
if(position == "prepend") {
|
||||||
'<p class="bookmark_actions">' +
|
$('.bookmarks_list').prepend(html);
|
||||||
'<span class="bookmark_edit">' +
|
} else {
|
||||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
|
$('.bookmarks_list').append(html);
|
||||||
'</span>' +
|
|
||||||
'<span class="bookmark_delete">' +
|
|
||||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
|
|
||||||
'</span> ' +
|
|
||||||
'</p>' +
|
|
||||||
'<p class="bookmark_title">'+
|
|
||||||
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +
|
|
||||||
'</p>' +
|
|
||||||
'<p class="bookmark_url"><a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.url) + '</a></p>' +
|
|
||||||
'<p class="bookmark_date">' + formatDate(bookmark.added_date) + '</p>' +
|
|
||||||
'<p class="bookmark_desc">'+ encodeEntities(bookmark.description) + '</p>' +
|
|
||||||
'</div>'
|
|
||||||
);
|
|
||||||
$('div[data-id="'+ bookmark.id +'"]').data('record', bookmark);
|
|
||||||
if(taglist != '') {
|
|
||||||
$('div[data-id="'+ bookmark.id +'"]').append('<p class="bookmark_tags">' + taglist + '</p>');
|
|
||||||
}
|
}
|
||||||
$('div[data-id="'+ bookmark.id +'"] a.bookmark_tag').bind('click', addFilterTag);
|
line = $('div[data-id="'+ bookmark.id +'"]');
|
||||||
|
line.data('record', bookmark);
|
||||||
|
if(taglist != '') {
|
||||||
|
line.append('<p class="bookmark_tags">' + taglist + '</p>');
|
||||||
|
}
|
||||||
|
line.find('a.bookmark_tag').bind('click', addFilterTag);
|
||||||
|
line.find('.bookmark_link').click(recordClick);
|
||||||
|
line.find('.bookmark_delete').click(delBookmark);
|
||||||
|
line.find('.bookmark_edit').click(editBookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<textarea name="desc" class="desc" value="<?php echo $_['bookmark']['desc']; ?>" placeholder="<?php echo $l->t('Description of the page');?>"></textarea>
|
<textarea name="description" class="desc" value="<?php echo $_['bookmark']['desc']; ?>" placeholder="<?php echo $l->t('Description of the page');?>"></textarea>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="bookmark_title">
|
<p class="bookmark_title">
|
||||||
<a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link"><%= encodeEntities(title) %></a>
|
<a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link"><%= encodeEntities(title == '' ? url : title ) %></a>
|
||||||
</p>
|
</p>
|
||||||
<p class="bookmark_url"><a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link"><%= encodeEntities(url) %></a></p>
|
<p class="bookmark_url"><a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link"><%= encodeEntities(url) %></a></p>
|
||||||
<p class="bookmark_date"><%= formatDate(added_date) %></p>
|
<p class="bookmark_date"><%= formatDate(added_date) %></p>
|
||||||
@ -90,7 +90,7 @@
|
|||||||
<li><%=tags[i]%></li>
|
<li><%=tags[i]%></li>
|
||||||
<% } %>
|
<% } %>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p class="bookmark_form_desc"><textarea name="desc" placeholder="<?php echo $l->t('Description of the page');?>"><%= description%></textarea> </p>
|
<p class="bookmark_form_desc"><textarea name="description" placeholder="<?php echo $l->t('Description of the page');?>"><%= description%></textarea> </p>
|
||||||
<p class="bookmark_form_submit"><button class="reset" ><?php echo $l->t('Cancel');?></button><input type="submit" value="<?php echo $l->t('Save');?>"></p>
|
<p class="bookmark_form_submit"><button class="reset" ><?php echo $l->t('Cancel');?></button><input type="submit" value="<?php echo $l->t('Save');?>"></p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user