var sankoreLang = {
display : "Afficher" ,
edit : "Modifier" ,
text _content : "Ceci est un exemple. Au lieu de ce texte, vous pouvez mettre votre propre texte ou glisser-déposer une image, un son ou une vidéo." ,
new _txt : "Nouveau bloc de texte" ,
new _slide : "Ceci est une nouvelle diapositive." ,
wgt _name : "Etudier" ,
slate : "Bois" ,
pad : "Pad" ,
none : "Aucun" ,
help : "Aide" ,
help _content : "<p><h2>Etudier</h2></p>" +
"<p><h3>Livret de pages.</h3></p>" +
"<p>L’interactivité Etudier permet d’ajouter un livret avec des pages. Ce livret peut être enrichi avec du texte, des images, du son et des vidéos.</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 les pages du livret.</li></ul>" +
"<p>Sur chaque page, vous pouvez :</p>" +
"<ul><li>insérer des zones de texte avec le bouton “+T” situé en haut à gauche de l’interactivité. (pour modifier ces zones de texte, cliquez à l’intérieur et écrivez du texte),</li>" +
"<li>insérer des images, sons et vidéos par glisser-déposer de fichiers depuis la bibliothèque jusqu’à l’intérieur de la page du livret,</li>" +
"<li>déplacer les textes, images, sons et vidéos à l’intérieur de la page en cliquant et en déplaçant la flèche multidirectionnelle qui se situe dans le coin supérieur gauche de chaque élément,</li>" +
"<li>agrandir la taille d’un élément avec la double flèche en bas à droite de celui-ci,</li>" +
"<li>supprimer un élément avec la case en haut à droite de celui-ci.</li></ul>" +
"<p>Pour ajouter une page, cliquez sur la flèche verte accompagnée d’un “+” se trouvant en bas à gauche et à droite.</p>" +
"<p>Pour supprimer une page, cliquez sur la croix rouge située en haut à droite de la page.</p>" +
"<p>Le bouton “Afficher” vous permet d’utiliser l’activité.</p>"
} ;
//some flags
var mouse _state = false ;
//object for resize
var resize _obj = {
object : null ,
top : 0 ,
left : 0 ,
clicked : false
}
//main function
function start ( ) {
$ ( "#wgt_display" ) . text ( sankoreLang . display ) ;
$ ( "#wgt_edit" ) . text ( sankoreLang . edit ) ;
$ ( "#wgt_name" ) . text ( sankoreLang . wgt _name ) ;
$ ( "#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 ( "etudier" , "" ) ) {
var data = jQuery . parseJSON ( sankore . preference ( "etudier" , "" ) ) ;
importData ( data ) ;
}
else
showExample ( ) ;
if ( sankore . preference ( "etudier_style" , "" ) ) {
changeStyle ( sankore . preference ( "etudier_style" , "" ) ) ;
$ ( ".style_select" ) . val ( sankore . preference ( "etudier_style" , "" ) ) ;
} else
changeStyle ( "3" )
}
else
showExample ( ) ;
//events
if ( window . widget ) {
window . widget . onleave = function ( ) {
if ( ! $ ( "#wgt_help" ) . hasClass ( "open" ) ) {
exportData ( ) ;
sankore . setPreference ( "etudier_style" , $ ( ".style_select" ) . find ( "option:selected" ) . val ( ) ) ;
sankore . setPreference ( "etudier_cur_page" , $ ( "#slider" ) . getPage ( ) ) ;
sankore . setPreference ( "etudier_left_nav" , $ ( "#prevBtn a" ) . css ( "display" ) ) ;
sankore . setPreference ( "etudier_right_nav" , $ ( "#nextBtn a" ) . css ( "display" ) ) ;
}
}
}
$ ( ".style_select" ) . change ( function ( event ) {
changeStyle ( $ ( this ) . find ( "option:selected" ) . val ( ) ) ;
} )
$ ( "#wgt_help" ) . click ( function ( ) {
var tmp = $ ( this ) ;
if ( $ ( this ) . hasClass ( "open" ) ) {
$ ( "#help" ) . hide ( ) ;
tmp . removeClass ( "open" ) ;
$ ( "#slider" ) . show ( ) ;
} else {
exportData ( ) ;
sankore . setPreference ( "etudier_style" , $ ( ".style_select" ) . find ( "option:selected" ) . val ( ) ) ;
sankore . setPreference ( "etudier_cur_page" , $ ( "#slider" ) . getPage ( ) ) ;
sankore . setPreference ( "etudier_left_nav" , $ ( "#prevBtn a" ) . css ( "display" ) ) ;
sankore . setPreference ( "etudier_right_nav" , $ ( "#nextBtn a" ) . css ( "display" ) ) ;
$ ( "#slider" ) . hide ( ) ;
$ ( "#help" ) . show ( ) ;
tmp . addClass ( "open" ) ;
}
} ) ;
$ ( "#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" ) ;
$ ( "#slider li>div" ) . each ( function ( ) {
var container = $ ( this ) ;
container . removeAttr ( "ondragenter" )
. removeAttr ( "ondragleave" )
. removeAttr ( "ondragover" )
. removeAttr ( "ondrop" ) ;
container . find ( ".text_block" ) . each ( function ( ) {
$ ( this ) . draggable ( ) ;
$ ( this ) . find ( ".move_block" ) . remove ( ) ;
$ ( this ) . find ( ".close_img" ) . remove ( ) ;
$ ( this ) . find ( ".size_up" ) . remove ( ) ;
$ ( this ) . find ( ".size_down" ) . remove ( ) ;
$ ( this ) . find ( ".resize_block" ) . remove ( ) ;
$ ( this ) . find ( ".real_text" ) . removeAttr ( "contenteditable" ) ;
$ ( this ) . removeClass ( "block_border" ) ;
$ ( this ) . css ( "position" , "absolute" ) ;
} ) ;
container . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . draggable ( ) ;
$ ( this ) . find ( ".close_img" ) . remove ( ) ;
$ ( this ) . find ( ".move_block" ) . remove ( ) ;
$ ( this ) . find ( ".resize_block" ) . remove ( ) ;
$ ( this ) . removeClass ( "block_border" ) ;
$ ( this ) . css ( "position" , "absolute" ) ;
} ) ;
container . find ( ".audio_block" ) . each ( function ( ) {
$ ( this ) . find ( ".close_img" ) . remove ( ) ;
$ ( this ) . removeClass ( "block_border" ) ;
$ ( this ) . css ( "position" , "absolute" ) ;
} ) ;
container . find ( ".add_left" ) . remove ( ) ;
container . find ( ".add_right" ) . remove ( ) ;
container . find ( ".close_slide" ) . remove ( ) ;
container . find ( ".add_text" ) . remove ( ) ;
} ) ;
$ ( 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" ) ;
$ ( "#slider li>div" ) . each ( function ( ) {
var container = $ ( this ) ;
container . attr ( "ondragenter" , "return false;" )
. attr ( "ondragleave" , "$(this).css(\"background\",\"none\"); return false;" )
. attr ( "ondragover" , "$(this).css(\"background-color\",\"#ccc\"); return false;" )
. attr ( "ondrop" , "$(this).css(\"background\",\"none\"); return onDropTarget(this,event);" ) ;
container . find ( ".text_block" ) . each ( function ( ) {
$ ( this ) . draggable ( "destroy" ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='size_up' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='size_down' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( this ) . find ( ".real_text" ) . attr ( "contenteditable" , "true" ) ;
$ ( this ) . addClass ( "block_border" ) ;
} ) ;
container . find ( ".img_block" ) . each ( function ( ) {
$ ( this ) . draggable ( "destroy" ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( this ) . addClass ( "block_border" ) ;
} ) ;
container . find ( ".audio_block" ) . each ( function ( ) {
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( $ ( this ) ) ;
$ ( this ) . addClass ( "block_border" ) ;
} ) ;
$ ( "<div class='add_left'>" ) . appendTo ( container ) ;
$ ( "<div class='add_right'>" ) . appendTo ( container ) ;
$ ( "<div class='close_slide'>" ) . appendTo ( container ) ;
$ ( "<div class='add_text'>" ) . appendTo ( container ) ;
$ ( window ) . trigger ( "resize" )
} ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_display" ) . css ( "display" , "block" ) ;
}
}
$ ( "audio" ) . each ( function ( ) {
this . pause ( ) ;
$ ( this ) . parent ( ) . find ( ":first-child" ) . removeClass ( "stop" ) . addClass ( "play" ) ;
} ) ;
} ) ;
//deleting the img block
$ ( ".close_img" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . remove ( ) ;
} ) ;
//increase a size of text
$ ( ".size_up" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . height ( "" ) ;
var fz = parseInt ( $ ( this ) . parent ( ) . css ( "font-size" ) . replace ( "px" , "" ) ) ;
$ ( this ) . parent ( ) . css ( "font-size" , fz + 1 + "px" ) ;
} ) ;
//decrease a size of text
$ ( ".size_down" ) . live ( "click" , function ( ) {
var fz = parseInt ( $ ( this ) . parent ( ) . css ( "font-size" ) . replace ( "px" , "" ) ) ;
fz = ( ( fz - 1 ) < 8 ) ? 8 : fz - 1 ;
$ ( this ) . parent ( ) . css ( "font-size" , fz + "px" ) ;
} ) ;
//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 ( ) ;
}
} ) ;
//moving objects
$ ( ".move_block" ) . live ( "mouseover" , function ( ) {
$ ( this ) . parent ( ) . draggable ( ) ;
} ) ;
$ ( ".move_block" ) . live ( "mouseleave" , function ( ) {
if ( ! mouse _state )
$ ( this ) . parent ( ) . draggable ( "destroy" ) ;
} ) ;
$ ( ".move_block" ) . live ( "mousedown" , function ( ) {
mouse _state = true ;
} ) ;
$ ( ".move_block" ) . live ( "mouseup" , function ( ) {
mouse _state = false ;
} ) ;
//resize block
$ ( ".resize_block" ) . live ( "mousedown" , function ( ) {
resize _obj . object = $ ( this ) ;
resize _obj . top = event . clientY ;
resize _obj . left = event . clientX ;
resize _obj . clicked = true ;
} )
$ ( "li>div" ) . live ( "mouseup" , function ( ) {
resize _obj . object = null ;
resize _obj . top = 0 ;
resize _obj . left = 0 ;
resize _obj . clicked = false ;
} )
$ ( "li>div" ) . live ( "mousemove" , function ( ) {
if ( resize _obj . clicked ) {
if ( resize _obj . object . parent ( ) . hasClass ( "text_block" ) ) {
var width = resize _obj . object . parent ( ) . width ( ) - resize _obj . left + event . clientX ;
//var height = resize_obj.object.parent().height() - resize_obj.top + event.clientY;
resize _obj . left = event . clientX ;
resize _obj . top = event . clientY ;
resize _obj . object . parent ( ) . width ( width ) ;
} else {
width = resize _obj . object . parent ( ) . width ( ) - resize _obj . left + event . clientX ;
var height = resize _obj . object . parent ( ) . height ( ) - resize _obj . top + event . clientY ;
var img _width = resize _obj . object . parent ( ) . find ( "img" ) . width ( ) - resize _obj . left + event . clientX ;
var img _height = resize _obj . object . parent ( ) . find ( "img" ) . height ( ) - resize _obj . top + event . clientY ;
resize _obj . left = event . clientX ;
resize _obj . top = event . clientY ;
resize _obj . object . parent ( ) . width ( width ) . height ( height ) ;
resize _obj . object . parent ( ) . find ( "img" ) . width ( img _width ) . height ( img _height ) ;
}
}
} ) ;
//closing a slide
$ ( ".close_slide" ) . live ( "click" , function ( ) {
$ ( this ) . parent ( ) . parent ( ) . remove ( ) ;
$ ( "#slider" ) . removeSlide ( ) ;
} ) ;
//adding new slides
$ ( ".add_left" ) . live ( "click" , function ( ) {
var cur _li = $ ( this ) . parent ( ) . parent ( ) ;
var new _li = $ ( "<li>" ) ;
new _li . width ( cur _li . width ( ) ) . height ( cur _li . height ( ) ) . css ( "float" , "left" ) ;
var new _div = $ ( "<div>" ) . appendTo ( new _li ) ;
new _div . 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);" ) ;
var example = $ ( "<div class='text_block' style='position: absolute;'>" ) . addClass ( "block_border" ) ;
$ ( "<div class='real_text' contenteditable='true'>" + sankoreLang . new _slide + "</div>" ) . appendTo ( example ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='size_up' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='size_down' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( example ) ;
example . css ( "top" , "40%" ) . css ( "left" , "40%" ) ;
new _div . append ( example ) ;
$ ( "<div class='add_left'>" ) . appendTo ( new _div ) ;
$ ( "<div class='add_right'>" ) . appendTo ( new _div ) ;
$ ( "<div class='close_slide'>" ) . appendTo ( new _div ) ;
$ ( "<div class='add_text'>" ) . appendTo ( new _div ) ;
new _li . insertBefore ( cur _li ) ;
$ ( "#slider" ) . addSlide ( "before" ) ;
} ) ;
$ ( ".add_right" ) . live ( "click" , function ( ) {
var cur _li = $ ( this ) . parent ( ) . parent ( ) ;
var new _li = $ ( "<li>" ) ;
new _li . width ( cur _li . width ( ) ) . height ( cur _li . height ( ) ) . css ( "float" , "left" ) ;
var new _div = $ ( "<div>" ) . appendTo ( new _li ) ;
new _div . 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);" ) ;
var example = $ ( "<div class='text_block' style='position: absolute;'>" ) . addClass ( "block_border" ) ;
$ ( "<div class='real_text' contenteditable='true'>" + sankoreLang . new _slide + "</div>" ) . appendTo ( example ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='size_up' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='size_down' contenteditable='false'>" ) . appendTo ( example ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( example ) ;
example . css ( "top" , "40%" ) . css ( "left" , "40%" ) ;
new _div . append ( example ) ;
$ ( "<div class='add_left'>" ) . appendTo ( new _div ) ;
$ ( "<div class='add_right'>" ) . appendTo ( new _div ) ;
$ ( "<div class='close_slide'>" ) . appendTo ( new _div ) ;
$ ( "<div class='add_text'>" ) . appendTo ( new _div ) ;
new _li . insertAfter ( cur _li ) ;
$ ( "#slider" ) . addSlide ( "after" ) ;
} ) ;
$ ( ".add_text" ) . live ( "click" , function ( ) {
var container = $ ( this ) . parent ( ) ;
var text _block = $ ( "<div class='text_block'><div class='real_text' contenteditable='true'>" + sankoreLang . new _txt + "</div></div>" ) . appendTo ( container ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( text _block ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( text _block ) ;
$ ( "<div class='size_up' contenteditable='false'>" ) . appendTo ( text _block ) ;
$ ( "<div class='size_down' contenteditable='false'>" ) . appendTo ( text _block ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( text _block ) ;
text _block . addClass ( "block_border" ) ;
} ) ;
}
//export
function exportData ( ) {
var array _to _export = [ ] ;
$ ( "#slider li>div" ) . each ( function ( ) {
var cont _obj = new Object ( ) ;
cont _obj . w = $ ( this ) . parent ( ) . width ( ) ;
cont _obj . h = $ ( this ) . parent ( ) . height ( ) ;
cont _obj . text = [ ] ;
$ ( this ) . find ( ".text_block" ) . each ( function ( ) {
var txt _block = new Object ( ) ;
txt _block . top = $ ( this ) . position ( ) . top ;
txt _block . left = $ ( this ) . position ( ) . left ;
txt _block . w = $ ( this ) . width ( ) ;
txt _block . fz = $ ( this ) . css ( "font-size" ) ;
txt _block . val = $ ( this ) . find ( ".real_text" ) . html ( ) ;
cont _obj . text . push ( txt _block ) ;
} ) ;
cont _obj . imgs = [ ] ;
$ ( this ) . find ( ".img_block" ) . each ( function ( ) {
var img _obj = new Object ( ) ;
img _obj . link = $ ( this ) . find ( "img" ) . attr ( "src" ) . replace ( "../../" , "" ) ;
img _obj . h = $ ( this ) . find ( "img" ) . height ( ) ;
img _obj . w = $ ( this ) . find ( "img" ) . width ( ) ;
img _obj . block _h = $ ( this ) . height ( ) ;
img _obj . block _w = $ ( this ) . width ( ) ;
img _obj . top = $ ( this ) . position ( ) . top ;
img _obj . left = $ ( this ) . position ( ) . left ;
cont _obj . imgs . push ( img _obj ) ;
} ) ;
cont _obj . audio = [ ] ;
$ ( this ) . find ( ".audio_block" ) . each ( function ( ) {
var audio _block = new Object ( ) ;
audio _block . top = $ ( this ) . position ( ) . top ;
audio _block . left = $ ( this ) . position ( ) . left ;
audio _block . val = $ ( this ) . find ( "source" ) . attr ( "src" ) . replace ( "../../" , "" ) ;
cont _obj . audio . push ( audio _block ) ;
} ) ;
array _to _export . push ( cont _obj ) ;
} ) ;
sankore . setPreference ( "etudier" , JSON . stringify ( array _to _export ) ) ;
}
//import
function importData ( data ) {
var width = 0 ;
var height = 0 ;
for ( var i in data ) {
width = data [ i ] . w ;
height = data [ i ] . h ;
var li = $ ( "<li style='float: left; width: " + data [ i ] . w + "; height: " + data [ i ] . h + ";'>" ) ;
var div = $ ( "<div>" ) . appendTo ( li ) ;
for ( var j in data [ i ] . text ) {
var text _div = $ ( "<div class='text_block'><div class='real_text'>" + data [ i ] . text [ j ] . val + "</div></div>" ) ;
text _div . draggable ( ) . css ( "position" , "absolute" )
. width ( data [ i ] . text [ j ] . w )
. css ( "top" , data [ i ] . text [ j ] . top )
. css ( "left" , data [ i ] . text [ j ] . left )
. css ( "font-size" , data [ i ] . text [ j ] . fz )
. appendTo ( div ) ;
}
for ( j in data [ i ] . imgs ) {
var img _div = $ ( "<div class='img_block' style='text-align: center;'>" ) ;
img _div . draggable ( ) . css ( "position" , "absolute" )
. width ( data [ i ] . imgs [ j ] . block _w )
. height ( data [ i ] . imgs [ j ] . block _h )
. css ( "top" , data [ i ] . imgs [ j ] . top )
. css ( "left" , data [ i ] . imgs [ j ] . left )
. appendTo ( div ) ;
$ ( "<img src='../../" + data [ i ] . imgs [ j ] . link + "' style='display: inline;' width='" + data [ i ] . imgs [ j ] . w + "' height='" + data [ i ] . imgs [ j ] . h + "'/>" ) . appendTo ( img _div ) ;
}
for ( j in data [ i ] . audio ) {
var audio _div = $ ( "<div class='audio_block'>" ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _div ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _div ) ;
var tmp _audio = $ ( "<audio>" ) . appendTo ( audio _div ) ;
$ ( "<source src='../../" + data [ i ] . audio [ j ] . val + "' />" ) . appendTo ( tmp _audio ) ;
audio _div . draggable ( ) . css ( "position" , "absolute" )
. css ( "top" , data [ i ] . audio [ j ] . top )
. css ( "left" , data [ i ] . audio [ j ] . left )
. appendTo ( div ) ;
}
$ ( "#slider ul" ) . append ( li ) ;
}
$ ( window ) . trigger ( "resize" )
$ ( "#slider" ) . width ( width ) . height ( height ) . easySlider ( {
prevText : '' ,
nextText : '' ,
controlsShow : false
} ) ;
$ ( "#slider" ) . goToSlide ( sankore . preference ( "etudier_cur_page" , "" ) ) ;
$ ( "#prevBtn a" ) . css ( "display" , sankore . preference ( "etudier_left_nav" , "" ) ) ;
$ ( "#nextBtn a" ) . css ( "display" , sankore . preference ( "etudier_right_nav" , "" ) ) ;
}
//example
function showExample ( ) {
var li1 = $ ( "<li>" ) ;
var div1 = $ ( "<div>" ) . appendTo ( li1 ) ;
$ ( "<div class='text_block'><div class='real_text'>" + sankoreLang . text _content + "</div></div>" ) . draggable ( ) . appendTo ( div1 )
li1 . width ( $ ( "#slider" ) . width ( ) ) . height ( $ ( "#slider" ) . height ( ) ) ;
$ ( "#slider ul" ) . append ( li1 ) ;
var li2 = $ ( "<li>" ) ;
var div2 = $ ( "<div>" ) . appendTo ( li2 ) ;
var img = $ ( "<div class='img_block' style='text-align: center;'></div>" ) . draggable ( ) . appendTo ( div2 ) ;
$ ( "<img src=\"../../objects/1.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img ) ;
li2 . width ( $ ( "#slider" ) . width ( ) ) . height ( $ ( "#slider" ) . height ( ) ) ;
$ ( "#slider ul" ) . append ( li2 ) ;
var li3 = $ ( "<li>" ) ;
var div3 = $ ( "<div>" ) . appendTo ( li3 ) ;
li3 . width ( $ ( "#slider" ) . width ( ) ) . height ( $ ( "#slider" ) . height ( ) ) ;
var audio _block = $ ( "<div class='audio_block'>" ) . draggable ( ) . appendTo ( div3 ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "../../objects/bateaux.mp3" ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
$ ( "#slider ul" ) . append ( li3 ) ;
var li4 = $ ( "<li>" ) ;
var div4 = $ ( "<div>" ) . appendTo ( li4 ) ;
$ ( "<div class='text_block'><div class='real_text'>" + sankoreLang . text _content + "</div></div>" ) . draggable ( ) . appendTo ( div4 ) ;
var img2 = $ ( "<div class='img_block' style='text-align: center;'></div>" ) . draggable ( ) . appendTo ( div4 ) ;
$ ( "<img src=\"../../objects/1.gif\" style=\"display: inline;\" height=\"120\"/>" ) . appendTo ( img2 ) ;
var audio _block2 = $ ( "<div class='audio_block'>" ) . draggable ( ) . appendTo ( div4 ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block2 ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block2 ) ;
var source2 = $ ( "<source/>" ) . attr ( "src" , "../../objects/bateaux.mp3" ) ;
var audio2 = $ ( "<audio>" ) . appendTo ( audio _block2 ) ;
audio2 . append ( source2 ) ;
li4 . width ( $ ( "#slider" ) . width ( ) ) . height ( $ ( "#slider" ) . height ( ) ) ;
$ ( "#slider ul" ) . append ( li4 ) ;
$ ( ".text_block, .audio_block, .img_block" ) . each ( function ( ) {
$ ( this ) . css ( "position" , "absolute" ) ;
} ) ;
$ ( "#slider" ) . easySlider ( {
prevText : '' ,
nextText : '' ,
controlsShow : false
} ) ;
}
//string into xml-format
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_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_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_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 ;
}
}
//drop handler
function onDropTarget ( 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 = $ ( "<div class='audio_block'>" ) . draggable ( ) . appendTo ( $ ( obj ) ) ;
audio _block . css ( "position" , "absolute" ) . css ( "top" , event . clientY - 54 ) . css ( "left" , event . clientX - 54 ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( audio _block ) ;
audio _block . addClass ( "block_border" ) ;
$ ( "<div class='play'>" ) . appendTo ( audio _block ) ;
$ ( "<div class='replay'>" ) . appendTo ( audio _block ) ;
var source = $ ( "<source/>" ) . attr ( "src" , "../../" + tmp ) ;
var audio = $ ( "<audio>" ) . appendTo ( audio _block ) ;
audio . append ( source ) ;
} else {
var img _block = $ ( "<div class='img_block' style='text-align: center;'></div>" ) . appendTo ( $ ( obj ) ) ;
img _block . css ( "top" , event . clientY - 54 ) . css ( "left" , event . clientX - 54 ) ;
$ ( "<div class='move_block' contenteditable='false'>" ) . appendTo ( img _block ) ;
$ ( "<div class='close_img' contenteditable='false'>" ) . appendTo ( img _block ) ;
$ ( "<div class='resize_block' contenteditable='false'>" ) . appendTo ( img _block ) ;
img _block . addClass ( "block_border" ) ;
var tmp _img = $ ( "<img src=\"../../" + tmp + "\" style=\"display: inline;\"/>" ) . appendTo ( img _block ) ;
setTimeout ( function ( ) {
if ( tmp _img . height ( ) >= tmp _img . width ( ) )
tmp _img . attr ( "height" , "120" ) ;
else {
tmp _img . attr ( "width" , "120" ) ;
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 ;
}
if ( window . widget ) {
window . widget . onremove = function ( ) {
$ ( "audio" ) . each ( function ( ) {
this . pause ( ) ;
$ ( this ) . parent ( ) . find ( ":first-child" ) . removeClass ( "stop" ) . addClass ( "play" ) ;
} ) ;
}
}
$ ( window ) . resize ( function ( ) {
var slider = $ ( "#slider" ) ;
slider . width ( $ ( this ) . width ( ) - 108 ) . height ( $ ( this ) . height ( ) - 108 ) ;
$ ( "#slider li" ) . each ( function ( ) {
$ ( this ) . width ( slider . width ( ) ) . height ( slider . height ( ) ) ;
} ) ;
slider . setSize ( slider . width ( ) , slider . height ( ) ) ;
} )