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');
|
||||
|
||||
|
||||
$url ='';
|
||||
if(isset($_GET['url']) ){
|
||||
$url = $_GET['url'];
|
||||
}
|
||||
|
||||
if(!isset($_GET['url']) || trim($_GET['url']) == '') {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
$tmpl = new OCP\Template( '', '404', 'guest' );
|
||||
$tmpl->printPage();
|
||||
exit;
|
||||
}elseif(isset($_POST['url'])) {
|
||||
if(isset($_POST['url'])) {
|
||||
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
|
||||
$pub = isset($_POST['is_public']) ? true : false;
|
||||
$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');
|
||||
|
||||
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
|
||||
$datas = getURLMetadata($_GET['url']);
|
||||
$datas = getURLMetadata($url);
|
||||
$title = isset($datas['title']) ? $datas['title'] : '';
|
||||
}
|
||||
else{
|
||||
@ -59,7 +58,7 @@ else{
|
||||
}
|
||||
|
||||
$bm = array('title'=> $title,
|
||||
'url'=> $_GET['url'],
|
||||
'url'=> $url,
|
||||
'tags'=> array(),
|
||||
'desc'=>'',
|
||||
'is_public'=>0,
|
||||
|
@ -99,7 +99,7 @@
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#addBm {
|
||||
.addBm {
|
||||
background: none repeat scroll 0 0 #F8F8F8;
|
||||
border-radius: 0.5em 0.5em 0.5em 0.5em;
|
||||
color: #555555;
|
||||
@ -112,35 +112,35 @@
|
||||
.bm_desc {
|
||||
width:90%;
|
||||
}
|
||||
#addBm h1 {
|
||||
.addBm h1 {
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid #BABABA;
|
||||
|
||||
}
|
||||
|
||||
#addBm #url {
|
||||
.addBm .url {
|
||||
display:none;
|
||||
}
|
||||
|
||||
#addBm fieldset > ul > li {
|
||||
.addBm fieldset > ul > li {
|
||||
margin-top: 1em;
|
||||
}
|
||||
#addBm label {
|
||||
.addBm label {
|
||||
display:block;
|
||||
width:100%;
|
||||
}
|
||||
#addBm #is_public_label {
|
||||
.addBm .is_public_label {
|
||||
display: inline;
|
||||
|
||||
}
|
||||
#addBm fieldset input[type="text"], #addBm textarea {
|
||||
.addBm fieldset input[type="text"], .addBm textarea {
|
||||
width:100%;
|
||||
}
|
||||
#addBm textarea{
|
||||
.addBm textarea{
|
||||
min-width:250px;
|
||||
/* min-height: 70px; */
|
||||
}
|
||||
#addBm #close_btn
|
||||
.addBm .close_btn
|
||||
{
|
||||
/* background-color: #EEEEEE; */
|
||||
height: 18px;
|
||||
@ -149,14 +149,15 @@
|
||||
float:right;
|
||||
width: 19px;
|
||||
}
|
||||
#addBm .submit {
|
||||
.addBm .submit {
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
.ui-autocomplete {
|
||||
|
12
index.php
12
index.php
@ -31,6 +31,8 @@ OCP\App::setActiveNavigationEntry( 'bookmarks_index' );
|
||||
|
||||
OCP\Util::addscript('bookmarks','bookmarks');
|
||||
OCP\Util::addStyle('bookmarks', 'bookmarks');
|
||||
OCP\Util::addscript('bookmarks','addBm');
|
||||
|
||||
|
||||
OCP\Util::addscript('bookmarks','tag-it');
|
||||
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
|
||||
@ -42,7 +44,17 @@ foreach($qtags as $tag) {
|
||||
$tags[] = $tag['tag'];
|
||||
}
|
||||
|
||||
$bm = array('title'=> '',
|
||||
'url'=> '',
|
||||
'tags'=> array(),
|
||||
'desc'=>'',
|
||||
'is_public'=>0,
|
||||
);
|
||||
|
||||
$tmpl = new OCP\Template( 'bookmarks', 'list', 'user' );
|
||||
|
||||
$tmpl->assign('bookmark', $bm);
|
||||
|
||||
$tmpl->assign('req_tag',isset($_GET['tag']) ? $_GET['tag'] : '');
|
||||
$tmpl->assign('tags', json_encode($tags), false);
|
||||
$tmpl->assign('shared', $shared);
|
||||
|
90
js/addBm.js
90
js/addBm.js
@ -1,42 +1,66 @@
|
||||
$(document).ready(function() {
|
||||
$('#bookmark_add_submit').click(addBookmark);
|
||||
$('#url-ro img').click(editUrl);
|
||||
$('#url').keypress(changeUrl);
|
||||
$('#addBm').submit(bookletSubmit);
|
||||
$('#tags').tagit({
|
||||
allowSpaces: true,
|
||||
availableTags: sampleTags
|
||||
});
|
||||
});
|
||||
(function($){
|
||||
$.bookmark_dialog = function(el, options){
|
||||
// To avoid scope issues, use 'base' instead of 'this'
|
||||
// to reference this class from internal events and functions.
|
||||
var base = this;
|
||||
|
||||
function addBookmark(event) {
|
||||
var url = $('#bookmark_add_url').val();
|
||||
var tags = $('#bookmark_add_tags').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax/addBookmark.php',
|
||||
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
|
||||
success: function(data){
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
function editUrl(event) {
|
||||
$('#url').slideToggle();
|
||||
}
|
||||
function changeUrl(event) {
|
||||
$('#url-ro code').text($('#url').val());
|
||||
}
|
||||
function bookletSubmit(event) {
|
||||
// Access to jQuery and DOM versions of element
|
||||
base.$el = $(el);
|
||||
base.el = el;
|
||||
|
||||
// Add a reverse reference to the DOM object
|
||||
base.$el.data("bookmark_dialog", base);
|
||||
|
||||
base.form_submit = function search_form_submit(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $('#addBm').attr('action'),
|
||||
data: $('#addBm').serialize(),
|
||||
url: $(this).attr('action'),
|
||||
data: $(this).serialize(),
|
||||
success: function(data){
|
||||
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()
|
||||
{
|
||||
$('#bookmarkFilterTag').val($('#tag_filter input:hidden').val());
|
||||
console.log($('#bookmarkFilterTag').val());
|
||||
bookmarks_page = 0;
|
||||
$('.bookmarks_list').empty();
|
||||
getBookmarks();
|
||||
@ -103,7 +104,25 @@ function getBookmarks() {
|
||||
// addOrEditBookmark() to make .js file more compact.
|
||||
|
||||
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 title = encodeEntities($('#bookmark_add_title').val());
|
||||
var tags = encodeEntities($('#bookmark_add_tags').val());
|
||||
@ -143,7 +162,7 @@ function addOrEditBookmark(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>
|
||||
<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">
|
||||
<ul>
|
||||
<li>
|
||||
<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>
|
||||
<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>
|
||||
<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');?>" />
|
||||
</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>
|
||||
<label for="tags"><strong><?php echo $l->t('Tags');?></strong></label>
|
||||
<ul id="tags" >
|
||||
<ul class="tags" >
|
||||
<?php foreach($_['bookmark']['tags'] as $tag):?>
|
||||
<li><?php echo $tag;?></li>
|
||||
<?php endforeach;?>
|
||||
@ -29,19 +39,16 @@
|
||||
|
||||
<li>
|
||||
<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>
|
||||
<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">
|
||||
<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>
|
||||
|
||||
</ul>
|
||||
|
||||
</fieldset>
|
||||
<script>
|
||||
var sampleTags = <?php echo $_['tags'];?>;
|
||||
</script>
|
||||
</form>
|
@ -44,6 +44,7 @@
|
||||
<div id="firstrun" style="display: none;">
|
||||
<?php
|
||||
echo $l->t('You have no bookmarks');
|
||||
$embedded = true;
|
||||
require_once(OC_App::getAppPath('bookmarks') .'/templates/bookmarklet.php');
|
||||
createBookmarklet();
|
||||
?>
|
||||
@ -51,3 +52,6 @@
|
||||
<script>
|
||||
var fullTags = <?php echo $_['tags'];?>;
|
||||
</script>
|
||||
<div id="edit_dialog" style="display:none;">
|
||||
<?php include 'addBm.php';?>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user