delete / edit / new annotation head
authorAnthony Ly <anthonyly.com@gmail.com>
Fri, 24 May 2013 11:02:32 +0200
changeset 35 6eb0de10e9f8
parent 34 e3a17ec94cd8
child 36 4c2428524c22
delete / edit / new annotation head
integration/edition.html
integration/js/edition.js
integration/template.html
--- a/integration/edition.html	Thu May 23 18:11:55 2013 +0200
+++ b/integration/edition.html	Fri May 24 11:02:32 2013 +0200
@@ -257,6 +257,28 @@
 										</div>
 									</div>
 								</form>
+	<!-- Son -->
+								<div class="edit-annotation-title row">
+									<h3 class="span3"><i class="icon-volume-up"></i> Son</h3>
+								</div>
+								<div class="row annotation-son-content">
+										<div class="span6">
+											<form class="form-horizontal">
+												<div class="control-group">
+													<label class="control-label" for="url-source">URL source :</label>
+													<div class="controls">
+														<input type="text" id="url-source" placeholder="http://">
+													</div>
+												</div>
+												<div class="control-group">
+													<label class="control-label" for="embed">Code embed :</label>
+													<div class="controls">
+														<textarea name="" id="embed" cols="30" rows="10"></textarea>
+													</div>
+												</div>
+											</form>
+										</div>
+								</div>
 	<!-- vidéo -->
 								<div class="edit-annotation-title row">
 									<h3 class="span3"><i class="icon-film"></i> Vidéo</h3>
--- a/integration/js/edition.js	Thu May 23 18:11:55 2013 +0200
+++ b/integration/js/edition.js	Fri May 24 11:02:32 2013 +0200
@@ -98,17 +98,7 @@
         $('.popup').modal('hide');
     });
 
-    $(document).on('click','.btn-delete-annotation', function(e){
-        e.preventDefault();
-        //si c'est une annotation et que la tab est ouverte, on la ferme
-        var type = $(this).attr('data-type');
-     
-        var idAnnotation = $(this).attr('data-id');
-        $('a[href=#tab-annotation-'+idAnnotation+']').closest('li').remove();
-        $('.tab-content #annotation'+idAnnotation).remove();
-        $('#tab-list-annotation').tab('show');
-        
-    });
+    
 
     //confirmation suppression
     $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
@@ -327,6 +317,7 @@
             };
 
         newAnnotation(dataAnnotation);
+        renderAnnotation();
     }
 
     function newAnnotation(dataAnnotation){
@@ -341,7 +332,8 @@
             annotation.keywords = dataAnnotation.keywords;
 
         annotations.push(annotation);
-        renderAnnotation();
+        
+        return annotation;
     }
 
     function renderAnnotation(){
@@ -404,6 +396,18 @@
         }
     });
 
+    //delete annotation
+    $(document).on('click','.btn-delete-annotation', function(e){
+        e.preventDefault();
+
+        var idAnnotation = $(this).attr('data-id');
+        annotations = _(annotations).reject(function(c) { return c.id == idAnnotation; });
+        closeTab(idAnnotation);
+        if(!$(this).hasAttr('data-no-render'))//si on ferme à partir de la tab renderAnnotation sera appelé 2 fois
+            renderAnnotation();
+
+    });
+
 //tab
     $('#onglet-annotations').on('click', 'a', function(e){
         e.preventDefault();
@@ -419,10 +423,18 @@
 
     function openTab(type, data){
         
-        var dataView = {};
+        var dataView;
         if(_.isUndefined(data)){//nouveau
-            dataView.id = 'id' + (new Date()).getTime();
-            dataView.title = 'New';
+            var dataAnnotation = {
+                title : 'Nouveau',
+                begin : 60 * 1000,
+                end : 60 * 1000 * 2,
+                description : 'description',
+                type : type,
+                keywords : []
+            };
+            dataView = newAnnotation(dataAnnotation);
+            renderAnnotation();
         }else{//édition
             dataView = data;
         }
@@ -449,6 +461,8 @@
 
             //particularité selon type
             switch(type){
+                case 'son': iconTab = 'volume-up';
+                    break;
                 case 'video': iconTab = 'film';
                     break;
                 case 'text': 
--- a/integration/template.html	Thu May 23 18:11:55 2013 +0200
+++ b/integration/template.html	Fri May 24 11:02:32 2013 +0200
@@ -31,6 +31,9 @@
 			<div data-id="{{id}}" id="" class="slider-duration"></div>
 		</div>
 		<div class="span6 text-right">
+			<a class="btn btn-danger btn-delete-annotation" data-id="{{id}}" data-no-render>
+				<i class="icon-trash"></i> Delete
+			</a>
 			<a class="btn btn-primary btn-save-annotation" data-id="{{id}}">
 				<i class="icon-ok"></i> Ok
 			</a>
@@ -49,6 +52,30 @@
 </li>
 </script>
 
+<script id="tpl-son" type="text/html">
+<div class="edit-annotation-title row">
+	<h3 class="span3"><i class="icon-volume-up"></i> Son</h3>
+</div>
+<div class="row annotation-son-content">
+		<div class="span6">
+			<form class="form-horizontal">
+				<div class="control-group">
+					<label class="control-label" for="url-source">URL source :</label>
+					<div class="controls">
+						<input type="text" id="url-source" placeholder="http://">
+					</div>
+				</div>
+				<div class="control-group">
+					<label class="control-label" for="embed">Code embed :</label>
+					<div class="controls">
+						<textarea name="" id="embed" cols="30" rows="10"></textarea>
+					</div>
+				</div>
+			</form>
+		</div>
+</div>
+</script>
+
 <script id="tpl-video" type="text/html">
 <div class="edit-annotation-title row">
 	<h3 class="span3"><i class="icon-film"></i> Vidéo</h3>
@@ -186,7 +213,7 @@
 	<td>
 		<a href="#" data-id="{{id}}" class="btn btn-edit-annotation" data-type="{{type}}">
 			<i class="icon-pencil"></i></a>
-		<a data-id="{{id}}" data-type="annotation" data-title="{{title}}" href="#row-list-annotation-{{id}}" class="btn btn-delete btn-delete-annotation">
+		<a data-id="{{id}}" data-type="annotation" data-title="{{title}}" href="#row-list-annotation-{{id}}" class="btn btn-delete-annotation">
 			<i class="icon-trash delete-annotation"></i>
 		</a>
 	</td>
@@ -207,7 +234,7 @@
 					<a href="#" class="btn btn-edit-chapter" data-chapter-id="{{id}}"><i class="icon-pencil"></i></a>
 				</td>
 				<td>
-					<a data-title="Chapitre 1" data-chapter-id="{{id}}" href="#row-list-chapter-{{id}}" class="btn btn-delete-chapter"><i class="icon-trash delete-annotation"></i></a>
+					<a data-title="{{title}}" data-chapter-id="{{id}}" href="#row-list-chapter-{{id}}" class="btn btn-delete-chapter"><i class="icon-trash delete-annotation"></i></a>
 				</td>
 			</tr>
 		</table>