|
@@ -7,17 +7,11 @@ function init_plugin_hackpoint(){
|
|
init_components();
|
|
init_components();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- case 'list.part':
|
|
|
|
- hackpoint_part_search();
|
|
|
|
- break;
|
|
|
|
|
|
+
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- $('#parts').sortable_table({
|
|
|
|
- onSort : hackpoint_part_search
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
$('#sketchs').sortable_table({
|
|
$('#sketchs').sortable_table({
|
|
onSort : hackpoint_sketch_search
|
|
onSort : hackpoint_sketch_search
|
|
});
|
|
});
|
|
@@ -82,245 +76,6 @@ modalize : function(options){
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-/** PART **/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-//Récuperation d'une liste de part dans le tableau #parts
|
|
|
|
-function hackpoint_resource_part_search(callback){
|
|
|
|
-
|
|
|
|
- $('#parts').fill({
|
|
|
|
- action:'hackpoint_resource_part_search',
|
|
|
|
- resource : $('#sketch-editor').attr('data-id'),
|
|
|
|
- showing : function(li,i){
|
|
|
|
- li.css('transform','scale(0)').removeClass('hidden');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- li.css('transform','scale(1)');
|
|
|
|
- },i*200);
|
|
|
|
- }
|
|
|
|
- },function(){
|
|
|
|
- $('#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');
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- if(callback!=null) callback();
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-//Récuperation d'une liste de part dans le tableau #parts
|
|
|
|
-function hackpoint_part_search(callback){
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $('#parts').fill({
|
|
|
|
- action:'hackpoint_part_search',
|
|
|
|
- resource : $('#sketch-editor').attr('data-id'),
|
|
|
|
- },function(){
|
|
|
|
- $('#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){
|
|
|
|
- var li = $(li);
|
|
|
|
- setTimeout(function(){
|
|
|
|
- li.css('transform','scale(1)');
|
|
|
|
- },i*200);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if(callback!=null) callback();
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Ajout ou modification d'élément part
|
|
|
|
-function hackpoint_part_save(element){
|
|
|
|
- var li = $(element).closest('li');
|
|
|
|
-
|
|
|
|
- var data = {
|
|
|
|
- action : 'hackpoint_part_save',
|
|
|
|
- resource : $('#sketch-editor').attr('data-id'),
|
|
|
|
- part : li.attr('data-part'),
|
|
|
|
- id : li.attr('data-id'),
|
|
|
|
- label : li.find('.label').val(),
|
|
|
|
- brand : li.find('.brand input').val(),
|
|
|
|
- price : li.find('.price input').val(),
|
|
|
|
- url : li.find('.url').val(),
|
|
|
|
- picture : li.find('.part-image').attr('data-stream')
|
|
|
|
- }
|
|
|
|
- $.action(data,function(r){
|
|
|
|
-
|
|
|
|
- li.attr('data-part',r.part);
|
|
|
|
- li.attr('data-id',r.id)
|
|
|
|
- $.message('success','Enregistré');
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function hackpoint_part_find(element){
|
|
|
|
- var li = $(element).closest('li');
|
|
|
|
- var label = li.find('.label').val();
|
|
|
|
- var brand = li.find('.brand input').val();
|
|
|
|
- var url = "https://www.ebay.fr/sch/i.html?_from=R40&_sacat=0&LH_BIN=1&LH_PrefLoc=2&_sop=15";
|
|
|
|
- if(null!=brand && brand !='') label = brand+'+'+label;
|
|
|
|
- url += "&_nkw="+label;
|
|
|
|
- window.open(url);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function hackpoint_part_add(){
|
|
|
|
-
|
|
|
|
- var tpl = $('#parts li:eq(0)').get(0).outerHTML;
|
|
|
|
-
|
|
|
|
- var data = {
|
|
|
|
- price : 1,
|
|
|
|
- url : 'http://ebay.com'
|
|
|
|
- }
|
|
|
|
- var item = $(Mustache.render(tpl,data));
|
|
|
|
- item.removeClass('hidden');
|
|
|
|
- item.css({
|
|
|
|
- transform : 'scale(0)',
|
|
|
|
- opacity : 0,
|
|
|
|
- });
|
|
|
|
- $('#parts li:eq(0)').after(item);
|
|
|
|
-
|
|
|
|
- item.css({
|
|
|
|
- transform : 'scale(1) rotate(0deg)',
|
|
|
|
- opacity : 1,
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- 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();
|
|
|
|
- e.stopPropagation();
|
|
|
|
- var picker = image.next('input[type="file"]');
|
|
|
|
- picker.trigger('click');
|
|
|
|
- picker.change(function(){
|
|
|
|
- var file = picker.get(0).files[0];
|
|
|
|
- var reader = new FileReader();
|
|
|
|
- reader.addEventListener("load", function () {
|
|
|
|
-
|
|
|
|
- image.css('background','url('+reader.result+')')
|
|
|
|
- .attr('data-stream',reader.result)
|
|
|
|
- .css('background-size','cover');
|
|
|
|
- }, false);
|
|
|
|
- reader.readAsDataURL(file);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- image.on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
|
|
|
|
- e.preventDefault();
|
|
|
|
- e.stopPropagation();
|
|
|
|
- })
|
|
|
|
- image.on('drop', function (e) {
|
|
|
|
- var droppedFiles = e.originalEvent.dataTransfer.files;
|
|
|
|
- var reader = new FileReader();
|
|
|
|
- reader.readAsDataURL(droppedFiles[0]);
|
|
|
|
- reader.onload = function () {
|
|
|
|
-
|
|
|
|
- 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());
|
|
|
|
- item.find('.part-image').upload({
|
|
|
|
- allowed : 'jpg,png,jpeg,bmp,svg',
|
|
|
|
- size : 0,
|
|
|
|
- action : 'hackpoint_part_image_upload',
|
|
|
|
- readonly: false,
|
|
|
|
- start: function(){
|
|
|
|
- preload.show();
|
|
|
|
- },
|
|
|
|
- success: function(response){
|
|
|
|
- if(response.previews.length && response.previews[0].name) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- console.log(response);
|
|
|
|
- preload.fadeOut();
|
|
|
|
- },
|
|
|
|
- complete: function(){
|
|
|
|
- preload.fadeOut();
|
|
|
|
- }
|
|
|
|
- });*/
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Suppression d'élement part
|
|
|
|
-function hackpoint_resource_part_delete(element){
|
|
|
|
- if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
|
|
|
|
- var line = $(element).closest('li');
|
|
|
|
-
|
|
|
|
- if(line.attr('data-id')==''){
|
|
|
|
- line.css('transform','scale(0)');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- line.remove()
|
|
|
|
- },210);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $.action({
|
|
|
|
- action : 'hackpoint_resource_part_delete',
|
|
|
|
- id : line.attr('data-id')
|
|
|
|
- },function(r){
|
|
|
|
- line.css('transform','scale(0)');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- line.remove()
|
|
|
|
- },210);
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//Suppression d'élement part
|
|
|
|
-function hackpoint_part_delete(element){
|
|
|
|
- if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
|
|
|
|
- var line = $(element).closest('li');
|
|
|
|
-
|
|
|
|
- if(line.attr('data-id')==''){
|
|
|
|
- line.css('transform','scale(0)');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- line.remove()
|
|
|
|
- },210);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $.action({
|
|
|
|
- action : 'hackpoint_part_delete',
|
|
|
|
- id : line.attr('data-id')
|
|
|
|
- },function(r){
|
|
|
|
- line.css('transform','scale(0)');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- line.remove()
|
|
|
|
- },210);
|
|
|
|
- });
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
/** SKETCH **/
|
|
/** SKETCH **/
|