diff options
author | 2011-04-05 18:56:51 +0200 | |
---|---|---|
committer | 2011-04-05 18:56:51 +0200 | |
commit | 705d016301194b39b87ec4f1223633bf1ac4489e (patch) | |
tree | 5d32505e338d90bd544e47401eabcc91ce1817b9 | |
parent | 1527555a9631cce1eb37dd7fa76cac27adaeba96 (diff) | |
download | scuttle-705d016301194b39b87ec4f1223633bf1ac4489e.tar.gz scuttle-705d016301194b39b87ec4f1223633bf1ac4489e.zip |
move bookmarklet code to own template file
-rw-r--r-- | data/templates/bookmarklet.inc.php | 117 | ||||
-rw-r--r-- | data/templates/editbookmark.tpl.php | 121 |
2 files changed, 119 insertions, 119 deletions
diff --git a/data/templates/bookmarklet.inc.php b/data/templates/bookmarklet.inc.php new file mode 100644 index 0000000..9867745 --- /dev/null +++ b/data/templates/bookmarklet.inc.php @@ -0,0 +1,117 @@ +<h3><?php echo T_('Bookmarklet'); ?></h3> +<p id="bookmarklet"></p> +<script type="text/javascript"> +//<![CDATA[ +var browser = navigator.appName; +jQuery(function($) { +if (browser == "Opera") { + $('#bookmarklet').append( + <?php echo json_encode( + sprintf( + T_("Click one of the following bookmarklets to add a button you can click whenever you want to add the page you are on to %s") . ':', + $GLOBALS['sitename'] + ) + ); ?> + ); +} else { + $('#bookmarklet').append( + <?php echo json_encode( + sprintf( + T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s") . ':', + $GLOBALS['sitename'] + ) + ); + ?> + ); +} +}); +//]]> +</script> +<script type="text/javascript"> +//<![CDATA[ +var selection = ''; +if (window.getSelection) { + selection = 'window.getSelection()'; +} else if (document.getSelection) { + selection = 'document.getSelection()'; +} else if (document.selection) { + selection = 'document.selection.createRange().text'; +} +if (browser == "Opera") { + $('#bookmarklet').append( + '<ul>' + + '<li>' + + '<a class="bookmarklet" href="' + + '<?php +$popupLink = 'javascript:' + . "location.href='" + . createURL('bookmarks', $GLOBALS['user']) + . '?action=add' + . "&address='+encodeURIComponent(document.location.href)+'" + . "&title='+encodeURIComponent(document.title)+'" + . "&description='+encodeURIComponent(SELECTION)" + . ";"; +$link = 'opera:/button/' + //Opera command + . 'Go to page' + //command parameter 1 + . ',"' . rawurlencode($popupLink) . '"' + //command parameter 2 + . ',' + //button title + . ',"Post to ' . fixOperaButtonName($GLOBALS['sitename']) . '"' + //button icon name + . ',"Scuttle"'; +echo jsEscTitle(htmlspecialchars($link)); +?>'.replace('SELECTION', selection) + + '"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?></a>' + + '</li>' + + '<li>' + + '<a class="bookmarklet" href="' + + '<?php +$popupLink = 'javascript:' + . 'open(' + . "'" . createURL('bookmarks', $GLOBALS['user']) + . '?action=add' + . '&popup=1' + . "&address='+encodeURIComponent(document.location.href)+'" + . "&title='+encodeURIComponent(document.title)+'" + . "&description='+encodeURIComponent(SELECTION)" + . "," + . "'" . htmlspecialchars(jsEscTitle($GLOBALS['sitename'])) . "'," + . "'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465" + . ",left='+(screen.width-790)/2+',top='+(screen.height-425)/2" + . ");void 0"; +$link = 'opera:/button/' + . 'Go to page' + . ',"' . rawurlencode($popupLink) . '"' + . ',' + . ',"Post to ' . fixOperaButtonName($GLOBALS['sitename']) . ' (Pop-up)"' + . ',"Scuttle"'; +echo jsEscTitle(htmlspecialchars($link)); +?>'.replace('SELECTION', selection) + + '"><?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?></a>' + + '</li>' + + '</ul>' + ); +} else { + $('#bookmarklet').append( + '<ul>' + + '<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?><\/a><\/li>' + + '<li>' + + '<a class="bookmarklet" href="' + + 'javascript:x=document;' + + 'a=encodeURIComponent(x.location.href);' + + 't=encodeURIComponent(x.title);' + + 'd=encodeURIComponent('+selection+');' + + 'open(' + + '\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo htmlspecialchars(jsEscTitleDouble($GLOBALS['sitename'])); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2' + + ');void 0;">' + + '<?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?>' + + '</a>' + + '</li>' + + '</ul>' + ); +} +//]]> +</script> diff --git a/data/templates/editbookmark.tpl.php b/data/templates/editbookmark.tpl.php index b7fb227..8b71230 100644 --- a/data/templates/editbookmark.tpl.php +++ b/data/templates/editbookmark.tpl.php @@ -206,126 +206,9 @@ $this->includeTemplate('dynamictags.inc'); // Bookmarklets and import links if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) { -?> - -<h3><?php echo T_('Bookmarklet'); ?></h3> -<p id="bookmarklet"></p> -<script type="text/javascript"> -//<![CDATA[ -var browser = navigator.appName; -jQuery(function($) { -if (browser == "Opera") { - $('#bookmarklet').append( - <?php echo json_encode( - sprintf( - T_("Click one of the following bookmarklets to add a button you can click whenever you want to add the page you are on to %s") . ':', - $GLOBALS['sitename'] - ) - ); ?> - ); -} else { - $('#bookmarklet').append( - <?php echo json_encode( - sprintf( - T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s") . ':', - $GLOBALS['sitename'] - ) - ); - ?> - ); -} -}); -//]]> -</script> -<script type="text/javascript"> -//<![CDATA[ -var selection = ''; -if (window.getSelection) { - selection = 'window.getSelection()'; -} else if (document.getSelection) { - selection = 'document.getSelection()'; -} else if (document.selection) { - selection = 'document.selection.createRange().text'; -} -if (browser == "Opera") { - $('#bookmarklet').append( - '<ul>' - + '<li>' - + '<a class="bookmarklet" href="' - + '<?php -$popupLink = 'javascript:' - . "location.href='" - . createURL('bookmarks', $GLOBALS['user']) - . '?action=add' - . "&address='+encodeURIComponent(document.location.href)+'" - . "&title='+encodeURIComponent(document.title)+'" - . "&description='+encodeURIComponent(SELECTION)" - . ";"; -$link = 'opera:/button/' - //Opera command - . 'Go to page' - //command parameter 1 - . ',"' . rawurlencode($popupLink) . '"' - //command parameter 2 - . ',' - //button title - . ',"Post to ' . fixOperaButtonName($GLOBALS['sitename']) . '"' - //button icon name - . ',"Scuttle"'; -echo jsEscTitle(htmlspecialchars($link)); -?>'.replace('SELECTION', selection) - + '"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?></a>' - + '</li>' - + '<li>' - + '<a class="bookmarklet" href="' - + '<?php -$popupLink = 'javascript:' - . 'open(' - . "'" . createURL('bookmarks', $GLOBALS['user']) - . '?action=add' - . '&popup=1' - . "&address='+encodeURIComponent(document.location.href)+'" - . "&title='+encodeURIComponent(document.title)+'" - . "&description='+encodeURIComponent(SELECTION)" - . "," - . "'" . htmlspecialchars(jsEscTitle($GLOBALS['sitename'])) . "'," - . "'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465" - . ",left='+(screen.width-790)/2+',top='+(screen.height-425)/2" - . ");void 0"; -$link = 'opera:/button/' - . 'Go to page' - . ',"' . rawurlencode($popupLink) . '"' - . ',' - . ',"Post to ' . fixOperaButtonName($GLOBALS['sitename']) . ' (Pop-up)"' - . ',"Scuttle"'; -echo jsEscTitle(htmlspecialchars($link)); -?>'.replace('SELECTION', selection) - + '"><?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?></a>' - + '</li>' - + '</ul>' - ); -} else { - $('#bookmarklet').append( - '<ul>' - + '<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?><\/a><\/li>' - + '<li>' - + '<a class="bookmarklet" href="' - + 'javascript:x=document;' - + 'a=encodeURIComponent(x.location.href);' - + 't=encodeURIComponent(x.title);' - + 'd=encodeURIComponent('+selection+');' - + 'open(' - + '\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo htmlspecialchars(jsEscTitleDouble($GLOBALS['sitename'])); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2' - + ');void 0;">' - + '<?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?>' - + '</a>' - + '</li>' - + '</ul>' - ); -} -//]]> -</script> +$this->includeTemplate('bookmarklet.inc.php'); +?> <h3><?php echo T_('Import'); ?></h3> <ul> <li><a href="<?php echo createURL('importNetscape'); ?>"><?php echo T_('Import bookmarks from bookmark file'); ?></a> (<?php echo T_('Internet Explorer, Mozilla Firefox and Netscape'); ?>)</li> |