web/static/ldt/js/projectscontents.js
branchmodal_update
changeset 31 0d829ac13c4b
parent 24 57a2650a7f87
child 32 7bb37c869d0d
equal deleted inserted replaced
30:83f4abc7568f 31:0d829ac13c4b
    14 };
    14 };
    15 
    15 
    16 
    16 
    17 function init_events_base(base_node, embed_url) {
    17 function init_events_base(base_node, embed_url) {
    18 	
    18 	
    19 	$('.ldt_link',base_node).each(function(i){
       
    20 		$(this).attr("target","_iri");
       
    21 	});
       
    22 	$('.ldt_link',base_node).nyroModal({
       
    23 		filters: ['iriIFrame'],
       
    24 		sizes: {
       
    25 			minW: '1022',
       
    26 			minH: '662'
       
    27 		},
       
    28 		showCloseButton: true,
       
    29 		callbacks: {
       
    30 			afterShowCont: function(nm) {
       
    31 				nm.store.iframe.height(662);
       
    32 				nm.store.iframe.width(1022);
       
    33 			}
       
    34 		}
       
    35       });
       
    36     	
       
    37 
       
    38 	$('.ldt_link_embed',base_node).click(function(e) {
    19 	$('.ldt_link_embed',base_node).click(function(e) {
    39 		e.preventDefault();
    20 		e.preventDefault();
    40 		var link = $(e.target);
    21 		var link = $(e.target);
    41 		var json_url = link.attr("href");
    22 		var json_url = link.attr("href");
    42 		var player_id = link.attr("id");
    23 		var player_id = link.attr("id");
    86 		} 
    67 		} 
    87 	});
    68 	});
    88 	
    69 	
    89 
    70 
    90 };
    71 };
       
    72 
       
    73 function testAndClose() {
       
    74 	// Here we ask LDT if the current work is modified and if the user want to save it.
       
    75 	var ldtSwf =  $('#ldtInitSwf',$.nmTop().store.iframe.contents()).get(0);
       
    76 	// In the ldt_link_create case, the modal page can be the form, or the ldt swf. So we have to test.
       
    77 	if (ldtSwf) {
       
    78 		if (ldtSwf.name=="ldtInitSwf") {
       
    79             if(ldtSwf.isModified()=="true") {
       
    80                 //ldtSwf.forceSave();
       
    81                 ldtSwf.askSave();
       
    82             }
       
    83 			else{
       
    84 				forceModalClose();
       
    85 			}
       
    86 		}
       
    87 		else{
       
    88 			forceModalClose();
       
    89 		}
       
    90 	}
       
    91 	else{
       
    92 		forceModalClose();
       
    93 	}
       
    94 }
    91 
    95 
    92 
    96 
    93 function searchCallback(target, container_selector, url, timeout) {
    97 function searchCallback(target, container_selector, url, timeout) {
    94 
    98 
    95 	timeout = typeof(timeout) != 'undefined' ? timeout : 0;
    99 	timeout = typeof(timeout) != 'undefined' ? timeout : 0;
   189 	});
   193 	});
   190 }
   194 }
   191 
   195 
   192 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
   196 function init_events_base_projects(base_node, embed_url, searchprojectfilterurl, publishprojecturl, unpublishprojecturl) {
   193 
   197 
       
   198 	// These are the functions called when we display a project in an LDT modal window
       
   199 	$('.ldt_link',base_node).each(function(i){
       
   200 		$(this).attr("target","_iri");
       
   201 	});
       
   202 	$('.ldt_link',base_node).nyroModal({
       
   203 		filters: ['iriIframe'],
       
   204 		sizes: {
       
   205 			minW: '1022',
       
   206 			minH: '662'
       
   207 		},
       
   208 		showCloseButton: true,
       
   209 		closeOnEscape:false,
       
   210 		closeOnClick:false,
       
   211 		callbacks: {
       
   212 			afterShowCont: function(nm) {
       
   213 				nm.store.iframe.height(662);
       
   214 				nm.store.iframe.width(1022);
       
   215 			},
       
   216 			close: function(nm) {
       
   217 				// We don't do anything here, we hack the callback directly from the close function.
       
   218 			},
       
   219 			afterClose: function(nm) {
       
   220 				// Can't do that because searchprojectfilterurl is not defined in init_events_base params
       
   221 				searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0);
       
   222 			}
       
   223 		},
       
   224 		close:function(nm){
       
   225 			testAndClose();
       
   226 		}
       
   227     });
       
   228 
       
   229 
   194 	$('.ldt_link_create',base_node).each(function(i){
   230 	$('.ldt_link_create',base_node).each(function(i){
   195 		$(this).attr("target","_iri");
   231 		$(this).attr("target","_iri");
   196 	});
   232 	});
   197  	$('.ldt_link_create',base_node).nyroModal({
   233  	$('.ldt_link_create',base_node).nyroModal({
   198  		
   234  		
   199  		filters: ['iriIframe'],
   235  		filters: ['iriIframe'],
   200 		sizes: {
   236 		sizes: {
   201 			minW: '600',
   237 			minW: '600',
   202 			minH: '500'
   238 			minH: '500'
   203 		},
   239 		},
       
   240 		showCloseButton:true,
       
   241 		closeOnEscape:false,
       
   242 		closeOnClick:false,
   204 		callbacks: {
   243 		callbacks: {
   205 			afterShowCont: function(nm) {
   244 			afterShowCont: function(nm) {
   206 				nm.store.iframe.width(600);
   245 				nm.store.iframe.width(600);
   207 				nm.store.iframe.height(500);
   246 				nm.store.iframe.height(500);
   208 				var iframe = nm.store.iframe;
   247 				var iframe = nm.store.iframe;
   222 				});
   261 				});
   223 			},
   262 			},
   224 			afterClose: function(nm) {
   263 			afterClose: function(nm) {
   225 				searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0);
   264 				searchCallback($('#searchprojectsinput'), "#projectslistcontainer", searchprojectfilterurl, 0);
   226 			}	
   265 			}	
   227 	    }
   266 	    },
       
   267 		close:function(){
       
   268 			testAndClose();
       
   269 		}
   228 		
   270 		
   229     });
   271     });
   230 
   272 
   231 	
   273 	
   232 	$('.publishedproject', base_node).click(function(e) {
   274 	$('.publishedproject', base_node).click(function(e) {