Check-in Number:
|
21 | |
Date: |
2007-Apr-01 11:10:01 (local)
2007-Apr-01 09:10:01 (UTC) |
User: | rse |
Branch: | |
Comment: |
improve external link plugin
|
Tickets: |
|
Inspections: |
|
Files: |
|
Modified: jquery/jquery.extlink.html
===================================================================
--- jquery/jquery.extlink.html 2007-04-01 09:09:17 UTC (rev 20)
+++ jquery/jquery.extlink.html 2007-04-01 09:10:01 UTC (rev 21)
@@ -6,6 +6,11 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://jquery.com/src/jquery-latest.pack.js"></script>
<script type="text/javascript" src="jquery.extlink.js"></script>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ $(this).extlink("grey");
+ });
+ </script>
</head>
<body>
<h1>jQuery External Link Annotation Plugin Demo</h1>
@@ -16,7 +21,5 @@
<a href="foo.html">foo.html</a>
<a href="http:bar.html">http:bar.html</a>
<a href="http://www.example.com/">http://www.example.com</a>
-
- </script>
</body>
</html>
Modified: jquery/jquery.extlink.js
===================================================================
--- jquery/jquery.extlink.js 2007-04-01 09:09:17 UTC (rev 20)
+++ jquery/jquery.extlink.js 2007-04-01 09:10:01 UTC (rev 21)
@@ -8,17 +8,22 @@
*/
(function($) {
- $(document).ready(function () {
- var site = String(document.location)
- .replace(/^(https?:\/\/[^:\/]+).*$/, "$1");
- $("a").filter(function (i) {
- return ($(this).attr("href").match(RegExp("^("+site+"|(https?:)?/)")) != null);
- }).after("<img class=\"extlink\" src=\"jquery.extlink.d/extlink-grey.gif\"/>");
- $("img.extlink")
- .css("border", "0px")
- .css("padding", "0px 2px 0px 2px")
- .css("position", "relative")
- .css("bottom", "-1px");
+ $.fn.extend({
+ extlink: function (color) {
+ if (typeof color === "undefined")
+ color = "grey";
+ var site = String(document.location)
+ .replace(/^(https?:\/\/[^:\/]+).*$/, "$1");
+ $("a", this).filter(function (i) {
+ return ($(this).attr("href").match(RegExp("^("+site+"|(https?:)?/)")) != null);
+ }).each(function () {
+ $(this)
+ .css("backgroundImage", "url('jquery.extlink.d/extlink-" + color + ".gif')")
+ .css("backgroundRepeat", "no-repeat")
+ .css("backgroundPosition", "right center")
+ .css("padding-right", "11px");
+ });
+ }
});
})(jQuery);