web/static/js/projectscontents.js
changeset 44 b7e3f3b2d150
child 45 db4e163c7c8e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/static/js/projectscontents.js	Thu Sep 09 16:47:51 2010 +0200
@@ -0,0 +1,194 @@
+$.fn.realVal = function() {
+	var obj = $(this[0]);
+	if(obj.val) {
+		if(obj.val() == obj.attr('defaultText')) {
+			return '';
+		}
+		else {
+			return obj.val();
+		}
+	}
+	else {
+		return null;
+	}
+};
+
+function init_events_base(base_node) {
+
+	$('.ldt_link',base_node).nyroModal({
+       	type: 'iframe',
+       	forceType: 'iframe',
+   		height:662, 
+   		width:1022,
+   		bgColor: 'rgb(239, 239, 239)',
+   		padding: 5,
+   		titleFromIframe: false
+      	});
+    	
+ 	$('.ldt_link_create',base_node).nyroModal({
+        type: 'iframe',
+        forceType: 'iframe',
+        height:662, 
+        width:1022,
+        bgColor: 'rgb(239, 239, 239)',
+        padding: 5,
+        titleFromIframe: false,
+        beforeHideContent: function(elts, settings, callback){
+             try {
+	              var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
+	              if(res.length > 0)
+	              {
+	              	   res.get(0).forceSave();
+	              }
+             }
+             catch(err)
+             {
+              // do nothing
+             }                   
+             callback();
+        	}
+    	});
+
+	$('.ldt_link_embed',base_node).click(function(e) {
+		e.preventDefault();
+		var link = $(e.target);
+		var json_url = link.attr("href");
+		var player_id = link.attr("id");
+		/*$.nyroModalSettings({
+		 	ajax: { data: ({ json_url:json_url, player_id:player_id }) }
+		  	});*/
+		   $.nyroModalManual({
+		         type: 'iframe',
+		         forceType: 'iframe',
+		         titleFromIframe: false,
+		   	height:662, 
+		  		width:650,
+		  		bgColor: 'rgb(239, 239, 239)',
+		  		padding: 5,
+		    url: '{% url franceculture.views.popup_embed %}?json_url='+escape(json_url)+'&player_id='+escape(player_id),
+		   });
+		   return false;
+	});
+
+
+	$('.imageline',base_node).each(function(i) {
+	    var tr = $(this);
+		tr.mouseover(function() {
+	    	$('.cellimgdiv',this).css('visibility', 'visible');
+		}); 
+		tr.mouseout(function() {
+	    	$('.cellimgdiv',this).css('visibility', 'hidden');
+		});
+	});
+	
+	$('.cellimgdiv img').qtip({ 
+		style: { 
+			'name': 'dark',
+			'filter':'alpha(opacity=70)',
+			'-moz-opacity':'0.7',
+			'-khtml-opacity': '0.7',
+			'opacity': '0.7',
+			'border': {
+				'width' : '0',
+				'color': '#505050',
+			}, 
+			'tip': true
+		} 
+	});
+	
+
+};
+
+
+function searchCallback(target, container_selector, url, timeout) {
+
+	timeout = typeof(timeout) != 'undefined' ? timeout : 0;
+	var target = $(target); 
+
+	if(target.attr('timer')) {
+		clearTimeout(target.attr('timer'));
+	}
+	
+	target.attr('timer',setTimeout(function() {
+		target.next(".searchajaxloader").show();
+		url = url.replace('__FILTER__',escape($(target).realVal()));
+		$(container_selector).load(url, null, function() {
+			target.next(".searchajaxloader").hide();
+			init_events($(container_selector));
+			target.removeAttr('timer');
+		});
+	},
+	300));
+};
+
+
+function init_events_contents(base_node) {
+
+	init_events_base(base_node);
+	
+	$('.content_link_create').nyroModal({
+	    type: 'iframe',
+	    forceType: 'iframe',
+	    height:500, 
+	    width:765,
+	    bgColor: 'rgb(239, 239, 239)',
+	    padding: 5,
+	    titleFromIframe: false,
+	    endRemove: function(elts, settings) {
+	    	searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url)
+		},
+	  	endShowContent: function(elts, settings) {
+		  	$('#nyroModalIframe', elts.content).load(function() {
+			  	var form_status = $(this).contents().find("#content_form_status").val(); 
+			  	if(form_status == 'saved') {
+			  		$.nyroModalRemove();
+			  	}
+		  	});
+		}
+	});
+
+}
+
+
+
+function searchFieldInit(input_list_init) {
+
+	$(".searchfieldinputbase").keydown(function (e) {
+	 	if(e.which == 27) {
+	 	 	$(e.target).blur();
+	 	 	$(e.target).next(".searchajaxloader").hide();
+	 	}
+	});
+	
+	 
+	$('.searchfieldinput').each(function(i) {
+	     var sbox = $(this);
+	     if(sbox.val() != '') {
+	    	 sbox.attr('defaultText', sbox.val());
+	     }
+	
+	     sbox.focus(function() {
+	         box = $(this);
+	         if(box.val() == box.attr('defaultText')) {
+	             box.val('');
+	             box.toggleClass("searchfieldinput");
+	         }
+	     });
+	
+	     sbox.blur(function() {
+	         var box = $(this);
+	         if(box.val() == '' && box.attr('defaultText')) {
+	             box.val(box.attr('defaultText'));
+	             box.toggleClass("searchfieldinput");
+	         }
+	     });
+	     
+	});
+
+	$.each(input_list_init, function(index, value) {
+		$(value['input_selector']).keyup(function (e) {
+			searchCallback(e.target, value['container_selector'], value['url']);
+		});
+	});
+
+}