mirror of
https://github.com/owncloud/bookmarks.git
synced 2024-11-29 04:24:11 +01:00
First step for re-adding the Add button
This commit is contained in:
parent
c156399c60
commit
d1fa11e936
15
addBm.php
15
addBm.php
@ -31,13 +31,12 @@ OCP\App::checkAppEnabled('bookmarks');
|
|||||||
require_once('bookmarksHelper.php');
|
require_once('bookmarksHelper.php');
|
||||||
|
|
||||||
|
|
||||||
|
$url ='';
|
||||||
|
if(isset($_GET['url']) ){
|
||||||
|
$url = $_GET['url'];
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($_GET['url']) || trim($_GET['url']) == '') {
|
if(isset($_POST['url'])) {
|
||||||
header("HTTP/1.0 404 Not Found");
|
|
||||||
$tmpl = new OCP\Template( '', '404', 'guest' );
|
|
||||||
$tmpl->printPage();
|
|
||||||
exit;
|
|
||||||
}elseif(isset($_POST['url'])) {
|
|
||||||
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
|
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
|
||||||
$pub = isset($_POST['is_public']) ? true : false;
|
$pub = isset($_POST['is_public']) ? true : false;
|
||||||
$bm = addBookmark($_POST['url'], $_POST['title'], implode(',',$tags),$_POST['desc'], $pub);
|
$bm = addBookmark($_POST['url'], $_POST['title'], implode(',',$tags),$_POST['desc'], $pub);
|
||||||
@ -51,7 +50,7 @@ OCP\Util::addStyle('bookmarks', 'bookmarks');
|
|||||||
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
|
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
|
||||||
|
|
||||||
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
|
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
|
||||||
$datas = getURLMetadata($_GET['url']);
|
$datas = getURLMetadata($url);
|
||||||
$title = isset($datas['title']) ? $datas['title'] : '';
|
$title = isset($datas['title']) ? $datas['title'] : '';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -59,7 +58,7 @@ else{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bm = array('title'=> $title,
|
$bm = array('title'=> $title,
|
||||||
'url'=> $_GET['url'],
|
'url'=> $url,
|
||||||
'tags'=> array(),
|
'tags'=> array(),
|
||||||
'desc'=>'',
|
'desc'=>'',
|
||||||
'is_public'=>0,
|
'is_public'=>0,
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#addBm {
|
.addBm {
|
||||||
background: none repeat scroll 0 0 #F8F8F8;
|
background: none repeat scroll 0 0 #F8F8F8;
|
||||||
border-radius: 0.5em 0.5em 0.5em 0.5em;
|
border-radius: 0.5em 0.5em 0.5em 0.5em;
|
||||||
color: #555555;
|
color: #555555;
|
||||||
@ -112,35 +112,35 @@
|
|||||||
.bm_desc {
|
.bm_desc {
|
||||||
width:90%;
|
width:90%;
|
||||||
}
|
}
|
||||||
#addBm h1 {
|
.addBm h1 {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
border-bottom: 1px solid #BABABA;
|
border-bottom: 1px solid #BABABA;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#addBm #url {
|
.addBm .url {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#addBm fieldset > ul > li {
|
.addBm fieldset > ul > li {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
#addBm label {
|
.addBm label {
|
||||||
display:block;
|
display:block;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
#addBm #is_public_label {
|
.addBm .is_public_label {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|
||||||
}
|
}
|
||||||
#addBm fieldset input[type="text"], #addBm textarea {
|
.addBm fieldset input[type="text"], .addBm textarea {
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
#addBm textarea{
|
.addBm textarea{
|
||||||
min-width:250px;
|
min-width:250px;
|
||||||
/* min-height: 70px; */
|
/* min-height: 70px; */
|
||||||
}
|
}
|
||||||
#addBm #close_btn
|
.addBm .close_btn
|
||||||
{
|
{
|
||||||
/* background-color: #EEEEEE; */
|
/* background-color: #EEEEEE; */
|
||||||
height: 18px;
|
height: 18px;
|
||||||
@ -149,14 +149,15 @@
|
|||||||
float:right;
|
float:right;
|
||||||
width: 19px;
|
width: 19px;
|
||||||
}
|
}
|
||||||
#addBm .submit {
|
.addBm .submit {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#addBm ul.tagit { background:white; }
|
.addBm ul.tagit { background:white; }
|
||||||
|
|
||||||
#addBm input.ui-autocomplete-input, #tag_filter input.ui-autocomplete-input{
|
.addBm input.ui-autocomplete-input, #tag_filter input.ui-autocomplete-input{
|
||||||
box-shadow:none;
|
box-shadow:none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-autocomplete {
|
.ui-autocomplete {
|
||||||
|
12
index.php
12
index.php
@ -31,6 +31,8 @@ OCP\App::setActiveNavigationEntry( 'bookmarks_index' );
|
|||||||
|
|
||||||
OCP\Util::addscript('bookmarks','bookmarks');
|
OCP\Util::addscript('bookmarks','bookmarks');
|
||||||
OCP\Util::addStyle('bookmarks', 'bookmarks');
|
OCP\Util::addStyle('bookmarks', 'bookmarks');
|
||||||
|
OCP\Util::addscript('bookmarks','addBm');
|
||||||
|
|
||||||
|
|
||||||
OCP\Util::addscript('bookmarks','tag-it');
|
OCP\Util::addscript('bookmarks','tag-it');
|
||||||
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
|
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
|
||||||
@ -42,7 +44,17 @@ foreach($qtags as $tag) {
|
|||||||
$tags[] = $tag['tag'];
|
$tags[] = $tag['tag'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bm = array('title'=> '',
|
||||||
|
'url'=> '',
|
||||||
|
'tags'=> array(),
|
||||||
|
'desc'=>'',
|
||||||
|
'is_public'=>0,
|
||||||
|
);
|
||||||
|
|
||||||
$tmpl = new OCP\Template( 'bookmarks', 'list', 'user' );
|
$tmpl = new OCP\Template( 'bookmarks', 'list', 'user' );
|
||||||
|
|
||||||
|
$tmpl->assign('bookmark', $bm);
|
||||||
|
|
||||||
$tmpl->assign('req_tag',isset($_GET['tag']) ? $_GET['tag'] : '');
|
$tmpl->assign('req_tag',isset($_GET['tag']) ? $_GET['tag'] : '');
|
||||||
$tmpl->assign('tags', json_encode($tags), false);
|
$tmpl->assign('tags', json_encode($tags), false);
|
||||||
$tmpl->assign('shared', $shared);
|
$tmpl->assign('shared', $shared);
|
||||||
|
90
js/addBm.js
90
js/addBm.js
@ -1,42 +1,66 @@
|
|||||||
$(document).ready(function() {
|
(function($){
|
||||||
$('#bookmark_add_submit').click(addBookmark);
|
$.bookmark_dialog = function(el, options){
|
||||||
$('#url-ro img').click(editUrl);
|
// To avoid scope issues, use 'base' instead of 'this'
|
||||||
$('#url').keypress(changeUrl);
|
// to reference this class from internal events and functions.
|
||||||
$('#addBm').submit(bookletSubmit);
|
var base = this;
|
||||||
$('#tags').tagit({
|
|
||||||
allowSpaces: true,
|
|
||||||
availableTags: sampleTags
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function addBookmark(event) {
|
// Access to jQuery and DOM versions of element
|
||||||
var url = $('#bookmark_add_url').val();
|
base.$el = $(el);
|
||||||
var tags = $('#bookmark_add_tags').val();
|
base.el = el;
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
// Add a reverse reference to the DOM object
|
||||||
url: 'ajax/addBookmark.php',
|
base.$el.data("bookmark_dialog", base);
|
||||||
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
|
|
||||||
success: function(data){
|
base.form_submit = function search_form_submit(event)
|
||||||
window.close();
|
{
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function editUrl(event) {
|
|
||||||
$('#url').slideToggle();
|
|
||||||
}
|
|
||||||
function changeUrl(event) {
|
|
||||||
$('#url-ro code').text($('#url').val());
|
|
||||||
}
|
|
||||||
function bookletSubmit(event) {
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: $('#addBm').attr('action'),
|
url: $(this).attr('action'),
|
||||||
data: $('#addBm').serialize(),
|
data: $(this).serialize(),
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if(data.status == 'success'){
|
if(data.status == 'success'){
|
||||||
self.close();
|
base.options['on_success'](data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.edit_url = function (event) {
|
||||||
|
base.$el.find('.url_input').slideToggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.change_url = function (event) {
|
||||||
|
base.$el.find('.url-ro code').text(base.$el.find('.url_input').val());
|
||||||
|
}
|
||||||
|
|
||||||
|
base.init = function(){
|
||||||
|
base.options = $.extend({},$.bookmark_dialog.defaultOptions, options);
|
||||||
|
base.$el.find('form').bind('submit.addBmform',base.form_submit);
|
||||||
|
base.$el.find('.url-ro img').bind('click',base.edit_url);
|
||||||
|
base.$el.find('.url_input').bind('keypress',base.change_url);
|
||||||
|
// Init Tagging thing
|
||||||
|
base.$el.find('.tags').tagit({
|
||||||
|
allowSpaces: true,
|
||||||
|
availableTags: fullTags
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
base.init();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$.bookmark_dialog.defaultOptions = {
|
||||||
|
on_success: function(){}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.bookmark_dialog = function(options){
|
||||||
|
return this.each(function(){
|
||||||
|
(new $.bookmark_dialog(this, options));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
@ -43,6 +43,7 @@ function updateTagsList(tag) {
|
|||||||
function filterTagsChanged()
|
function filterTagsChanged()
|
||||||
{
|
{
|
||||||
$('#bookmarkFilterTag').val($('#tag_filter input:hidden').val());
|
$('#bookmarkFilterTag').val($('#tag_filter input:hidden').val());
|
||||||
|
console.log($('#bookmarkFilterTag').val());
|
||||||
bookmarks_page = 0;
|
bookmarks_page = 0;
|
||||||
$('.bookmarks_list').empty();
|
$('.bookmarks_list').empty();
|
||||||
getBookmarks();
|
getBookmarks();
|
||||||
@ -103,7 +104,25 @@ function getBookmarks() {
|
|||||||
// addOrEditBookmark() to make .js file more compact.
|
// addOrEditBookmark() to make .js file more compact.
|
||||||
|
|
||||||
function addOrEditBookmark(event) {
|
function addOrEditBookmark(event) {
|
||||||
var id = $('#bookmark_add_id').val();
|
dialog_html = $('#edit_dialog').html();
|
||||||
|
var dialog = $(dialog_html).dialog({
|
||||||
|
width : 620,
|
||||||
|
height: 450,
|
||||||
|
title: t('bookmark', 'Edit bookmark'),
|
||||||
|
modal: true,
|
||||||
|
close : function(event, ui) {
|
||||||
|
$(this).dialog('destroy').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.ui-dialog').bookmark_dialog({
|
||||||
|
'on_success': function(){
|
||||||
|
dialog.dialog('destroy').remove();
|
||||||
|
filterTagsChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*var id = $('#bookmark_add_id').val();
|
||||||
var url = encodeEntities($('#bookmark_add_url').val());
|
var url = encodeEntities($('#bookmark_add_url').val());
|
||||||
var title = encodeEntities($('#bookmark_add_title').val());
|
var title = encodeEntities($('#bookmark_add_title').val());
|
||||||
var tags = encodeEntities($('#bookmark_add_tags').val());
|
var tags = encodeEntities($('#bookmark_add_tags').val());
|
||||||
@ -143,7 +162,7 @@ function addOrEditBookmark(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function delBookmark(event) {
|
function delBookmark(event) {
|
||||||
|
@ -1,26 +1,36 @@
|
|||||||
<form id="addBm" method="post" action="<?php OCP\Util::linkToAbsolute('bookmarks', 'addBm.php');?>">
|
<form class="addBm" method="post" action="<?php echo OCP\Util::linkToAbsolute('bookmarks', 'addBm.php');?>">
|
||||||
|
<?php if(!isset($embedded) || !$embedded):?>
|
||||||
|
<script>
|
||||||
|
var fullTags = <?php echo $_['tags'];?>;
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('body').bookmark_dialog({
|
||||||
|
'on_success': function(){ self.close(); }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<h1><?php echo $l->t('Add a bookmark');?></h1>
|
<h1><?php echo $l->t('Add a bookmark');?></h1>
|
||||||
<div id="close_btn"><a href="javascript:self.close()" class="ui-icon ui-icon-closethick"><?php echo $l->t('Close');?></a></div>
|
<div class="close_btn"><a href="javascript:self.close()" class="ui-icon ui-icon-closethick"><?php echo $l->t('Close');?></a></div>
|
||||||
|
<?php endif;?>
|
||||||
<fieldset class="bm_desc">
|
<fieldset class="bm_desc">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<label for="title"><strong><?php echo $l->t('Title');?></strong></label>
|
<label for="title"><strong><?php echo $l->t('Title');?></strong></label>
|
||||||
<input type="text" name="title" id="title" value="<?php echo $_['bookmark']['title']; ?>" placeholder="<?php echo $l->t('The title of the page');?>" />
|
<input type="text" name="title" class="title" value="<?php echo $_['bookmark']['title']; ?>" placeholder="<?php echo $l->t('The title of the page');?>" />
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label for="url"><strong><?php echo $l->t('Address');?></strong></label>
|
<label for="url"><strong><?php echo $l->t('Address');?></strong></label>
|
||||||
<div id="url-ro">
|
<div class="url-ro">
|
||||||
<code><?php echo $_['bookmark']['url']; ?></code>
|
<code><?php echo $_['bookmark']['url']; ?></code>
|
||||||
<img class="svg action" src="<?php echo image_path('core','actions/rename.svg')?>"
|
<img class="svg action" src="<?php echo image_path('core','actions/rename.svg')?>"
|
||||||
alt="<?php echo $l->t('Edit');?>" title="<?php echo $l->t('Edit');?>" />
|
alt="<?php echo $l->t('Edit');?>" title="<?php echo $l->t('Edit');?>" />
|
||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" value="<?php echo $_['bookmark']['url']; ?>" placeholder="<?php echo $l->t('The address of the page');?>" />
|
<input type="text" name="url" class="url_input" value="<?php echo $_['bookmark']['url']; ?>" placeholder="<?php echo $l->t('The address of the page');?>" />
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label for="tags"><strong><?php echo $l->t('Tags');?></strong></label>
|
<label for="tags"><strong><?php echo $l->t('Tags');?></strong></label>
|
||||||
<ul id="tags" >
|
<ul class="tags" >
|
||||||
<?php foreach($_['bookmark']['tags'] as $tag):?>
|
<?php foreach($_['bookmark']['tags'] as $tag):?>
|
||||||
<li><?php echo $tag;?></li>
|
<li><?php echo $tag;?></li>
|
||||||
<?php endforeach;?>
|
<?php endforeach;?>
|
||||||
@ -29,19 +39,16 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<label for="desc"><strong><?php echo $l->t('Description');?></strong></label>
|
<label for="desc"><strong><?php echo $l->t('Description');?></strong></label>
|
||||||
<textarea name="desc" id="desc" value="<?php echo $_['bookmark']['desc']; ?>" placeholder="<?php echo $l->t('Description of the page');?>"></textarea>
|
<textarea name="desc" class="desc" value="<?php echo $_['bookmark']['desc']; ?>" placeholder="<?php echo $l->t('Description of the page');?>"></textarea>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<input type="submit" class="submit" value="<?php echo $l->t("Submit");?>" />
|
<input type="submit" class="submit" value="<?php echo $l->t("Submit");?>" />
|
||||||
<input type="checkbox" <?php if($_['bookmark']['is_public']){echo 'checked="checked"';} ?> id="is_public" name="is_public">
|
<input type="checkbox" <?php if($_['bookmark']['is_public']){echo 'checked="checked"';} ?> id="is_public" name="is_public">
|
||||||
<label for="is_public" id="is_public_label"><?php echo $l->t("Make this link public");?></label>
|
<label for="is_public" class="is_public_label"><?php echo $l->t("Make this link public");?></label>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<script>
|
|
||||||
var sampleTags = <?php echo $_['tags'];?>;
|
|
||||||
</script>
|
|
||||||
</form>
|
</form>
|
@ -44,6 +44,7 @@
|
|||||||
<div id="firstrun" style="display: none;">
|
<div id="firstrun" style="display: none;">
|
||||||
<?php
|
<?php
|
||||||
echo $l->t('You have no bookmarks');
|
echo $l->t('You have no bookmarks');
|
||||||
|
$embedded = true;
|
||||||
require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
|
require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
|
||||||
createBookmarklet();
|
createBookmarklet();
|
||||||
?>
|
?>
|
||||||
@ -51,3 +52,6 @@
|
|||||||
<script>
|
<script>
|
||||||
var fullTags = <?php echo $_['tags'];?>;
|
var fullTags = <?php echo $_['tags'];?>;
|
||||||
</script>
|
</script>
|
||||||
|
<div id="edit_dialog" style="display:none;">
|
||||||
|
<?php include 'addBm.php';?>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user