var sankoreLang = {
display : "Afficher" ,
edit : "Modifier" ,
short _desc : "Ecoutez le son et replacer les lettres dans l'ordre." ,
add : "Nouveau bloc" ,
enter : "Saisir la consigne ici ..." ,
example : "exemple" ,
wgt _name : "Ordonner des lettres" ,
reload : "Recharger" ,
slate : "Bois" ,
pad : "Pad" ,
none : "Aucun" ,
help : "Aide" ,
help _content : "<p><h2>Ordre des lettres</h2></p>" +
"<p><h3>Ordonner des lettres pour reconstituer un mot.</h3></p>" +
"<p>L’intégration d’un fichier son (facultatif) permet d’écouter le mot à reconstituer. Lorsque les lettres sont dans le bon ordre, l’interactivité se colore en vert.</p>" +
"<p>L’activité s’effectue par un glisser-déposer des étiquettes pour remettre les lettres en ordre.<b> NB : vous pouvez également utiliser cette activité avec des chiffres.</b></p>" +
"<p>Le bouton “Recharger” réinitialise les exercices.</p>" +
"<p>Le bouton “Modifier” vous permet :</p>" +
"<ul><li>de choisir le thème de l’interactivité : tablette, ardoise ou aucun (par défaut aucun),</li>" +
"<li>de déterminer le mot à reconstituer.</li></ul>" +
"<p>Pour créer un nouvel exercice, cliquez sur “Nouveau bloc” en bas, puis</p>" +
"<ul><li>insérez une consigne en cliquant sur le champ de texte “Saisir la consigne ici ...”,</li>" +
"<li>insérez un son dans la zone à gauche de la consigne par glisser-déposer d’un son à partir de votre bibliothèque (facultatif),</li>" +
"<li>écrivez le mot souhaité à la place de “exemple”.</li></ul>" +
"<p>Pour supprimer un exercice, cliquez sur la croix à gauche du numéro de l’exercice.</p>" +
"<p>Le bouton “Afficher” vous permet d’utiliser l’activité.</p>"
} ;
//main function
function start ( ) {
$ ( "#wgt_display" ) . text ( sankoreLang . display ) ;
$ ( "#wgt_edit" ) . text ( sankoreLang . edit ) ;
$ ( "#wgt_name" ) . text ( sankoreLang . wgt _name ) ;
$ ( "#wgt_reload" ) . text ( sankoreLang . reload ) ;
$ ( "#wgt_help" ) . text ( sankoreLang . help ) ;
$ ( "#help" ) . html ( sankoreLang . help _content ) ;
$ ( ".style_select option[value='1']" ) . text ( sankoreLang . slate ) ;
$ ( ".style_select option[value='2']" ) . text ( sankoreLang . pad ) ;
$ ( ".style_select option[value='3']" ) . text ( sankoreLang . none ) ;
if ( window . sankore ) {
if ( sankore . preference ( "associer_sound" , "" ) ) {
var data = jQuery . parseJSON ( sankore . preference ( "associer_sound" , "" ) ) ;
importData ( data ) ;
}
else
showExample ( ) ;
if ( sankore . preference ( "ord_let_style" , "" ) ) {
changeStyle ( sankore . preference ( "ord_let_style" , "" ) ) ;
$ ( ".style_select" ) . val ( sankore . preference ( "ord_let_style" , "" ) ) ;
} else
changeStyle ( "3" )
}
else
showExample ( ) ;
//events
if ( window . widget ) {
window . widget . onleave = function ( ) {
exportData ( ) ;
sankore . setPreference ( "ord_let_style" , $ ( ".style_select" ) . find ( "option:selected" ) . val ( ) ) ;
}
}
$ ( "#wgt_help" ) . click ( function ( ) {
var tmp = $ ( this ) ;
if ( $ ( this ) . hasClass ( "open" ) ) {
$ ( "#help" ) . slideUp ( "100" , function ( ) {
tmp . removeClass ( "open" ) ;
$ ( "#data" ) . show ( ) ;
} ) ;
} else {
$ ( "#data" ) . hide ( ) ;
$ ( "#help" ) . slideDown ( "100" , function ( ) {
tmp . addClass ( "open" ) ;
} ) ;
}
} ) ;
$ ( "#wgt_reload" ) . click ( function ( ) {
if ( $ ( "#wgt_display" ) . hasClass ( "selected" ) ) {
setTimeout ( '$("#wgt_display").trigger("click")' , 10 )
$ ( "#wgt_edit" ) . trigger ( "click" ) ;
} else {
$ ( "#wgt_display" ) . trigger ( "click" ) ;
}
} ) ;
$ ( "#wgt_reload, #wgt_display, #wgt_edit" ) . mouseover ( function ( ) {
exportData ( ) ;
} ) ;
$ ( ".style_select" ) . change ( function ( event ) {
changeStyle ( $ ( this ) . find ( "option:selected" ) . val ( ) ) ;
} )
$ ( "#wgt_display, #wgt_edit" ) . click ( function ( event ) {
if ( this . id == "wgt_display" ) {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
if ( window . sankore )
sankore . enableDropOnWidget ( false ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_edit" ) . removeClass ( "selected" ) ;
$ ( ".style_select" ) . css ( "display" , "none" ) ;
$ ( ".add_block" ) . remove ( ) ;
$ ( ".cont" ) . each ( function ( ) {
var container = $ ( this ) ;
var tmp _array = [ ] ;
var ans _container = container . find ( ".audio_answer" ) ;
container . find ( ".text_cont .audio_desc" ) . removeAttr ( "contenteditable" ) ;
container . find ( ".audio_block" ) . removeAttr ( "ondragenter" )
. removeAttr ( "ondragleave" )
. removeAttr ( "ondragover" )
. removeAttr ( "ondrop" )
container . find ( ".close_cont" ) . remove ( ) ;
var answer = ans _container . text ( ) ;
ans _container . prev ( ) . val ( answer )
ans _container . remove ( ) ;
var ul _cont = $ ( "<ul id='sortable' class='imgs_answers_gray'>" ) . insertAfter ( container . find ( ".sub_cont" ) ) ;
for ( var j in answer ) {
var tmp _letter = $ ( "<li class='ui-state-default'>" + answer [ j ] + "</li>" ) ;
tmp _array . push ( tmp _letter ) ;
}
tmp _array = shuffle ( tmp _array ) ;
for ( var i = 0 ; i < tmp _array . length ; i ++ )
tmp _array [ i ] . appendTo ( ul _cont ) ;
ul _cont . sortable ( { revert : true , placeholder : "highlight" , update : checkResult } ) ;
} ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_edit" ) . css ( "display" , "block" ) ;
}
} else {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
if ( window . sankore )
sankore . enableDropOnWidget ( true ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_display" ) . removeClass ( "selected" ) ;
$ ( ".style_select" ) . css ( "display" , "block" ) ;
$ ( ".cont" ) . each ( function ( ) {
var container = $ ( this ) ;
$ ( "<div class='close_cont'>" ) . appendTo ( container ) ;
container . find ( "#sortable" ) . removeClass ( "imgs_answers_red" )
. removeClass ( "imgs_answers_green" )
. addClass ( "imgs_answers_gray" )
. sortable ( "destroy" ) ;
container . find ( ".text_cont .audio_desc" ) . attr ( "contenteditable" , "true" ) ;
container . find ( ".audio_block" ) . attr ( "ondragenter" , "return false;" )
. attr ( "ondragleave" , "$(this).removeClass('audio_gray'); return false;" )
. attr ( "ondragover" , "$(this).addClass('audio_gray'); return false;" )
. attr ( "ondrop" , "$(this).removeClass('audio_gray'); return onDropAudio(this,event);" ) ;
$ ( "<div class='audio_answer' contenteditable>" + container . find ( "ul" ) . next ( ) . val ( ) + "</div>" ) . appendTo ( container ) ;
container . find ( "ul" ) . remove ( ) ;
} ) ;
$ ( "<div class='add_block'>" + sankoreLang . add + "</div>" ) . appendTo ( "#data" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_display" ) . css ( "display" , "block" ) ;
}
}
$ ( "audio" ) . each ( function ( ) {
this . pause ( ) ;
$ ( this ) . parent ( ) . find ( ":first-child" ) . removeClass ( "stop" ) . addClass ( "play" ) ;
} ) ;
} ) ;
//add new block
$ ( ".add_block" ) . live ( "click" , function ( ) {
addContainer ( ) ;
} ) ;
//adding new img
$ ( ".add_img" ) . live ( "click" , function ( ) {
addImgBlock ( $ ( this ) ) ;
} ) ;
//deleting a block
$ ( ".close_cont" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . remove ( ) ;
refreshBlockNumbers ( ) ;
} ) ;
//deleting the img block
$ ( ".close_img" ) . live ( "click" , function ( ) {
var i = 0 ;
var tmp _obj = $ ( this ) . parent ( ) . parent ( ) ;
$ ( this ) . parent ( ) . remove ( ) ;
} ) ;
//correct image
$ ( ".true_img" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . parent ( ) . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . find ( "input" ) . val ( 0 ) ;
var tmp _div = $ ( this ) . find ( ".false_img" ) ;
if ( tmp _div )
tmp _div . removeClass ( "false_img" ) . addClass ( "true_img" ) ;
} )
$ ( this ) . parent ( ) . find ( "input" ) . val ( 1 ) ;
$ ( this ) . removeClass ( "true_img" ) . addClass ( "false_img" ) ;
} ) ;
//wrong image
$ ( ".false_img" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . find ( "input" ) . val ( 0 ) ;
$ ( this ) . removeClass ( "false_img" ) . addClass ( "true_img" ) ;
} ) ;
//play/pause event
$ ( ".play, .stop" ) . live ( "click" , function ( ) {
var tmp _audio = $ ( this ) ;
var audio = tmp _audio . parent ( ) . find ( "audio" ) . get ( 0 ) ;
if ( $ ( this ) . hasClass ( "play" ) ) {
if ( tmp _audio . parent ( ) . find ( "source" ) . attr ( "src" ) ) {
tmp _audio . removeClass ( "play" ) . addClass ( "stop" ) ;
var id = setInterval ( function ( ) {
if ( audio . currentTime == audio . duration ) {
clearInterval ( id ) ;
tmp _audio . removeClass ( "stop" ) . addClass ( "play" ) ;
}
} , 10 ) ;
tmp _audio . parent ( ) . find ( "input" ) . val ( id ) ;
audio . play ( ) ;
}
} else {
$ ( this ) . removeClass ( "stop" ) . addClass ( "play" ) ;
clearInterval ( tmp _audio . parent ( ) . find ( "input" ) . val ( ) )
audio . pause ( ) ;
}
} ) ;
$ ( ".replay" ) . live ( "click" , function ( ) {
var tmp _audio = $ ( this ) . prev ( ) ;
var audio = $ ( this ) . parent ( ) . find ( "audio" ) . get ( 0 ) ;
if ( tmp _audio . parent ( ) . find ( "source" ) . attr ( "src" ) ) {
$ ( this ) . prev ( ) . removeClass ( "play" ) . addClass ( "stop" ) ;
clearInterval ( $ ( this ) . parent ( ) . find ( "input" ) . val ( ) ) ;
var id = setInterval ( function ( ) {
if ( audio . currentTime == audio . duration ) {
clearInterval ( id ) ;
tmp _audio . removeClass ( "stop" ) . addClass ( "play" ) ;
}
} , 10 ) ;
tmp _audio . parent ( ) . find ( "input" ) . val ( id ) ;
audio . currentTime = 0 ;
audio . play ( ) ;
}
} ) ;
}
//export
function exportData ( ) {
var array _to _export = [ ] ;
if ( $ ( "#wgt_edit" ) . hasClass ( "selected" ) ) {
$ ( ".cont" ) . each ( function ( ) {
var cont _obj = new Object ( ) ;
cont _obj . text = $ ( this ) . find ( ".audio_desc" ) . text ( ) ;
cont _obj . audio = $ ( this ) . find ( "source" ) . attr ( "src" ) . replace ( "../../" , "" ) ;
cont _obj . answer = $ ( this ) . find ( ".audio_answer" ) . text ( ) ;
cont _obj . cur _answer = "" ;
array _to _export . push ( cont _obj ) ;
} ) ;
} else {
$ ( ".cont" ) . each ( function ( ) {
var cont _obj = new Object ( ) ;
cont _obj . text = $ ( this ) . find ( ".audio_desc" ) . text ( ) ;
cont _obj . audio = $ ( this ) . find ( "source" ) . attr ( "src" ) . replace ( "../../" , "" ) ;
cont _obj . answer = $ ( this ) . find ( "ul" ) . next ( ) . val ( ) ;
cont _obj . cur _answer = getAnswer ( $ ( this ) . find ( "ul" ) ) ;
array _to _export . push ( cont _obj ) ;
} ) ;
}
sankore . setPreference ( "associer_sound" , JSON . stringify ( array _to _export ) ) ;
if ( $ ( "#wgt_display" ) . hasClass ( "selected" ) )
sankore . setPreference ( "associer_sound_state" , "display" ) ;
else
sankore . setPreference ( "associer_sound_state" , "edit" ) ;
}
//import
function importData ( data ) {
var tmp = 0 ;
for ( var i in data ) {
var tmp _array = [ ] ;
var container = $ ( "<div class='cont'>" ) . appendTo ( "#data" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
var imgs _container = $ ( "<ul id='sortable' class='imgs_answers_gray'>" ) . appendTo ( container ) ;
$ ( "<div class='number_cont'>" + ( ++ tmp ) + "</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont'>" ) . appendTo ( sub _container ) ;
var audio _block = $ ( "<div class='audio_block'>" ) . appendTo ( text ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "../../" + data [ i ] . audio ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
$ ( "<input type='hidden'/>" ) . appendTo ( audio _block ) ;
$ ( "<div class='audio_desc'>" + data [ i ] . text + "</div>" ) . appendTo ( text ) ;
$ ( "<input type='hidden' value='" + data [ i ] . answer + "'/>" ) . appendTo ( container ) ;
if ( data [ i ] . cur _answer )
for ( var j in data [ i ] . cur _answer ) {
var tmp _letter = $ ( "<li class='ui-state-default'>" + data [ i ] . cur _answer [ j ] + "</li>" ) ;
tmp _array . push ( tmp _letter ) ;
}
else
for ( j in data [ i ] . answer ) {
tmp _letter = $ ( "<li class='ui-state-default'>" + data [ i ] . answer [ j ] + "</li>" ) ;
tmp _array . push ( tmp _letter ) ;
}
if ( sankore . preference ( "associer_sound_state" , "" ) ) {
if ( sankore . preference ( "associer_sound_state" , "" ) == "edit" )
tmp _array = shuffle ( tmp _array ) ;
} else
tmp _array = shuffle ( tmp _array ) ;
for ( j = 0 ; j < tmp _array . length ; j ++ )
tmp _array [ j ] . appendTo ( imgs _container ) ;
imgs _container . sortable ( { revert : true , placeholder : "highlight" } ) . bind ( 'sortupdate' , function ( event , ui ) {
checkResult ( event ) ;
} ) ;
if ( data [ i ] . cur _answer )
imgs _container . trigger ( "sortupdate" )
}
}
//example
function showExample ( ) {
var tmp _array = [ ] ;
var container = $ ( "<div class='cont'>" ) . appendTo ( "#data" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
var imgs _container = $ ( "<ul id='sortable' class='imgs_answers_gray'>" ) . appendTo ( container ) ;
var number = $ ( "<div class='number_cont'>1</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont'>" ) . appendTo ( sub _container ) ;
var audio _block = $ ( "<div class='audio_block'>" ) . appendTo ( text ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "objects/beep.mp3" ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
$ ( "<input type='hidden'/>" ) . appendTo ( audio _block ) ;
var audio _desc = $ ( "<div class='audio_desc'>" + sankoreLang . short _desc + "</div>" ) . appendTo ( text ) ;
$ ( "<input type='hidden' value='" + sankoreLang . example + "'/>" ) . appendTo ( container ) ;
for ( var j in sankoreLang . example ) {
var tmp _letter = $ ( "<li class='ui-state-default'>" + sankoreLang . example [ j ] + "</li>" ) ;
tmp _array . push ( tmp _letter ) ;
}
tmp _array = shuffle ( tmp _array ) ;
for ( var i = 0 ; i < tmp _array . length ; i ++ )
tmp _array [ i ] . appendTo ( imgs _container ) ;
imgs _container . sortable ( { revert : true , placeholder : "highlight" } ) . bind ( 'sortupdate' , function ( event , ui ) {
checkResult ( event ) ;
} ) ;
}
//add new container
function addContainer ( ) {
var container = $ ( "<div class='cont'>" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
$ ( "<div class='number_cont'>" + ( $ ( ".cont" ) . size ( ) + 1 ) + "</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont'>" ) . appendTo ( sub _container ) ;
text . attr ( "ondragenter" , "return false;" )
. attr ( "ondragleave" , "$(this).removeClass('gray'); return false;" )
. attr ( "ondragover" , "$(this).addClass('gray'); return false;" )
. attr ( "ondrop" , "$(this).removeClass('gray'); return onDropAudio(this,event);" ) ;
var audio _block = $ ( "<div class='audio_block'>" ) . appendTo ( text ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "" ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
$ ( "<input type='hidden'/>" ) . appendTo ( audio _block ) ;
$ ( "<div class='audio_desc' contenteditable>" + sankoreLang . enter + "</div>" ) . appendTo ( text ) ;
var tmp _input = $ ( "<input type='hidden' value=''/>" ) . insertAfter ( sub _container ) ;
var close = $ ( "<div class='close_cont'>" ) . insertAfter ( tmp _input ) ;
$ ( "<div class='audio_answer' contenteditable>" + sankoreLang . example + "</div>" ) . insertAfter ( close ) ;
container . insertBefore ( $ ( ".add_block" ) ) ;
}
function refreshBlockNumbers ( ) {
var i = 0 ;
$ ( ".cont" ) . each ( function ( ) {
$ ( this ) . find ( ".number_cont" ) . text ( ++ i ) ;
} )
}
//shuffles an array
function shuffle ( arr )
{
var pos , tmp ;
for ( var i = 0 ; i < arr . length ; i ++ )
{
pos = Math . round ( Math . random ( ) * ( arr . length - 1 ) ) ;
tmp = arr [ pos ] ;
arr [ pos ] = arr [ i ] ;
arr [ i ] = tmp ;
}
return arr ;
}
//check result
function checkResult ( event )
{
var str = "" ;
var right _str = $ ( event . target ) . next ( ) . val ( ) ;
$ ( event . target ) . find ( "li.ui-state-default" ) . each ( function ( ) {
str += $ ( this ) . text ( ) ;
} ) ;
if ( str == right _str )
$ ( event . target ) . removeClass ( "imgs_answers_gray" )
. removeClass ( "imgs_answers_red" )
. addClass ( "imgs_answers_green" ) ;
else
$ ( event . target ) . removeClass ( "imgs_answers_gray" )
. removeClass ( "imgs_answers_green" ) ;
}
function stringToXML ( text ) {
if ( window . ActiveXObject ) {
var doc = new ActiveXObject ( 'Microsoft.XMLDOM' ) ;
doc . async = 'false' ;
doc . loadXML ( text ) ;
} else {
var parser = new DOMParser ( ) ;
doc = parser . parseFromString ( text , 'text/xml' ) ;
}
return doc ;
}
//changing the style
function changeStyle ( val ) {
switch ( val ) {
case "1" :
$ ( ".b_top_left" ) . removeClass ( "btl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_top_center" ) . removeClass ( "btc_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_top_right" ) . removeClass ( "btr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_center_left" ) . removeClass ( "bcl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_center_right" ) . removeClass ( "bcr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_right" ) . removeClass ( "bbr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_left" ) . removeClass ( "bbl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_center" ) . removeClass ( "bbc_pad" ) . removeClass ( "without_back" ) ;
$ ( "#wgt_reload" ) . removeClass ( "pad_color" ) . removeClass ( "pad_reload" ) ;
$ ( "#wgt_help" ) . removeClass ( "pad_color" ) . removeClass ( "pad_help" ) ;
$ ( "#wgt_edit" ) . removeClass ( "pad_color" ) . removeClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . removeClass ( "pad_color" ) . removeClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . removeClass ( "pad_color" ) ;
$ ( ".style_select" ) . removeClass ( "pad_select" ) . removeClass ( "none_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) ;
break ;
case "2" :
$ ( ".b_top_left" ) . addClass ( "btl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_top_center" ) . addClass ( "btc_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_top_right" ) . addClass ( "btr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_center_left" ) . addClass ( "bcl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_center_right" ) . addClass ( "bcr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_right" ) . addClass ( "bbr_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_left" ) . addClass ( "bbl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_bottom_center" ) . addClass ( "bbc_pad" ) . removeClass ( "without_back" ) ;
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( ".style_select" ) . addClass ( "pad_select" ) . removeClass ( "none_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) ;
break ;
case "3" :
$ ( ".b_top_left" ) . addClass ( "without_back" ) . removeClass ( "btl_pad" ) ;
$ ( ".b_top_center" ) . addClass ( "without_back" ) . removeClass ( "btc_pad" ) ;
$ ( ".b_top_right" ) . addClass ( "without_back" ) . removeClass ( "btr_pad" ) ;
$ ( ".b_center_left" ) . addClass ( "without_back" ) . removeClass ( "bcl_pad" ) ;
$ ( ".b_center_right" ) . addClass ( "without_back" ) . removeClass ( "bcr_pad" ) ;
$ ( ".b_bottom_right" ) . addClass ( "without_back" ) . removeClass ( "bbr_pad" ) ;
$ ( ".b_bottom_left" ) . addClass ( "without_back" ) . removeClass ( "bbl_pad" ) ;
$ ( ".b_bottom_center" ) . addClass ( "without_back" ) . removeClass ( "bbc_pad" ) ;
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( ".style_select" ) . addClass ( "none_select" ) . val ( val ) ;
$ ( "body, html" ) . addClass ( "without_radius" ) ;
break ;
}
}
function onDropAudio ( obj , event ) {
if ( event . dataTransfer ) {
var format = "text/plain" ;
var textData = event . dataTransfer . getData ( format ) ;
if ( ! textData ) {
alert ( ":(" ) ;
}
textData = stringToXML ( textData ) ;
var tmp = textData . getElementsByTagName ( "path" ) [ 0 ] . firstChild . textContent ;
var tmp _type = textData . getElementsByTagName ( "type" ) [ 0 ] . firstChild . textContent ;
if ( tmp _type . substr ( 0 , 5 ) == "audio" ) {
var audio _block = $ ( obj ) . find ( ".audio_block" ) ;
$ ( obj ) . find ( "audio" ) . remove ( ) ;
audio _block . find ( ":first-child" ) . removeClass ( "stop" ) . addClass ( "play" ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "../../" + tmp ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
}
}
else {
alert ( "Your browser does not support the dataTransfer object." ) ;
}
if ( event . stopPropagation ) {
event . stopPropagation ( ) ;
}
else {
event . cancelBubble = true ;
}
return false ;
}
//get text
function getAnswer ( obj ) {
var answer = "" ;
obj . find ( "li.ui-state-default" ) . each ( function ( ) {
answer += $ ( this ) . text ( ) ;
} ) ;
return answer ;
}
if ( window . widget ) {
window . widget . onremove = function ( ) {
$ ( "audio" ) . each ( function ( ) {
this . pause ( ) ;
$ ( this ) . parent ( ) . find ( ":first-child" ) . removeClass ( "stop" ) . addClass ( "play" ) ;
} ) ;
}
}