var sankoreLang = {
display : "Fermer" ,
edit : "Modifier" ,
short _desc : "Placez les images dans l'ordre croissant." ,
add : "Nouveau bloc" ,
enter : "Saisir votre consigne ici ..." ,
wgt _name : "Ordonner des images" ,
reload : "Recharger" ,
slate : "ardoise" ,
pad : "tablette" ,
none : "aucun" ,
help : "Aide" ,
help _content : "<p><h2>Ordonner des images</h2></p>" +
"<p><h3>Classer des images dans l’ordre demandé.</h3></p>" +
"<p>La consigne indique dans quel ordre les images doivent être classées. Le classement des images s’effectue par un glisser-déposer. Une fois que toutes les images sont correctement classées, la zone se colore en vert.</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 modifier un exercice ou d’en créer de nouveaux dans la même activité.</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 votre consigne ici …”,</li>" +
"<li>insérez des images dans les zones de dépôt par glisser-déposer des images à partir de votre bibliothèque,</li>" +
"<li>modifiez éventuellement l’ordre des images par un glisser-déposer de l’image concernée pour la mettre au bon endroit dans la suite.</li></ul>" +
"<p>Pour ajouter une zone image, cliquez sur le gros “+” en bas.</p>" +
"<p>Pour supprimer une zone image, cliquez sur la croix située dans le coin supérieur droit de l’image.</p>" +
"<p>Pour changer d’image, cliquez sur l’icône située au milieu à droite de l’image.</p>" +
"<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>" ,
theme : "Thème"
} ;
//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 ) ;
var tmpl = $ ( "div.inline label" ) . html ( ) ;
$ ( "div.inline label" ) . html ( sankoreLang . theme + tmpl )
if ( window . sankore ) {
if ( sankore . preference ( "odr_des_imgs" , "" ) ) {
var data = jQuery . parseJSON ( sankore . preference ( "odr_des_imgs" , "" ) ) ;
importData ( data ) ;
} else {
showExample ( ) ;
}
}
else
showExample ( ) ;
//events
if ( window . widget ) {
window . widget . onleave = function ( ) {
exportData ( ) ;
}
}
$ ( "#wgt_help" ) . click ( function ( ) {
var tmp = $ ( this ) ;
if ( $ ( this ) . hasClass ( "open" ) ) {
$ ( this ) . removeClass ( "help_pad" ) . removeClass ( "help_wood" )
$ ( "#help" ) . slideUp ( "100" , function ( ) {
tmp . removeClass ( "open" ) ;
$ ( "#data" ) . show ( ) ;
} ) ;
} else {
( $ ( "#style_select" ) . val ( ) == 1 ) ? $ ( this ) . removeClass ( "help_pad" ) . addClass ( "help_wood" ) : $ ( this ) . removeClass ( "help_wood" ) . addClass ( "help_pad" ) ;
$ ( "#data" ) . hide ( ) ;
$ ( "#help" ) . slideDown ( "100" , function ( ) {
tmp . addClass ( "open" ) ;
} ) ;
}
} ) ;
$ ( "#wgt_reload" ) . click ( function ( ) {
if ( $ ( "#wgt_display" ) . hasClass ( "selected" ) ) {
$ ( "#wgt_edit" ) . trigger ( "click" ) ;
$ ( "#wgt_display" ) . 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" ) ) {
sankore . enableDropOnWidget ( false ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_edit" ) . removeClass ( "selected" ) ;
$ ( "#parameters" ) . css ( "display" , "none" ) ;
$ ( ".add_block" ) . remove ( ) ;
$ ( ".cont" ) . each ( function ( ) {
var container = $ ( this ) ;
var tmp _i = 0 ;
var tmp _right = "" ;
var tmp _array = [ ] ;
container . find ( ".text_cont" ) . removeAttr ( "contenteditable" ) ;
container . find ( ".add_img" ) . remove ( ) ;
container . find ( ".close_cont" ) . remove ( ) ;
container . find ( ".img_block" ) . each ( function ( ) {
if ( $ ( this ) . find ( "img" ) . attr ( "src" ) != "img/drop_img.png" ) {
$ ( this ) . find ( ".close_img" ) . remove ( ) ;
$ ( this ) . find ( ".clear_img" ) . remove ( ) ;
$ ( this ) . find ( ".numb_img" ) . remove ( ) ;
$ ( this ) . removeAttr ( "ondragenter" )
. removeAttr ( "ondragleave" )
. removeAttr ( "ondragover" )
. removeAttr ( "ondrop" ) ;
$ ( this ) . find ( "input" ) . val ( ++ tmp _i )
tmp _right += tmp _i + "*" ;
} else
$ ( this ) . remove ( ) ;
} ) ;
container . find ( ".imgs_cont>input" ) . val ( tmp _right ) ;
container . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . css ( "float" , "" ) ;
tmp _array . push ( $ ( this ) ) ;
} ) ;
tmp _array = shuffle ( tmp _array ) ;
for ( var i = 0 ; i < tmp _array . length ; i ++ )
tmp _array [ i ] . appendTo ( container . find ( ".imgs_cont" ) ) ;
container . find ( ".imgs_cont" ) . sortable ( {
update : checkResult
} ) ;
} ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_edit" ) . css ( "display" , "block" ) ;
}
} else {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
sankore . enableDropOnWidget ( true ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_display" ) . removeClass ( "selected" ) ;
$ ( "#parameters" ) . css ( "display" , "block" ) ;
$ ( ".cont" ) . each ( function ( ) {
var container = $ ( this ) ;
$ ( "<div class='close_cont'>" ) . appendTo ( container ) ;
container . find ( ".text_cont" ) . attr ( "contenteditable" , "true" ) ;
//container.find(".imgs_cont").sortable("destroy");
container . find ( ".imgs_cont" ) . css ( "background-color" , "" ) ;
var add _img = $ ( "<div class='add_img'>" ) ;
container . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . attr ( "ondragenter" , "return false;" )
. attr ( "ondragleave" , "$(this).css(\"background-color\",\"\"); return false;" )
. attr ( "ondragover" , "$(this).css(\"background-color\",\"#ccc\"); return false;" )
. attr ( "ondrop" , "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);" )
//.css("float","left");
$ ( "<div class='close_img'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='clear_img'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='numb_img'>" + $ ( this ) . find ( "input" ) . val ( ) + "</div>" ) . appendTo ( $ ( this ) ) ;
} ) ;
rightOrder ( container . find ( ".imgs_cont" ) ) ;
container . find ( ".imgs_cont" ) . append ( add _img )
} ) ;
$ ( "<div class='add_block'>" + sankoreLang . add + "</div>" ) . appendTo ( "#data" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_display" ) . css ( "display" , "block" ) ;
}
}
} ) ;
//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 ( ) ;
if ( tmp _obj . find ( ".img_block" ) . size ( ) > 0 ) {
refreshImgNumbers ( tmp _obj ) ;
}
} ) ;
//cleaning an image
$ ( ".clear_img" ) . live ( "click" , function ( ) {
//$(this).parent().find(".fill_img").remove();
$ ( this ) . parent ( ) . find ( "img" ) . attr ( "src" , "img/drop_img.png" ) ;
} ) ;
}
//export
function exportData ( ) {
var array _to _export = [ ] ;
if ( $ ( "#edit" ) . hasClass ( "selected" ) ) {
$ ( ".cont" ) . each ( function ( ) {
var container = $ ( this ) ;
var tmp _right = "" ;
var tmp _i = 0 ;
container . find ( ".img_block" ) . each ( function ( ) {
if ( $ ( this ) . html ( ) . match ( /<img/ ) ) {
$ ( this ) . find ( "input" ) . val ( ++ tmp _i )
tmp _right += tmp _i + "*" ;
}
} ) ;
container . find ( ".imgs_cont>input" ) . val ( tmp _right ) ;
} ) ;
}
$ ( ".cont" ) . each ( function ( ) {
var cont _obj = new Object ( ) ;
cont _obj . style = $ ( "#style_select" ) . find ( "option:selected" ) . val ( ) ;
cont _obj . text = $ ( this ) . find ( ".text_cont" ) . text ( ) ;
cont _obj . right = $ ( this ) . find ( ".imgs_cont>input" ) . val ( ) ;
cont _obj . imgs = [ ] ;
$ ( this ) . find ( ".img_block" ) . each ( function ( ) {
var img _obj = new Object ( ) ;
img _obj . value = $ ( this ) . find ( "input" ) . val ( ) ;
img _obj . link = $ ( this ) . find ( "img" ) . attr ( "src" ) . replace ( "../../" , "" ) ;
img _obj . ht = $ ( this ) . find ( "img" ) . height ( ) ;
img _obj . wd = $ ( this ) . find ( "img" ) . width ( ) ;
cont _obj . imgs . push ( img _obj ) ;
} ) ;
array _to _export . push ( cont _obj ) ;
} ) ;
if ( $ ( ".cont" ) . size ( ) == 0 ) {
var cont _obj = new Object ( ) ;
cont _obj . style = $ ( "#style_select" ) . find ( "option:selected" ) . val ( ) ;
cont _obj . tmp = "clear" ;
array _to _export . push ( cont _obj ) ;
}
sankore . setPreference ( "odr_des_imgs" , JSON . stringify ( array _to _export ) ) ;
if ( $ ( "#wgt_display" ) . hasClass ( "selected" ) )
sankore . setPreference ( "odr_des_imgs_state" , "display" ) ;
else
sankore . setPreference ( "odr_des_imgs_state" , "edit" ) ;
}
//import
function importData ( data ) {
var tmp = 0 ;
for ( var i in data ) {
if ( data [ i ] . tmp ) {
changeStyle ( data [ i ] . style ) ;
$ ( "#style_select" ) . val ( data [ i ] . style ) ;
} else {
if ( i == 0 ) {
changeStyle ( data [ i ] . style ) ;
$ ( "#style_select" ) . val ( data [ i ] . style ) ;
}
var tmp _array = [ ] ;
var container = $ ( "<div class='cont'>" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
var imgs _container = $ ( "<div class='imgs_cont'>" ) . appendTo ( container ) ;
var number = $ ( "<div class='number_cont'>" + ( ++ tmp ) + "</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont'>" + data [ i ] . text + "</div>" ) . appendTo ( sub _container ) ;
$ ( "<input type='hidden' value='" + data [ i ] . right + "'/>" ) . appendTo ( imgs _container ) ;
for ( var j in data [ i ] . imgs ) {
var img _block = $ ( "<div class='img_block' style='text-align: center;'>" ) ;
var img = $ ( "<img src='../../" + data [ i ] . imgs [ j ] . link + "' style='display: inline;'>" ) ;
img . height ( data [ i ] . imgs [ j ] . ht ) ;
if ( ( 120 - data [ i ] . imgs [ j ] . ht ) > 0 )
img . css ( "margin" , ( 120 - data [ i ] . imgs [ j ] . ht ) / 2 + "px 0" ) ;
var hidden _input = $ ( "<input type='hidden'>" ) . val ( data [ i ] . imgs [ j ] . value ) ;
img _block . append ( hidden _input ) . append ( img ) ;
tmp _array . push ( img _block ) ;
}
if ( sankore . preference ( "odr_des_imgs_state" , "" ) ) {
if ( sankore . preference ( "odr_des_imgs_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 ( ) . bind ( 'sortupdate' , function ( event , ui ) {
checkResult ( event ) ;
} ) ;
container . appendTo ( "#data" ) ;
imgs _container . trigger ( "sortupdate" )
}
}
}
//example
function showExample ( ) {
changeStyle ( "3" ) ;
var tmp _array = [ ] ;
var container = $ ( "<div class='cont'>" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
var imgs _container = $ ( "<div class='imgs_cont'>" ) . appendTo ( container ) ;
var number = $ ( "<div class='number_cont'>1</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont'>" + sankoreLang . short _desc + "</div>" ) . appendTo ( sub _container ) ;
$ ( "<input type='hidden' value='1*2*3*4*5*'/>" ) . appendTo ( imgs _container ) ;
var img1 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) ;
$ ( "<input type='hidden' value='1'/>" ) . appendTo ( img1 ) ;
$ ( "<img src=\"../../objects/0.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img1 ) ;
var img2 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) ;
$ ( "<input type='hidden' value='2'/>" ) . appendTo ( img2 ) ;
$ ( "<img src=\"../../objects/1.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img2 ) ;
var img3 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) ;
$ ( "<input type='hidden' value='3'/>" ) . appendTo ( img3 ) ;
$ ( "<img src=\"../../objects/2.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img3 ) ;
var img4 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) ;
$ ( "<input type='hidden' value='4'/>" ) . appendTo ( img4 ) ;
$ ( "<img src=\"../../objects/3.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img4 ) ;
var img5 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) ;
$ ( "<input type='hidden' value='5'/>" ) . appendTo ( img5 ) ;
$ ( "<img src=\"../../objects/4.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img5 ) ;
tmp _array . push ( img1 , img2 , img3 , img4 , img5 ) ;
tmp _array = shuffle ( tmp _array ) ;
for ( var i = 0 ; i < tmp _array . length ; i ++ )
tmp _array [ i ] . appendTo ( imgs _container ) ;
imgs _container . sortable ( ) . bind ( 'sortupdate' , function ( event , ui ) {
checkResult ( event ) ;
} ) ;
container . appendTo ( "#data" ) ;
}
//check result
function checkResult ( event )
{
if ( $ ( "#wgt_display" ) . hasClass ( "selected" ) ) {
var str = "" ;
var right _str = $ ( event . target ) . find ( "input" ) . val ( ) ;
$ ( event . target ) . find ( ".img_block" ) . each ( function ( ) {
str += $ ( this ) . find ( "input" ) . val ( ) + "*" ;
} ) ;
if ( str == right _str )
$ ( event . target ) . css ( "background-color" , "#9f9" ) ;
else
$ ( event . target ) . css ( "background-color" , "" ) ;
} else {
refreshImgNumbers ( $ ( event . target ) ) ;
}
}
//add new container
function addContainer ( ) {
var container = $ ( "<div class='cont'>" ) ;
var sub _container = $ ( "<div class='sub_cont'>" ) . appendTo ( container ) ;
var imgs _container = $ ( "<div class='imgs_cont'>" ) . appendTo ( container ) ;
var close = $ ( "<div class='close_cont'>" ) . appendTo ( container ) ;
var number = $ ( "<div class='number_cont'>" + ( $ ( ".cont" ) . size ( ) + 1 ) + "</div>" ) . appendTo ( sub _container ) ;
var text = $ ( "<div class='text_cont' contenteditable>" + sankoreLang . enter + "</div>" ) . appendTo ( sub _container ) ;
$ ( "<input type='hidden' value='1*2*3*4*5*'/>" ) . appendTo ( imgs _container ) ;
var add _img = $ ( "<div class='add_img'>" ) . appendTo ( imgs _container ) ;
container . insertBefore ( $ ( ".add_block" ) ) ;
}
//add new img block
function addImgBlock ( dest ) {
var img _block = $ ( "<div class='img_block' ondragenter='return false;' ondragleave='$(this).css(\"background-color\",\"\"); return false;' ondragover='$(this).css(\"background-color\",\"#ccc\"); return false;' ondrop='$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);' style='text-align: center;'></div>" ) . insertBefore ( dest ) ;
var tmp _counter = dest . parent ( ) . find ( ".img_block" ) . size ( ) ;
$ ( "<div class='close_img'>" ) . appendTo ( img _block ) ;
$ ( "<div class='clear_img'>" ) . appendTo ( img _block ) ;
$ ( "<div class='numb_img'>" + tmp _counter + "</div>" ) . appendTo ( img _block ) ;
$ ( "<input type='hidden' value='" + tmp _counter + "'/>" ) . appendTo ( img _block ) ;
$ ( "<img src='img/drop_img.png' height='120'/>" ) . appendTo ( img _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 ;
}
//regulation the images in right order
function rightOrder ( source ) {
var tmp _arr = [ ] ;
var tmp _var ;
source . find ( ".img_block" ) . each ( function ( ) {
tmp _arr . push ( $ ( this ) ) ;
$ ( this ) . remove ( ) ;
} ) ;
for ( var i = 0 ; i < tmp _arr . length ; i ++ )
for ( var j = 0 ; j < tmp _arr . length - 1 ; j ++ ) {
if ( tmp _arr [ j ] . find ( "input" ) . val ( ) > tmp _arr [ j + 1 ] . find ( "input" ) . val ( ) ) {
tmp _var = tmp _arr [ j ] ;
tmp _arr [ j ] = tmp _arr [ j + 1 ] ;
tmp _arr [ j + 1 ] = tmp _var ;
}
}
for ( i in tmp _arr )
source . append ( tmp _arr [ i ] ) ;
}
//refresh the numbers of the images
function refreshImgNumbers ( source ) {
var tmp = 1 ;
source . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . find ( "input" ) . val ( tmp ) ;
$ ( this ) . find ( ".numb_img" ) . text ( tmp ) ;
tmp ++ ;
} ) ;
}
//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_name" ) . removeClass ( "pad_color" ) ;
$ ( "#wgt_display" ) . addClass ( "display_wood" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) . addClass ( "radius_ft" ) ;
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_name" ) . addClass ( "pad_color" ) ;
$ ( "#wgt_display" ) . removeClass ( "display_wood" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) . removeClass ( "radius_ft" ) ;
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_name" ) . addClass ( "pad_color" ) ;
$ ( "#wgt_display" ) . removeClass ( "display_wood" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . addClass ( "without_radius" ) . removeClass ( "radius_ft" ) ;
break ;
}
}
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 ;
}
function onDropTarget ( obj , event ) {
$ ( obj ) . find ( "img" ) . remove ( ) ;
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 _img = $ ( "<img/>" ) . attr ( "src" , "../../" + tmp ) ;
$ ( obj ) . append ( tmp _img ) ;
setTimeout ( function ( ) {
if ( tmp _img . height ( ) >= tmp _img . width ( ) )
tmp _img . attr ( "height" , "120" ) ;
else {
tmp _img . attr ( "width" , "120" ) ;
var h = tmp _img . height ( ) ;
tmp _img . attr ( "height" , h ) ;
tmp _img . css ( "margin" , ( 120 - tmp _img . height ( ) ) / 2 + "px 0" ) ;
}
} , 6 )
}
else {
alert ( "Your browser does not support the dataTransfer object." ) ;
}
if ( event . stopPropagation ) {
event . stopPropagation ( ) ;
}
else {
event . cancelBubble = true ;
}
return false ;
}