From 78c3940cdfe40f7ad7aa5d008a62e70836ab5138 Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Wed, 12 Nov 2008 17:56:36 +0530 Subject: [PATCH] add pronunciation thing done, sort of. --- static/js/iwdb.lib.js | 10 ++++++++++ static/js/jquery.forms.js | 19 ++++++++++++++++++- templates/words/view.html | 8 ++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 static/js/iwdb.lib.js diff --git a/static/js/iwdb.lib.js b/static/js/iwdb.lib.js new file mode 100644 index 0000000..e58ce78 --- /dev/null +++ b/static/js/iwdb.lib.js @@ -0,0 +1,10 @@ +function get_class_data(o, prefix){ + var classes = jQuery(o).attr("class").split(" "); + var data = ""; + $.each(classes, function(i, cls){ + if(cls.indexOf(prefix) == 0){ + data = cls.substring(prefix.length); + } + }); + return data; +} diff --git a/static/js/jquery.forms.js b/static/js/jquery.forms.js index 6e79878..db61188 100644 --- a/static/js/jquery.forms.js +++ b/static/js/jquery.forms.js @@ -29,6 +29,7 @@ $.fn.pronunciationize = function(options){ $.fn.formui = function(options){ return this.each(function(i, o){ + options.form = get_class_data(o, "f_"); $(o).hoverIntent({ sensitivity: 1, interval: 200, timeout: 500, over: function(){ @@ -45,8 +46,23 @@ $.fn.formui = function(options){ $("div.del_form", o).hide(); }); $("ul", o).append( - '
  • add pronunciation
  • ' + '
  • \ + add pronunciation\ +
    \ +
    \ + \ + \ + \ + \ +
    \ +
    \ +
  • ' ); + $("li.add_pronon a.add", o).click(function(){ + $("li.add_pronon div.dnone").toggle(); + }); $("li", o).pronunciationize(options); }); }; @@ -54,6 +70,7 @@ $.fn.formui = function(options){ $.fn.formize = function(options){ this.add_formize(options); return this.each(function(i, o){ + options.word = get_class_data(o, "w_"); $("div.form", o).formui(options); }); }; diff --git a/templates/words/view.html b/templates/words/view.html index 399d8bf..85e1ee7 100644 --- a/templates/words/view.html +++ b/templates/words/view.html @@ -15,6 +15,8 @@ + {% endblock %} {% block extra_head_late %} @@ -49,7 +51,7 @@ jQuery(function($){

    {{ word.word }}

    {% for form in word.get_form_data %} -
    +
    {{ form.form }} @@ -74,7 +76,9 @@ jQuery(function($){
      {% for pronunciation in form.pronunciations %} -
    • +
    • {{ pronunciation.pronunciation_key }} -- 2.11.4.GIT