<commit_before><?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl"
	xmlns:html="http://www.w3.org/1999/xhtml"
	xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">	
	
	<binding id="cPreviewImgUrl" extends="layout.cDocumentEditor#cProperty">
		<implementation>					
			<method name="setValue">
				<parameter name="val" />
				<body><![CDATA[
					if (val)
					{
						this.setAttribute("value", val.image);
						this.setAttribute("docid", val.id);
						this.setAttribute("doclang", val.lang);
						this.removeAttribute("hidden");
					}
					else
					{
						this.removeAttribute("value");
						this.setAttribute("hidden", true);
					}
				]]></body>
			</method>	
			
			<method name="download">
				<body><![CDATA[			
					var documentId   = this.getAttribute("docid");
					var documentLang = this.getAttribute("doclang");
					wToolkit.openlink('media', 'BoDisplay', {cmpref: documentId, lang: documentLang, forceDownload: true});
				]]></body>
			</method>	
		</implementation>
		<content>
			<xul:hbox style="padding-bottom:5px">
				<xul:label class="label" xbl:inherits="value=label" />
				<xul:label class="label separator" value=":" />
				<xul:hbox pack="start" align="start">
					<xul:image xbl:inherits="src=value" style="max-height: 128px; max-width: 128px" /><xul:spacer width="10" />
					<xul:label class="text-link" onclick="document.getBindingParent(this).download()" 
						value="&amp;modules.media.bo.doceditor.property.Previewimgurl-download;"/>
				</xul:hbox>	
			</xul:hbox>			
		</content>
	</binding>
	
	<binding id="cMediaUsages" extends="layout.cDocumentEditor#cProperty">
		<implementation>					
			<method name="setValue">
				<parameter name="val" />
				<body><![CDATA[
					var lst = document.getAnonymousElementByAttribute(this, "anonid", "lstdoc");
					while (lst.lastChild) {lst.removeChild(lst.lastChild)}
					
					if (val)
					{
						for (var i = 0; i < val.length; i++)
						{
							var label = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "xul:label");
							lst.appendChild(label);
							label.value = val[i];
						}
						this.removeAttribute("hidden");
					}
					else
					{
						this.setAttribute("hidden", true);
					}
				]]></body>
			</method>	
		</implementation>
		<content>
			<xul:hbox>
				<xul:label class="label" xbl:inherits="value=label" />
				<xul:label class="label separator" value=":" />
				<xul:vbox anonid="lstdoc">				
				</xul:vbox>
			</xul:hbox>			
		</content>
	</binding>	
	
	
	
	<binding id="wMediaModuleList" extends="widgets.cNavigation#cModuleThumbnailList">
		<implementation>
			<field name="mUploadCount">0</field>
			
			<method name="onDragEnter">
				<parameter name="event" />		
				<body><![CDATA[
					wCore.debug('wMediaModuleList.onDragEnter');		
					this.mDropData = null;
					var dropNodeInfo = event.dataTransfer.mozGetDataAt("application/json-documentidtype-array", 0);
					if (dropNodeInfo)
					{
						wCore.debug('wMediaModuleList.document');
						var dropNode = wCore.parseJSON(dropNodeInfo);
						var dropItemData = {id:dropNode[0][0], modelName: this._convertTypeToModel(dropNode[0][1]), ids:[]};
						for (var i = 0; i < dropNode.length; i++)
						{
							dropItemData.ids.push(dropNode[i][0]);
						} 
						this.dragFeedBack = {dropOn : -1, dropAfter: -1, dropBefore : -1, action: null, dropItemData: dropItemData};
						event.preventDefault();
					}
					else if (event.dataTransfer.types.contains('application/x-moz-file'))
					{
						wCore.debug('wMediaModuleList.files');
						var dropItemData = {id:-1, modelName: 'modules_media/media', ids:[-1]};
						this.dragFeedBack = {dropOn : -1, dropAfter: -1, dropBefore : -1, action: null, dropItemData: dropItemData};
						event.preventDefault();
					}
					else
					{
						this.dragFeedBack = null;
					}
				]]></body>	
			</method>			
	
			<method name="onDrop">
				<parameter name="event" />			
				<body><![CDATA[
					wCore.debug('onDrop');
					var dragFeedBack = this.mDropData;
					this.mDropData = null;
					
					if (dragFeedBack == null)
					{
						event.preventDefault();
						return;
					}

					
					var dropInfo = {cmpref:dragFeedBack.dropItemData.ids, action: dragFeedBack.action};
					var view = this.tree.view;
					var tn;
					if (dragFeedBack.dropOn < 0)
					{
						dropInfo.parentid  = this.mBaseItemData.id;
						if (dragFeedBack.dropBefore != -1)
						{
							 tn = view.getItemAtIndex(dragFeedBack.dropBefore);
							 dropInfo.beforeid = tn.itemData.id;
						}
						else if (dragFeedBack.dropAfter != -1)
						{
							 tn = view.getItemAtIndex(dragFeedBack.dropAfter);
							 dropInfo.afterid = tn.itemData.id;
						}	
					}
					else
					{
						tn = view.getItemAtIndex(dragFeedBack.dropOn);
						dropInfo.parentid  = tn.itemData.id;
					}
					if (dragFeedBack.dropItemData.id == -1)
					{
						dropInfo.dt = event.dataTransfer;
						this.executeDropFileCommand(dropInfo);
					}
					else
					{
						this.executeDropCommand(dropInfo);
					}
					event.preventDefault();
				]]></body>	
			</method>	
			
			<method name="executeDropFileCommand">
				<parameter name="dropInfo" />
				<body><![CDATA[
					wCore.debug('executeDropFileCommand');
					var dt = dropInfo.dt;
					var file = null;
					var parameters = {lang: Context.W_LANG, cmpref: dropInfo.parentid};
					if (dropInfo.beforeid) {parameters.beforeid = dropInfo.beforeid;}
					if (dropInfo.afterid) {parameters.afterid = dropInfo.afterid;}
					
					for (var i = 0; i < dt.mozItemCount; i++)
					{
						file = dt.mozGetDataAt("application/x-moz-file", i);
  						if (file instanceof Components.interfaces.nsIFile)
  						{
							this.startUploadFile(file, parameters);
						}							
					}					
				]]></body>
			</method>
			
			<method name="startUploadFile">
				<parameter name="nsIFile" />
				<parameter name="parameters" />
				<body><![CDATA[
					try
                    {
                    	if (this.mUploadCount === 0)
                    	{
							this.disabled = true;
						}
						this.mUploadCount++;<commit_msg>[FIX] Correction de l'affichage du drag and drop de fichiers locale<commit_after><?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl"
	xmlns:html="http://www.w3.org/1999/xhtml"
	xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">	
	
	<binding id="cPreviewImgUrl" extends="layout.cDocumentEditor#cProperty">
		<implementation>					
			<method name="setValue">
				<parameter name="val" />
				<body><![CDATA[
					if (val)
					{
						this.setAttribute("value", val.image);
						this.setAttribute("docid", val.id);
						this.setAttribute("doclang", val.lang);
						this.removeAttribute("hidden");
					}
					else
					{
						this.removeAttribute("value");
						this.setAttribute("hidden", true);
					}
				]]></body>
			</method>	
			
			<method name="download">
				<body><![CDATA[			
					var documentId   = this.getAttribute("docid");
					var documentLang = this.getAttribute("doclang");
					wToolkit.openlink('media', 'BoDisplay', {cmpref: documentId, lang: documentLang, forceDownload: true});
				]]></body>
			</method>	
		</implementation>
		<content>
			<xul:hbox style="padding-bottom:5px">
				<xul:label class="label" xbl:inherits="value=label" />
				<xul:label class="label separator" value=":" />
				<xul:hbox pack="start" align="start">
					<xul:image xbl:inherits="src=value" style="max-height: 128px; max-width: 128px" /><xul:spacer width="10" />
					<xul:label class="text-link" onclick="document.getBindingParent(this).download()" 
						value="&amp;modules.media.bo.doceditor.property.Previewimgurl-download;"/>
				</xul:hbox>	
			</xul:hbox>			
		</content>
	</binding>
	
	<binding id="cMediaUsages" extends="layout.cDocumentEditor#cProperty">
		<implementation>					
			<method name="setValue">
				<parameter name="val" />
				<body><![CDATA[
					var lst = document.getAnonymousElementByAttribute(this, "anonid", "lstdoc");
					while (lst.lastChild) {lst.removeChild(lst.lastChild)}
					
					if (val)
					{
						for (var i = 0; i < val.length; i++)
						{
							var label = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "xul:label");
							lst.appendChild(label);
							label.value = val[i];
						}
						this.removeAttribute("hidden");
					}
					else
					{
						this.setAttribute("hidden", true);
					}
				]]></body>
			</method>	
		</implementation>
		<content>
			<xul:hbox>
				<xul:label class="label" xbl:inherits="value=label" />
				<xul:label class="label separator" value=":" />
				<xul:vbox anonid="lstdoc">				
				</xul:vbox>
			</xul:hbox>			
		</content>
	</binding>	
	
	

	<binding id="wMediaModuleList" extends="widgets.cNavigation#cModuleThumbnailList">
		<implementation>
			<field name="mUploadCount">0</field>
			
			<method name="onDragEnter">
				<parameter name="event" />		
				<body><![CDATA[
					//wCore.debug('wMediaModuleList.onDragEnter');		
					this.mDropData = null;
					var dropNodeInfo = event.dataTransfer.mozGetDataAt("application/json-documentidtype-array", 0);
					if (dropNodeInfo)
					{
						//wCore.debug('wMediaModuleList.document');
						var dropNode = wCore.parseJSON(dropNodeInfo);
						var dropItemData = {id:dropNode[0][0], modelName: this._convertTypeToModel(dropNode[0][1]), ids:[]};
						for (var i = 0; i < dropNode.length; i++)
						{
							dropItemData.ids.push(dropNode[i][0]);
						} 
						this.dragFeedBack = {dropOn : -1, dropAfter: -1, dropBefore : -1, action: null, dropItemData: dropItemData};
					}
					else if (event.dataTransfer.types.contains('application/x-moz-file'))
					{
						//wCore.debug('wMediaModuleList.files');
						var dropItemData = {id:-1, modelName: 'modules_media/media', ids:[-1]};
						this.dragFeedBack = {dropOn : -1, dropAfter: -1, dropBefore : -1, action: null, dropItemData: dropItemData};
					}
					else
					{
						event.dataTransfer.effectAllowed = 'none';
						this.dragFeedBack = null;
					}
					event.preventDefault();
				]]></body>	
			</method>	
					
			<method name="onDragOver">
				<parameter name="event" />			
				<body><![CDATA[
					if (!this.dragFeedBack) 
					{
						event.dataTransfer.effectAllowed = 'none';
						event.preventDefault();
						return;
					}
					
					var tree = this.tree;
					var rowIndex = tree.treeBoxObject.getRowAt(event.clientX, event.clientY);					
							
					var currentDragFeedBack = this.dragFeedBack;
					var dropItemData = currentDragFeedBack.dropItemData; 
					var dragFeedBack = this.getDragFeedBack(rowIndex, event.clientY);
					
					var itemData = (dragFeedBack.dropOn < 0) ? this.mBaseItemData : tree.view.getItemAtIndex(dragFeedBack.dropOn).itemData;
					if (!itemData || itemData.id  == dropItemData.id) 
					{
						this.cleanDragFeedBack();
						event.dataTransfer.effectAllowed = 'none';
						event.preventDefault();
						return;					
					}

					currentDragFeedBack.action = this.getDropAction(itemData, dropItemData);	
					if (!currentDragFeedBack.action)
					{
						event.dataTransfer.effectAllowed = 'none';
					}
														
					if (currentDragFeedBack.dropOn != dragFeedBack.dropOn)
					{
						this.cleanDragFeedBack();
						if (currentDragFeedBack.action) { this.applyDragFeedBack(dragFeedBack);}	
					}
					else if (currentDragFeedBack.dropBefore != dragFeedBack.dropBefore ||
							 currentDragFeedBack.dropAfter != dragFeedBack.dropAfter)
					{
						this.cleanDragFeedBack();
						if (currentDragFeedBack.action)
						{ 
							this.applyDragFeedBack(dragFeedBack);
						}
					}						
													
					event.preventDefault();
				]]></body>	
			</method>
							
			<method name="onDrop">
				<parameter name="event" />			
				<body><![CDATA[
					//wCore.debug('onDrop');
					var dragFeedBack = this.mDropData;
					this.mDropData = null;
					
					if (dragFeedBack == null)
					{
						event.preventDefault();
						return;
					}

					var dropInfo = {cmpref:dragFeedBack.dropItemData.ids, action: dragFeedBack.action};
					var view = this.tree.view;
					var tn;
					if (dragFeedBack.dropOn < 0)
					{
						dropInfo.parentid  = this.mBaseItemData.id;
						if (dragFeedBack.dropBefore != -1)
						{
							 tn = view.getItemAtIndex(dragFeedBack.dropBefore);
							 dropInfo.beforeid = tn.itemData.id;
						}
						else if (dragFeedBack.dropAfter != -1)
						{
							 tn = view.getItemAtIndex(dragFeedBack.dropAfter);
							 dropInfo.afterid = tn.itemData.id;
						}	
					}
					else
					{
						tn = view.getItemAtIndex(dragFeedBack.dropOn);
						dropInfo.parentid  = tn.itemData.id;
					}
					if (dragFeedBack.dropItemData.id == -1)
					{
						dropInfo.dt = event.dataTransfer;
						this.executeDropFileCommand(dropInfo);
					}
					else
					{
						this.executeDropCommand(dropInfo);
					}
					event.preventDefault();
				]]></body>	
			</method>	
			
			<method name="executeDropFileCommand">
				<parameter name="dropInfo" />
				<body><![CDATA[
					//wCore.debug('executeDropFileCommand');
					var dt = dropInfo.dt;
					var file = null;
					var parameters = {lang: Context.W_LANG, cmpref: dropInfo.parentid};
					if (dropInfo.beforeid) {parameters.beforeid = dropInfo.beforeid;}
					if (dropInfo.afterid) {parameters.afterid = dropInfo.afterid;}
					
					for (var i = 0; i < dt.mozItemCount; i++)
					{
						file = dt.mozGetDataAt("application/x-moz-file", i);
  						if (file instanceof Components.interfaces.nsIFile)
  						{
							this.startUploadFile(file, parameters);
						}							
					}					
				]]></body>
			</method>
			
			<method name="startUploadFile">
				<parameter name="nsIFile" />
				<parameter name="parameters" />
				<body><![CDATA[
					try
                    {
                    	if (this.mUploadCount === 0)
                    	{
							this.disabled = true;
						}
						this.mUploadCount++;
{'fraction_non_alphanumeric': 0.1529755125284738, 'fraction_numerical': 0.005623576309794988, 'mean_word_length': 2.6758241758241756, 'pattern_counts': {'":': 4, '<': 164, '<?xml version=': 2, '>': 153, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3718768', 'n_tokens_mistral': 6410, 'n_tokens_neox': 4614, 'n_words': 744}