web/static/ldt/js/projectscontents.js
changeset 94 9927a619d2b5
parent 91 9c83809fda01
child 105 75c412f2c620
equal deleted inserted replaced
93:2f978b081c4c 94:9927a619d2b5
    21        	windowResize: false,
    21        	windowResize: false,
    22    		height:662, 
    22    		height:662, 
    23    		width:1022,
    23    		width:1022,
    24    		bgColor: 'rgb(239, 239, 239)',
    24    		bgColor: 'rgb(239, 239, 239)',
    25    		padding: 5,
    25    		padding: 5,
    26    		titleFromIframe: false
    26    		titleFromIframe: false,
       
    27         beforeHideContent: function(elts, settings, callback){
       
    28 	        try {
       
    29 	             var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
       
    30 	             if(res.length > 0)
       
    31 	             {
       
    32 	             	   res.get(0).forceSave();
       
    33 	             }
       
    34 	        }
       
    35 	        catch(err)
       
    36 	        {
       
    37 	         // do nothing
       
    38 	        }                   
       
    39 	        callback();
       
    40    		},
       
    41 
    27       	});
    42       	});
    28     	
    43     	
       
    44 
       
    45 	$('.ldt_link_embed',base_node).click(function(e) {
       
    46 		e.preventDefault();
       
    47 		var link = $(e.target);
       
    48 		var json_url = link.attr("href");
       
    49 		var player_id = link.attr("id");
       
    50 		var ldt_id = player_id.substring(15);
       
    51 		/*$.nyroModalSettings({
       
    52 		 	ajax: { data: ({ json_url:json_url, player_id:player_id }) }
       
    53 		  	});*/
       
    54 		   $.nyroModalManual({
       
    55 		       type: 'iframe',
       
    56 		       forceType: 'iframe',
       
    57 		       titleFromIframe: false,
       
    58 		       height:662, 
       
    59                width:750,
       
    60                bgColor: 'rgb(239, 239, 239)',
       
    61                padding: 5,
       
    62 		       url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id)+'&ldt_id='+escape(ldt_id),
       
    63 		   });
       
    64 		   return false;
       
    65 	});
       
    66 
       
    67 
       
    68 	$('.imageline',base_node).each(function(i) {
       
    69 	    var tr = $(this);
       
    70 		tr.mouseover(function() {
       
    71 	    	$('.cellimgdiv',this).css('visibility', 'visible');
       
    72 		}); 
       
    73 		tr.mouseout(function() {
       
    74 	    	$('.cellimgdiv',this).css('visibility', 'hidden');
       
    75 		});
       
    76 	});
       
    77 	
       
    78 	$('.cellimgdiv img').qtip({ 
       
    79 		style: { 
       
    80 			'name': 'dark',
       
    81 			'filter':'alpha(opacity=70)',
       
    82 			'-moz-opacity':'0.7',
       
    83 			'-khtml-opacity': '0.7',
       
    84 			'opacity': '0.7',
       
    85 			'border': {
       
    86 				'width' : '0',
       
    87 				'color': '#505050',
       
    88 			}, 
       
    89 			'tip': true
       
    90 		} 
       
    91 	});
       
    92 	
       
    93 
       
    94 };
       
    95 
       
    96 
       
    97 function searchCallback(target, container_selector, url, timeout) {
       
    98 
       
    99 	timeout = typeof(timeout) != 'undefined' ? timeout : 0;
       
   100 	var target = $(target);
       
   101 	
       
   102 	// remove all qtip
       
   103 	$(".qtip").remove();
       
   104 	
       
   105 	if(target.realVal().length > 0) {
       
   106 		target.nextAll(".searchclear").show();
       
   107 	}
       
   108 
       
   109 	if(target.attr('timer')) {
       
   110 		clearTimeout(target.attr('timer'));
       
   111 	}
       
   112 
       
   113 	target.attr(
       
   114 		'timer',
       
   115 		setTimeout(function() {
       
   116 			target.next(".searchajaxloader").show();
       
   117 			target.nextAll(".searchclear").hide();
       
   118 			var filterVal = "_" + escape(target.realVal());
       
   119 			url = url.replace('__FILTER__',filterVal);
       
   120 			$.ajax({
       
   121 				url: url,
       
   122 				cache: false,
       
   123 				success: function(data, status, request) {
       
   124 					$(container_selector).html(data);
       
   125 					target.next(".searchajaxloader").hide();
       
   126 					if(target.realVal().length > 0) {
       
   127 						target.nextAll(".searchclear").show();
       
   128 					}
       
   129 					init_events($(container_selector));
       
   130 					target.removeAttr('timer');
       
   131 				}
       
   132 			});	
       
   133 		},
       
   134 		300)
       
   135 	);
       
   136 };
       
   137 
       
   138 
       
   139 function init_events_contents(base_node, embed_url, content_filter_url) {
       
   140 
       
   141 	init_events_base(base_node, embed_url);
       
   142 	
       
   143 	$('.content_link_create').nyroModal({
       
   144 	    type: 'iframe',
       
   145 	    forceType: 'iframe',
       
   146 	    height:500, 
       
   147 	    width:765,
       
   148 	    bgColor: 'rgb(239, 239, 239)',
       
   149 	    padding: 5,
       
   150 	    titleFromIframe: false,
       
   151 	    endRemove: function(elts, settings) {
       
   152 	    	searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url)
       
   153 		},
       
   154 	  	endShowContent: function(elts, settings) {
       
   155 		  	$('#nyroModalIframe', elts.content).load(function() {
       
   156 			  	var form_status = $(this).contents().find("#content_form_status").val(); 
       
   157 			  	if(form_status == 'saved' || form_status == 'deleted' ) {
       
   158 			  		$.nyroModalRemove();
       
   159 			  	}
       
   160 		  	});
       
   161 		}
       
   162 	});
       
   163 	
       
   164 	$('.contenttitlelink').nyroModal({
       
   165 	    type: 'iframe',
       
   166 	    forceType: 'iframe',
       
   167 	    height:500, 
       
   168 	    width:765,
       
   169 	    bgColor: 'rgb(239, 239, 239)',
       
   170 	    padding: 5,
       
   171 	    titleFromIframe: false,
       
   172 	    endRemove: function(elts, settings) {
       
   173 	    	searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url,0);
       
   174 		},
       
   175 	  	endShowContent: function(elts, settings) {
       
   176 		  	$('#nyroModalIframe', elts.content).load(function() {
       
   177 			  	var form_status = $(this).contents().find("#content_form_status").val(); 
       
   178 			  	if(form_status == 'saved' || form_status == 'deleted') {
       
   179 			  		$.nyroModalRemove();
       
   180 			  	}
       
   181 		  	});
       
   182 		}
       
   183 	});
       
   184 
       
   185 
       
   186 }
       
   187 
       
   188 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
       
   189 
    29  	$('.ldt_link_create',base_node).nyroModal({
   190  	$('.ldt_link_create',base_node).nyroModal({
    30         type: 'iframe',
   191         type: 'iframe',
    31         forceType: 'iframe',
   192         forceType: 'iframe',
    32         windowResize: false,
   193         windowResize: false,
    33         height:680, 
   194         height:680, 
    34         width:500,
   195         width:500,
    35         bgColor: 'rgb(239, 239, 239)',
   196         bgColor: 'rgb(239, 239, 239)',
    36         padding: 5,
   197         padding: 5,
    37         titleFromIframe: false,
   198         titleFromIframe: false,
       
   199 	    endRemove: function(elts, settings) {
       
   200  			searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0);
       
   201 		},
    38         beforeHideContent: function(elts, settings, callback){
   202         beforeHideContent: function(elts, settings, callback){
    39              try {
   203              try {
    40 	              var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
   204 	              var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
    41 	              if(res.length > 0)
   205 	              if(res.length > 0)
    42 	              {
   206 	              {
    47              {
   211              {
    48               // do nothing
   212               // do nothing
    49              }                   
   213              }                   
    50              callback();
   214              callback();
    51         	},
   215         	},
    52         	endShowContent: function(elts, settings){
   216         endShowContent: function(elts, settings){
    53         		var iframe = $('#nyroModalIframe', elts.content);
   217     		var iframe = $('#nyroModalIframe', elts.content);
    54     			iframe.load(function(){
   218 			iframe.load(function(){
    55     				var swfobject = $(this).contents().find("#ldtInitSwf"); 
   219 			  	var form_status = $(this).contents().find("#project_form_status").val(); 
    56     				if (swfobject.length) {
   220 			  	if(form_status == 'saved' || form_status == 'deleted' ) {
    57     					$.nyroModalSettings({
   221 			  		$.nyroModalRemove();
    58     						height: swfobject.height() + 31,
   222 			  	}
    59     						width: swfobject.width() + 21
   223 				var swfobject = $(this).contents().find("#ldtInitSwf"); 
    60     					});
   224 				if (swfobject.length) {
    61     				}
   225 					$.nyroModalSettings({
    62     			});
   226 						height: swfobject.height() + 31,
       
   227 						width: swfobject.width() + 21
       
   228 					});
       
   229 				}
       
   230 			});
    63         	}
   231         	}
    64     	});
   232     	});
    65 
   233 
    66 	$('.ldt_link_embed',base_node).click(function(e) {
   234 	
    67 		e.preventDefault();
       
    68 		var link = $(e.target);
       
    69 		var json_url = link.attr("href");
       
    70 		var player_id = link.attr("id");
       
    71 		/*$.nyroModalSettings({
       
    72 		 	ajax: { data: ({ json_url:json_url, player_id:player_id }) }
       
    73 		  	});*/
       
    74 		   $.nyroModalManual({
       
    75 		       type: 'iframe',
       
    76 		       forceType: 'iframe',
       
    77 		       titleFromIframe: false,
       
    78 		       height:662, 
       
    79                width:750,
       
    80                bgColor: 'rgb(239, 239, 239)',
       
    81                padding: 5,
       
    82 		       url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id),
       
    83 		   });
       
    84 		   return false;
       
    85 	});
       
    86 
       
    87 
       
    88 	$('.imageline',base_node).each(function(i) {
       
    89 	    var tr = $(this);
       
    90 		tr.mouseover(function() {
       
    91 	    	$('.cellimgdiv',this).css('visibility', 'visible');
       
    92 		}); 
       
    93 		tr.mouseout(function() {
       
    94 	    	$('.cellimgdiv',this).css('visibility', 'hidden');
       
    95 		});
       
    96 	});
       
    97 	
       
    98 	$('.cellimgdiv img').qtip({ 
       
    99 		style: { 
       
   100 			'name': 'dark',
       
   101 			'filter':'alpha(opacity=70)',
       
   102 			'-moz-opacity':'0.7',
       
   103 			'-khtml-opacity': '0.7',
       
   104 			'opacity': '0.7',
       
   105 			'border': {
       
   106 				'width' : '0',
       
   107 				'color': '#505050',
       
   108 			}, 
       
   109 			'tip': true
       
   110 		} 
       
   111 	});
       
   112 	
       
   113 
       
   114 };
       
   115 
       
   116 
       
   117 function searchCallback(target, container_selector, url, timeout) {
       
   118 
       
   119 	timeout = typeof(timeout) != 'undefined' ? timeout : 0;
       
   120 	var target = $(target);
       
   121 	
       
   122 	// remove all qtip
       
   123 	$(".qtip").remove();
       
   124 	
       
   125 	if(target.realVal().length > 0) {
       
   126 		target.nextAll(".searchclear").show();
       
   127 	}
       
   128 
       
   129 	if(target.attr('timer')) {
       
   130 		clearTimeout(target.attr('timer'));
       
   131 	}
       
   132 	
       
   133 	target.attr('timer',setTimeout(function() {
       
   134 		target.next(".searchajaxloader").show();
       
   135 		target.nextAll(".searchclear").hide();
       
   136 		var realVal = target.realVal();
       
   137 		if(realVal.length == 0) {
       
   138 			realVal = "_";
       
   139 		}
       
   140 		url = url.replace('__FILTER__',escape(realVal));
       
   141 		$(container_selector).load(url, null, function() {
       
   142 			target.next(".searchajaxloader").hide();
       
   143 			if(target.realVal().length > 0) {
       
   144 				target.nextAll(".searchclear").show();
       
   145 			}
       
   146 			init_events($(container_selector));
       
   147 			target.removeAttr('timer');
       
   148 		});
       
   149 	},
       
   150 	300));
       
   151 };
       
   152 
       
   153 
       
   154 function init_events_contents(base_node, embed_url, content_filter_url) {
       
   155 
       
   156 	init_events_base(base_node, embed_url);
       
   157 	
       
   158 	$('.content_link_create').nyroModal({
       
   159 	    type: 'iframe',
       
   160 	    forceType: 'iframe',
       
   161 	    height:500, 
       
   162 	    width:765,
       
   163 	    bgColor: 'rgb(239, 239, 239)',
       
   164 	    padding: 5,
       
   165 	    titleFromIframe: false,
       
   166 	    endRemove: function(elts, settings) {
       
   167 	    	searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url)
       
   168 		},
       
   169 	  	endShowContent: function(elts, settings) {
       
   170 		  	$('#nyroModalIframe', elts.content).load(function() {
       
   171 			  	var form_status = $(this).contents().find("#content_form_status").val(); 
       
   172 			  	if(form_status == 'saved') {
       
   173 			  		$.nyroModalRemove();
       
   174 			  	}
       
   175 		  	});
       
   176 		}
       
   177 	});
       
   178 	
       
   179 	$('.contenttitlelink').nyroModal({
       
   180 	    type: 'iframe',
       
   181 	    forceType: 'iframe',
       
   182 	    height:500, 
       
   183 	    width:765,
       
   184 	    bgColor: 'rgb(239, 239, 239)',
       
   185 	    padding: 5,
       
   186 	    titleFromIframe: false,
       
   187 	    endRemove: function(elts, settings) {
       
   188 	    	searchCallback($("#searchcontentsinput"),"#contentslistcontainer",content_filter_url)
       
   189 		},
       
   190 	  	endShowContent: function(elts, settings) {
       
   191 		  	$('#nyroModalIframe', elts.content).load(function() {
       
   192 			  	var form_status = $(this).contents().find("#content_form_status").val(); 
       
   193 			  	if(form_status == 'saved') {
       
   194 			  		$.nyroModalRemove();
       
   195 			  	}
       
   196 		  	});
       
   197 		}
       
   198 	});
       
   199 
       
   200 
       
   201 }
       
   202 
       
   203 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
       
   204 		
       
   205 	$('.publishedproject', base_node).click(function(e) {
   235 	$('.publishedproject', base_node).click(function(e) {
   206 		e.preventDefault();
   236 		e.preventDefault();
   207 		var target = $(e.target);
   237 		var target = $(e.target);
   208 		var project_id = target.attr('id').replace('project_','');
   238 		var project_id = target.attr('id').replace('project_','');
   209 		var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id);
   239 		var url = unpublishprojecturl.replace('__PROJECT_ID__', project_id);
   234 				}
   264 				}
   235 			}
   265 			}
   236 		});
   266 		});
   237 	});
   267 	});
   238 
   268 
       
   269 	$('.projecttitlelink').nyroModal({
       
   270 	    type: 'iframe',
       
   271 	    forceType: 'iframe',
       
   272         height:680, 
       
   273         width:500,
       
   274 	    bgColor: 'rgb(239, 239, 239)',
       
   275 	    padding: 5,
       
   276 	    titleFromIframe: false,
       
   277 	    endRemove: function(elts, settings) {
       
   278 			searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0);
       
   279 		},
       
   280 	  	endShowContent: function(elts, settings) {
       
   281 		  	$('#nyroModalIframe', elts.content).load(function() {
       
   282 			  	var form_status = $(this).contents().find("#project_form_status").val(); 
       
   283 			  	if(form_status == 'saved' || form_status == 'deleted') {
       
   284 			  		$.nyroModalRemove();
       
   285 			  	}
       
   286 		  	});
       
   287 		}
       
   288 	});
       
   289 	
   239 }
   290 }
   240 
   291 
   241 function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
   292 function init_events_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
   242 	
   293 	
   243 	init_events_base(base_node, embed_url);
   294 	init_events_base(base_node, embed_url);