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

Add Url input to control bar

This commit is contained in:
Brice Maron 2012-08-13 19:58:46 +00:00
parent da55c5c23d
commit 269e09ff9e
4 changed files with 64 additions and 6 deletions

39
ajax/getInfos.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* ownCloud - bookmarks plugin
*
* @author Brice Maron
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php');
$req_type=isset($_GET['type']) ? $_GET['type'] : '';
if($req_type == 'url_info' && $_GET['url']) {
$datas = getURLMetadata($_GET['url']);
$title = isset($datas['title']) ? $datas['title'] : '';
OCP\JSON::success(array('title' => $title));
exit();
}
OC_JSON::error();
exit();

View File

@ -28,6 +28,9 @@
});
return false;
}
base.setTitle = function (str) {
base.$el.find('.title').val(str);
}
base.init = function(){
base.options = $.extend({},$.bookmark_dialog.defaultOptions, options);
@ -45,10 +48,12 @@
base.$el.find('.url_input').val(record.url);
base.$el.find('.desc').val(record.description);
tagit_elem = base.$el.find('.tags');
if(record.tags) {
for(var i=0;i<record.tags.length;i++) {
tagit_elem.tagit('createTag', record.tags[i]);
}
}
}
base.$el.find('.tagit-new input').attr('placeholder',t('bookmark', 'Tags'));

View File

@ -1,6 +1,6 @@
var bookmarks_page = 0;
var bookmarks_loading = false;
var dialog;
var bookmarks_sorting = 'bookmarks_sorting_recent';
var bookmark_view = 'image';
@ -173,7 +173,7 @@ function getBookmarks() {
function createEditDialog(record){
dialog_html = $('#edit_dialog').html();
var dialog = $(dialog_html).dialog({
var oc_dialog= $(dialog_html).dialog({
width : 620,
height: 350,
title: t('bookmark', 'Edit bookmark'),
@ -193,7 +193,20 @@ function createEditDialog(record){
}
function addBookmark(event) {
createEditDialog();
url = $('#add_url').val();
createEditDialog({ url: url});
$('#add_url').val('');
$.ajax({
type: 'GET',
url: OC.filePath('bookmarks', 'ajax', 'getInfos.php'),
data: { type: 'url_info', url: url},
success: function(data){
if (data.status == 'success') {
$('.ui-dialog').data('bookmark_dialog').setTitle(data.title);
}
}
});
}
function delBookmark(event) {

View File

@ -9,7 +9,8 @@
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php echo $_['req_tag']; ?>" />
<div id="controls">
<input type="submit" value="<?php echo $l->t('New bookmark'); ?>" id="bookmark_add_submit" />
<input type="text" id="add_url" value="" placeholder="<?php echo $l->t('Address'); ?>"/>
<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />
<div id="view_type">
<input type="button" class="list" value="<?php echo $l->t('List')?>" />