Browse Source

corectif part images (en cours)

idleman 5 years ago
parent
commit
6c0fced430
4 changed files with 26 additions and 44 deletions
  1. 1 1
      .gitignore
  2. 0 33
      constant.php
  3. 1 1
      plugin/hackpoint/action.php
  4. 24 9
      plugin/hackpoint/js/main.js

+ 1 - 1
.gitignore

@@ -5,4 +5,4 @@
 *.maintenance
 *.sublime-project
 *.sublime-workspace
-/plugin/document/logs/*.*
+/plugin/document/logs/*.*

+ 0 - 33
constant.php

@@ -1,33 +0,0 @@
-<?php
-define('SLASH',DIRECTORY_SEPARATOR);
-define('__ROOT__',dirname(__FILE__).SLASH);
-define('TIME_ZONE','Europe/Paris');
-define('ENTITY_PREFIX', '');
-define('LOG_PATH',__ROOT__.'log');
-define('FILE_PATH','file'.SLASH);
-define('PLUGIN_PATH','plugin'.SLASH);
-define('LIB_PATH',__ROOT__.'lib'.SLASH);
-
-define('AVATAR_PATH','avatar'.SLASH);
-
-define('BASE_SGBD','Mysql');
-define('BASE_HOST','localhost');
-define('BASE_NAME','hackpoint');
-define('BASE_LOGIN','root');
-define('BASE_PASSWORD','root');
-
-define('ROOT_URL','http://127.0.0.1/perso/hackpoint');
-define('CRYPTKEY','MTU1NDc5OTI1N3Jvb3QxODA=');
-//logs toutes les requetes sans formattage
-define('BASE_DEBUG',false);
-
-define('COOKIE_NAME','erp-core-cookie');
-
-define('PROGRAM_NAME','Hackpoint');
-define('PROGRAM_UID','idleman/hackpoint');
-define('PROGRAM_TECHNICIAN','valentin.carruesco');
-
-define('SOURCE_VERSION','1.5');
-define('BASE_VERSION','1.5');
-
-?>

+ 1 - 1
plugin/hackpoint/action.php

@@ -302,7 +302,7 @@ switch($_['action']){
 				file_put_contents($dir.SLASH.'cover.jpg', $stream);
 			}
 
-			$item = new ResourcePart();
+			$item =  ResourcePart::provide();
 			$item->part = $part->id;
 			$item->resource = $_['resource'];
 			$item->save();

+ 24 - 9
plugin/hackpoint/js/main.js

@@ -40,12 +40,18 @@ function hackpoint_part_search(callback){
 		resource : $('#sketch-editor').attr('data-id'),
 		showItems : false
 	},function(){
-		$('#parts li:not(:eq(0)) [data-stream]').each(function(i,div){
+		$('#parts li:not(:eq(0))').each(function(i,li){
+
+			hackpoint_resource_part_upload(li);
+
+			var div  = $('[data-stream]',li);
+
 			if($(div).attr('data-stream') =='') return;
 			$(div).css('background','url(data:'+$(div).attr('data-stream')+')')
 		     	.css('background-size','cover');
 		});
 
+
 		$('#parts li:not(:eq(0))').css('transform','scale(0)').removeClass('hidden')
 
 		$('#parts li:not(:eq(0))').each(function(i,li){
@@ -116,6 +122,16 @@ function hackpoint_part_add(){
 
 	init_components(item);
 
+	hackpoint_resource_part_upload(item);
+
+
+
+
+
+}
+
+function hackpoint_resource_part_upload(item){
+	var item = $(item);
 	var image = item.find('.part-image');
 	image.click(function(e){
 		e.preventDefault();
@@ -126,7 +142,8 @@ function hackpoint_part_add(){
 			var file = picker.get(0).files[0];
 			 var reader  = new FileReader();
 			 reader.addEventListener("load", function () {
-			    image.css('background','url(data:'+reader.result+')')
+			
+			    image.css('background','url('+reader.result+')')
 			    .attr('data-stream',reader.result)
 		     	.css('background-size','cover');
 			  }, false);
@@ -142,15 +159,17 @@ function hackpoint_part_add(){
 		var reader = new FileReader();
 		   reader.readAsDataURL(droppedFiles[0]);
 		   reader.onload = function () {
-		     image.css('background','url(data:image/jpeg;'+reader.result+')');
-		     image.css('background-size','cover');
+		   
+		     image.css('background','url('+reader.result+')')
+			    .attr('data-stream',reader.result)
+		     	.css('background-size','cover');
 		   };
 		   reader.onerror = function (error) {
 		     console.log('Error: ', error);
 		   };
 
 	});
-	/*
+		/*
 	var preload = $('<div class="preload progress-bar progress-bar-striped progress-bar-animated"></div>');
 	item.find('.part-image').append(preload);
 	item.find('.part-image').attr('id','part-image-'+$('#parts li').length());
@@ -173,12 +192,8 @@ function hackpoint_part_add(){
 			preload.fadeOut();
 		}
 	});*/
-
-
-
 }
 
-
 //Suppression d'élement part
 function hackpoint_resource_part_delete(element){
 	if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;