Permalink
Browse files

Added Joost Faber. do_clickable is used to make a parent element of a…

…n anchor clickable.
  • Loading branch information...
1 parent 456e1da commit 4d63575b02f09133f51615146e27e748a05d761d @mworrell mworrell committed May 21, 2012
Showing with 61 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +60 −0 modules/mod_base/lib/js/modules/z.clickable.js
View
@@ -10,6 +10,7 @@
Andreas Stenius <andreas.stenius@astekk.se>
Arjan Scherpenisse <arjan@scherpenisse.net>
Atilla Erdődi <atilla.erdodi@gmail.com>
+Joost Faber <info@joostfaber.nl>
Maas-Maarten Zeeman <maas.maarten.zeeman@gmail.com>
Marc Worrell <marc@worrell.nl>
Tim Benniks <tim@timbenniks.nl>
@@ -0,0 +1,60 @@
+/* clickable js
+----------------------------------------------------------
+
+@package: Zotonic 2012
+@Author: Joost Faber <info@joostfaber.nl>
+
+Copyright 2012 Joost Faber
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+---------------------------------------------------------- */
+
+$.widget("ui.clickable",
+{
+ _init: function()
+ {
+ $(this.element).click(function(e) {
+ var target = $(this).find("a").attr("href");
+ if($(this).find("a").attr("rel") == "external"){
+ window.open(target);
+ } else {
+ window.location=target;
+ }
+ return false;
+ }).addClass("clickable").hover(
+ function () {
+ $(this).addClass("hover");
+ },
+ function () {
+ $(this).removeClass("hover");
+ }
+ );
+
+ // Make sure that checkboxes still work
+ $(":checkbox", this.element).click(function(e) {
+ var checkbox = this;
+ setTimeout(function() {
+ if ($(checkbox).attr('checked'))
+ $(checkbox).attr('checked', false);
+ else
+ $(checkbox).attr('checked', true);
+ }, 10);
+ e.stopPropagation();
+ return false;
+ });
+ }
+});
+
+$.ui.clickable.defaults = {
+}

0 comments on commit 4d63575

Please sign in to comment.