fixed separe texte and syllabes widgets

preferencesAboutTextFull
unknown 13 years ago
parent 69677464b3
commit 91bc8159de
  1. 8
      resources/library/interactivities/Separe texte.wgt/scripts/app2.js
  2. 69
      resources/library/interactivities/Syllabes.wgt/scripts/spl-word.js

@ -30,14 +30,6 @@ $(document).ready(function()
else else
sentences = sankoreLang.example; sentences = sankoreLang.example;
w.elements.container.find( "textarea" ).live("change", function(){
sankore.setPreference("spl_text_style", $(".style_select").find("option:selected").val());
if(w.editMode)
sankore.setPreference("ordSplText", w.elements.container.find( "textarea" ).val());
else
sankore.setPreference("ordSplText", w.getData( "text" ));
})
if (window.widget) { if (window.widget) {
window.widget.onleave = function(){ window.widget.onleave = function(){
sankore.setPreference("spl_text_style", $(".style_select").find("option:selected").val()); sankore.setPreference("spl_text_style", $(".style_select").find("option:selected").val());

@ -1,3 +1,5 @@
//just a flag
var flag = true;
function createWord( word ) function createWord( word )
{ {
@ -19,11 +21,41 @@ var w;
$(document).ready(function() $(document).ready(function()
{ {
var w = new wcontainer( "#ub-widget" );
var words = "";
if(window.sankore)
words = (sankore.preference("ordSplWords", ""))?sankore.preference("ordSplWords", ""):sankoreLang.example;
else
words = sankoreLang.example;
w.setEditContent( '<div class="inputwrap"><input class="percent" value="' + words + '"></div>' );
w.setViewContent( '<span class="upper"><span class="dash fixed">&mdash;</span></span>' );
w.setData( "dashWidth", w.elements.container.find( "span.dash" ).outerWidth() );
w.setViewContent( "" );
if (window.widget) {
window.widget.onleave = function(){
sankore.setPreference("spl_word_style", $(".style_select").find("option:selected").val());
if(w.editMode){
sankore.setPreference("ordSplWords", w.elements.container.find( "input" ).val().trim( ['*'] ));
sankore.setPreference("ordSplWordsState", "0");
}
else{
sankore.setPreference("ordSplWordsCode", $(".viewmode").html());
sankore.setPreference("ordSplWordsState", "1");
sankore.setPreference("ordSplWordsAnswer", ($("#ub-widget").hasClass("answerRight"))?"answerRight":"");
sankore.setPreference("ordSplWords", w.getData( "word" ));
}
}
}
if(sankore.preference("spl_word_style","")){ if(sankore.preference("spl_word_style","")){
changeStyle(sankore.preference("spl_word_style","")); changeStyle(sankore.preference("spl_word_style",""));
$(".style_select").val(sankore.preference("spl_word_style","")); $(".style_select").val(sankore.preference("spl_word_style",""));
} else } else
changeStyle(1) changeStyle(1)
$("#wgt_display").text(sankoreLang.view); $("#wgt_display").text(sankoreLang.view);
$("#wgt_edit").text(sankoreLang.edit); $("#wgt_edit").text(sankoreLang.edit);
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
@ -48,8 +80,14 @@ $(document).ready(function()
} }
}); });
$("#wgt_name").text(sankoreLang.wgt_name); $("#wgt_name").text(sankoreLang.wgt_name);
$("#wgt_reload").text(sankoreLang.reload).click(function(){ $("#wgt_reload").text(sankoreLang.reload).click(function(){
window.location.reload(); if($("#wgt_display").hasClass("selected")){
$("#wgt_edit").trigger("click");
$("#wgt_display").trigger("click");
} else {
$("#wgt_display").trigger("click");
}
}); });
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
@ -59,33 +97,22 @@ $(document).ready(function()
changeStyle($(this).find("option:selected").val()); changeStyle($(this).find("option:selected").val());
}) })
var w = new wcontainer( "#ub-widget" );
var words = "";
if(window.sankore)
words = (sankore.preference("ordSplWords", ""))?sankore.preference("ordSplWords", ""):sankoreLang.example;
else
words = sankoreLang.example;
w.setEditContent( '<div class="inputwrap"><input class="percent" value="' + words + '"></div>' );
w.setViewContent( '<span class="upper"><span class="dash fixed">&mdash;</span></span>' );
w.setData( "dashWidth", w.elements.container.find( "span.dash" ).outerWidth() );
w.setViewContent( "" );
w.elements.container.find( "input" ).live("change", function(){
sankore.setPreference("spl_word_style", $(".style_select").find("option:selected").val());
if(w.editMode)
sankore.setPreference("ordSplWords", w.elements.container.find( "input" ).val().trim( ['*'] ));
else
sankore.setPreference("ordSplWords", w.getData( "word" ));
})
// onViewMode // onViewMode
w.onViewMode = function() w.onViewMode = function()
{ {
var word = w.elements.container.find( "input" ).val().trim( ['*'] ); var word = w.elements.container.find( "input" ).val().trim( ['*'] );
w.setData( "word", word ); w.setData( "word", word );
word = word.replace( /\*/g, '' ); word = word.replace( /\*/g, '' );
if(sankore.preference("ordSplWordsState", "") == "1" && flag){
$(".viewmode").html(sankore.preference("ordSplWordsCode", ""));
if(sankore.preference("ordSplWordsAnswer", ""))
$("#ub-widget").addClass(sankore.preference("ordSplWordAnswer", ""));
flag = false;
}
else
w.setViewContent( createWord( word ) ); w.setViewContent( createWord( word ) );
w.elements.container.find( "span.upper" ).click( function(){ w.elements.container.find( "span.upper" ).click( function(){
$( this ).find( "span.dash" ).toggleClass( "fixed" ); $( this ).find( "span.dash" ).toggleClass( "fixed" );
w.checkAnswer(); w.checkAnswer();

Loading…
Cancel
Save