[Tynstep-svn] r192 - trunk/step/step-web/src/main/webapp/js
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Thu Dec 2 13:16:25 MST 2010
Author: ChrisBurrell
Date: 2010-12-02 13:16:25 -0700 (Thu, 02 Dec 2010)
New Revision: 192
Modified:
trunk/step/step-web/src/main/webapp/js/init.js
trunk/step/step-web/src/main/webapp/js/passage.js
trunk/step/step-web/src/main/webapp/js/ui_hooks.js
Log:
Modified: trunk/step/step-web/src/main/webapp/js/init.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/init.js 2010-12-01 22:28:34 UTC (rev 191)
+++ trunk/step/step-web/src/main/webapp/js/init.js 2010-12-02 20:16:25 UTC (rev 192)
@@ -1,8 +1,11 @@
-
// call the initialisation functions
init();
+//some extensions (perhaps should go in another file)
+String.prototype.startsWith = function(str) { return (this.match("^"+str)==str) }
+
+
function init() {
$(document).ready(function() {
initLayout();
Modified: trunk/step/step-web/src/main/webapp/js/passage.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/passage.js 2010-12-01 22:28:34 UTC (rev 191)
+++ trunk/step/step-web/src/main/webapp/js/passage.js 2010-12-02 20:16:25 UTC (rev 192)
@@ -61,6 +61,11 @@
this.reference.change(function(){
self.changePassage();
});
+
+ //register to listen for events that click a word/phrase:
+ this.passage.hear("show-all-strong-morphs", function(selfElement, data) {
+ self.higlightStrongs(data);
+ } );
}
/**
@@ -125,3 +130,32 @@
return this.container;
}
+/**
+ * highlights all strongs match parameter strongReference
+ * @strongReference the reference look for across this passage pane and highlight
+ */
+Passage.prototype.highlightStrong = function(strongReference) {
+ $(".verse span[onclick*=" + strongReference + "]", this.container).css("text-decoration", "underline");
+ $("span.w[onclick*=" + strongReference + "] span.text", this.container).css("text-decoration", "underline");
+}
+
+/**
+ * if a number of strongs are given, separated by a space, highlights all of them
+ * @param strongMorphReference the references of all strongs and morphs asked for
+ */
+Passage.prototype.higlightStrongs = function(strongMorphReference) {
+ var references = strongMorphReference.split(' ');
+
+ //reset all spans that are underlined:
+ $(".verse span", this.container).css("text-decoration", "none");
+ $("span.text", this.container).css("text-decoration", "none");
+
+
+ for(var ii = 0; ii < references.length; ii++) {
+ if(references[ii].startsWith("strong:")) {
+ this.highlightStrong(references[ii]);
+ }
+ //we ignore everything else
+ }
+}
+
Modified: trunk/step/step-web/src/main/webapp/js/ui_hooks.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/ui_hooks.js 2010-12-01 22:28:34 UTC (rev 191)
+++ trunk/step/step-web/src/main/webapp/js/ui_hooks.js 2010-12-02 20:16:25 UTC (rev 192)
@@ -16,6 +16,8 @@
* @param strong strong to be displayed
*/
function showStrong(strong) {
+ $.shout("show-strong", strong);
+
//need to find what event is coming in, to get the clicked element and pass that down
//invoke show-all-strong-morphs first, for all
More information about the Tynstep-svn
mailing list