Skip to content

Commit

Permalink
Added Joost Faber. do_clickable is used to make a parent element of a…
Browse files Browse the repository at this point in the history
…n anchor clickable.
  • Loading branch information
mworrell committed May 21, 2012
1 parent 456e1da commit 4d63575
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -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>
Expand Down
60 changes: 60 additions & 0 deletions modules/mod_base/lib/js/modules/z.clickable.js
@@ -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.