소스 검색

Evolution #196: Liste de lecture

Sevajol Bastien 11 년 전
부모
커밋
98b26e3576

+ 2 - 0
app/Resources/translations/elements.fr.yml 파일 보기

@@ -88,6 +88,8 @@ elements:
88 88
   ajax:
89 89
     more:
90 90
       noelements:       Pas d'autres éléments
91
+  autoplay:
92
+    launch:             Créer une liste de lecture avec ces paramètres
91 93
       
92 94
 show:
93 95
   user:

+ 26 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig 파일 보기

@@ -23,6 +23,10 @@
23 23
   {% endif %}
24 24
   <script src="{{ asset('js/jquery-ui-1.8.7.min.js') }}" type="text/javascript"></script>
25 25
 	<script src="{{ asset('bundles/muzichcore/js/muzich.js') }}" type="text/javascript"></script>
26
+	
27
+  <script type="text/javascript" src="{{ asset('js/swfobject.js') }}"></script> 
28
+  <script src="{{ asset('bundles/muzichcore/js/autoplay.js') }}" type="text/javascript"></script>
29
+  
26 30
   <script src="{{ asset('js/tags/jquery.autoGrowInput.js') }}" type="text/javascript"></script>
27 31
   <script src="{{ asset('js/tags/jquery.tagBox.js') }}" type="text/javascript"></script>
28 32
   <script src="{{ asset('js/formdefault/jquery.formdefaults.js') }}" type="text/javascript"></script>
@@ -76,6 +80,28 @@
76 80
 </head>
77 81
 <body>
78 82
   
83
+  <div id="autoplay" class="popin_block" style="display: none;">
84
+    <a href="javascript:void(0);" id="autoplay_close" >
85
+      <img src="{{ asset('/bundles/muzichcore/img/1328276855_list-remove.png') }}" alt="close" />
86
+    </a>
87
+    <div id="autoplay_controls">
88
+      
89
+      <a href="javascript:void(0);" id="autoplay_previous">
90
+        <img src="{{ asset('/bundles/muzichcore/img/player_start.png') }}" alt="previous" />
91
+      </a>
92
+      <a href="javascript:void(0);" id="autoplay_next">
93
+        <img src="{{ asset('/bundles/muzichcore/img/player_end.png') }}" alt="next" />
94
+      </a>
95
+        
96
+      <div id="autoplay_title"></div>
97
+      
98
+    </div>
99
+    <div id="autoplay_player_container">
100
+      <div id="autoplay_player"></div>
101
+    </div>
102
+    <img id="autoplay_loader" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loader" />
103
+  </div>
104
+    
79 105
   {% include "MuzichCoreBundle:Language:languages.html.twig" %}
80 106
   
81 107
   {% include "MuzichUserBundle:Account:topBar.html.twig" %}

+ 55 - 0
src/Muzich/CoreBundle/lib/AutoplayManager.php 파일 보기

@@ -0,0 +1,55 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\lib;
4
+
5
+use Muzich\CoreBundle\Entity\Element;
6
+
7
+/**
8
+ *  Boite a outils pour les Tags. 
9
+ */
10
+class AutoplayManager
11
+{
12
+  
13
+  /**
14
+   *
15
+   * @var array of Element
16
+   */
17
+  private $elements;
18
+  
19
+  /**
20
+   *
21
+   * @param array $elements 
22
+   */
23
+  public function __construct($elements)
24
+  {
25
+    $this->elements = $elements;
26
+  }
27
+  
28
+  public function getListJSON()
29
+  {
30
+    $list = array();
31
+    
32
+    foreach ($this->elements as $element)
33
+    {
34
+      if (
35
+        // On doit connaitre l'id externe
36
+        ($ref_id = $element->getData(Element::DATA_REF_ID)) && 
37
+        // Et le site doit être pris en charge pour le autoplay
38
+        in_array(
39
+          ($element_type = $element->getType()), 
40
+          $this->container->getParameter('dailymotion_player_width')
41
+        )
42
+      )
43
+      
44
+      $list[] = array(
45
+        'element_ref_id'   => $ref_id,
46
+        'element_type'     => $element->getType(),
47
+        'element_id'       => $element->getId(),
48
+        'element_name'     => $element->getName()
49
+      );
50
+    }
51
+    
52
+    return json_encode($list);
53
+  }
54
+  
55
+}

+ 5 - 0
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig 파일 보기

@@ -90,6 +90,11 @@
90 90
     } %}
91 91
     
92 92
     <input class="main button" type="submit" value="{{ 'filter.submit'|trans({}, 'userui') }}"/>
93
+    
94
+    <a href="javascript:void(0);" class="button" id="autoplay_launch">
95
+      {{ 'elements.autoplay.launch'|trans({}, 'elements') }}
96
+    </a>
97
+    
93 98
   </form>
94 99
 
95 100
   <div class="display_more_elements" style="display: none;">

+ 37 - 0
web/bundles/muzichcore/css/main.css 파일 보기

@@ -1306,4 +1306,41 @@ span#add_url_title
1306 1306
 {
1307 1307
   font-weight: bold;
1308 1308
   font-size: 15px;
1309
+}
1310
+
1311
+div#autoplay.popin_block
1312
+{
1313
+  width: 500px;
1314
+}
1315
+
1316
+div#autoplay.popin_block div#autoplay_controls
1317
+{
1318
+ text-align: left;
1319
+}
1320
+
1321
+a#autoplay_previous
1322
+{
1323
+  float: left;
1324
+  text-decoration: none;
1325
+}
1326
+
1327
+a#autoplay_next
1328
+{
1329
+  float: right;
1330
+  text-decoration: none;
1331
+}
1332
+
1333
+div#autoplay_title
1334
+{
1335
+  font-weight: bold;
1336
+  margin-left: 35px;
1337
+  margin-right: 35px;
1338
+}
1339
+
1340
+a#autoplay_close
1341
+{
1342
+  float: right;
1343
+  text-decoration: none;
1344
+  margin-top: -27px;
1345
+  margin-right: -27px;
1309 1346
 }

BIN
web/bundles/muzichcore/img/player_end.png 파일 보기


BIN
web/bundles/muzichcore/img/player_pause.png 파일 보기


BIN
web/bundles/muzichcore/img/player_play.png 파일 보기


BIN
web/bundles/muzichcore/img/player_start.png 파일 보기


+ 130 - 0
web/bundles/muzichcore/js/autoplay.js 파일 보기

@@ -0,0 +1,130 @@
1
+/* Librairie Autoplay pour muzi.ch  */
2
+$(document).ready(function(){
3
+ 
4
+  /*
5
+   * Section commune
6
+   */
7
+  
8
+  var autoplay_list = new Array;
9
+  var autoplay_player = null;
10
+  var autoplay_player_div_id = "autoplay_player";
11
+  var autoplay_player_id     = "autoplay_player_id";
12
+  var autoplay_step = 0;
13
+  
14
+  $('a#autoplay_launch').click(function(){
15
+    
16
+    // on fake l'ajax pour les tests
17
+    
18
+    var firdtvidz = new Array;
19
+    firdtvidz['element_ref_id'] = 'tq4DjQK7nsM';
20
+    firdtvidz['element_type']   = 'youtu.be';
21
+    firdtvidz['element_id']     = '99989';
22
+    firdtvidz['element_name']   = 'Ed Cox - La fanfare des teuffeurs (Hardcordian)';
23
+    
24
+    var secondvidz = new Array;
25
+    secondvidz['element_ref_id'] = 'bIAFB4vRdGw';
26
+    secondvidz['element_type']   = 'youtube.com';
27
+    secondvidz['element_id']     = '2345';
28
+    secondvidz['element_name']   = 'Babylon Pression - Des Tasers et des Pauvres';
29
+    
30
+    autoplay_list[0] = firdtvidz;
31
+    autoplay_list[1] = secondvidz;
32
+  
33
+    open_popin_dialog('autoplay');
34
+    autoplay_run(0);
35
+  });
36
+  
37
+  function autoplay_run(step)
38
+  {
39
+    $('div#'+autoplay_player_div_id+'_container').html('<div id="'+autoplay_player_div_id+'"></div>');
40
+    
41
+    if (autoplay_list[step].element_type == 'youtube.com' || autoplay_list[step].element_type == 'youtu.be')
42
+    {
43
+      $('img#autoplay_loader').show();
44
+      $('div#autoplay_title').text(autoplay_list[step].element_name);
45
+      youtube_create_player(autoplay_list[step].element_ref_id);
46
+    }
47
+  }
48
+  
49
+  function autoplay_next()
50
+  {
51
+    autoplay_step++;
52
+    if (array_key_exists(autoplay_step, autoplay_list))
53
+    {
54
+      autoplay_run(autoplay_step);
55
+    }
56
+    else
57
+    {
58
+      autoplay_step--;
59
+    }
60
+  }
61
+  
62
+  function autoplay_previous()
63
+  {
64
+    autoplay_step--;
65
+    if (array_key_exists(autoplay_step, autoplay_list))
66
+    {
67
+      autoplay_run(autoplay_step);
68
+    }
69
+    else
70
+    {
71
+      autoplay_step++;
72
+    }
73
+  }
74
+  
75
+  
76
+  $('a#autoplay_previous').click(function(){ autoplay_previous(); });
77
+  $('a#autoplay_next').click(function(){ autoplay_next(); });
78
+  $('a#autoplay_close').click(function(){
79
+    $('#fade').fadeOut(1000, function(){$('#fade').remove();});
80
+    $('#autoplay').hide();
81
+  });
82
+   
83
+  
84
+  /*
85
+   * Fonction youtube.com et youtu.be
86
+   */
87
+    
88
+  function youtube_create_player(ref_id)
89
+  {
90
+    var playerapiid = "ytplayerapiid";
91
+    var params = { allowScriptAccess: "always" };
92
+    var atts = { id: autoplay_player_id };
93
+    swfobject.embedSWF(
94
+      "http://www.youtube.com/v/"+ref_id+"?enablejsapi=1&playerapiid="+playerapiid+"&version=3",
95
+      autoplay_player_div_id,
96
+      "425",
97
+      "356",
98
+      "8",
99
+      null,
100
+      null,
101
+      params,
102
+      atts
103
+    );
104
+  }
105
+  
106
+  window.onYouTubePlayerReady = function()
107
+  {
108
+    autoplay_player = document.getElementById(autoplay_player_id);
109
+    autoplay_player.addEventListener("onStateChange", "youtube_StateChange");
110
+    $('img#autoplay_loader').hide();
111
+    youtube_play();
112
+  }
113
+  
114
+  window.youtube_StateChange = function(newState)
115
+  {
116
+    if (newState === 0)
117
+    {
118
+      autoplay_next();
119
+    }
120
+  }
121
+
122
+  function youtube_play()
123
+  {
124
+    if (autoplay_player)
125
+    {
126
+      autoplay_player.playVideo();
127
+    }
128
+  }
129
+  
130
+});

+ 43 - 1
web/bundles/muzichcore/js/muzich.js 파일 보기

@@ -46,6 +46,21 @@ function findKeyWithValue(arrayt, value)
46 46
   return "";
47 47
 }
48 48
 
49
+function array_key_exists (key, search) {
50
+  // http://kevin.vanzonneveld.net
51
+  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
52
+  // +   improved by: Felix Geisendoerfer (http://www.debuggable.com/felix)
53
+  // *     example 1: array_key_exists('kevin', {'kevin': 'van Zonneveld'});
54
+  // *     returns 1: true
55
+  // input sanitation
56
+  if (!search || (search.constructor !== Array && search.constructor !== Object)) {
57
+    return false;
58
+  }
59
+
60
+  return key in search;
61
+}
62
+
63
+
49 64
 function json_to_array(json_string)
50 65
 {
51 66
   if (json_string.length)
@@ -2350,5 +2365,32 @@ $(document).ready(function(){
2350 2365
     
2351 2366
   });
2352 2367
 
2368
+});
2369
+
2370
+
2371
+
2372
+/*
2373
+ * Ouverture d'une boite avec effet fade et centré
2374
+ *   code origine: form_add_open_dialog_for_new_tag
2375
+ */
2353 2376
 
2354
-});
2377
+  function open_popin_dialog(object_id)
2378
+  {
2379
+    
2380
+    // Effet fade-in du fond opaque
2381
+    $('body').append($('<div>').attr('id', 'fade')); 
2382
+    //Apparition du fond - .css({'filter' : 'alpha(opacity=80)'}) pour corriger les bogues de IE
2383
+    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
2384
+    
2385
+    $('#'+object_id).css({
2386
+      position: 'absolute',
2387
+      left: ($(window).width() 
2388
+        - $('#'+object_id).width())/2,
2389
+//      top: ($(window).height() 
2390
+//        - $('#'+object_id).height())/2
2391
+        top: '20%'
2392
+      });
2393
+    $('#'+object_id).show();
2394
+    
2395
+    console.debug('width: '+$('#'+object_id).width());
2396
+  }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 0
web/js/swfobject.js