From fe859591f437b5677747297945bdec69baaad391 Mon Sep 17 00:00:00 2001 From: mespeche Date: Fri, 30 Aug 2013 16:32:01 +0200 Subject: [PATCH] WIP Refonte et mise en place du minibrowser --- templates/admin/default/assets/js/main.js | 131 +++++++++++----------- templates/admin/default/coupon/edit.html | 16 +-- 2 files changed, 68 insertions(+), 79 deletions(-) diff --git a/templates/admin/default/assets/js/main.js b/templates/admin/default/assets/js/main.js index 7b5cc812f..e8f4a0aa7 100644 --- a/templates/admin/default/assets/js/main.js +++ b/templates/admin/default/assets/js/main.js @@ -1,6 +1,6 @@ (function($, window, document){ - $(function($){ + $(function(){ // -- Init datepicker -- if($('.date').length){ @@ -41,76 +41,71 @@ } }); - } + } - }); - - - -}(window.jQuery, window, document)); - -// -- Mini browser -- -function miniBrowser(root, url){ - - $.getJSON(url, { - root: root - }) - .done(function(data) { - var resultat = data; + // -- Mini browser -- + miniBrowser = function (root, url){ - var breadcrumb = $('
'); - $(resultat.breadcrumb).each(function(k, v){ - breadcrumb.append( - $('').html(' > '), - $('').attr('href', '#').html(v.display).click(function(e){ - e.preventDefault(); + $.getJSON(url, { + root: root + }) + .done(function(data) { + var resultat = data; - miniBrowser(v.url) - }) - ); - }); - - var categories = $('
'); - $(resultat.categories).each(function(k, v){ - categories.append( - $('

').append( - $('').attr('href', '#').html(v.titre).click(function(e){ - e.preventDefault(); + var breadcrumb = $('

'); + $(resultat.breadcrumb).each(function(k, v){ + breadcrumb.append( + $('').html(' > '), + $('').attr('href', '#').html(v.display).click(function(e){ + e.preventDefault(); + miniBrowser(v.url); + }) + ); + }); + + var categories = $('
'); + $(resultat.categories).each(function(k, v){ + categories.append( + $('

').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); + miniBrowser(v.id); + }) + ) + ); + }); + + var products = $('

'); + $(resultat.products).each(function(k, v){ + products.append( + $('

').append( + $('').attr('href', '#').html(v.titre).click(function(e){ + e.preventDefault(); - miniBrowser(v.id) - }) - ) - ); - }); - - var products = $('

'); - $(resultat.products).each(function(k, v){ - products.append( - $('

').append( - $('').attr('href', '#').html(v.titre).click(function(e){ - e.preventDefault(); + $('#productToAdd_ref').val(v.ref); + $('#productToAdd_titre').val(v.titre); + $('#productToAdd_quantite').val(1); + + manageStock(v.variants, v.promo?v.prix2:v.prix); + + $('#productToAdd_tva').val(v.tva); + + $('.productToAddInformation').show(); + $('#btn_ajout_produit').show(); + }) + ) + ); + }); + + $('#minibrowser-breadcrumb').unbind().empty().append(breadcrumb); + $('#minibrowser-categories').unbind().empty().append(categories); + }) + .fail(function() { + console.log('The JSON file cant be read'); + }); + + } - $('#productToAdd_ref').val(v.ref); - $('#productToAdd_titre').val(v.titre); - $('#productToAdd_quantite').val(1); - - manageStock(v.variants, v.promo?v.prix2:v.prix); - - $('#productToAdd_tva').val(v.tva); - - $('.productToAddInformation').show(); - $('#btn_ajout_produit').show(); - }) - ) - ); - }); - - $('#fastBrowser_breadcrumb').unbind().empty().append(breadcrumb); - $('#fastBrowser_categories').unbind().empty().append(categories); - $('#fastBrowser_products').unbind().empty().append(products); - }) - .fail(function() { - console.log('The JSON file cant be read'); }); - -} \ No newline at end of file + +}(window.jQuery, window, document)); \ No newline at end of file diff --git a/templates/admin/default/coupon/edit.html b/templates/admin/default/coupon/edit.html index 4ad8f28c0..6e2692480 100755 --- a/templates/admin/default/coupon/edit.html +++ b/templates/admin/default/coupon/edit.html @@ -201,7 +201,7 @@

-
+
- +
- + - - + - - +
- - - - Categories list