From 3d9cce09fdb4e913fa21cbb97879d8d79e48121e Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Fri, 25 Jan 2019 16:49:11 -0200 Subject: [PATCH] =?UTF-8?q?ajuste=20de=20layout=20para=20notas=20e=20de=20?= =?UTF-8?q?c=C3=B3digo=20eslint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl-frontend/.eslintrc.js | 16 +- sapl-frontend/babel.config.js | 4 +- sapl-frontend/postcss.config.js | 2 +- .../apps/compilacao/js/old/compilacao_edit.js | 1081 +++++----- .../compilacao/js/old/compilacao_notas.js | 4 +- .../src/apps/compilacao/scss/compilacao.scss | 1 + sapl-frontend/src/global/functions.js | 189 +- .../global/image_cropping/js/jquery.Jcrop.js | 1857 +++++++++-------- .../global/image_cropping/js/jquery.color.js | 1356 ++++++------ sapl-frontend/src/global/main.js | 4 +- .../src/hellow/components/HelloWorld.vue | 4 +- sapl-frontend/src/hellow/main.js | 10 +- sapl-frontend/src/hellow/router.js | 6 +- sapl-frontend/src/hellow/store.js | 6 +- sapl-frontend/src/hellow/views/Home.vue | 4 +- sapl-frontend/vue.config.js | 27 +- sapl/compilacao/forms.py | 29 +- sapl/crispy_layout_mixin.py | 3 +- 18 files changed, 2324 insertions(+), 2279 deletions(-) diff --git a/sapl-frontend/.eslintrc.js b/sapl-frontend/.eslintrc.js index 36d51155e..5ffba63a0 100644 --- a/sapl-frontend/.eslintrc.js +++ b/sapl-frontend/.eslintrc.js @@ -6,25 +6,25 @@ module.exports = { jquery: true }, extends: [ - "plugin:vue/essential", + 'plugin:vue/essential', 'standard' - ], + ], rules: { 'generator-star-spacing': 'off', - "no-console": process.env.NODE_ENV === "production" ? "error" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' }, // required to lint *.vue files plugins: [ 'vue' ], parserOptions: { - parser: "babel-eslint" + parser: 'babel-eslint' }, globals: { - "$": true, - "jQuery": true, + '$': true, + 'jQuery': true, '_': true } -}; +} diff --git a/sapl-frontend/babel.config.js b/sapl-frontend/babel.config.js index 3ecebf1a5..df151586e 100644 --- a/sapl-frontend/babel.config.js +++ b/sapl-frontend/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: ["@vue/app"] -}; + presets: ['@vue/app'] +} diff --git a/sapl-frontend/postcss.config.js b/sapl-frontend/postcss.config.js index 5bfb8f628..961986e2b 100644 --- a/sapl-frontend/postcss.config.js +++ b/sapl-frontend/postcss.config.js @@ -2,4 +2,4 @@ module.exports = { plugins: { autoprefixer: {} } -}; +} diff --git a/sapl-frontend/src/apps/compilacao/js/old/compilacao_edit.js b/sapl-frontend/src/apps/compilacao/js/old/compilacao_edit.js index 7b5183979..bf9621fc1 100644 --- a/sapl-frontend/src/apps/compilacao/js/old/compilacao_edit.js +++ b/sapl-frontend/src/apps/compilacao/js/old/compilacao_edit.js @@ -1,610 +1,563 @@ -function DispositivoEdit() { - // Função única - Singleton pattern - operador new sempre devolve o mesmo objeto - var instance; +function DispositivoEdit () { + // Função única - Singleton pattern - operador new sempre devolve o mesmo objeto + var instance - var editortype = "textarea"; + var editortype = 'textarea' - if (!(this instanceof DispositivoEdit)) { - if (!instance) { - instance = new DispositivoEdit(); - } - return instance; + if (!(this instanceof DispositivoEdit)) { + if (!instance) { + instance = new DispositivoEdit() } - instance = this; - DispositivoEdit = function() { - return instance; - }; - - instance.bindActionsEditorType = function(event) { - editortype = this.getAttribute('editortype'); - SetCookie("editortype", editortype, 30); - var dpt = $(this).closest('.dpt'); - - var pk = dpt.attr('pk'); - instance.clearEditSelected(); - instance.triggerBtnDptEdit(pk); + return instance + } + instance = this + DispositivoEdit = function () { + return instance + } + + instance.bindActionsEditorType = function (event) { + editortype = this.getAttribute('editortype') + SetCookie('editortype', editortype, 30) + var dpt = $(this).closest('.dpt') + + var pk = dpt.attr('pk') + instance.clearEditSelected() + instance.triggerBtnDptEdit(pk) + } + + instance.bindActionsClick = function (event) { + var pk = this.getAttribute('pk') + + var form_data = { + 'action': this.getAttribute('action'), + 'tipo_pk': this.getAttribute('tipo_pk'), + 'perfil_pk': this.getAttribute('perfil_pk'), + 'variacao': this.getAttribute('variacao'), + 'pk_bloco': this.getAttribute('pk_bloco') } - instance.bindActionsClick = function(event) { - var pk = this.getAttribute('pk'); - - var form_data = { - 'action' : this.getAttribute('action'), - 'tipo_pk' : this.getAttribute('tipo_pk'), - 'perfil_pk' : this.getAttribute('perfil_pk'), - 'variacao' : this.getAttribute('variacao'), - 'pk_bloco' : this.getAttribute('pk_bloco'), - }; - - var url = pk+'/refresh'; - instance.waitShow(); - - $.get(url, form_data).done(function(data) { - instance.clearEditSelected(); - if (data.pk != null) { - instance.message(data); - } - }).fail(instance.waitHide).always(instance.waitHide); + var url = pk + '/refresh' + instance.waitShow() + + $.get(url, form_data).done(function (data) { + instance.clearEditSelected() + if (data.pk != null) { + instance.message(data) + } + }).fail(instance.waitHide).always(instance.waitHide) + } + + instance.clearEditSelected = function () { + $('.dpt-selected > .dpt-form').html('') + $('.dpt-actions, .dpt-actions-bottom').html('') + tinymce.remove() + $('.dpt-selected').removeClass('dpt-selected') + } + + instance.editDispositivo = function (event) { + var obj_click = (event.target.classList.contains('dpt-link') + ? event.target + : (event.target.parentElement.classList.contains('dpt-link') + ? event.target.parentElement + : null)) + + if (obj_click && obj_click.getAttribute('href') && obj_click.getAttribute('href').length > 0) { return } + + var dpt = $(this).closest('.dpt') + if (dpt.hasClass('dpt-selected')) { + if (this.getAttribute('action') == 'editor-close') { instance.clearEditSelected() } + return } - - instance.clearEditSelected = function() { - $('.dpt-selected > .dpt-form').html(''); - $('.dpt-actions, .dpt-actions-bottom').html(''); - tinymce.remove(); - $('.dpt-selected').removeClass('dpt-selected'); + instance.clearEditSelected() + instance.loadActionsEdit(dpt) + + var formtype = dpt.attr('formtype') + dpt.on(formtype, instance[formtype]) + instance.loadForm(dpt, formtype) + } + + instance.gc = function () { + setTimeout(function () { + $('.dpt:not(.dpt-selected) > .dpt-form').html('') + }, 500) + } + + instance.get_form_base = function () { + var _this = $(this) + _this.addClass('dpt-selected') + + var dpt_form = _this.children().filter('.dpt-form') + dpt_form.find('form').submit(instance.onSubmitEditFormBase) + + instance.scrollTo(_this) + _this.off('get_form_base') + + var btn_fechar = _this.find('.btn-fechar') + btn_fechar.on('click', function () { + instance.clearEditSelected() + }) + + var btns_excluir = _this.find('.btns-excluir') + _this.find('.dpt-actions-bottom').first().append(btns_excluir) + + btns_excluir.find('.btn-outline-danger').on('click', instance.bindActionsClick) + } + + instance.get_form_alteracao = function () { + var _this = $(this) + _this.off('get_form_alteracao') + $('.dpt-actions, .dpt-actions-bottom').html('') + + var dpt_form = _this.children().filter('.dpt-form').children().first() + var url_search = dpt_form[0]['id_dispositivo_search_form'].value + DispositivoSearch({ + 'url_form': url_search, + 'text_button': 'Selecionar' + }) + + instance.scrollTo(_this) + dpt_form.submit(instance.onSubmitFormRegistraAlteracao) + + var btn_fechar = _this.find('.btn-fechar') + btn_fechar.on('click', function () { + instance.clearEditSelected() + instance.triggerBtnDptEdit(_this.attr('pk')) + }) + } + + instance.get_form_inclusao = function () { + var _this = $(this) + _this.off('get_form_inclusao') + $('.dpt-actions, .dpt-actions-bottom').html('') + + var dpt_form = _this.children().filter('.dpt-form').children().first() + var url_search = dpt_form[0]['id_dispositivo_search_form'].value + DispositivoSearch({ + 'url_form': url_search, + 'text_button': 'Selecionar', + 'post_selected': instance.allowed_inserts_registro_inclusao, + 'params_post_selected': { 'pk_bloco': _this.attr('pk') } + + }) + + instance.scrollTo(_this) + dpt_form.submit(instance.onSubmitFormRegistraInclusao) + + var btn_fechar = _this.find('.btn-fechar') + btn_fechar.on('click', function () { + instance.clearEditSelected() + instance.triggerBtnDptEdit(_this.attr('pk')) + }) + } + + instance.get_form_revogacao = function () { + var _this = $(this) + _this.off('get_form_revogacao') + $('.dpt-actions, .dpt-actions-bottom').html('') + + var dpt_form = _this.children().filter('.dpt-form').children().first() + var url_search = dpt_form[0]['id_dispositivo_search_form'].value + DispositivoSearch({ + 'url_form': url_search, + 'text_button': 'Selecionar' + }) + + instance.scrollTo(_this) + dpt_form.submit(instance.onSubmitFormRegistraRevogacao) + + var btn_fechar = _this.find('.btn-fechar') + btn_fechar.on('click', function () { + instance.clearEditSelected() + instance.triggerBtnDptEdit(_this.attr('pk')) + }) + } + + instance.allowed_inserts_registro_inclusao = function (params) { + var dispositivo_base_para_inclusao = $('#id' + params.pk_bloco + " input[name='dispositivo_base_para_inclusao']") + if (dispositivo_base_para_inclusao.length == 0) { return } + + var pk = dispositivo_base_para_inclusao[0].value + var form_data = { + 'action': 'get_actions_allowed_inserts_registro_inclusao', + 'pk_bloco': params.pk_bloco } - instance.editDispositivo = function(event) { - var obj_click = (event.target.classList.contains('dpt-link') - ? event.target - : (event.target.parentElement.classList.contains('dpt-link') - ? event.target.parentElement - : null)); - - if (obj_click && obj_click.getAttribute('href') && obj_click.getAttribute('href').length > 0) - return; - - var dpt = $(this).closest('.dpt'); - if (dpt.hasClass('dpt-selected')) { - if (this.getAttribute('action') == 'editor-close') - instance.clearEditSelected(); - return; + var url = pk + '/refresh' + instance.waitShow() + + $.get(url, form_data).done(function (data) { + $('.allowed_inserts').html(data) + $('.allowed_inserts').find('.btn-action').on('click', instance.bindActionsClick) + }).fail(instance.waitHide).always(instance.waitHide) + } + + instance.loadActionsEdit = function (dpt) { + var pk = dpt.attr('pk') + var url = pk + '/refresh?action=get_actions' + $.get(url).done(function (data) { + dpt.find('.dpt-actions').first().html(data) + dpt.find('.btn-action').on('click', instance.bindActionsClick) + // dpt.find('.btn-perfis').on('click', instance.bindActionsClick); + dpt.find('.btn-compila').on('click', instance.loadFormsCompilacao) + dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType) + + if (editortype == 'construct') { dpt.find('.btn-group-inserts').first().addClass('open') } + + dpt.find('.btn-group-inserts button').mouseenter(function (event) { + dpt.find('.btn-group-inserts').removeClass('open') + $(this.parentElement).addClass('open') + }) + + instance.gc() + }) + } + + instance.loadForm = function (dpt, trigger) { + var pk = dpt.attr('pk') + var dpt_form = dpt.children().filter('.dpt-form') + if (dpt_form.length == 1) { + var url = pk + '/refresh?action=' + trigger + $.get(url).done(function (data) { + if (editortype != 'construct') { + dpt_form.html(data) + if (editortype == 'tinymce') { + initTextRichEditor() + } + OptionalCustomFrontEnd().init() } - instance.clearEditSelected(); - instance.loadActionsEdit(dpt); - - var formtype = dpt.attr('formtype'); - dpt.on(formtype, instance[formtype]); - instance.loadForm(dpt, formtype); + dpt.trigger(trigger) + }).always(function () { + instance.waitHide() + }) } - - instance.gc = function() { - setTimeout(function() { - $('.dpt:not(.dpt-selected) > .dpt-form').html(''); - },500); + } + + instance.loadFormsCompilacao = function (event) { + var dpt = $(this).closest('.dpt') + var formtype = this.getAttribute('action') + dpt.on(formtype, instance[formtype]) + instance.loadForm(dpt, formtype) + } + + instance.modalMessage = function (message, alert, closeFunction) { + if (message != null && message != '') { + $('#modal-message #message').html(message) + $('#modal-message').modal('show') + $('#modal-message, #modal-message .alert button').off() + $('#modal-message .alert').removeClass('alert-success alert-info alert-warning alert-danger alert-danger') + $('#modal-message .alert').addClass(alert) + + if (closeFunction != null) { $('#modal-message').on('hidden.bs.modal', closeFunction) } + + $('#modal-message .alert button').on('click', function () { + $('#modal-message').modal('hide') + }) + return true } - - instance.get_form_base = function () { - var _this = $(this); - _this.addClass('dpt-selected'); - - var dpt_form = _this.children().filter('.dpt-form'); - dpt_form.find('form').submit(instance.onSubmitEditFormBase); - - instance.scrollTo(_this); - _this.off('get_form_base') - - var btn_fechar = _this.find('.btn-fechar'); - btn_fechar.on('click', function() { - instance.clearEditSelected(); - }); - - var btns_excluir = _this.find('.btns-excluir'); - _this.find('.dpt-actions-bottom').first().append(btns_excluir); - - btns_excluir.find('.btn-outline-danger').on('click', instance.bindActionsClick); + return false + } + + instance.message = function (data) { + if (data.message !== undefined) { + if (data.message.modal) { + instance.modalMessage(data.message.value, 'alert-' + data.message.type, function () { + instance.waitShow() + instance.refreshScreenFocusPk(data) + }) + } else { + instance.refreshScreenFocusPk(data) + if (!('message' in data)) { return } + var cp_notify = $('.cp-notify') + cp_notify.removeClass('hide') + var msg = cp_notify.find('.message') + msg.text(data.message.value) + msg.removeClass('bg-primary bg-success bg-info bg-warning bg-danger').addClass('bg-' + data.message.type) + setTimeout(function () { + cp_notify.addClass('hide') + }, (data.message.time ? data.message.time : 3000)) + } + } else { + instance.refreshScreenFocusPk(data) } - - instance.get_form_alteracao = function () { - var _this = $(this); - _this.off('get_form_alteracao'); - $('.dpt-actions, .dpt-actions-bottom').html(''); - - var dpt_form = _this.children().filter('.dpt-form').children().first(); - var url_search = dpt_form[0]['id_dispositivo_search_form'].value; - DispositivoSearch({ - 'url_form': url_search, - 'text_button': 'Selecionar' - }); - - instance.scrollTo(_this); - dpt_form.submit(instance.onSubmitFormRegistraAlteracao); - - var btn_fechar = _this.find('.btn-fechar'); - btn_fechar.on('click', function() { - instance.clearEditSelected(); - instance.triggerBtnDptEdit(_this.attr('pk')); - }); + } + instance.offClicks = function () { + $('.btn-dpt-edit').off() + } + instance.onClicks = function (container) { + var objects + if (container == null) { objects = $('.btn-dpt-edit') } else { objects = $(container).find('.btn-dpt-edit') } + objects.on('click', instance.editDispositivo) + } + + instance.onSubmitFormRegistraAlteracao = function (event) { + var _this = this + + if (this.dispositivo_alterado === undefined) { + instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') + if (event != null) { event.preventDefault() } + return } - - instance.get_form_inclusao = function () { - var _this = $(this); - _this.off('get_form_inclusao'); - $('.dpt-actions, .dpt-actions-bottom').html(''); - - var dpt_form = _this.children().filter('.dpt-form').children().first(); - var url_search = dpt_form[0]['id_dispositivo_search_form'].value; - DispositivoSearch({ - 'url_form': url_search, - 'text_button': 'Selecionar', - 'post_selected': instance.allowed_inserts_registro_inclusao, - 'params_post_selected': {'pk_bloco': _this.attr('pk')} - - }); - - instance.scrollTo(_this); - dpt_form.submit(instance.onSubmitFormRegistraInclusao); - - var btn_fechar = _this.find('.btn-fechar'); - btn_fechar.on('click', function() { - instance.clearEditSelected(); - instance.triggerBtnDptEdit(_this.attr('pk')); - }); - } - - instance.get_form_revogacao = function () { - var _this = $(this); - _this.off('get_form_revogacao'); - $('.dpt-actions, .dpt-actions-bottom').html(''); - - var dpt_form = _this.children().filter('.dpt-form').children().first(); - var url_search = dpt_form[0]['id_dispositivo_search_form'].value; - DispositivoSearch({ - 'url_form': url_search, - 'text_button': 'Selecionar' - }); - - instance.scrollTo(_this); - dpt_form.submit(instance.onSubmitFormRegistraRevogacao); - - - var btn_fechar = _this.find('.btn-fechar'); - btn_fechar.on('click', function() { - instance.clearEditSelected(); - instance.triggerBtnDptEdit(_this.attr('pk')); - }); + var dispositivo_alterado = this.dispositivo_alterado.length === undefined ? [this.dispositivo_alterado ] : Array.from(this.dispositivo_alterado) + var form_data = { + 'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, + 'dispositivo_alterado': dispositivo_alterado.filter( + function (elem, idx, array) { + return elem.checked + } + ).map(function (dsp) { + return dsp.value + }), + 'formtype': 'get_form_alteracao' } + var url = $(this).closest('.dpt').attr('pk') + '/refresh' - instance.allowed_inserts_registro_inclusao = function(params) { - - var dispositivo_base_para_inclusao = $("#id"+params.pk_bloco+" input[name='dispositivo_base_para_inclusao']") - if (dispositivo_base_para_inclusao.length == 0) - return; - - var pk = dispositivo_base_para_inclusao[0].value; - var form_data = { - 'action' : 'get_actions_allowed_inserts_registro_inclusao', - 'pk_bloco' : params.pk_bloco - }; + instance.waitShow() - var url = pk+'/refresh'; - instance.waitShow(); + $.post(url, form_data, dataType = 'json') + .done(function (data) { + instance.clearEditSelected() - $.get(url, form_data).done(function(data) { - $(".allowed_inserts").html(data); - $(".allowed_inserts").find('.btn-action').on('click', instance.bindActionsClick); - }).fail(instance.waitHide).always(instance.waitHide); - } - - instance.loadActionsEdit = function(dpt) { - var pk = dpt.attr('pk'); - var url = pk+'/refresh?action=get_actions'; - $.get(url).done(function(data) { - dpt.find('.dpt-actions').first().html(data); - dpt.find('.btn-action').on('click', instance.bindActionsClick); - //dpt.find('.btn-perfis').on('click', instance.bindActionsClick); - dpt.find('.btn-compila').on('click', instance.loadFormsCompilacao); - dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType); - - if (editortype == 'construct') - dpt.find('.btn-group-inserts').first().addClass('open'); - - dpt.find('.btn-group-inserts button').mouseenter(function(event) { - dpt.find('.btn-group-inserts').removeClass('open'); - $(this.parentElement).addClass('open') - }); - - instance.gc(); - }); - } - - instance.loadForm = function(dpt, trigger) { - var pk = dpt.attr('pk'); - var dpt_form = dpt.children().filter('.dpt-form'); - if (dpt_form.length == 1) { - var url = pk+'/refresh?action='+trigger; - $.get(url).done(function(data) { - if (editortype != "construct") { - dpt_form.html(data); - if (editortype == 'tinymce' ) { - initTextRichEditor(); - } - //OptionalCustomFrontEnd().init(); - } - dpt.trigger(trigger); - }).always(function() { - instance.waitHide(); - }); + if (data.pk != null) { + instance.message(data) + } else { + alert('Erro na resposta!') } + }).always(function () { + instance.waitHide() + }) + if (event != null) { event.preventDefault() } + } + + instance.onSubmitFormRegistraInclusao = function (event) { + var _this = this + + var form_data = { + 'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, + 'dispositivo_base_para_inclusao': this['dispositivo_base_para_inclusao'].value, + 'formtype': 'get_form_inclusao' } + var url = $(this).closest('.dpt').attr('pk') + '/refresh' - instance.loadFormsCompilacao = function(event) { - var dpt = $(this).closest('.dpt'); - var formtype = this.getAttribute('action'); - dpt.on(formtype, instance[formtype]); - instance.loadForm(dpt, formtype); - } + instance.waitShow() - instance.modalMessage = function(message, alert, closeFunction) { - if (message != null && message != '') { - $('#modal-message #message').html(message); - $('#modal-message').modal('show'); - $('#modal-message, #modal-message .alert button').off(); - $('#modal-message .alert').removeClass('alert-success alert-info alert-warning alert-danger alert-danger'); - $('#modal-message .alert').addClass(alert); - - if (closeFunction != null) - $('#modal-message').on('hidden.bs.modal', closeFunction); - - $('#modal-message .alert button').on('click', function() { - $('#modal-message').modal('hide'); - }); - return true; - } - return false; - } + $.post(url, form_data) + .done(function (data) { + instance.clearEditSelected() - instance.message = function(data) { - if (data.message !== undefined) { - if (data.message.modal) { - instance.modalMessage(data.message.value, 'alert-'+data.message.type, function() { - instance.waitShow(); - instance.refreshScreenFocusPk(data); - }); - return; - } - else { - instance.refreshScreenFocusPk(data); - if (!('message' in data)) - return; - var cp_notify = $(".cp-notify") - cp_notify.removeClass('hide') - var msg = cp_notify.find('.message'); - msg.text(data.message.value); - msg.removeClass('bg-primary bg-success bg-info bg-warning bg-danger').addClass('bg-'+data.message.type); - setTimeout(function() { - cp_notify.addClass('hide'); - }, (data.message.time?data.message.time: 3000)); - } - } - else { - instance.refreshScreenFocusPk(data); + if (data.pk != null) { + instance.message(data) + } else { + alert('Erro na resposta!') } + }).always(function () { + instance.waitHide() + }) + if (event != null) { event.preventDefault() } + } + + instance.onSubmitFormRegistraRevogacao = function (event) { + var _this = this + + if (this.dispositivo_revogado === undefined) { + instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') + if (event != null) { event.preventDefault() } + return } - instance.offClicks = function() { - $('.btn-dpt-edit').off() - } - instance.onClicks = function(container) { - var objects; - if (container == null) - objects = $('.btn-dpt-edit'); - else - objects = $(container).find('.btn-dpt-edit'); - objects.on('click', instance.editDispositivo); - } - - instance.onSubmitFormRegistraAlteracao = function(event) { - var _this = this; - - if (this.dispositivo_alterado === undefined) { - instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') - if (event != null) - event.preventDefault(); - return + var dispositivo_revogado = this.dispositivo_revogado.length === undefined ? [this.dispositivo_revogado ] : Array.from(this.dispositivo_revogado) + var form_data = { + 'csrfmiddlewaretoken': this.csrfmiddlewaretoken.value, + 'dispositivo_revogado': dispositivo_revogado.filter( + function (elem, idx, array) { + return elem.checked } - var dispositivo_alterado = this.dispositivo_alterado.length === undefined ? [this.dispositivo_alterado, ] : Array.from(this.dispositivo_alterado) - var form_data = { - 'csrfmiddlewaretoken' : this.csrfmiddlewaretoken.value, - 'dispositivo_alterado' : dispositivo_alterado.filter( - function(elem, idx, array) { - return elem.checked - } - ).map(function(dsp) { - return dsp.value - }), - 'formtype': 'get_form_alteracao', - }; - var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; - - instance.waitShow(); - - $.post(url, form_data, dataType="json") - .done(function(data) { - instance.clearEditSelected(); - - if (data.pk != null) { - instance.message(data); - } - else { - alert('Erro na resposta!'); - } - - }).always(function() { - instance.waitHide(); - }); - if (event != null) - event.preventDefault(); + ).map(function (dsp) { + return dsp.value + }), + 'revogacao_em_bloco': this.revogacao_em_bloco.value, + 'formtype': 'get_form_revogacao' } - instance.onSubmitFormRegistraInclusao = function(event) { - var _this = this; - - var form_data = { - 'csrfmiddlewaretoken' : this['csrfmiddlewaretoken'].value, - 'dispositivo_base_para_inclusao' : this['dispositivo_base_para_inclusao'].value, - 'formtype': 'get_form_inclusao', - }; - var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; - - instance.waitShow(); - - $.post(url, form_data) - .done(function(data) { - instance.clearEditSelected(); - - if (data.pk != null) { - instance.message(data); - } - else { - alert('Erro na resposta!'); - } - - }).always(function() { - instance.waitHide(); - }); - if (event != null) - event.preventDefault(); - } + var url = $(this).closest('.dpt').attr('pk') + '/refresh' - instance.onSubmitFormRegistraRevogacao = function(event) { - var _this = this; + instance.waitShow() + $.post(url, form_data) + .done(function (data) { + instance.clearEditSelected() - if (this.dispositivo_revogado === undefined) { - instance.modalMessage('Nenhum dispositivo selecionado', 'alert-info') - if (event != null) - event.preventDefault(); - return + if (data.pk != null) { + instance.message(data) + } else { + alert('Erro na resposta!') } - var dispositivo_revogado = this.dispositivo_revogado.length === undefined ? [this.dispositivo_revogado, ] : Array.from(this.dispositivo_revogado) - var form_data = { - 'csrfmiddlewaretoken' : this.csrfmiddlewaretoken.value, - 'dispositivo_revogado' : dispositivo_revogado.filter( - function(elem, idx, array) { - return elem.checked - } - ).map(function(dsp) { - return dsp.value - }), - 'revogacao_em_bloco': this.revogacao_em_bloco.value, - 'formtype': 'get_form_revogacao', - }; - - var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; - - instance.waitShow(); - - $.post(url, form_data) - .done(function(data) { - instance.clearEditSelected(); - - if (data.pk != null) { - instance.message(data); - } - else { - alert('Erro na resposta!'); - } - - }).always(function() { - instance.waitHide(); - }); - if (event != null) - event.preventDefault(); + }).always(function () { + instance.waitHide() + }) + if (event != null) { event.preventDefault() } + } + + instance.onSubmitEditFormBase = function (event) { + var _this = this + var texto = '' + var texto_atualizador = '' + var visibilidade = '' + var editor_tiny_texto = tinymce.get('id_texto') + var editor_tiny_texto_atualizador = tinymce.get('id_texto_atualizador') + + if (editor_tiny_texto != null) { texto = editor_tiny_texto.getContent() } else { texto = this['id_texto'].value } + + if (editor_tiny_texto_atualizador != null) { texto_atualizador = editor_tiny_texto_atualizador.getContent() } else if ('id_texto_atualizador' in this) { texto_atualizador = this['id_texto_atualizador'].value } + + if ('visibilidade' in this) { visibilidade = this['visibilidade'].value } + + var form_data = { + 'csrfmiddlewaretoken': this['csrfmiddlewaretoken'].value, + 'texto': texto, + 'texto_atualizador': texto_atualizador, + 'visibilidade': visibilidade, + 'formtype': 'get_form_base' } - instance.onSubmitEditFormBase = function(event) { - - var _this = this; - var texto = ''; - var texto_atualizador = ''; - var visibilidade = ''; - var editor_tiny_texto = tinymce.get('id_texto'); - var editor_tiny_texto_atualizador = tinymce.get('id_texto_atualizador'); - - if (editor_tiny_texto != null) - texto = editor_tiny_texto.getContent(); - else - texto = this['id_texto'].value; - - if (editor_tiny_texto_atualizador != null) - texto_atualizador = editor_tiny_texto_atualizador.getContent(); - else if ('id_texto_atualizador' in this) - texto_atualizador = this['id_texto_atualizador'].value; - - if ('visibilidade' in this) - visibilidade = this['visibilidade'].value; - - var form_data = { - 'csrfmiddlewaretoken' : this['csrfmiddlewaretoken'].value, - 'texto' : texto, - 'texto_atualizador' : texto_atualizador, - 'visibilidade' : visibilidade, - 'formtype': 'get_form_base', - }; - - var url = $(this).closest('.dpt').attr( "pk" )+'/refresh'; - - instance.waitShow(); - - $.post(url, form_data) - .done(function(data) { - if (typeof data == "string") { /* if obsoleto */ - var dpt = $(_this).closest('.dpt'); - dpt = $('#'+dpt.replaceWith(data).attr('id')); - instance.onClicks(dpt); - instance.waitHide(); - return; - } - instance.clearEditSelected(); - - if (data.pk != null) { - instance.message(data); - } - else { - alert('Erro na resposta!'); - } - - }).always(function() { - instance.waitHide(); - }); - if (event != null) - event.preventDefault(); - } - instance.refreshContent = function(pais, trigger_edit_pk) { - if (pais.length == 0) { - instance.waitHide(); - return; - } - var pk = pais.shift(); - var url = pk+'/refresh'; + var url = $(this).closest('.dpt').attr('pk') + '/refresh' - $.get(url).done(function(data) { - var dpt = $('#id'+pk).closest('.dpt'); - dpt = $('#'+dpt.replaceWith(data).attr('id')); - instance.onClicks(dpt); - instance.reloadFunctionsDraggables(); + instance.waitShow() - if (trigger_edit_pk > 0) - instance.triggerBtnDptEdit(trigger_edit_pk) + $.post(url, form_data) + .done(function (data) { + if (typeof data === 'string') { /* if obsoleto */ + var dpt = $(_this).closest('.dpt') + dpt = $('#' + dpt.replaceWith(data).attr('id')) + instance.onClicks(dpt) + instance.waitHide() + return + } + instance.clearEditSelected() - instance.refreshContent(pais); - }); + if (data.pk != null) { + instance.message(data) + } else { + alert('Erro na resposta!') + } + }).always(function () { + instance.waitHide() + }) + if (event != null) { event.preventDefault() } + } + instance.refreshContent = function (pais, trigger_edit_pk) { + if (pais.length == 0) { + instance.waitHide() + return } - instance.refreshScreenFocusPk = function (data) { - instance.waitShow(); - if (data.pai[0] == -1) { - instance.waitShow() - href = location.href.split('#')[0] - location.href = href+'#'+data.pk; - location.reload(true) - } - else { - instance.refreshContent(data.pai, data.pk); - - /*setTimeout(function() { + var pk = pais.shift() + var url = pk + '/refresh' + + $.get(url).done(function (data) { + var dpt = $('#id' + pk).closest('.dpt') + dpt = $('#' + dpt.replaceWith(data).attr('id')) + instance.onClicks(dpt) + instance.reloadFunctionsDraggables() + + if (trigger_edit_pk > 0) { instance.triggerBtnDptEdit(trigger_edit_pk) } + + instance.refreshContent(pais) + }) + } + instance.refreshScreenFocusPk = function (data) { + instance.waitShow() + if (data.pai[0] == -1) { + instance.waitShow() + href = location.href.split('#')[0] + location.href = href + '#' + data.pk + location.reload(true) + } else { + instance.refreshContent(data.pai, data.pk) + + /* setTimeout(function() { for (var pai = 1; pai < data.pai.length; pai++) instance.refreshContent(data.pai[pai]); instance.waitHide(); - }, 1000);*/ - } - } - - instance.reloadFunctionsDraggables = function() { - $( ".dpt-alts" ).sortable({ - revert: true, - distance: 15, - start: function( event, ui ) { - } - , - stop: function( event, ui ) { - var pk = ui.item.attr('pk'); - var bloco_pk = ui.item.closest('.dpt-alts').closest('.dpt').attr('pk'); - - var url = pk+'/refresh?action=json_drag_move_dpt_alterado&index='+ui.item.index()+'&bloco_pk='+bloco_pk; - $.get(url).done(function( data ) { - console.log(pk+ ' - '+ bloco_pk); - //reloadFunctionsForObjectsOfCompilacao(); - }); - } - }); - - $( ".dpt-alts .dpt" ).draggable({ - connectToSortable: ".dpt-alts", - revert: 'invalid', - zIndex: 1, - distance: 15, - drag: function( event, ui ) { - //$('.dpt-comp-selected').removeClass('dpt-comp-selected'); - $(".dpt-alts").addClass('drag'); - }, - stop: function( event, ui ) { - $(".dpt-alts").removeClass('drag'); - }, - }); - - $(".dpt-alts").disableSelection(); - } - instance.scrollTo = function(dpt) { - try { - $('html, body').animate({ - scrollTop: dpt.offset().top - window.innerHeight / 9 - }, 100); - } - catch(err) { - } - } - instance.triggerBtnDptEdit =function(pk) { - var btn_dpt_edit = $('#id'+pk + ' > .dpt-text.btn-dpt-edit'); - if (btn_dpt_edit.length == 0) - btn_dpt_edit = $('#id'+pk + ' > .dpt-actions-fixed > .btn-dpt-edit'); - btn_dpt_edit.trigger( "click" ); + }, 1000); */ } - instance.waitHide = function() { - $("#wait_message").addClass("displaynone"); + } + + instance.reloadFunctionsDraggables = function () { + $('.dpt-alts').sortable({ + revert: true, + distance: 15, + start: function (event, ui) { + }, + stop: function (event, ui) { + var pk = ui.item.attr('pk') + var bloco_pk = ui.item.closest('.dpt-alts').closest('.dpt').attr('pk') + + var url = pk + '/refresh?action=json_drag_move_dpt_alterado&index=' + ui.item.index() + '&bloco_pk=' + bloco_pk + $.get(url).done(function (data) { + console.log(pk + ' - ' + bloco_pk) + // reloadFunctionsForObjectsOfCompilacao(); + }) + } + }) + + $('.dpt-alts .dpt').draggable({ + connectToSortable: '.dpt-alts', + revert: 'invalid', + zIndex: 1, + distance: 15, + drag: function (event, ui) { + // $('.dpt-comp-selected').removeClass('dpt-comp-selected'); + $('.dpt-alts').addClass('drag') + }, + stop: function (event, ui) { + $('.dpt-alts').removeClass('drag') + } + }) + + $('.dpt-alts').disableSelection() + } + instance.scrollTo = function (dpt) { + try { + $('html, body').animate({ + scrollTop: dpt.offset().top - window.innerHeight / 9 + }, 100) + } catch (err) { } - instance.waitShow = function() { - $("#wait_message").removeClass("displaynone"); + } + instance.triggerBtnDptEdit = function (pk) { + var btn_dpt_edit = $('#id' + pk + ' > .dpt-text.btn-dpt-edit') + if (btn_dpt_edit.length == 0) { btn_dpt_edit = $('#id' + pk + ' > .dpt-actions-fixed > .btn-dpt-edit') } + btn_dpt_edit.trigger('click') + } + instance.waitHide = function () { + $('#wait_message').addClass('displaynone') + } + instance.waitShow = function () { + $('#wait_message').removeClass('displaynone') + } + + instance.init = function () { + $('.dpt-actions-fixed').first().css('opacity', '1') + editortype = ReadCookie('editortype') + if (editortype == null || editortype == '') { + editortype = 'textarea' + SetCookie('editortype', editortype, 30) } - - - instance.init = function() { - $('.dpt-actions-fixed').first().css('opacity','1'); - editortype = ReadCookie("editortype"); - if (editortype == null || editortype == '') { - editortype = "textarea" - SetCookie("editortype", editortype, 30) - } - //editortype = "textarea"; - instance.offClicks(); - instance.onClicks(); - instance.reloadFunctionsDraggables(); - - href = location.href.split('#') - if (href.length == 2 && href[1] != '') { - instance.triggerBtnDptEdit(href[1]) - } - $('main').click(function(event) { - if (event.target == this || event.target == this.firstElementChild) - instance.clearEditSelected(); - }); - instance.waitHide(); + // editortype = "textarea"; + instance.offClicks() + instance.onClicks() + instance.reloadFunctionsDraggables() + + href = location.href.split('#') + if (href.length == 2 && href[1] != '') { + instance.triggerBtnDptEdit(href[1]) } - instance.init(); + $('main').click(function (event) { + if (event.target == this || event.target == this.firstElementChild) { instance.clearEditSelected() } + }) + instance.waitHide() + } + instance.init() } - -$(document).ready(function() { - - DispositivoEdit(); - -}); +$(document).ready(function () { + DispositivoEdit() +}) diff --git a/sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js b/sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js index ee0a33947..972a7a883 100644 --- a/sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js +++ b/sapl-frontend/src/apps/compilacao/js/old/compilacao_notas.js @@ -32,11 +32,11 @@ function onSubmitEditNVForm (event) { let url = '' let model = 'nota' let idEdit = null - let idDispositivo = $('#idDispositivo').val() + let idDispositivo = $('#id_dispositivo').val() if (idDispositivo === null) { // trata-se de um vide // $('#idDispositivo_ref').remove() - idDispositivo = $('#idDispositivo_base').val() + idDispositivo = $('#id_dispositivo_base').val() model = 'vide' } diff --git a/sapl-frontend/src/apps/compilacao/scss/compilacao.scss b/sapl-frontend/src/apps/compilacao/scss/compilacao.scss index fed4b6bb1..c84cf9d39 100644 --- a/sapl-frontend/src/apps/compilacao/scss/compilacao.scss +++ b/sapl-frontend/src/apps/compilacao/scss/compilacao.scss @@ -337,6 +337,7 @@ a:link:after, a:visited:after { min-height: 2.5em; &:hover { ul { + font-size: 1rem; transition: opacity 0.5s linear, clip 0s 0.3s; clip: auto; opacity: 1; diff --git a/sapl-frontend/src/global/functions.js b/sapl-frontend/src/global/functions.js index 6fd05b6af..745fd82b1 100644 --- a/sapl-frontend/src/global/functions.js +++ b/sapl-frontend/src/global/functions.js @@ -1,120 +1,121 @@ -window.getCookie = function(name) { - var cookieValue = null; - if (document.cookie && document.cookie !== "") { - var cookies = document.cookie.split(";"); +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 = $.trim(cookies[i]); - if (cookie.substring(0, name.length + 1) === name + "=") { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; + var cookie = $.trim(cookies[i]) + if (cookie.substring(0, name.length + 1) === name + '=') { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)) + break } } } - return cookieValue; -}; + return cookieValue +} -window.autorModal = function() { - $(function() { - var dialog = $("#modal_autor").dialog({ +window.autorModal = function () { + $(function () { + var dialog = $('#modal_autor').dialog({ autoOpen: false, modal: true, width: 500, height: 340, show: { - effect: "blind", + effect: 'blind', duration: 500 }, hide: { - effect: "explode", + effect: 'explode', duration: 500 } - }); + }) - $("#button-id-limpar").click(function() { - $("#nome_autor").text(""); + $('#button-id-limpar').click(function () { + $('#nome_autor').text('') - function clean_if_exists(fieldname) { + function clean_if_exists (fieldname) { if ($(fieldname).length > 0) { - $(fieldname).val(""); + $(fieldname).val('') } } - clean_if_exists("#id_autor"); - clean_if_exists("#id_autoria__autor"); - }); + clean_if_exists('#id_autor') + clean_if_exists('#id_autoria__autor') + }) - $("#button-id-pesquisar").click(function() { - $("#q").val(""); - $("#div-resultado") + $('#button-id-pesquisar').click(function () { + $('#q').val('') + $('#div-resultado') .children() - .remove(); - $("#modal_autor").dialog("open"); - $("#selecionar").attr("hidden", "hidden"); - }); - - $("#pesquisar").click(function() { - var name_in_query = $("#q").val(); - //var q_0 = "q_0=nome__icontains" - //var q_1 = name_in_query - //query = q_1 - - $.get("/api/autor?q=" + name_in_query, function(data) { - $("#div-resultado") + .remove() + $('#modal_autor').dialog('open') + $('#selecionar').attr('hidden', 'hidden') + }) + + $('#pesquisar').click(function () { + var name_in_query = $('#q').val() + // var q_0 = "q_0=nome__icontains" + // var q_1 = name_in_query + // query = q_1 + + $.get('/api/autor?q=' + name_in_query, function (data) { + $('#div-resultado') .children() - .remove(); + .remove() if (data.pagination.total_entries == 0) { - $("#selecionar").attr("hidden", "hidden"); - $("#div-resultado").html( + $('#selecionar').attr('hidden', 'hidden') + $('#div-resultado').html( "Nenhum resultado" - ); - return; + ) + return } var select = $( '').css({ position: 'fixed', left: '-120px', width: '12px' - }).addClass('jcrop-keymgr'), + }).addClass('jcrop-keymgr') - $keywrap = $('
').css({ - position: 'absolute', - overflow: 'hidden' - }).append($keymgr); + var $keywrap = $('
').css({ + position: 'absolute', + overflow: 'hidden' + }).append($keymgr) - function watchKeys() //{{{ + function watchKeys () // {{{ { if (options.keySupport) { - $keymgr.show(); - $keymgr.focus(); + $keymgr.show() + $keymgr.focus() } } - //}}} - function onBlur(e) //{{{ + // }}} + function onBlur (e) // {{{ { - $keymgr.hide(); + $keymgr.hide() } - //}}} - function doNudge(e, x, y) //{{{ + // }}} + function doNudge (e, x, y) // {{{ { if (options.allowMove) { - Coords.moveOffset([x, y]); - Selection.updateVisible(true); + Coords.moveOffset([x, y]) + Selection.updateVisible(true) } - e.preventDefault(); - e.stopPropagation(); + e.preventDefault() + e.stopPropagation() } - //}}} - function parseKey(e) //{{{ + // }}} + function parseKey (e) // {{{ { if (e.ctrlKey || e.metaKey) { - return true; + return true } - shift_down = e.shiftKey ? true : false; - var nudge = shift_down ? 10 : 1; + shift_down = !!e.shiftKey + var nudge = shift_down ? 10 : 1 switch (e.keyCode) { - case 37: - doNudge(e, -nudge, 0); - break; - case 39: - doNudge(e, nudge, 0); - break; - case 38: - doNudge(e, 0, -nudge); - break; - case 40: - doNudge(e, 0, nudge); - break; - case 27: - if (options.allowSelect) Selection.release(); - break; - case 9: - return true; + case 37: + doNudge(e, -nudge, 0) + break + case 39: + doNudge(e, nudge, 0) + break + case 38: + doNudge(e, 0, -nudge) + break + case 40: + doNudge(e, 0, nudge) + break + case 27: + if (options.allowSelect) Selection.release() + break + case 9: + return true } - return false; + return false } - //}}} + // }}} if (options.keySupport) { - $keymgr.keydown(parseKey).blur(onBlur); + $keymgr.keydown(parseKey).blur(onBlur) if (ie6mode || !options.fixedSupport) { $keymgr.css({ position: 'absolute', left: '-20px' - }); - $keywrap.append($keymgr).insertBefore($img); + }) + $keywrap.append($keymgr).insertBefore($img) } else { - $keymgr.insertBefore($img); + $keymgr.insertBefore($img) } } - return { watchKeys: watchKeys - }; - }()); - //}}} + } + }()) + // }}} // }}} // API methods {{{ - function setClass(cname) //{{{ + function setClass (cname) // {{{ { - $div.removeClass().addClass(cssClass('holder')).addClass(cname); + $div.removeClass().addClass(cssClass('holder')).addClass(cname) } - //}}} - function animateTo(a, callback) //{{{ + // }}} + function animateTo (a, callback) // {{{ { - var x1 = a[0] / xscale, - y1 = a[1] / yscale, - x2 = a[2] / xscale, - y2 = a[3] / yscale; + var x1 = a[0] / xscale + + var y1 = a[1] / yscale + + var x2 = a[2] / xscale + + var y2 = a[3] / yscale if (animating) { - return; + return } - var animto = Coords.flipCoords(x1, y1, x2, y2), - c = Coords.getFixed(), - initcr = [c.x, c.y, c.x2, c.y2], - animat = initcr, - interv = options.animationDelay, - ix1 = animto[0] - initcr[0], - iy1 = animto[1] - initcr[1], - ix2 = animto[2] - initcr[2], - iy2 = animto[3] - initcr[3], - pcent = 0, - velocity = options.swingSpeed; + var animto = Coords.flipCoords(x1, y1, x2, y2) + + var c = Coords.getFixed() + + var initcr = [c.x, c.y, c.x2, c.y2] + + var animat = initcr - x1 = animat[0]; - y1 = animat[1]; - x2 = animat[2]; - y2 = animat[3]; + var interv = options.animationDelay - Selection.animMode(true); - var anim_timer; + var ix1 = animto[0] - initcr[0] - function queueAnimator() { - window.setTimeout(animator, interv); + var iy1 = animto[1] - initcr[1] + + var ix2 = animto[2] - initcr[2] + + var iy2 = animto[3] - initcr[3] + + var pcent = 0 + + var velocity = options.swingSpeed + + x1 = animat[0] + y1 = animat[1] + x2 = animat[2] + y2 = animat[3] + + Selection.animMode(true) + var anim_timer + + function queueAnimator () { + window.setTimeout(animator, interv) } var animator = (function () { return function () { - pcent += (100 - pcent) / velocity; + pcent += (100 - pcent) / velocity - animat[0] = Math.round(x1 + ((pcent / 100) * ix1)); - animat[1] = Math.round(y1 + ((pcent / 100) * iy1)); - animat[2] = Math.round(x2 + ((pcent / 100) * ix2)); - animat[3] = Math.round(y2 + ((pcent / 100) * iy2)); + animat[0] = Math.round(x1 + ((pcent / 100) * ix1)) + animat[1] = Math.round(y1 + ((pcent / 100) * iy1)) + animat[2] = Math.round(x2 + ((pcent / 100) * ix2)) + animat[3] = Math.round(y2 + ((pcent / 100) * iy2)) if (pcent >= 99.8) { - pcent = 100; + pcent = 100 } if (pcent < 100) { - setSelectRaw(animat); - queueAnimator(); + setSelectRaw(animat) + queueAnimator() } else { - Selection.done(); - Selection.animMode(false); - if (typeof(callback) === 'function') { - callback.call(api); + Selection.done() + Selection.animMode(false) + if (typeof (callback) === 'function') { + callback.call(api) } } - }; - }()); - queueAnimator(); + } + }()) + queueAnimator() } - //}}} - function setSelect(rect) //{{{ + // }}} + function setSelect (rect) // {{{ { - setSelectRaw([rect[0] / xscale, rect[1] / yscale, rect[2] / xscale, rect[3] / yscale]); - options.onSelect.call(api, unscale(Coords.getFixed())); - Selection.enableHandles(); + setSelectRaw([rect[0] / xscale, rect[1] / yscale, rect[2] / xscale, rect[3] / yscale]) + options.onSelect.call(api, unscale(Coords.getFixed())) + Selection.enableHandles() } - //}}} - function setSelectRaw(l) //{{{ + // }}} + function setSelectRaw (l) // {{{ { - Coords.setPressed([l[0], l[1]]); - Coords.setCurrent([l[2], l[3]]); - Selection.update(); + Coords.setPressed([l[0], l[1]]) + Coords.setCurrent([l[2], l[3]]) + Selection.update() } - //}}} - function tellSelect() //{{{ + // }}} + function tellSelect () // {{{ { - return unscale(Coords.getFixed()); + return unscale(Coords.getFixed()) } - //}}} - function tellScaled() //{{{ + // }}} + function tellScaled () // {{{ { - return Coords.getFixed(); + return Coords.getFixed() } - //}}} - function setOptionsNew(opt) //{{{ + // }}} + function setOptionsNew (opt) // {{{ { - setOptions(opt); - interfaceUpdate(); + setOptions(opt) + interfaceUpdate() } - //}}} - function disableCrop() //{{{ + // }}} + function disableCrop () // {{{ { - options.disabled = true; - Selection.disableHandles(); - Selection.setCursor('default'); - Tracker.setCursor('default'); + options.disabled = true + Selection.disableHandles() + Selection.setCursor('default') + Tracker.setCursor('default') } - //}}} - function enableCrop() //{{{ + // }}} + function enableCrop () // {{{ { - options.disabled = false; - interfaceUpdate(); + options.disabled = false + interfaceUpdate() } - //}}} - function cancelCrop() //{{{ + // }}} + function cancelCrop () // {{{ { - Selection.done(); - Tracker.activateHandlers(null, null); + Selection.done() + Tracker.activateHandlers(null, null) } - //}}} - function destroy() //{{{ + // }}} + function destroy () // {{{ { - $div.remove(); - $origimg.show(); - $origimg.css('visibility','visible'); - $(obj).removeData('Jcrop'); + $div.remove() + $origimg.show() + $origimg.css('visibility', 'visible') + $(obj).removeData('Jcrop') } - //}}} - function setImage(src, callback) //{{{ + // }}} + function setImage (src, callback) // {{{ { - Selection.release(); - disableCrop(); - var img = new Image(); + Selection.release() + disableCrop() + var img = new Image() img.onload = function () { - var iw = img.width; - var ih = img.height; - var bw = options.boxWidth; - var bh = options.boxHeight; - $img.width(iw).height(ih); - $img.attr('src', src); - $img2.attr('src', src); - presize($img, bw, bh); - boundx = $img.width(); - boundy = $img.height(); - $img2.width(boundx).height(boundy); - $trk.width(boundx + (bound * 2)).height(boundy + (bound * 2)); - $div.width(boundx).height(boundy); - Shade.resize(boundx,boundy); - enableCrop(); - - if (typeof(callback) === 'function') { - callback.call(api); + var iw = img.width + var ih = img.height + var bw = options.boxWidth + var bh = options.boxHeight + $img.width(iw).height(ih) + $img.attr('src', src) + $img2.attr('src', src) + presize($img, bw, bh) + boundx = $img.width() + boundy = $img.height() + $img2.width(boundx).height(boundy) + $trk.width(boundx + (bound * 2)).height(boundy + (bound * 2)) + $div.width(boundx).height(boundy) + Shade.resize(boundx, boundy) + enableCrop() + + if (typeof (callback) === 'function') { + callback.call(api) } - }; - img.src = src; + } + img.src = src } - //}}} - function colorChangeMacro($obj,color,now) { - var mycolor = color || options.bgColor; + // }}} + function colorChangeMacro ($obj, color, now) { + var mycolor = color || options.bgColor if (options.bgFade && supportsColorFade() && options.fadeTime && !now) { $obj.animate({ backgroundColor: mycolor }, { queue: false, duration: options.fadeTime - }); + }) } else { - $obj.css('backgroundColor', mycolor); + $obj.css('backgroundColor', mycolor) } } - function interfaceUpdate(alt) //{{{ + function interfaceUpdate (alt) // {{{ // This method tweaks the interface based on options object. // Called when options are changed and at end of initialization. { if (options.allowResize) { if (alt) { - Selection.enableOnly(); + Selection.enableOnly() } else { - Selection.enableHandles(); + Selection.enableHandles() } } else { - Selection.disableHandles(); + Selection.disableHandles() } - Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default'); - Selection.setCursor(options.allowMove ? 'move' : 'default'); + Tracker.setCursor(options.allowSelect ? 'crosshair' : 'default') + Selection.setCursor(options.allowMove ? 'move' : 'default') if (options.hasOwnProperty('trueSize')) { - xscale = options.trueSize[0] / boundx; - yscale = options.trueSize[1] / boundy; + xscale = options.trueSize[0] / boundx + yscale = options.trueSize[1] / boundy } if (options.hasOwnProperty('setSelect')) { - setSelect(options.setSelect); - Selection.done(); - delete(options.setSelect); + setSelect(options.setSelect) + Selection.done() + delete (options.setSelect) } - Shade.refresh(); + Shade.refresh() if (options.bgColor != bgcolor) { colorChangeMacro( - options.shade? Shade.getShades(): $div, - options.shade? - (options.shadeColor || options.bgColor): - options.bgColor - ); - bgcolor = options.bgColor; + options.shade ? Shade.getShades() : $div, + options.shade + ? (options.shadeColor || options.bgColor) + : options.bgColor + ) + bgcolor = options.bgColor } if (bgopacity != options.bgOpacity) { - bgopacity = options.bgOpacity; - if (options.shade) Shade.refresh(); - else Selection.setBgOpacity(bgopacity); + bgopacity = options.bgOpacity + if (options.shade) Shade.refresh() + else Selection.setBgOpacity(bgopacity) } - xlimit = options.maxSize[0] || 0; - ylimit = options.maxSize[1] || 0; - xmin = options.minSize[0] || 0; - ymin = options.minSize[1] || 0; + xlimit = options.maxSize[0] || 0 + ylimit = options.maxSize[1] || 0 + xmin = options.minSize[0] || 0 + ymin = options.minSize[1] || 0 if (options.hasOwnProperty('outerImage')) { - $img.attr('src', options.outerImage); - delete(options.outerImage); + $img.attr('src', options.outerImage) + delete (options.outerImage) } - Selection.refresh(); + Selection.refresh() } - //}}} - //}}} + // }}} + // }}} - if (Touch.support) $trk.bind('touchstart.jcrop', Touch.newSelection); + if (Touch.support) $trk.bind('touchstart.jcrop', Touch.newSelection) - $hdl_holder.hide(); - interfaceUpdate(true); + $hdl_holder.hide() + interfaceUpdate(true) var api = { setImage: setImage, @@ -1557,89 +1593,88 @@ focus: KeyManager.watchKeys, getBounds: function () { - return [boundx * xscale, boundy * yscale]; + return [boundx * xscale, boundy * yscale] }, getWidgetSize: function () { - return [boundx, boundy]; + return [boundx, boundy] }, getScaleFactor: function () { - return [xscale, yscale]; + return [xscale, yscale] }, - getOptions: function() { + getOptions: function () { // careful: internal values are returned - return options; + return options }, ui: { holder: $div, selection: $sel } - }; + } - if (is_msie) $div.bind('selectstart', function () { return false; }); + if (is_msie) $div.bind('selectstart', function () { return false }) - $origimg.data('Jcrop', api); - return api; - }; - $.fn.Jcrop = function (options, callback) //{{{ + $origimg.data('Jcrop', api) + return api + } + $.fn.Jcrop = function (options, callback) // {{{ { - var api; + var api // Iterate over each object, attach Jcrop this.each(function () { // If we've already attached to this object if ($(this).data('Jcrop')) { // The API can be requested this way (undocumented) - if (options === 'api') return $(this).data('Jcrop'); + if (options === 'api') return $(this).data('Jcrop') // Otherwise, we just reset the options... - else $(this).data('Jcrop').setOptions(options); + else $(this).data('Jcrop').setOptions(options) } // If we haven't been attached, preload and attach else { - if (this.tagName == 'IMG') - $.Jcrop.Loader(this,function(){ - $(this).css({display:'block',visibility:'hidden'}); - api = $.Jcrop(this, options); - if ($.isFunction(callback)) callback.call(api); - }); - else { - $(this).css({display:'block',visibility:'hidden'}); - api = $.Jcrop(this, options); - if ($.isFunction(callback)) callback.call(api); + if (this.tagName == 'IMG') { + $.Jcrop.Loader(this, function () { + $(this).css({ display: 'block', visibility: 'hidden' }) + api = $.Jcrop(this, options) + if ($.isFunction(callback)) callback.call(api) + }) + } else { + $(this).css({ display: 'block', visibility: 'hidden' }) + api = $.Jcrop(this, options) + if ($.isFunction(callback)) callback.call(api) } } - }); + }) // Return "this" so the object is chainable (jQuery-style) - return this; - }; - //}}} + return this + } + // }}} // $.Jcrop.Loader - basic image loader {{{ - $.Jcrop.Loader = function(imgobj,success,error){ - var $img = $(imgobj), img = $img[0]; + $.Jcrop.Loader = function (imgobj, success, error) { + var $img = $(imgobj); var img = $img[0] - function completeCheck(){ + function completeCheck () { if (img.complete) { - $img.unbind('.jcloader'); - if ($.isFunction(success)) success.call(img); - } - else window.setTimeout(completeCheck,50); + $img.unbind('.jcloader') + if ($.isFunction(success)) success.call(img) + } else window.setTimeout(completeCheck, 50) } $img - .bind('load.jcloader',completeCheck) - .bind('error.jcloader',function(e){ - $img.unbind('.jcloader'); - if ($.isFunction(error)) error.call(img); - }); - - if (img.complete && $.isFunction(success)){ - $img.unbind('.jcloader'); - success.call(img); + .bind('load.jcloader', completeCheck) + .bind('error.jcloader', function (e) { + $img.unbind('.jcloader') + if ($.isFunction(error)) error.call(img) + }) + + if (img.complete && $.isFunction(success)) { + $img.unbind('.jcloader') + success.call(img) } - }; + } - //}}} + // }}} // Global Defaults {{{ $.Jcrop.defaults = { @@ -1662,9 +1697,9 @@ aspectRatio: 0, keySupport: true, - createHandles: ['n','s','e','w','nw','ne','se','sw'], - createDragbars: ['n','s','e','w'], - createBorders: ['n','s','e','w'], + createHandles: ['n', 's', 'e', 'w', 'nw', 'ne', 'se', 'sw'], + createDragbars: ['n', 's', 'e', 'w'], + createBorders: ['n', 's', 'e', 'w'], drawBorders: true, dragEdges: true, fixedSupport: true, @@ -1688,7 +1723,7 @@ onSelect: function () {}, onDblClick: function () {}, onRelease: function () {} - }; + } // }}} -}(jQuery)); +}(jQuery)) diff --git a/sapl-frontend/src/global/image_cropping/js/jquery.color.js b/sapl-frontend/src/global/image_cropping/js/jquery.color.js index 3ca61fb6f..7626106bc 100644 --- a/sapl-frontend/src/global/image_cropping/js/jquery.color.js +++ b/sapl-frontend/src/global/image_cropping/js/jquery.color.js @@ -7,655 +7,709 @@ * http://jquery.org/license */ -(function( jQuery, undefined ){ - var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "), - - // plusequals test for += 100 -= 100 - rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, - // a set of RE's that can match strings and generate color tuples. - stringParsers = [{ - re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - execResult[ 1 ], - execResult[ 2 ], - execResult[ 3 ], - execResult[ 4 ] - ]; - } - }, { - re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - parse: function( execResult ) { - return [ - 2.55 * execResult[1], - 2.55 * execResult[2], - 2.55 * execResult[3], - execResult[ 4 ] - ]; - } - }, { - re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ], 16 ) - ]; - } - }, { - re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/, - parse: function( execResult ) { - return [ - parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), - parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), - parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) - ]; - } - }, { - re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, - space: "hsla", - parse: function( execResult ) { - return [ - execResult[1], - execResult[2] / 100, - execResult[3] / 100, - execResult[4] - ]; - } - }], - - // jQuery.Color( ) - color = jQuery.Color = function( color, green, blue, alpha ) { - return new jQuery.Color.fn.parse( color, green, blue, alpha ); - }, - spaces = { - rgba: { - cache: "_rgba", - props: { - red: { - idx: 0, - type: "byte", - empty: true - }, - green: { - idx: 1, - type: "byte", - empty: true - }, - blue: { - idx: 2, - type: "byte", - empty: true - }, - alpha: { - idx: 3, - type: "percent", - def: 1 - } - } - }, - hsla: { - cache: "_hsla", - props: { - hue: { - idx: 0, - type: "degrees", - empty: true - }, - saturation: { - idx: 1, - type: "percent", - empty: true - }, - lightness: { - idx: 2, - type: "percent", - empty: true - } - } - } - }, - propTypes = { - "byte": { - floor: true, - min: 0, - max: 255 - }, - "percent": { - min: 0, - max: 1 - }, - "degrees": { - mod: 360, - floor: true - } - }, - rgbaspace = spaces.rgba.props, - support = color.support = {}, - - // colors = jQuery.Color.names - colors, - - // local aliases of functions called often - each = jQuery.each; - - spaces.hsla.props.alpha = rgbaspace.alpha; - - function clamp( value, prop, alwaysAllowEmpty ) { - var type = propTypes[ prop.type ] || {}, - allowEmpty = prop.empty || alwaysAllowEmpty; - - if ( allowEmpty && value == null ) { - return null; - } - if ( prop.def && value == null ) { - return prop.def; - } - if ( type.floor ) { - value = ~~value; - } else { - value = parseFloat( value ); - } - if ( value == null || isNaN( value ) ) { - return prop.def; - } - if ( type.mod ) { - value = value % type.mod; - // -10 -> 350 - return value < 0 ? type.mod + value : value; - } - - // for now all property types without mod have min and max - return type.min > value ? type.min : type.max < value ? type.max : value; - } - - function stringParse( string ) { - var inst = color(), - rgba = inst._rgba = []; - - string = string.toLowerCase(); - - each( stringParsers, function( i, parser ) { - var match = parser.re.exec( string ), - values = match && parser.parse( match ), - parsed, - spaceName = parser.space || "rgba", - cache = spaces[ spaceName ].cache; - - - if ( values ) { - parsed = inst[ spaceName ]( values ); - - // if this was an rgba parse the assignment might happen twice - // oh well.... - inst[ cache ] = parsed[ cache ]; - rgba = inst._rgba = parsed._rgba; - - // exit each( stringParsers ) here because we matched - return false; - } - }); - - // Found a stringParser that handled it - if ( rgba.length !== 0 ) { - - // if this came from a parsed string, force "transparent" when alpha is 0 - // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) - if ( Math.max.apply( Math, rgba ) === 0 ) { - jQuery.extend( rgba, colors.transparent ); - } - return inst; - } - - // named colors / default - filter back through parse function - if ( string = colors[ string ] ) { - return string; - } - } - - color.fn = color.prototype = { - constructor: color, - parse: function( red, green, blue, alpha ) { - if ( red === undefined ) { - this._rgba = [ null, null, null, null ]; - return this; - } - if ( red instanceof jQuery || red.nodeType ) { - red = red instanceof jQuery ? red.css( green ) : jQuery( red ).css( green ); - green = undefined; - } - - var inst = this, - type = jQuery.type( red ), - rgba = this._rgba = [], - source; - - // more than 1 argument specified - assume ( red, green, blue, alpha ) - if ( green !== undefined ) { - red = [ red, green, blue, alpha ]; - type = "array"; - } - - if ( type === "string" ) { - return this.parse( stringParse( red ) || colors._default ); - } - - if ( type === "array" ) { - each( rgbaspace, function( key, prop ) { - rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); - }); - return this; - } - - if ( type === "object" ) { - if ( red instanceof color ) { - each( spaces, function( spaceName, space ) { - if ( red[ space.cache ] ) { - inst[ space.cache ] = red[ space.cache ].slice(); - } - }); - } else { - each( spaces, function( spaceName, space ) { - each( space.props, function( key, prop ) { - var cache = space.cache; - - // if the cache doesn't exist, and we know how to convert - if ( !inst[ cache ] && space.to ) { - - // if the value was null, we don't need to copy it - // if the key was alpha, we don't need to copy it either - if ( red[ key ] == null || key === "alpha") { - return; - } - inst[ cache ] = space.to( inst._rgba ); - } - - // this is the only case where we allow nulls for ALL properties. - // call clamp with alwaysAllowEmpty - inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); - }); - }); - } - return this; - } - }, - is: function( compare ) { - var is = color( compare ), - same = true, - myself = this; - - each( spaces, function( _, space ) { - var isCache = is[ space.cache ], - localCache; - if (isCache) { - localCache = myself[ space.cache ] || space.to && space.to( myself._rgba ) || []; - each( space.props, function( _, prop ) { - if ( isCache[ prop.idx ] != null ) { - same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); - return same; - } - }); - } - return same; - }); - return same; - }, - _space: function() { - var used = [], - inst = this; - each( spaces, function( spaceName, space ) { - if ( inst[ space.cache ] ) { - used.push( spaceName ); - } - }); - return used.pop(); - }, - transition: function( other, distance ) { - var end = color( other ), - spaceName = end._space(), - space = spaces[ spaceName ], - start = this[ space.cache ] || space.to( this._rgba ), - result = start.slice(); - - end = end[ space.cache ]; - each( space.props, function( key, prop ) { - var index = prop.idx, - startValue = start[ index ], - endValue = end[ index ], - type = propTypes[ prop.type ] || {}; - - // if null, don't override start value - if ( endValue === null ) { - return; - } - // if null - use end - if ( startValue === null ) { - result[ index ] = endValue; - } else { - if ( type.mod ) { - if ( endValue - startValue > type.mod / 2 ) { - startValue += type.mod; - } else if ( startValue - endValue > type.mod / 2 ) { - startValue -= type.mod; - } - } - result[ prop.idx ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); - } - }); - return this[ spaceName ]( result ); - }, - blend: function( opaque ) { - // if we are already opaque - return ourself - if ( this._rgba[ 3 ] === 1 ) { - return this; - } - - var rgb = this._rgba.slice(), - a = rgb.pop(), - blend = color( opaque )._rgba; - - return color( jQuery.map( rgb, function( v, i ) { - return ( 1 - a ) * blend[ i ] + a * v; - })); - }, - toRgbaString: function() { - var prefix = "rgba(", - rgba = jQuery.map( this._rgba, function( v, i ) { - return v == null ? ( i > 2 ? 1 : 0 ) : v; - }); - - if ( rgba[ 3 ] === 1 ) { - rgba.pop(); - prefix = "rgb("; - } - - return prefix + rgba.join(",") + ")"; - }, - toHslaString: function() { - var prefix = "hsla(", - hsla = jQuery.map( this.hsla(), function( v, i ) { - if ( v == null ) { - v = i > 2 ? 1 : 0; - } - - // catch 1 and 2 - if ( i && i < 3 ) { - v = Math.round( v * 100 ) + "%"; - } - return v; - }); - - if ( hsla[ 3 ] === 1 ) { - hsla.pop(); - prefix = "hsl("; - } - return prefix + hsla.join(",") + ")"; - }, - toHexString: function( includeAlpha ) { - var rgba = this._rgba.slice(), - alpha = rgba.pop(); - - if ( includeAlpha ) { - rgba.push( ~~( alpha * 255 ) ); - } - - return "#" + jQuery.map( rgba, function( v, i ) { - - // default to 0 when nulls exist - v = ( v || 0 ).toString( 16 ); - return v.length === 1 ? "0" + v : v; - }).join(""); - }, - toString: function() { - return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); - } - }; - color.fn.parse.prototype = color.fn; - - // hsla conversions adapted from: - // http://www.google.com/codesearch/p#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&d=7&l=193 - - function hue2rgb( p, q, h ) { - h = ( h + 1 ) % 1; - if ( h * 6 < 1 ) { - return p + (q - p) * 6 * h; - } - if ( h * 2 < 1) { - return q; - } - if ( h * 3 < 2 ) { - return p + (q - p) * ((2/3) - h) * 6; - } - return p; - } - - spaces.hsla.to = function ( rgba ) { - if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { - return [ null, null, null, rgba[ 3 ] ]; - } - var r = rgba[ 0 ] / 255, - g = rgba[ 1 ] / 255, - b = rgba[ 2 ] / 255, - a = rgba[ 3 ], - max = Math.max( r, g, b ), - min = Math.min( r, g, b ), - diff = max - min, - add = max + min, - l = add * 0.5, - h, s; - - if ( min === max ) { - h = 0; - } else if ( r === max ) { - h = ( 60 * ( g - b ) / diff ) + 360; - } else if ( g === max ) { - h = ( 60 * ( b - r ) / diff ) + 120; - } else { - h = ( 60 * ( r - g ) / diff ) + 240; - } - - if ( l === 0 || l === 1 ) { - s = l; - } else if ( l <= 0.5 ) { - s = diff / add; - } else { - s = diff / ( 2 - add ); - } - return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; - }; - - spaces.hsla.from = function ( hsla ) { - if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { - return [ null, null, null, hsla[ 3 ] ]; - } - var h = hsla[ 0 ] / 360, - s = hsla[ 1 ], - l = hsla[ 2 ], - a = hsla[ 3 ], - q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, - p = 2 * l - q, - r, g, b; - - return [ - Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), - Math.round( hue2rgb( p, q, h ) * 255 ), - Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), - a - ]; - }; - - - each( spaces, function( spaceName, space ) { - var props = space.props, - cache = space.cache, - to = space.to, - from = space.from; - - // makes rgba() and hsla() - color.fn[ spaceName ] = function( value ) { - - // generate a cache for this space if it doesn't exist - if ( to && !this[ cache ] ) { - this[ cache ] = to( this._rgba ); - } - if ( value === undefined ) { - return this[ cache ].slice(); - } - - var type = jQuery.type( value ), - arr = ( type === "array" || type === "object" ) ? value : arguments, - local = this[ cache ].slice(), - ret; - - each( props, function( key, prop ) { - var val = arr[ type === "object" ? key : prop.idx ]; - if ( val == null ) { - val = local[ prop.idx ]; - } - local[ prop.idx ] = clamp( val, prop ); - }); - - if ( from ) { - ret = color( from( local ) ); - ret[ cache ] = local; - return ret; - } else { - return color( local ); - } - }; - - // makes red() green() blue() alpha() hue() saturation() lightness() - each( props, function( key, prop ) { - // alpha is included in more than one space - if ( color.fn[ key ] ) { - return; - } - color.fn[ key ] = function( value ) { - var vtype = jQuery.type( value ), - fn = ( key === 'alpha' ? ( this._hsla ? 'hsla' : 'rgba' ) : spaceName ), - local = this[ fn ](), - cur = local[ prop.idx ], - match; - - if ( vtype === "undefined" ) { - return cur; - } - - if ( vtype === "function" ) { - value = value.call( this, cur ); - vtype = jQuery.type( value ); - } - if ( value == null && prop.empty ) { - return this; - } - if ( vtype === "string" ) { - match = rplusequals.exec( value ); - if ( match ) { - value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); - } - } - local[ prop.idx ] = value; - return this[ fn ]( local ); - }; - }); - }); - - // add .fx.step functions - each( stepHooks, function( i, hook ) { - jQuery.cssHooks[ hook ] = { - set: function( elem, value ) { - var parsed, backgroundColor, curElem; - - if ( jQuery.type( value ) !== 'string' || ( parsed = stringParse( value ) ) ) - { - value = color( parsed || value ); - if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { - curElem = hook === "backgroundColor" ? elem.parentNode : elem; - do { - backgroundColor = jQuery.curCSS( curElem, "backgroundColor" ); - } while ( - ( backgroundColor === "" || backgroundColor === "transparent" ) && - ( curElem = curElem.parentNode ) && +(function (jQuery, undefined) { + var stepHooks = 'backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor'.split(' ') + + // plusequals test for += 100 -= 100 + + var rplusequals = /^([\-+])=\s*(\d+\.?\d*)/ + + // a set of RE's that can match strings and generate color tuples. + + var stringParsers = [{ + re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + parse: function (execResult) { + return [ + execResult[ 1 ], + execResult[ 2 ], + execResult[ 3 ], + execResult[ 4 ] + ] + } + }, { + re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + parse: function (execResult) { + return [ + 2.55 * execResult[1], + 2.55 * execResult[2], + 2.55 * execResult[3], + execResult[ 4 ] + ] + } + }, { + re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/, + parse: function (execResult) { + return [ + parseInt(execResult[ 1 ], 16), + parseInt(execResult[ 2 ], 16), + parseInt(execResult[ 3 ], 16) + ] + } + }, { + re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/, + parse: function (execResult) { + return [ + parseInt(execResult[ 1 ] + execResult[ 1 ], 16), + parseInt(execResult[ 2 ] + execResult[ 2 ], 16), + parseInt(execResult[ 3 ] + execResult[ 3 ], 16) + ] + } + }, { + re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + space: 'hsla', + parse: function (execResult) { + return [ + execResult[1], + execResult[2] / 100, + execResult[3] / 100, + execResult[4] + ] + } + }] + + // jQuery.Color( ) + + var color = jQuery.Color = function (color, green, blue, alpha) { + return new jQuery.Color.fn.parse(color, green, blue, alpha) + } + + var spaces = { + rgba: { + cache: '_rgba', + props: { + red: { + idx: 0, + type: 'byte', + empty: true + }, + green: { + idx: 1, + type: 'byte', + empty: true + }, + blue: { + idx: 2, + type: 'byte', + empty: true + }, + alpha: { + idx: 3, + type: 'percent', + def: 1 + } + } + }, + hsla: { + cache: '_hsla', + props: { + hue: { + idx: 0, + type: 'degrees', + empty: true + }, + saturation: { + idx: 1, + type: 'percent', + empty: true + }, + lightness: { + idx: 2, + type: 'percent', + empty: true + } + } + } + } + + var propTypes = { + 'byte': { + floor: true, + min: 0, + max: 255 + }, + 'percent': { + min: 0, + max: 1 + }, + 'degrees': { + mod: 360, + floor: true + } + } + + var rgbaspace = spaces.rgba.props + + var support = color.support = {} + + // colors = jQuery.Color.names + + var colors + + // local aliases of functions called often + + var each = jQuery.each + + spaces.hsla.props.alpha = rgbaspace.alpha + + function clamp (value, prop, alwaysAllowEmpty) { + var type = propTypes[ prop.type ] || {} + + var allowEmpty = prop.empty || alwaysAllowEmpty + + if (allowEmpty && value == null) { + return null + } + if (prop.def && value == null) { + return prop.def + } + if (type.floor) { + value = ~~value + } else { + value = parseFloat(value) + } + if (value == null || isNaN(value)) { + return prop.def + } + if (type.mod) { + value = value % type.mod + // -10 -> 350 + return value < 0 ? type.mod + value : value + } + + // for now all property types without mod have min and max + return type.min > value ? type.min : type.max < value ? type.max : value + } + + function stringParse (string) { + var inst = color() + + var rgba = inst._rgba = [] + + string = string.toLowerCase() + + each(stringParsers, function (i, parser) { + var match = parser.re.exec(string) + + var values = match && parser.parse(match) + + var parsed + + var spaceName = parser.space || 'rgba' + + var cache = spaces[ spaceName ].cache + + if (values) { + parsed = inst[ spaceName ](values) + + // if this was an rgba parse the assignment might happen twice + // oh well.... + inst[ cache ] = parsed[ cache ] + rgba = inst._rgba = parsed._rgba + + // exit each( stringParsers ) here because we matched + return false + } + }) + + // Found a stringParser that handled it + if (rgba.length !== 0) { + // if this came from a parsed string, force "transparent" when alpha is 0 + // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) + if (Math.max.apply(Math, rgba) === 0) { + jQuery.extend(rgba, colors.transparent) + } + return inst + } + + // named colors / default - filter back through parse function + if (string = colors[ string ]) { + return string + } + } + + color.fn = color.prototype = { + constructor: color, + parse: function (red, green, blue, alpha) { + if (red === undefined) { + this._rgba = [ null, null, null, null ] + return this + } + if (red instanceof jQuery || red.nodeType) { + red = red instanceof jQuery ? red.css(green) : jQuery(red).css(green) + green = undefined + } + + var inst = this + + var type = jQuery.type(red) + + var rgba = this._rgba = [] + + var source + + // more than 1 argument specified - assume ( red, green, blue, alpha ) + if (green !== undefined) { + red = [ red, green, blue, alpha ] + type = 'array' + } + + if (type === 'string') { + return this.parse(stringParse(red) || colors._default) + } + + if (type === 'array') { + each(rgbaspace, function (key, prop) { + rgba[ prop.idx ] = clamp(red[ prop.idx ], prop) + }) + return this + } + + if (type === 'object') { + if (red instanceof color) { + each(spaces, function (spaceName, space) { + if (red[ space.cache ]) { + inst[ space.cache ] = red[ space.cache ].slice() + } + }) + } else { + each(spaces, function (spaceName, space) { + each(space.props, function (key, prop) { + var cache = space.cache + + // if the cache doesn't exist, and we know how to convert + if (!inst[ cache ] && space.to) { + // if the value was null, we don't need to copy it + // if the key was alpha, we don't need to copy it either + if (red[ key ] == null || key === 'alpha') { + return + } + inst[ cache ] = space.to(inst._rgba) + } + + // this is the only case where we allow nulls for ALL properties. + // call clamp with alwaysAllowEmpty + inst[ cache ][ prop.idx ] = clamp(red[ key ], prop, true) + }) + }) + } + return this + } + }, + is: function (compare) { + var is = color(compare) + + var same = true + + var myself = this + + each(spaces, function (_, space) { + var isCache = is[ space.cache ] + + var localCache + if (isCache) { + localCache = myself[ space.cache ] || space.to && space.to(myself._rgba) || [] + each(space.props, function (_, prop) { + if (isCache[ prop.idx ] != null) { + same = (isCache[ prop.idx ] === localCache[ prop.idx ]) + return same + } + }) + } + return same + }) + return same + }, + _space: function () { + var used = [] + + var inst = this + each(spaces, function (spaceName, space) { + if (inst[ space.cache ]) { + used.push(spaceName) + } + }) + return used.pop() + }, + transition: function (other, distance) { + var end = color(other) + + var spaceName = end._space() + + var space = spaces[ spaceName ] + + var start = this[ space.cache ] || space.to(this._rgba) + + var result = start.slice() + + end = end[ space.cache ] + each(space.props, function (key, prop) { + var index = prop.idx + + var startValue = start[ index ] + + var endValue = end[ index ] + + var type = propTypes[ prop.type ] || {} + + // if null, don't override start value + if (endValue === null) { + return + } + // if null - use end + if (startValue === null) { + result[ index ] = endValue + } else { + if (type.mod) { + if (endValue - startValue > type.mod / 2) { + startValue += type.mod + } else if (startValue - endValue > type.mod / 2) { + startValue -= type.mod + } + } + result[ prop.idx ] = clamp((endValue - startValue) * distance + startValue, prop) + } + }) + return this[ spaceName ](result) + }, + blend: function (opaque) { + // if we are already opaque - return ourself + if (this._rgba[ 3 ] === 1) { + return this + } + + var rgb = this._rgba.slice() + + var a = rgb.pop() + + var blend = color(opaque)._rgba + + return color(jQuery.map(rgb, function (v, i) { + return (1 - a) * blend[ i ] + a * v + })) + }, + toRgbaString: function () { + var prefix = 'rgba(' + + var rgba = jQuery.map(this._rgba, function (v, i) { + return v == null ? (i > 2 ? 1 : 0) : v + }) + + if (rgba[ 3 ] === 1) { + rgba.pop() + prefix = 'rgb(' + } + + return prefix + rgba.join(',') + ')' + }, + toHslaString: function () { + var prefix = 'hsla(' + + var hsla = jQuery.map(this.hsla(), function (v, i) { + if (v == null) { + v = i > 2 ? 1 : 0 + } + + // catch 1 and 2 + if (i && i < 3) { + v = Math.round(v * 100) + '%' + } + return v + }) + + if (hsla[ 3 ] === 1) { + hsla.pop() + prefix = 'hsl(' + } + return prefix + hsla.join(',') + ')' + }, + toHexString: function (includeAlpha) { + var rgba = this._rgba.slice() + + var alpha = rgba.pop() + + if (includeAlpha) { + rgba.push(~~(alpha * 255)) + } + + return '#' + jQuery.map(rgba, function (v, i) { + // default to 0 when nulls exist + v = (v || 0).toString(16) + return v.length === 1 ? '0' + v : v + }).join('') + }, + toString: function () { + return this._rgba[ 3 ] === 0 ? 'transparent' : this.toRgbaString() + } + } + color.fn.parse.prototype = color.fn + + // hsla conversions adapted from: + // http://www.google.com/codesearch/p#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&d=7&l=193 + + function hue2rgb (p, q, h) { + h = (h + 1) % 1 + if (h * 6 < 1) { + return p + (q - p) * 6 * h + } + if (h * 2 < 1) { + return q + } + if (h * 3 < 2) { + return p + (q - p) * ((2 / 3) - h) * 6 + } + return p + } + + spaces.hsla.to = function (rgba) { + if (rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null) { + return [ null, null, null, rgba[ 3 ] ] + } + var r = rgba[ 0 ] / 255 + + var g = rgba[ 1 ] / 255 + + var b = rgba[ 2 ] / 255 + + var a = rgba[ 3 ] + + var max = Math.max(r, g, b) + + var min = Math.min(r, g, b) + + var diff = max - min + + var add = max + min + + var l = add * 0.5 + + var h; var s + + if (min === max) { + h = 0 + } else if (r === max) { + h = (60 * (g - b) / diff) + 360 + } else if (g === max) { + h = (60 * (b - r) / diff) + 120 + } else { + h = (60 * (r - g) / diff) + 240 + } + + if (l === 0 || l === 1) { + s = l + } else if (l <= 0.5) { + s = diff / add + } else { + s = diff / (2 - add) + } + return [ Math.round(h) % 360, s, l, a == null ? 1 : a ] + } + + spaces.hsla.from = function (hsla) { + if (hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null) { + return [ null, null, null, hsla[ 3 ] ] + } + var h = hsla[ 0 ] / 360 + + var s = hsla[ 1 ] + + var l = hsla[ 2 ] + + var a = hsla[ 3 ] + + var q = l <= 0.5 ? l * (1 + s) : l + s - l * s + + var p = 2 * l - q + + var r; var g; var b + + return [ + Math.round(hue2rgb(p, q, h + (1 / 3)) * 255), + Math.round(hue2rgb(p, q, h) * 255), + Math.round(hue2rgb(p, q, h - (1 / 3)) * 255), + a + ] + } + + each(spaces, function (spaceName, space) { + var props = space.props + + var cache = space.cache + + var to = space.to + + var from = space.from + + // makes rgba() and hsla() + color.fn[ spaceName ] = function (value) { + // generate a cache for this space if it doesn't exist + if (to && !this[ cache ]) { + this[ cache ] = to(this._rgba) + } + if (value === undefined) { + return this[ cache ].slice() + } + + var type = jQuery.type(value) + + var arr = (type === 'array' || type === 'object') ? value : arguments + + var local = this[ cache ].slice() + + var ret + + each(props, function (key, prop) { + var val = arr[ type === 'object' ? key : prop.idx ] + if (val == null) { + val = local[ prop.idx ] + } + local[ prop.idx ] = clamp(val, prop) + }) + + if (from) { + ret = color(from(local)) + ret[ cache ] = local + return ret + } else { + return color(local) + } + } + + // makes red() green() blue() alpha() hue() saturation() lightness() + each(props, function (key, prop) { + // alpha is included in more than one space + if (color.fn[ key ]) { + return + } + color.fn[ key ] = function (value) { + var vtype = jQuery.type(value) + + var fn = (key === 'alpha' ? (this._hsla ? 'hsla' : 'rgba') : spaceName) + + var local = this[ fn ]() + + var cur = local[ prop.idx ] + + var match + + if (vtype === 'undefined') { + return cur + } + + if (vtype === 'function') { + value = value.call(this, cur) + vtype = jQuery.type(value) + } + if (value == null && prop.empty) { + return this + } + if (vtype === 'string') { + match = rplusequals.exec(value) + if (match) { + value = cur + parseFloat(match[ 2 ]) * (match[ 1 ] === '+' ? 1 : -1) + } + } + local[ prop.idx ] = value + return this[ fn ](local) + } + }) + }) + + // add .fx.step functions + each(stepHooks, function (i, hook) { + jQuery.cssHooks[ hook ] = { + set: function (elem, value) { + var parsed, backgroundColor, curElem + + if (jQuery.type(value) !== 'string' || (parsed = stringParse(value))) { + value = color(parsed || value) + if (!support.rgba && value._rgba[ 3 ] !== 1) { + curElem = hook === 'backgroundColor' ? elem.parentNode : elem + do { + backgroundColor = jQuery.curCSS(curElem, 'backgroundColor') + } while ( + (backgroundColor === '' || backgroundColor === 'transparent') && + (curElem = curElem.parentNode) && curElem.style - ); - - value = value.blend( backgroundColor && backgroundColor !== "transparent" ? - backgroundColor : - "_default" ); - } - - value = value.toRgbaString(); - } - elem.style[ hook ] = value; - } - }; - jQuery.fx.step[ hook ] = function( fx ) { - if ( !fx.colorInit ) { - fx.start = color( fx.elem, hook ); - fx.end = color( fx.end ); - fx.colorInit = true; - } - jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); - }; - }); - - // detect rgba support - jQuery(function() { - var div = document.createElement( "div" ), - div_style = div.style; - - div_style.cssText = "background-color:rgba(1,1,1,.5)"; - support.rgba = div_style.backgroundColor.indexOf( "rgba" ) > -1; - }); - - // Some named colors to work with - // From Interface by Stefan Petre - // http://interface.eyecon.ro/ - colors = jQuery.Color.names = { - aqua: "#00ffff", - azure: "#f0ffff", - beige: "#f5f5dc", - black: "#000000", - blue: "#0000ff", - brown: "#a52a2a", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgrey: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkviolet: "#9400d3", - fuchsia: "#ff00ff", - gold: "#ffd700", - green: "#008000", - indigo: "#4b0082", - khaki: "#f0e68c", - lightblue: "#add8e6", - lightcyan: "#e0ffff", - lightgreen: "#90ee90", - lightgrey: "#d3d3d3", - lightpink: "#ffb6c1", - lightyellow: "#ffffe0", - lime: "#00ff00", - magenta: "#ff00ff", - maroon: "#800000", - navy: "#000080", - olive: "#808000", - orange: "#ffa500", - pink: "#ffc0cb", - purple: "#800080", - violet: "#800080", - red: "#ff0000", - silver: "#c0c0c0", - white: "#ffffff", - yellow: "#ffff00", - transparent: [ null, null, null, 0 ], - _default: "#ffffff" - }; -})( jQuery ); + ) + + value = value.blend(backgroundColor && backgroundColor !== 'transparent' + ? backgroundColor + : '_default') + } + + value = value.toRgbaString() + } + elem.style[ hook ] = value + } + } + jQuery.fx.step[ hook ] = function (fx) { + if (!fx.colorInit) { + fx.start = color(fx.elem, hook) + fx.end = color(fx.end) + fx.colorInit = true + } + jQuery.cssHooks[ hook ].set(fx.elem, fx.start.transition(fx.end, fx.pos)) + } + }) + + // detect rgba support + jQuery(function () { + var div = document.createElement('div') + + var div_style = div.style + + div_style.cssText = 'background-color:rgba(1,1,1,.5)' + support.rgba = div_style.backgroundColor.indexOf('rgba') > -1 + }) + + // Some named colors to work with + // From Interface by Stefan Petre + // http://interface.eyecon.ro/ + colors = jQuery.Color.names = { + aqua: '#00ffff', + azure: '#f0ffff', + beige: '#f5f5dc', + black: '#000000', + blue: '#0000ff', + brown: '#a52a2a', + cyan: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgrey: '#a9a9a9', + darkgreen: '#006400', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkviolet: '#9400d3', + fuchsia: '#ff00ff', + gold: '#ffd700', + green: '#008000', + indigo: '#4b0082', + khaki: '#f0e68c', + lightblue: '#add8e6', + lightcyan: '#e0ffff', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightyellow: '#ffffe0', + lime: '#00ff00', + magenta: '#ff00ff', + maroon: '#800000', + navy: '#000080', + olive: '#808000', + orange: '#ffa500', + pink: '#ffc0cb', + purple: '#800080', + violet: '#800080', + red: '#ff0000', + silver: '#c0c0c0', + white: '#ffffff', + yellow: '#ffff00', + transparent: [ null, null, null, 0 ], + _default: '#ffffff' + } +})(jQuery) diff --git a/sapl-frontend/src/global/main.js b/sapl-frontend/src/global/main.js index 7c1ad5072..008ae1d1c 100644 --- a/sapl-frontend/src/global/main.js +++ b/sapl-frontend/src/global/main.js @@ -1,6 +1,4 @@ // eslint-disable-next-line -require('imports-loader?window.jQuery=jquery!./jquery.runner.js') - import 'jquery-mask-plugin' import 'webpack-jquery-ui/dialog' @@ -12,6 +10,8 @@ import './functions' import './image_cropping' +require('imports-loader?window.jQuery=jquery!./jquery.runner.js') + window.jQuery = jQuery window.$ = jQuery diff --git a/sapl-frontend/src/hellow/components/HelloWorld.vue b/sapl-frontend/src/hellow/components/HelloWorld.vue index f2a7270cd..49e16cbf1 100644 --- a/sapl-frontend/src/hellow/components/HelloWorld.vue +++ b/sapl-frontend/src/hellow/components/HelloWorld.vue @@ -88,11 +88,11 @@ diff --git a/sapl-frontend/src/hellow/main.js b/sapl-frontend/src/hellow/main.js index 843306d69..f25345696 100644 --- a/sapl-frontend/src/hellow/main.js +++ b/sapl-frontend/src/hellow/main.js @@ -1,7 +1,7 @@ -import Vue from "vue" -import App from "./App.vue" -import router from "./router" -import store from "./store" +import Vue from 'vue' +import App from './App.vue' +import router from './router' +import store from './store' Vue.config.productionTip = false @@ -9,4 +9,4 @@ new Vue({ router, store, render: h => h(App) -}).$mount("#app") +}).$mount('#app') diff --git a/sapl-frontend/src/hellow/router.js b/sapl-frontend/src/hellow/router.js index 42f50e476..382a76480 100644 --- a/sapl-frontend/src/hellow/router.js +++ b/sapl-frontend/src/hellow/router.js @@ -1,10 +1,10 @@ -import Vue from "vue" -import Router from "vue-router" +import Vue from 'vue' +import Router from 'vue-router' Vue.use(Router) export default new Router({ - mode: "history", + mode: 'history', base: process.env.BASE_URL, routes: [] }) diff --git a/sapl-frontend/src/hellow/store.js b/sapl-frontend/src/hellow/store.js index 5cbb72d3b..ef5f0b780 100644 --- a/sapl-frontend/src/hellow/store.js +++ b/sapl-frontend/src/hellow/store.js @@ -1,5 +1,5 @@ -import Vue from "vue" -import Vuex from "vuex" +import Vue from 'vue' +import Vuex from 'vuex' Vue.use(Vuex) @@ -7,4 +7,4 @@ export default new Vuex.Store({ state: {}, mutations: {}, actions: {} -}); +}) diff --git a/sapl-frontend/src/hellow/views/Home.vue b/sapl-frontend/src/hellow/views/Home.vue index 3f6b1a8a7..7b7148c39 100644 --- a/sapl-frontend/src/hellow/views/Home.vue +++ b/sapl-frontend/src/hellow/views/Home.vue @@ -7,10 +7,10 @@