1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-11-29 04:24:11 +01:00

Put some js html constructions in a template file for bookmarks

This commit is contained in:
Brice Maron 2012-10-21 11:37:30 +00:00
parent 7b44736d24
commit 678073e2a7
3 changed files with 95 additions and 86 deletions

View File

@ -91,18 +91,8 @@ function addFilterTag(event) {
}
function updateTagsList(tag) {
$('.tag_list').append('<li><a href="" class="tag">'+tag['tag']+'</a>'+
'<p class="tags_actions">'+
'<span class="tag_edit">'+
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">'+
'</span>'+
'<span class="tag_delete">'+
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">'+
'</span>'+
'</p>'+
'<em>'+tag['nbr']+'</em>'+
'</li>');
html = tmpl("tag_tmpl", tag);
$('.tag_list').append(html);
}
function filterTagsChanged()
@ -290,24 +280,9 @@ function updateBookmarksList(bookmark, position) {
if(bookmark_view == 'image') { //View in images
service_url = formatString(shot_provider, {url: encodeEntities(bookmark.url), title: bookmark.title, width: 200});
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="shot"><img src="'+ service_url +'"></p>'+
'<p class="bookmark_actions">' +
'<span class="bookmark_edit">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
'</span>' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'</p>' +
'<p class="bookmark_title">'+
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +
'</p>' +
'<p class="bookmark_desc">'+ encodeEntities(bookmark.description) + '</p>' +
'<p class="bookmark_url"><a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.url) + '</a></p>' +
'</div>'
);
bookmark['service_url'] = service_url;
html = tmpl("img_item_tmpl", bookmark);
$('.bookmarks_list').append(html);
$('div[data-id="'+ bookmark.id +'"]').data('record', bookmark);
if(taglist != '') {
$('div[data-id="'+ bookmark.id +'"]').append('<p class="bookmark_tags">' + taglist + '</p>');

89
templates/js_tpl.php Normal file
View File

@ -0,0 +1,89 @@
<script type="text/html" id="item_tmpl">
<div class="bookmark_single" data-id="<%= id %>">
<p class="bookmark_actions">
<span class="bookmark_edit">
<img class="svg" src="<?php echo OCP\image_path("", "actions/rename.svg");?>"
title="<?php echo $l->t('Edit');?>">
</span>
<span class="bookmark_delete">
<img class="svg" src="<?php echo OCP\image_path("", "actions/delete.svg");?>"
title="<?php echo $l->t('Delete');?>">
</span>&nbsp;
</p>
<p class="bookmark_title">
<a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link">
<%= encodeEntities(title == '' ? url : title ) %>
</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_desc"><%= encodeEntities(description)%> </p>
</div>
</script>
<script type="text/html" id="item_form_tmpl">
<div class="bookmark_single_form" data-id="<%= id %>">
<form method="post" action="<?php echo OCP\Util::linkTo('bookmarks', 'ajax/editBookmark.php');?>" >
<input type="hidden" name="record_id" value="<%= id %>" />
<p class="bookmark_form_title">
<input type="text" name="title" placeholder="<?php echo $l->t('The title of the page');?>"
value="<%= title %>"/>
</p>
<p class="bookmark_form_url">
<input type="text" name="url" placeholder="<?php echo $l->t('The address of the page');?>"
value="<%= encodeEntities(url)%>"/>
</p>
<div class="bookmark_form_tags"><ul>
<% for ( var i = 0; i < tags.length; i++ ) { %>
<li><%=tags[i]%></li>
<% } %>
</ul></div>
<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>
</form>
</div>
</script>
<script type="text/html" id="tag_tmpl">
<li><a href="" class="tag"><%= tag %></a>
<p class="tags_actions">
<span class="tag_edit">
<img class="svg" src="<?php echo OCP\image_path("", "actions/rename.svg");?>"
title="<?php echo $l->t('Edit');?>">
</span>
<span class="tag_delete">
<img class="svg" src="<?php echo OCP\image_path("", "actions/delete.svg");?>"
title="<?php echo $l->t('Delete');?>">
</span>
</p>
<em><%= nbr %></em>
</li>
</script>
<script type="text/html" id="img_item_tmpl">
<div class="bookmark_single" data-id="<%= id %>" >
<p class="shot"><img src="<%= service_url %>"></p>
<p class="bookmark_actions">
<span class="bookmark_edit">
<img class="svg" src="<?php echo OCP\image_path("", "actions/rename.svg");?>"
title="<?php echo $l->t('Edit');?>">
</span>
<span class="bookmark_delete">
<img class="svg" src="<?php echo OCP\image_path("", "actions/delete.svg");?>"
title="<?php echo $l->t('Delete');?>">
</span>&nbsp;
</p>
<p class="bookmark_title">
<a href="<%= encodeEntities(url)%>" target="_blank" class="bookmark_link"><%= encodeEntities(title)%></a>
</p>
<p class="bookmark_desc"><%= encodeEntities(description)%></p>
<p class="bookmark_url"><a href="<%= encodeEntities(url)%>" target="_blank" class="bookmark_link"><%= encodeEntities(url)%></a></p>
</div>
</script>

View File

@ -54,59 +54,4 @@
<script type="text/html" id="edit_dialog_tmpl">
<?php require 'addBm.php';?>
</script>
<script type="text/html" id="item_tmpl">
<div class="bookmark_single" data-id="<%= id %>">
<p class="bookmark_actions">
<span class="bookmark_edit">
<img class="svg" src="<?php echo OCP\image_path("", "actions/rename.svg");?>"
title="<?php echo $l->t('Edit');?>">
</span>
<span class="bookmark_delete">
<img class="svg" src="<?php echo OCP\image_path("", "actions/delete.svg");?>"
title="<?php echo $l->t('Delete');?>">
</span>&nbsp;
</p>
<p class="bookmark_title">
<a href="<%= encodeEntities(url) %>" target="_blank" class="bookmark_link">
<%= encodeEntities(title == '' ? url : title ) %>
</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_desc"><%= encodeEntities(description)%> </p>
</div>
</script>
<script type="text/html" id="item_form_tmpl">
<div class="bookmark_single_form" data-id="<%= id %>">
<form method="post" action="<?php echo OCP\Util::linkTo('bookmarks', 'ajax/editBookmark.php');?>" >
<input type="hidden" name="record_id" value="<%= id %>" />
<p class="bookmark_form_title">
<input type="text" name="title" placeholder="<?php echo $l->t('The title of the page');?>"
value="<%= title %>"/>
</p>
<p class="bookmark_form_url">
<input type="text" name="url" placeholder="<?php echo $l->t('The address of the page');?>"
value="<%= encodeEntities(url)%>"/>
</p>
<div class="bookmark_form_tags"><ul>
<% for ( var i = 0; i < tags.length; i++ ) { %>
<li><%=tags[i]%></li>
<% } %>
</ul></div>
<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>
</form>
</div>
</script>
<?php require 'js_tpl.php';?>