Permalink
Browse files

Unify cyt.js with bookyt.

  • Loading branch information...
1 parent ed355d4 commit 3b934064574316e52ef4891383ee5ef01f45a03e @huerlisi committed May 5, 2011
Showing with 25 additions and 68 deletions.
  1. +23 −0 public/javascripts/application.js
  2. +2 −68 public/javascripts/cyt.js
@@ -1,5 +1,18 @@
// learnyt
+// Add tooltips for overview
+function addTooltipBehaviour() {
+ $(".tooltip-title[title]").each(function() {
+ if ( $(this).attr('title') != '' ) {
+ $(this).tooltip({
+ position: 'top center',
+ predelay: 500,
+ effect: 'fade'
+ });
+ }
+ });
+};
+
var selectables = $('#response form .possible_answer');
selectables.css('cursor', "pointer");
selectables.click(function(element) {
@@ -214,6 +227,16 @@ function addTabsBehaviour() {
// Initialize behaviours
function initializeBehaviours() {
+ // from cyt.js
+ addAutofocusBehaviour();
+ addDatePickerBehaviour();
+ addSortableBehaviour();
+ addLinkifyContainersBehaviour();
+ addTooltipBehaviour();
+ addOverviewTooltipBehaviour();
+ addIconTooltipBehaviour();
+
+ // application
addSelectableBehaviour();
addAutocompleteBehaviour();
addNestedFormsBehaviour();
View
@@ -17,7 +17,7 @@ function addSortableBehaviour() {
});
$(".sortable").disableSelection();
};
-
+
// Linkify containers having attribute data-href-container
function addLinkifyContainersBehaviour() {
@@ -28,7 +28,7 @@ function addLinkifyContainersBehaviour() {
container.css('cursor', "pointer");
var href = element.attr('href');
element.addClass('linkified_container')
-
+
container.delegate('*', 'click', {href: href}, function(event) {
// Don't override original link behaviour
if ($(event.target).parents('a').length == 0) {
@@ -41,19 +41,6 @@ function addLinkifyContainersBehaviour() {
// Autogrow
function addAutogrowBehaviour() {
$(".autogrow").elastic();
-}
-
-// Add tooltips for overview
-function addTooltipBehaviour() {
- $(".tooltip-title[title]").each(function() {
- if ( $(this).attr('title') != '' ) {
- $(this).tooltip({
- position: 'top center',
- predelay: 500,
- effect: 'fade'
- });
- }
- });
};
// Add tooltips for overview
@@ -73,56 +60,3 @@ function addIconTooltipBehaviour() {
fadeOutSpeed: 100
});
};
-// Javascript Highlighter
-// Fixed version of comment in
-// http://stackoverflow.com/questions/1650389/prototype-js-highlight-words-dom-traversing-correctly-and-efficiently
-// TODO: Check with Simon Hürlimann if this function is still in use and rewrite it for jQuery.
-//Element.addMethods({
-// highlight: function(element, term, className) {
-// function innerHighlight(element, term, className) {
-// className = className || 'highlight';
-// term = (term || '').toUpperCase();
-//
-// var skip = 0;
-// if ($(element).nodeType == 3) {
-// var pos = element.data.toUpperCase().indexOf(term);
-// if (pos >= 0) {
-// var middlebit = element.splitText(pos),
-// endbit = middlebit.splitText(term.length),
-// middleclone = middlebit.cloneNode(true),
-// spannode = document.createElement('span');
-//
-// spannode.className = className;
-// spannode.appendChild(middleclone);
-// middlebit.parentNode.replaceChild(spannode, middlebit);
-// skip = 1;
-// }
-// }
-// else if (element.nodeType == 1 && element.childNodes && !/(script|style)/i.test(element.tagName)) {
-// for (var i = 0; i < element.childNodes.length; ++i)
-// i += innerHighlight(element.childNodes[i], term, className);
-// }
-// return skip;
-// }
-// innerHighlight(element, term, className);
-// return element;
-// },
-// removeHighlight: function(element, term, className) {
-// className = className || 'highlight';
-// $(element).select("span."+className).each(function(e) {
-// e.parentNode.replaceChild(e.firstChild, e);
-// });
-// return element;
-// }
-//});
-
-// Loads functions after DOM is ready
-$(document).ready(function() {
- addAutofocusBehaviour();
- addDatePickerBehaviour();
- addSortableBehaviour();
- addLinkifyContainersBehaviour();
- addTooltipBehaviour();
- addOverviewTooltipBehaviour();
- addIconTooltipBehaviour();
-});

0 comments on commit 3b93406

Please sign in to comment.