From 9d396b3c3efba80de52c64fe6fe9544639646ff8 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Tue, 15 Jun 2010 12:18:31 +0000 Subject: [PATCH] JS improvements: fix Firebug warning about keycodes. Added: Sharebox when shortening from within the admin page. Fixes issue 365. git-svn-id: http://yourls.googlecode.com/svn/trunk@403 12232710-3e20-11de-b438-597f59cd7555 --- admin/index.php | 10 +++++++--- css/share.css | 5 +++++ css/tablesorter.css | 2 +- includes/functions-html.php | 14 ++++++++------ js/insert.js | 12 ++++++++++-- js/share.js | 2 +- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/admin/index.php b/admin/index.php index 59eacb4..4075f21 100644 --- a/admin/index.php +++ b/admin/index.php @@ -209,10 +209,14 @@ - Your short link', '

Quick Share

', true ); + } else { echo '

' . $return['message'] . '

'; - - } ?> + } + ?> diff --git a/css/share.css b/css/share.css index 822be75..cc0d715 100644 --- a/css/share.css +++ b/css/share.css @@ -1,6 +1,11 @@ #shareboxes, #tweet { overflow:hidden; } + +#shareboxes{ + margin-top:15px; +} + div.share { -moz-border-radius:5px; -webkit-border-radius:5px; diff --git a/css/tablesorter.css b/css/tablesorter.css index 2700b4c..ea53092 100644 --- a/css/tablesorter.css +++ b/css/tablesorter.css @@ -2,7 +2,7 @@ table.tblSorter { font-family:Verdana, Arial; background-color: #CDCDCD; - margin:10px 0pt 15px; + margin:10px 0px 0px; font-size: 8pt; width: 100%; text-align: left; diff --git a/includes/functions-html.php b/includes/functions-html.php index 04e7ed4..03b5e40 100644 --- a/includes/functions-html.php +++ b/includes/functions-html.php @@ -28,7 +28,7 @@ function yourls_html_head( $context = 'index' ) { break; case 'index': - $insert = $tablesorter = $cal = true; + $insert = $tablesorter = $cal = $share = true; break; case 'plugins': @@ -224,26 +224,28 @@ function yourls_html_tfooter( $params = array() ) { Your short link', $share_title = '

Quick Share

' ) { +// Display the Quick Share box +function yourls_share_box( $longurl, $shorturl, $title='', $text='', $shortlink_title = '

Your short link

', $share_title = '

Quick Share

', $hidden = false ) { $text = ( $text ? '"'.$text.'" ' : '' ); $title = ( $title ? "$title " : '' ); $share = htmlspecialchars_decode( $title.$text.$shorturl ); $_share = rawurlencode( $share ); $_url = rawurlencode( $shorturl ); $count = 140 - strlen( $share ); + + $hidden = ( $hidden ? 'style="display:none;"' : '' ); ?> -
+
> diff --git a/js/insert.js b/js/insert.js index ede8a58..39b7828 100644 --- a/js/insert.js +++ b/js/insert.js @@ -1,6 +1,8 @@ // Init some stuff $(document).ready(function(){ - $('#add-url, #add-keyword').keyup(function(e){ if (e.keyCode == 13) {add();} } ); + $('#add-url, #add-keyword').keypress(function(e){ + if (e.which == 13) {add();} + }); reset_url(); $('#new_url_form').attr('action', 'javascript:add();'); @@ -14,7 +16,6 @@ $(document).ready(function(){ function add() { var newurl = $("#add-url").val(); if ( !newurl || newurl == 'http://' || newurl == 'https://' ) { - alert('no URL ?'); return; } var keyword = $("#add-keyword").val(); @@ -31,6 +32,13 @@ function add() { increment(); } feedback(data.message, data.status); + + $('#copylink').val( data.shorturl ); + $('#origlink').attr( 'href', data.url.url ).html( data.url.url ); + $('#statlink').attr( 'href', data.shorturl+'+' ).html( data.shorturl+'+' ); + $('#tweet_body').val( data.shorturl ).keypress(); + $('#shareboxes').slideDown(); + end_loading("#add-button"); end_disable("#add-button"); } diff --git a/js/share.js b/js/share.js index 798c0fc..b5b6296 100644 --- a/js/share.js +++ b/js/share.js @@ -1,7 +1,7 @@ $(document).ready(function(){ $('#tweet_body').focus(); - $('#tweet_body').keyup(function(event){ + $('#tweet_body').keypress(function(event){ var text = encodeURI( $('#tweet_body').val() ); var tw = 'http://twitter.com/home?status='+text; var ff = 'http://friendfeed.com/share/bookmarklet/frame#title='+encodeURI( $('#tweet_body').val() ) ; -- 2.45.0