From 99a2129492180480377263a31ca459e7e2c30901 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Tue, 15 Jan 2019 00:47:53 -0200 Subject: [PATCH] add jquery na entrada global e migra getCookie --- sapl-frontend/src/global/functions.js | 16 ++++++++++++++++ sapl-frontend/src/global/main.js | 5 ++++- sapl/static/js/app.js | 16 ---------------- 3 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 sapl-frontend/src/global/functions.js diff --git a/sapl-frontend/src/global/functions.js b/sapl-frontend/src/global/functions.js new file mode 100644 index 000000000..a1faf86a4 --- /dev/null +++ b/sapl-frontend/src/global/functions.js @@ -0,0 +1,16 @@ +import jQuery from 'jquery' + +window.getCookie = function(name) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = jQuery.trim(cookies[i]); + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} diff --git a/sapl-frontend/src/global/main.js b/sapl-frontend/src/global/main.js index 15e186144..1aff45be1 100644 --- a/sapl-frontend/src/global/main.js +++ b/sapl-frontend/src/global/main.js @@ -1 +1,4 @@ -window.$ = window.jQuery = require("jquery"); +import jQuery from 'jquery' +import './functions' + +window.$ = window.jQuery = jQuery diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index 9a7e41604..f47cbc0da 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -234,19 +234,3 @@ $(document).ready(function(){ //OptionalCustomFrontEnd(); }); - -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie !== '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) === (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -}