Created
February 10, 2020 13:16
-
-
Save ivanferrer/0438940d1ff1396c16de91e95e4de581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gutenWebappApp | |
| .controller("EditorProducaoTextoController", [ | |
| "$scope","$sce","$rootScope", "$location", | |
| "$uibModal", "$timeout","$interval","$routeParams","$compile","$window", | |
| "ProducaoService", "GamesService","AutoriaService","QuillEditorService", | |
| function($scope,$sce, $rootScope, $location, | |
| $uibModal, $timeout, $interval, $routeParams, $compile, $window, | |
| ProducaoService, GamesService, AutoriaService,QuillEditorService) { | |
| $('.ql-bold,.ql-italic,.ql-underline').unbind().off(); | |
| $rootScope.editorQuill = true; | |
| $scope.firstime = true; | |
| $scope.is_revised = false; | |
| $scope.is_versioned = false; | |
| $scope.is_version_enable = true; | |
| $scope.on_error = false; | |
| $scope.content = { | |
| reviews:[] | |
| } | |
| $scope.tools = { | |
| show_proposta:false, | |
| show_revisoes:false, | |
| zoom_style:{ | |
| } | |
| } | |
| $(function() { | |
| $(document).find('.rule-actions').removeClass('ng-hide'); | |
| }); | |
| if (typeof data_form !== 'undefined' && typeof data_form.production_text_versioned !== 'undefined') { | |
| $scope.is_versioned = data_form.production_text_versioned; | |
| } | |
| $rootScope.actionClass += " producao-texto-view"; | |
| $scope.back_game = "Voltar"; | |
| // $rootScope.editor_producao_textual_url = PATH_DIR_PRO + 'css/vs-'+VERSION+'-editor.producao.textual.css'; | |
| $scope.is_mobile = false; | |
| $scope.is_mobile_400 = false; | |
| $scope.is_mobile_320 = false; | |
| $scope.verifyIsMobile = function(){ | |
| if (window.innerWidth < 769) { | |
| $scope.is_mobile = true; | |
| } else { | |
| $scope.is_mobile = false; | |
| } | |
| if (window.innerWidth < 400) { | |
| $scope.is_mobile_400 = true; | |
| } else { | |
| $scope.is_mobile_400 = false; | |
| } | |
| if (window.innerWidth < 320) { | |
| $scope.is_mobile_320 = true; | |
| } else { | |
| $scope.is_mobile_320 = false; | |
| } | |
| } | |
| $($window).on('resize', function(e){ | |
| $scope.verifyIsMobile(); | |
| }); | |
| $scope.is_touch = $rootScope.is_touchscreen; | |
| // function readFileView(file, id) { | |
| // var reader = new FileReader(); | |
| // reader.onload = function (e) { | |
| // $('#img_'+id_img).attr('src', e.target.result); | |
| // } | |
| // reader.readAsDataURL(file); | |
| // } | |
| // $scope.addImageMobile = function() { | |
| // var tk_os = checkCookies('tk_os'); | |
| // // if(tk_os == 'iphone' || tk_os == 'android'){ | |
| // | |
| // // $rootScope.toastMessage('warning', 'Atenção!', "Utilize a versão Web para acessar esse recurso. ", 4200); | |
| // | |
| // // }else{ | |
| // | |
| // | |
| // | |
| // if ($scope.is_touch) { | |
| // if ($('.upload-form').length == 0) { | |
| // $(this).append('<input type="file" multiple="multiple" class="ng-hide upload-form" id="uploadChange" />'); | |
| // } | |
| // $('#uploadChange').trigger('change'); | |
| // $('#uploadChange').on('change', function () { | |
| // var id = $(this).attr('id'); | |
| // | |
| // var totalFiles = $(this).get(0).files.length; | |
| // if(totalFiles == 0) { | |
| // $rootScope.toastMessage('warning', 'Atenção', 'Selecione uma ou mais imagens.', 9000); | |
| // } | |
| // if ( totalFiles > 1) { | |
| // $rootScope.toastMessage('success', 'Arquivo enviado',totalFiles+' arquivos selecionados.', 9000); | |
| // } else { | |
| // $rootScope.toastMessage('success', 'Arquivo enviado',totalFiles+' arquivos selecionado.', 9000); | |
| // } | |
| // var img=''; | |
| // for (var i=0; i < totalFiles; i++) { | |
| // var id_img = (i+randUrl()+new Date(currentDateTimeEng).getTime()).substring(0, 10); | |
| // var arquivo = $(this).get(0).files[i]; | |
| // var fileV = new readFileView(arquivo, id_img); | |
| // img += '<img class="the-imagem" id="img_'+id_img+'">'+"\n"; | |
| // } | |
| // if ($('.ql-editor').closest(':focus').length != 0){ | |
| // $('.ql-editor').closest(':focus').append(img); | |
| // } else { | |
| // $('.ql-editor p:last-child').append(img); | |
| // } | |
| // | |
| // }); | |
| // // } | |
| // | |
| // } | |
| // } | |
| $(function($) { | |
| var tk_os = checkCookies('tk_os'); | |
| if ($scope.is_mobile && (tk_os == 'iphone' || tk_os == 'ipad') && document.documentElement.clientHeight < 769) { | |
| $(document) | |
| .on('focus', '[contenteditable]', function (e) { | |
| $('body').addClass('fixed-toolbar'); | |
| window.scrollTo(0, 0); | |
| document.body.scrollTop = 0; | |
| }) | |
| .on('blur', '[contenteditable]', function (e) { | |
| $('body').removeClass('fixed-toolbar'); | |
| window.scrollTo(0, 0); | |
| document.body.scrollTop = 0; | |
| }); | |
| } | |
| // $('html, body').on('scroll touchmove touchstart touchend touchcancel', function(){ | |
| // window.scrollTo(0, 0); | |
| // document.body.scrollTop = 0; | |
| // $('html,body').animate({scrollTop:0}, 0) | |
| // .css({'max-height':'500px!important', 'overflow':'hidden!important'}); | |
| // | |
| // }); | |
| // | |
| // $(document).on('pinch-zoom', '[contenteditable]', function (e) { | |
| // $('body').addClass('fixed-toolbar'); | |
| // $('html,body').animate({scrollTop:0}, 0); | |
| // window.scrollTo(0, 0); | |
| // document.body.scrollTop = 0; | |
| // | |
| // }) | |
| }); | |
| //console.log('carregou') | |
| $rootScope.selectedTab = 'producao-texto'; | |
| $rootScope.backPage = false; | |
| $rootScope.currentTab = 1; | |
| $scope.intervalTime = null; | |
| $scope.seconds = 0; | |
| $scope.forceLeave = false; | |
| $scope.is_running_on_ipad = false; | |
| $scope.autosave_autoria = false; | |
| $scope.permissionAutoSaveAutoria = true; | |
| $scope.autoria_id = null; | |
| $scope.version = VERSION; | |
| $scope.dataForm = data_form; | |
| $scope.currentGame = 0; | |
| $scope.params_autoria = {}; | |
| $scope.requestParams = { | |
| activity_id:$routeParams.atividade, | |
| section_id:$routeParams.secao, | |
| edition_id:$routeParams.edicao | |
| }; | |
| if (angular.isDefined(is_running_on_ipad)) { | |
| $scope.is_running_on_ipad = is_running_on_ipad; | |
| } else { | |
| $scope.is_running_on_ipad = false; | |
| } | |
| $scope.read_only = false; | |
| $scope.data_autoria = null; | |
| $scope.data_activity = null; | |
| $scope.scroll_options = { | |
| 'wrapperClass': '', | |
| 'scrollBarClass': '', | |
| 'scrollBarContainerClass': '', | |
| 'scrollBarContainerSpecialClass': '', | |
| 'scrollBarMinHeight': '', | |
| 'scrollBarFixedHeight': '', | |
| 'keepFocus': false | |
| }; | |
| $scope.getQuillEditor = function(advancedEditor, call) { | |
| var _self = this; | |
| _self.editor = advancedEditor; | |
| _self.objQuill = Quill; | |
| _self.quillEditor = function() { | |
| loadingOn(''); | |
| if (! _self.objQuill) { | |
| loadingOn('Aguarde....'); | |
| } else { | |
| if (typeof _self.objQuill.import == 'function') { | |
| loadingOff(''); | |
| var GrammarlyInline = _self.objQuill.import('blots/inline'); | |
| GrammarlyInline.tagName = 'G'; | |
| GrammarlyInline.blotName = 'grammarly-inline'; | |
| GrammarlyInline.className = 'gr_'; | |
| var SizeStyle = _self.objQuill.import('attributors/style/size'); | |
| var Font = _self.objQuill.import('formats/font'); | |
| var imageResize = _self.objQuill.import('modules/ImageResize'); | |
| var Embed = _self.objQuill.import('blots/block/embed'); | |
| var _self_parent = this; | |
| _self_parent.customHrHandler = function () { | |
| // get the position of the cursor | |
| // if(typeof _self.objQuill.getSelection == 'function') { | |
| // var range = _self.objQuill.getSelection(); | |
| // if (range) { | |
| // // insert the <hr> where the cursor is | |
| // _self.objQuill.insertEmbed(range.index, "hr", "null") | |
| // } | |
| // } | |
| } | |
| _self.objQuill.register('formats/grammarly-inline', GrammarlyInline, true); | |
| _self.objQuill.prototype.getHtml = function () { | |
| return this.container.querySelector('.ql-editor').innerHTML; | |
| }; | |
| /* var ResizeImage = Quill.import('modules/ImageResize'); */ | |
| // We do not add Aref Ruqaa since it is the default | |
| Font.whitelist = ['helvetica', 'times', 'courier']; | |
| _self.objQuill.register(Font, true); | |
| var Delta = Quill.import('delta'); | |
| var j = 0; | |
| var countSize = []; | |
| for (var i = 12; i <= 38; i++) { | |
| if (i % 2 == 0) { | |
| countSize[j] = i + 'pt'; | |
| } | |
| j++; | |
| } | |
| SizeStyle.whitelist = countSize; | |
| _self.objQuill.register(SizeStyle, true); | |
| _self.objQuill.register('modules/imageResize', imageResize); | |
| //_self.objQuill.register('modules/imageResize', __imageResize["a" /* ImageResize */]); | |
| var options = { | |
| modules: { | |
| toolbar: '#toolbar-container', | |
| clipboard:{ | |
| matchVisual: false | |
| }, | |
| keyboard: { | |
| bindings: { | |
| tributeSelectOnEnter: { | |
| key: 13, | |
| shortKey: false, | |
| handler: function(event){ | |
| var range = this.quill.selection.lastRange.index; | |
| if (range) { | |
| $scope.opsDelta.insert({ | |
| ops: [ | |
| { insert: '\n'}, | |
| ] | |
| }); | |
| return true; | |
| } else { | |
| return true; | |
| } | |
| } | |
| }, | |
| } | |
| } | |
| }, | |
| handlers: { | |
| // 'hr': _self.customHrHandler | |
| image: imageHandler | |
| }, | |
| //placeholder: 'Compose an epic...', | |
| theme: 'snow', | |
| readOnly: $scope.read_only, | |
| imageHandler:imageHandler | |
| }; | |
| function imageHandler() { | |
| var range = this.quill.getSelection(); | |
| } | |
| if (!$scope.read_only && !$scope.loading_producao_texto) { | |
| options.modules.imageResize = {displaySize: true}; | |
| } else { | |
| options.modules.imageResize = {displaySize: false}; | |
| } | |
| if (window.innerWidth < 768) { | |
| options.modules.imageResize.displaySize = false; | |
| } else { | |
| if (!$scope.read_only && !$scope.loading_producao_texto) { | |
| options.modules.imageResize = {displaySize: true}; | |
| } else { | |
| options.modules.imageResize = {displaySize: false}; | |
| } | |
| } | |
| // options.modules.imageResize = {displaySize: true}; | |
| _self.editor = new _self.objQuill('#editor-container', options); | |
| _self.editor.on('focus', function(delta, source){ | |
| var tk_os = checkCookies('tk_os'); | |
| if (document.documentElement.clientHeight < 769 && (tk_os == 'iphone' || tk_os == 'ipad')) { | |
| window.scrollTo(0, 0); //the s | |
| } | |
| }); | |
| _self.editor.on('text-change', function (delta, source) { | |
| //autosave_autoria = false; | |
| // console.log(delta, source); | |
| $scope.opsDelta = delta; | |
| // console.log('text-change',delta, $rootScope.hasChangesProducaoTexto); | |
| if (!$scope.firstime) { | |
| $rootScope.hasChangesProducaoTexto = true; | |
| $scope.permissionAutoSaveAutoria = true; | |
| $scope.startAutoSaveAutoria(); | |
| if (angular.isDefined(data_form)) { | |
| data_form.start_game = true; | |
| } | |
| var current = _self.editor.getSelection(); | |
| // try { | |
| // var check = _self.objQuill.getSelection(); | |
| // $(this).trigger('click'); | |
| if (current) { | |
| $scope.current_focus = current; | |
| // _self.editor.setSelection(check.index, check.length); | |
| // var intterval = setInterval(function () { | |
| // _self.editor.update(); | |
| // }, 4); | |
| // clearInterval(intterval); | |
| } | |
| // } catch (e) { | |
| // | |
| // } | |
| } | |
| $scope.firstime = false; | |
| }); | |
| _self.editor.on('selection-change', function (delta, source) { | |
| $scope.current_focus = delta; | |
| }); | |
| _self.editor.clipboard.addMatcher (Node.ELEMENT_NODE, function (node, delta) { | |
| // matchStyles(node, delta); | |
| node = $sce.trustAsHtml(node); | |
| var plaintext = $(node).text().replace(/\—/gim, '-').replace(/\–/gim,'-').replace(/ /gim, ' '); | |
| return new Delta().insert (plaintext); | |
| }); | |
| // _self.editor.addFormat('reset', { | |
| // prepare: function() { | |
| // return document.execCommand('removeFormat') | |
| // } | |
| // }) | |
| // _self.editor.focus(); | |
| return _self.editor; | |
| } else { | |
| $scope.loading_producao_texto = false; | |
| loadingOn(''); | |
| // $window.location.reload(); | |
| } | |
| } | |
| } | |
| if (angular.isDefined(_self.objQuill)) { | |
| advancedEditor = _self.quillEditor(); | |
| advancedEditor.root.setAttribute('data-gramm', 'false'); | |
| call(advancedEditor); | |
| } | |
| } | |
| $scope.getSizeOptions = function() { | |
| $scope.options_size = []; | |
| var j = 0; | |
| for (var i = 12; i <= 36; i++) { | |
| if (i % 2 == 0) { | |
| $scope.options_size.push({label: i, value: i + 'pt'}); | |
| } | |
| j++; | |
| } | |
| // console.log($scope.options_size); | |
| }; | |
| $scope.is_new_production=true; | |
| $scope.getAutoriaForUser = function(advancedEditor, callback, request) { | |
| //loadingOn('Carregando editor...'); | |
| var user_id = data_form.user_id; | |
| if (!angular.isDefined(request) || request.activity_id == null || request.section_id == null) { | |
| $rootScope.alertMessageInfo('Não existem dados para estes parâmetros!') | |
| window.location.href = '/webapp/erro-404'; | |
| } else { | |
| if ((request.edition_id + request.section_id + request.activity_id) == 0) { | |
| $rootScope.alertMessageInfo('Falta de parâmetros requeridos: edição, seção e atividade!'); | |
| window.location.href = '/webapp/erro-404'; | |
| } | |
| var url = PATH_PRO + 'api/get-autoria-usuario'; | |
| $.ajax({ | |
| url: url + '/?rand=' + randUrl(), | |
| type: 'post', | |
| data: { | |
| edition_id: request.edition_id, | |
| section_id: request.section_id, | |
| activity_id: request.activity_id, | |
| user_id: user_id, | |
| csrf_token: csrf, | |
| token: getToken(url) | |
| }, | |
| dataType: 'json', | |
| timeout:60000, | |
| success: function (response) { | |
| if (response.status == true) { | |
| $scope.is_new_production = false; | |
| var contentAutoria = response.autoria; | |
| $scope.autoria_id = contentAutoria.autoria_id; | |
| $scope.autoria_section_title = contentAutoria.section_title; | |
| $scope.is_published = response.sended_version_to_teacher; | |
| callback($scope.autoria_id); | |
| if (contentAutoria.extra_1 != null && contentAutoria.extra_1 != '' && contentAutoria.extra_1 != 'extra_1') { | |
| advancedEditor.setContents(jQuery.parseJSON(contentAutoria.extra_1)); | |
| $rootScope.hasChangesProducaoTexto = false; | |
| data_form.start_game = false; | |
| } | |
| $scope.tools.show_proposta=false; | |
| $rootScope.has_first_click_close_prop=false; | |
| } else { | |
| $scope.tools.show_proposta=true; | |
| $scope.is_new_production = true; | |
| $(document).find('.ql-editor') | |
| .on('click', function(){ | |
| if(!$rootScope.has_first_click_close_prop) { | |
| $scope.closeProposta(); | |
| } | |
| $rootScope.has_first_click_close_prop = true; | |
| }); | |
| callback(null); | |
| } | |
| loadingOff(''); | |
| }, | |
| error: function(data) { | |
| if(typeof data_form !== 'undefined'){ | |
| if (data.status != 404 && data_form.withOutInternet == false){ | |
| data_form.withOutInternet = true; | |
| } | |
| } | |
| loadingOff(''); | |
| $rootScope.toastMessage("danger","ERRO DE CONEXÃO","Erro ao enviar informações, você pode estar sem internet, tente novamente.", 1400); | |
| }, | |
| fail: function (error) { | |
| $rootScope.toastMessage("danger", "ERRO DE CONEXÃO", error.responseJSON, 1400); | |
| loadingOff(''); | |
| } | |
| }); | |
| } | |
| }; | |
| $scope.stopAutoSaveAutoria = function() { | |
| $(document).stop(true).stopTime('startAutoSave'); | |
| $scope.autosave_autoria = false; | |
| }; | |
| $scope.updatePointsWithUserID = function(user_id, activity_id, points, callback) { | |
| // | |
| var token = readCookie("gutentoken"); | |
| var params = "gutentoken="+token+"&gutenemail="+data_form.email; | |
| var url = "/"+FOLDER_ADM+"/add-points-app.php?user_id="+user_id+"&activity_id="+activity_id+"&points="+points; | |
| $.ajax({ | |
| url: url, | |
| type: "POST", | |
| data: params, | |
| dataType: "json", | |
| timeout:60000, | |
| success: function(data) { | |
| if (data.status=="200") { | |
| if (angular.isDefined(data_form)) { | |
| data_form.played = true; | |
| } | |
| callback(parseFloat(data.percent)); | |
| } else { | |
| showAlertGuten(data.message); | |
| callback(0); | |
| } | |
| } | |
| }); | |
| }; | |
| $scope.sendDataWithAction_type = function(user_id, action_type, action_id, data_type, value, start, end, seconds_time, question_id, acerto, success, error, async) { | |
| var dataSave = { | |
| activity_id: action_id, | |
| value: value, | |
| action_type: action_type, | |
| data_type: data_type, | |
| question_id:question_id, | |
| descritor:value, | |
| step:'', | |
| change_alternative:'', | |
| start_date:'', | |
| end_date:'', | |
| timeoff:seconds_time, | |
| status_acerto: acerto | |
| }; | |
| GamesService.saveCurrentActivity(dataSave) | |
| .then(function (result) { | |
| if (result.status) { | |
| $scope.seconds = 0; | |
| } else { | |
| if (angular.isDefined(data_form)) { | |
| if (data.status != 404 && data_form.withOutInternet == false){ | |
| data_form.withOutInternet = true; | |
| } | |
| } | |
| $rootScope.alertMessageInfo("Erro ao enviar informações, você pode estar sem internet, tente novamente."); | |
| } | |
| }, function (data) { | |
| $rootScope.alertMessageInfo(data, 'ERRO DE SISTEMA'); | |
| }); | |
| } | |
| //start time edition | |
| $scope.saveTimeEdition = function() { | |
| $scope.sendDataWithAction_type(data_form.user_id,"autoria", $scope.data_activity.ID, "time", "", "0", "0", $scope.seconds, "0", '', function(){ // success | |
| //NSLog(@"sendDataWithAction_type success. Timer."); | |
| }, function(){ // error | |
| //NSLog(@"sendDataWithAction_type error"); | |
| }); | |
| }; | |
| $scope.displayFile = function(file, key, url, hasChangesActual) { | |
| var user_id = data_form.user_id; | |
| var data = [ | |
| {input:'file',valor:file}, | |
| {input:'key',valor:key}, | |
| {input:'token',valor:getToken(url)}, | |
| {input:'user_id',valor:user_id} | |
| ]; | |
| $rootScope.hasChangesProducaoTexto = hasChangesActual; | |
| if ($scope.is_running_on_ipad) { | |
| createFormRedirectObjectIos('save_pdf', data, url); | |
| } else { | |
| createFormRedirectObject('save_pdf', data, url + '/?rand=' + randUrl()); | |
| } | |
| loadingOff(''); | |
| }; | |
| $scope.displayLightBoxImage = function() { | |
| $('#moldal_img_'+$scope.dataForm.user_id) | |
| .on('show.bs.modal', function(event) { | |
| $target = {}; | |
| ['title','large'].forEach(function(value, key) { | |
| $target[value] = $(event.relatedTarget).data(value); | |
| }); | |
| $('.modal-backdrop').remove(); | |
| $("#moldal_img_"+$scope.dataForm.user_id+" .modal-title").text('PROPOSTA DA ATIVIDADE'); | |
| $("#moldal_img_"+$scope.dataForm.user_id+" .modal-body").html('<div class="text-scroller-modal"><div class="box-text-scroller">'+$('.content-prop').html()+'</div></div><img src="'+$target.large+'" border="0" class="img-responsive">'); | |
| }); | |
| }; | |
| $scope.leaveEdition = function() { | |
| window.onbeforeunload = function(e) { | |
| if ($rootScope.hasChangesProducaoTexto && !$scope.forceLeave && ($location.path()).indexOf('atividade-texto/atividade/') !== -1) { | |
| e = e || window.event; | |
| e.preventDefault = true; | |
| e.cancelBubble = true; | |
| e.returnValue = 'Você não salvou sua produção de texto!'; | |
| }else{ | |
| $scope.stopAutoSaveAutoria(); | |
| } | |
| } | |
| }; | |
| $scope.generatePDF = function(fileName, startAutoSave) { | |
| var hasChangesActual = $rootScope.hasChangesProducaoTexto; | |
| $rootScope.hasChangesProducaoTexto = false; | |
| var myClone = $('#scrolling-container').clone(); | |
| var height = "100%"; | |
| if($scope.is_mobile) { | |
| height = "98%"; | |
| } | |
| var css = "html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,code,del,dfn,em,img,q,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:normal;vertical-align:baseline;list-style:none;font-size:100%;font-family:Helvetica}.ql-editor{box-sizing:border-box;cursor:text;line-height:1.42;height:"+height+";outline:none;overflow-y:auto;padding:12px 15px;tab-size:4;-moz-tab-size:4;text-align:left;white-space:pre-wrap;word-wrap:break-word}.ql-editor p,.ql-editor ol,.ql-editor ul,.ql-editor pre,.ql-editor blockquote,.ql-editor h1,.ql-editor h2,.ql-editor h3,.ql-editor h4,.ql-editor h5,.ql-editor p{line-height:180%},.ql-editor h6{margin:0;padding:0;counter-reset:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol,.ql-editor ul{padding-left:1.5em}.ql-editor ol > li,.ql-editor ul > li{list-style-type:none}.ql-editor ul > li::before{content:'\2022'}.ql-editor ul[data-checked=true],.ql-editor ul[data-checked=false]{pointer-events:none}.ql-editor ul[data-checked=true] > li::before,.ql-editor ul[data-checked=false] > li::before{color:#777;cursor:pointer;pointer-events:all}.ql-editor ul[data-checked=true] > li::before{content:'\2611'}.ql-editor ul[data-checked=false] > li::before{content:'\2610'}.ql-editor li::before{display:inline-block;margin-right:0.3em;text-align:right;white-space:nowrap;width:1.2em}.ql-editor li:not(.ql-direction-rtl)::before{margin-left:-1.5em}.ql-editor ol li,.ql-editor ul li{padding-left:1.5em}.ql-editor ol li{counter-reset:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;counter-increment:list-num}.ql-editor ol li:before{content:counter(list-num, decimal) '. '}.ql-editor ol li.ql-indent-1{counter-increment:list-1}.ql-editor ol li.ql-indent-1:before{content:counter(list-1, lower-alpha) '. '}.ql-editor ol li.ql-indent-1{counter-reset:list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-2{counter-increment:list-2}.ql-editor ol li.ql-indent-2:before{content:counter(list-2, lower-roman) '. '}.ql-editor ol li.ql-indent-2{counter-reset:list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-3{counter-increment:list-3}.ql-editor ol li.ql-indent-3:before{content:counter(list-3, decimal) '. '}.ql-editor ol li.ql-indent-3{counter-reset:list-4 list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-4{counter-increment:list-4}.ql-editor ol li.ql-indent-4:before{content:counter(list-4, lower-alpha) '. '}.ql-editor ol li.ql-indent-4{counter-reset:list-5 list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-5{counter-increment:list-5}.ql-editor ol li.ql-indent-5:before{content:counter(list-5, lower-roman) '. '}.ql-editor ol li.ql-indent-5{counter-reset:list-6 list-7 list-8 list-9}.ql-editor ol li.ql-indent-6{counter-increment:list-6}.ql-editor ol li.ql-indent-6:before{content:counter(list-6, decimal) '. '}.ql-editor ol li.ql-indent-6{counter-reset:list-7 list-8 list-9}.ql-editor ol li.ql-indent-7{counter-increment:list-7}.ql-editor ol li.ql-indent-7:before{content:counter(list-7, lower-alpha) '. '}.ql-editor ol li.ql-indent-7{counter-reset:list-8 list-9}.ql-editor ol li.ql-indent-8{counter-increment:list-8}.ql-editor ol li.ql-indent-8:before{content:counter(list-8, lower-roman) '. '}.ql-editor ol li.ql-indent-8{counter-reset:list-9}.ql-editor ol li.ql-indent-9{counter-increment:list-9}.ql-editor ol li.ql-indent-9:before{content:counter(list-9, decimal) '. '}.ql-editor .ql-indent-1:not(.ql-direction-rtl){padding-left:3em}.ql-editor li.ql-indent-1:not(.ql-direction-rtl){padding-left:4.5em}.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right{padding-right:3em}.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right{padding-right:4.5em}.ql-editor .ql-indent-2:not(.ql-direction-rtl){padding-left:6em}.ql-editor li.ql-indent-2:not(.ql-direction-rtl){padding-left:7.5em}.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right{padding-right:6em}.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right{padding-right:7.5em}.ql-editor .ql-indent-3:not(.ql-direction-rtl){padding-left:9em}.ql-editor li.ql-indent-3:not(.ql-direction-rtl){padding-left:10.5em}.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right{padding-right:9em}.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right{padding-right:10.5em}.ql-editor .ql-indent-4:not(.ql-direction-rtl){padding-left:12em}.ql-editor li.ql-indent-4:not(.ql-direction-rtl){padding-left:13.5em}.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right{padding-right:12em}.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right{padding-right:13.5em}.ql-editor .ql-indent-5:not(.ql-direction-rtl){padding-left:15em}.ql-editor li.ql-indent-5:not(.ql-direction-rtl){padding-left:16.5em}.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right{padding-right:15em}.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right{padding-right:16.5em}.ql-editor .ql-indent-6:not(.ql-direction-rtl){padding-left:18em}.ql-editor li.ql-indent-6:not(.ql-direction-rtl){padding-left:19.5em}.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right{padding-right:18em}.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right{padding-right:19.5em}.ql-editor .ql-indent-7:not(.ql-direction-rtl){padding-left:21em}.ql-editor li.ql-indent-7:not(.ql-direction-rtl){padding-left:22.5em}.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right{padding-right:21em}.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right{padding-right:22.5em}.ql-editor .ql-indent-8:not(.ql-direction-rtl){padding-left:24em}.ql-editor li.ql-indent-8:not(.ql-direction-rtl){padding-left:25.5em}.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right{padding-right:24em}.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right{padding-right:25.5em}.ql-editor .ql-indent-9:not(.ql-direction-rtl){padding-left:27em}.ql-editor li.ql-indent-9:not(.ql-direction-rtl){padding-left:28.5em}.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right{padding-right:27em}.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right{padding-right:28.5em}.ql-editor .ql-video{display:block;max-width:100%}.ql-editor .ql-video.ql-align-center{margin:0 auto}.ql-editor .ql-video.ql-align-right{margin:0 0 0 auto}.ql-editor .ql-bg-black{background-color:#000}.ql-editor .ql-bg-red{background-color:#e60000}.ql-editor .ql-bg-orange{background-color:#f90}.ql-editor .ql-bg-yellow{background-color:#ff0}.ql-editor .ql-bg-green{background-color:#008a00}.ql-editor .ql-bg-blue{background-color:#06c}.ql-editor .ql-bg-purple{background-color:#93f}.ql-editor .ql-color-white{color:#fff}.ql-editor .ql-color-red{color:#e60000}.ql-editor .ql-color-orange{color:#f90}.ql-editor .ql-color-yellow{color:#ff0}.ql-editor .ql-color-green{color:#008a00}.ql-editor .ql-color-blue{color:#06c}.ql-editor .ql-color-purple{color:#93f}.ql-editor .ql-font-serif{font-family:georgia, times-roman, serif}.ql-editor .ql-font-monospace{font-family:Monaco, Courier New, monospace}.ql-editor .ql-size-small{font-size:0.75em}.ql-editor .ql-size-large{font-size:1.5em}.ql-editor .ql-size-huge{font-size:2.5em}.ql-editor .ql-direction-rtl{direction:rtl;text-align:inherit}.ql-editor .ql-align-center{text-align:center}.ql-editor .ql-align-justify{text-align:justify}.ql-editor .ql-align-right{text-align:right}.ql-editor.ql-blank::before{color:rgba(0,0,0,0.6);content:attr(data-placeholder);font-style:italic;pointer-events:none;position:absolute}#toolbar-container .ql-font span[data-label=\"Mirza\"]::before{font-family:\"mirza\"}#toolbar-container .ql-font span[data-label=\"roboto\"]::before{font-family:\"roboto\"}#toolbar-container .ql-font span[data-label=\"Arial\"]::before{font-family:\"Arial\"}#toolbar-container .ql-font span[data-label=\"monospace\"]::before{font-family:monospace}#toolbar-container .ql-font span[data-label=\"tahoma\"]::before{font-family:Tahoma}#toolbar-container .ql-font span[data-label=\"helvetica\"]::before{font-family:Helvetica}#toolbar-container .ql-font span[data-label=\"sans-serif\"]::before{font-family:sans-serif}#toolbar-container .ql-font span[data-label=\"verdana\"]::before{font-family:Verdana}#toolbar-container .ql-font span[data-label=\"courier-new\"]::before{font-family:\"Courier New\"}#toolbar-container .ql-font span[data-label=\"courier\"]::before{font-family:\"courier\"}#toolbar-container .ql-font span[data-label=\"times\"]::before{font-family:\"Times\"}.ql-font-mirza{font-family:\"Mirza\"}.ql-font-roboto{font-family:\"Roboto\"}.ql-font-arial{font-family:\"Arial\"}.ql-font-verdana{font-family:Verdana}.ql-font-helvetica{font-family:Helvetica}.ql-font-sans-serif{font-family:sans-serif}.ql-font-monospace{font-family:monospace}.ql-font-courier-new{font-family:\"courier-new\"}.ql-font-courier{font-family:\"courier\"}.ql-font-times{font-family:\"times\"}.ql-editor img.imagem,.ql-editor img{max-width:700px}"; | |
| $(myClone) | |
| //.find('span.ql-font-courier-new').attr('style', 'font-family: "Courier New"') | |
| .find('p.ql-align-justify').attr('style', 'text-align: justify;') | |
| .find('p.ql-align-right').attr('style', 'text-align: right') | |
| .find('p.ql-align-right').attr('style', 'text-align: right') | |
| .find('p.ql-align-center').attr('style', 'text-align: center') | |
| .find('.ql-align-center').attr('style', 'text-align: center') | |
| .find('em').removeClass('ql-align-center').attr('style', 'text-align: center'); | |
| $(myClone).find('.ql-align-center').removeClass('ql-align-center').attr('style', 'text-align:center'); | |
| $(myClone).find('p br').replaceWith(function () { | |
| return $('</p>', { | |
| html: '' | |
| }); | |
| }); | |
| $(myClone).find('u').replaceWith(function () { | |
| return '<span style="text-decoration: underline!important">' + this.outerHTML + '</span>' | |
| }); | |
| $(myClone).find('img').replaceWith(function () { | |
| return '<div class="img-box">' + this.outerHTML + '</div>' | |
| }); | |
| $(myClone).find('#editor-container .ql-clipboard').remove(); | |
| $(myClone).find('#editor-container .ql-tooltip').remove(); | |
| $(myClone).find('#editor-container').prepend('<style type="text/css">body { margin: 30px; font-family: helvetica, \"arial\", sans-serif} p {font-family: helvetica, \"arial\", sans-serif} .ql-editor {font-size: 12pt;} .ql-editor p {font-family: helvetica, arial, sans-serif} .ql-font-times { font-family: \"times\";} .ql-font-courier { font-family: \"courier\";} .legend .box-info-aluno {padding: 8px; width: 100%}</style>'); | |
| $(myClone).find('#editor-container').prepend('<style type="text/css">.legend{border: 1px solid #81c02e;font-size: 10px; line-height: 11px; display: block; width: 100%;} .box-info-aluno p { line-height: 13px} p strong.ql-font-courier {font-family:courier}</style>'); | |
| var contentEditor = $(myClone).find('#editor-container'); | |
| var content = contentEditor.html(); | |
| var base64content = Base64.encode('<!doctype html><html><title>' + fileName + '</title><body>' + content + '</body></html>'); | |
| var url = PATH_PRO + 'api/save-pdf'; | |
| var user_id = data_form.user_id; | |
| var data = { | |
| content: base64content, | |
| title: $.trim(fileName), | |
| section_id: $scope.requestParams.section_id, | |
| edition_id: $scope.requestParams.edition_id, | |
| activity_id: $scope.requestParams.activity_id, | |
| class_id: $scope.data_autoria.class_id, | |
| school_id: data_form.id_instituicao, | |
| user_id: user_id, | |
| token: getToken(url), | |
| csrf_token: csrf | |
| }; | |
| $.ajax({ | |
| url: url + '/?rand=' + randUrl(), | |
| type: 'POST', | |
| dataType: 'json', | |
| timeout: 60000, | |
| data: data, | |
| // beforeSend:function(){ | |
| // loadingOn('Carregando PDF da autoria...'); | |
| // }, | |
| success: function (rtn) { | |
| if (rtn.status) { | |
| $scope.displayFile(rtn.file, rtn.key, PATH_PRO + 'api/display-pdf', hasChangesActual); | |
| } else { | |
| loadingOff(''); | |
| $rootScope.alertMessageInfo(rtn.message); | |
| } | |
| }, | |
| error: function (data) { | |
| $scope.on_error=true; | |
| if (angular.isDefined(data_form) !== 'undefined') { | |
| if (data.status != 404 && data_form.withOutInternet == false) { | |
| data_form.withOutInternet = true; | |
| } | |
| } | |
| loadingOff(''); | |
| $rootScope.alertMessageInfo("Erro ao enviar informações, você pode estar sem internet, tente novamente."); | |
| } | |
| }); | |
| }; | |
| $scope.doDownload = function(){ | |
| $scope.autoSave($scope.params_autoria.editor, $scope.params_autoria.autoria_id); | |
| loadingOn('Baixando autoria...'); | |
| var filename = $('.download-pdf').data('filename'); | |
| $scope.permissionAutoSaveAutoria = false; | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.generatePDF(filename, function(){ | |
| $scope.permissionAutoSaveAutoria = true; | |
| }); | |
| }; | |
| // $(function(){ | |
| // var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; | |
| // $(document) | |
| // .find('.ql-bold').on('click', function() { | |
| // if(iOS) { | |
| // var e = $.Event('keydown', 'command+b');// right arrow key | |
| // } else { | |
| // var e = $.Event('keydown', 'ctrl+b');// right arrow key | |
| // } | |
| // $(this).parent().trigger(e); | |
| // }) | |
| // .find('.ql-italic').on('click', function() { | |
| // if(iOS) { | |
| // var e = $.Event('keydown', 'command+i');// right arrow key | |
| // } else { | |
| // var e = $.Event('keydown', 'ctrl+i');// right arrow key | |
| // } | |
| // $(this).parent().trigger(e); | |
| // }) | |
| // .find('.ql-underline').on('click', function() { | |
| // if(iOS) { | |
| // var e = $.Event('keydown', 'command+u');// right arrow key | |
| // } else { | |
| // var e = $.Event('keydown', 'ctrl+u');// right arrow key | |
| // } | |
| // $(this).parent().trigger(e); | |
| // }); | |
| // }); | |
| $scope.downloadFile = function(quill) { | |
| content = JSON.stringify(quill) | |
| extra_1 = content;//$rootScope.QuillEditorToHTML(content); | |
| var dados_autorias; | |
| dados_autorias = [{'first_name': $scope.dataForm.name, | |
| 'content' : extra_1, | |
| 'atividade' : { | |
| 'title': $scope.content.data_activity.title, | |
| 'type_variation' : 2, | |
| 'class_id' : $scope.data_autoria.section_id | |
| } | |
| }]; | |
| var type = 2; | |
| var dados = []; | |
| dados.materia = $scope.content.data_activity.id_section + ' - ' + $scope.autoria_section_title; | |
| dados.save_pdf = true; | |
| dados.is_content_base_64 = false; | |
| $rootScope.setDatacreatePDF(dados_autorias,type,dados) | |
| }; | |
| $scope.downloadPdf = function(quill) { | |
| doc = new jsPDF('p', 'pt', 'a4'); | |
| content = JSON.stringify(quill) | |
| extra_1 = $scope.QuillEditorToHTML(content); | |
| // console.log(extra_1) | |
| var name = $scope.dataForm.name; | |
| var materia = $scope.content.data_autoria.section_id + ' - ' + $scope.autoria_section_title | |
| var atividade = $scope.content.data_activity.title; | |
| var content_fundo = '/webapp/sistema/img/autoria/fundo_autoria_portrait.jpg'; | |
| $rootScope.getBase64ImageUrl(content_fundo,function(callBackImg){ | |
| doc.addImage(callBackImg,'JPEG',0,0,600,850); | |
| $scope.createHeader(doc,name,materia,atividade); | |
| if(extra_1){ | |
| var specialElementHandlers = { | |
| '.no-export': function(element, renderer) { | |
| return true; | |
| } | |
| }; | |
| var source = extra_1; | |
| var margins = { | |
| top: 160, | |
| bottom: 25, | |
| left: 40, | |
| width: 500 | |
| }; | |
| doc.fromHTML( | |
| source, // HTML string or DOM elem ref. | |
| margins.left, | |
| margins.top, { | |
| 'width': margins.width, | |
| 'elementHandlers': specialElementHandlers | |
| }, | |
| function(dispose) { | |
| var doc_name = materia + ".pdf"; | |
| doc.save(doc_name); | |
| }, margins); | |
| } | |
| }); | |
| } | |
| $scope.createHeader = function(doc,name,materia,atividade){ | |
| doc.setFontSize(11); | |
| doc.setFont("Helvetica"); | |
| doc.setFontType("bold"); | |
| doc.setTextColor(22,77,69); | |
| doc.text(40, 105, 'Nome: ' + name.trim()); | |
| doc.text(40, 120, 'Matéria: ' + materia); | |
| doc.text(40, 135, 'Atividade: ' + atividade.trim()); | |
| doc.setFontSize(12); | |
| doc.setFontType("normal"); | |
| return doc; | |
| } | |
| $scope.QuillEditorToHTML = function(json) { | |
| var contentQuil = ''; | |
| try{ | |
| contentQuil = QuillEditorService.getContent(json); | |
| if (angular.isDefined(contentQuil) && contentQuil != null) { | |
| return QuillEditorService.showHTMLPdf(contentQuil); | |
| } | |
| }catch(e){ | |
| console.log(e); | |
| return contentQuil | |
| } | |
| } | |
| $scope.startAutoSaveAutoria = function () { | |
| if (!$scope.autosave_autoria) { | |
| // | |
| $scope.autosave_autoria = true; | |
| $(document).everyTime('90s', 'startAutoSave',function () { | |
| if(!$rootScope.autosave_producao_texto){ | |
| $scope.stopAutoSaveAutoria(); | |
| } | |
| if ($scope.permissionAutoSaveAutoria == true && data_form.start_game && $rootScope.autosave_producao_texto) { | |
| if ($scope.params_autoria.hasOwnProperty('editor') && $scope.params_autoria.hasOwnProperty('autoria_id')) { | |
| if (angular.isDefined(data_form)) { | |
| // console.log("autosave"); | |
| data_form.start_game = true; | |
| } | |
| $scope.autoSave($scope.params_autoria.editor, $scope.params_autoria.autoria_id); | |
| } | |
| } | |
| }); | |
| } | |
| }; | |
| $scope.saveAutoria = function(displayInfo, advancedEditor, autoria_id, download, publish) { | |
| if(!$rootScope.hasChangesProducaoTexto) { | |
| $rootScope.toastMessage('warning', 'Atenção', 'Não existem alterações novas para salvar!', 5000); | |
| } else { | |
| if (displayInfo) { | |
| if (publish) { | |
| loadingOn('Salvando e publicando sua produção textual...'); | |
| } else { | |
| loadingOn('Salvando produção...'); | |
| } | |
| } | |
| $scope.is_new_production = false; | |
| advancedEditor.root.setAttribute('data-gramm', 'false'); | |
| var content = advancedEditor.getContents(); | |
| console.log(JSON.stringify(content)); | |
| var url = PATH_PRO + 'api/salvar-autoria-usuario'; | |
| var fulltext = $('.ql-editor').text(); | |
| try { | |
| if (angular.isDefined($scope.current_focus)) { | |
| advancedEditor.setSelection($scope.current_focus.index, $scope.current_focus.length); | |
| } | |
| } catch(e){ | |
| } | |
| if (angular.isDefined($scope.requestParams)) { | |
| if ($scope.requestParams != null && $scope.data_autoria != null && (displayInfo || (!displayInfo && $rootScope.hasChangesProducaoTexto))) { | |
| var dados = { | |
| usr_id: data_form.user_id, | |
| edition_id: $scope.requestParams.edition_id, | |
| section_id: $scope.requestParams.section_id, | |
| activity_id: $scope.requestParams.activity_id, | |
| autoria: { | |
| fulltext: fulltext, | |
| extra_1: JSON.stringify(content) | |
| }, | |
| csrf_token: csrf, | |
| token: getToken(url) | |
| }; | |
| if (autoria_id != null) { | |
| dados.autoria.autoria_id = autoria_id; | |
| var first_save = true; | |
| } else { | |
| var first_save = false; | |
| } | |
| $.ajax({ | |
| url: url + '/?rand=' + randUrl(), | |
| type: 'post', | |
| data: dados, | |
| dataType: 'json', | |
| timeout: 60000, | |
| success: function (response) { | |
| if (response.status == true) { | |
| loadingOff(''); | |
| $scope.is_published = response.sended_version_to_teacher; | |
| //$scope.getReviewsForStudent($scope.requestParams.activity_id, true); | |
| advancedEditor.root.setAttribute('data-gramm', 'false'); | |
| if (typeof data_form !== 'undefined') { | |
| data_form.start_game = false; | |
| } | |
| var total_possible = parseInt($scope.data_activity.points_success); | |
| var contentAutoria = response.data_send.autoria; | |
| if (contentAutoria.extra_1 != null && contentAutoria.extra_1 != '' && contentAutoria.extra_1 != 'extra_1' && contentAutoria.extra_1 == JSON.stringify(advancedEditor.getContents())) { | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.display_dialog_publish = false; | |
| $scope.stopAutoSaveAutoria(); | |
| } | |
| if (!$scope.updateAutoria) { | |
| $scope.updatePointsWithUserID(data_form.user_id, $scope.data_autoria.activity_id, total_possible, function () { | |
| }); | |
| var question_id = "", | |
| descritor = $scope.data_activity.descritor; | |
| $scope.sendDataWithAction_type(data_form.user_id, "autoria", $scope.data_autoria.activity_id, "descritor", descritor, "0", "0", "", question_id, 1, function success() { // success | |
| }, function () { | |
| //error | |
| }); | |
| $scope.updateAutoria = true; | |
| } | |
| $scope.saveTimeEdition(); | |
| if (angular.isDefined(publish) && publish) { | |
| sendTeacherAvailable(advancedEditor); | |
| displayInfo = false; | |
| $scope.permissionAutoSaveAutoria = true; | |
| $scope.startAutoSaveAutoria(); | |
| } | |
| if (displayInfo) { | |
| $rootScope.toastMessage('success', 'Sucesso', 'A autoria foi salva com sucesso!', 2000); | |
| // | |
| //showAlertGutenNews('A autoria foi salva com sucesso!', "Sucesso", 'ok'); | |
| // if (first_save) { | |
| // //se salvou a primeira vez injeta os dados... | |
| // $scope.postData(); | |
| // } | |
| $scope.permissionAutoSaveAutoria = true; | |
| $scope.startAutoSaveAutoria(); | |
| } | |
| if (download) { | |
| $scope.doDownload(); | |
| } | |
| } | |
| }, | |
| error: function (data) { | |
| if (angular.isDefined(data_form)) { | |
| if (data.status != 404 && data_form.withOutInternet == false) { | |
| data_form.withOutInternet = true; | |
| } | |
| } | |
| loadingOff(''); | |
| $scope.permissionAutoSaveAutoria = true; | |
| $scope.startAutoSaveAutoria(); | |
| $rootScope.alertMessageInfo('Erro ao enviar informações, você pode estar sem internet, tente novamente.', 'Erro de conexão'); | |
| } | |
| }); | |
| } else { | |
| if (download) { | |
| $scope.doDownload(); | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| $rootScope.has_first_click_close_prop = false; | |
| $scope.toggleProposta = function() { | |
| $scope.tools.show_proposta=!$scope.tools.show_proposta; | |
| $scope.tools.show_revisoes=false; | |
| $rootScope.has_first_click_close_prop = true; | |
| }; | |
| $scope.toggleRevisoes = function() { | |
| $scope.tools.show_revisoes=!$scope.tools.show_revisoes; | |
| $scope.tools.show_proposta=false; | |
| }; | |
| $scope.closeProposta = function() { | |
| $scope.tools.show_proposta=false; | |
| }; | |
| $scope.closeRevisoes = function() { | |
| $scope.tools.show_revisoes=false; | |
| }; | |
| $scope.stopAutoSaveAutoria = function() { | |
| $(document).stop(true).stopTime('startAutoSave'); | |
| $scope.autosave_autoria = false; | |
| }; | |
| $scope.autoSave = function(advancedEditor, autoria_id) { | |
| $scope.saveAutoria(false,advancedEditor,autoria_id,false); | |
| }; | |
| $scope.saveAutoriaDefine = function(advancedEditor, autoria_id) { | |
| $scope.params_autoria = { | |
| editor:advancedEditor, | |
| autoria_id:autoria_id | |
| }; | |
| }; | |
| $scope.breakLineToParagraph = function(text) { | |
| text = '<p>' + text + '</p>'; | |
| return text; | |
| } | |
| $scope.currentZoom = 1; | |
| $scope.zoomIn = function() { | |
| var zoom = $scope.currentZoom += .1; | |
| if($scope.currentZoom < 1.6 && $scope.currentZoom > .0000006) { | |
| $scope.tools.zoom_style = { | |
| 'transform': 'scale(' + zoom + ')', | |
| '-webkit-transform': 'scale(' + zoom + ')', | |
| '-ms-transform': 'scale(' + zoom + ')', | |
| '-moz-transform': 'scale(' + zoom + ')', | |
| '-o-transform': 'scale(' + zoom + ')', | |
| 'transform-origin': '30vw 30vh', | |
| '-webkit-transform-origin': '30vw 30vh', | |
| '-ms-transform-origin': '30vw 30vh', | |
| '-moz-transform-origin': '30vw 30vh', | |
| '-o-transform-origin': '30vw 30vh' | |
| } | |
| } else { | |
| $scope.currentZoom=1; | |
| zoom=$scope.currentZoom; | |
| $scope.tools.zoom_style={} | |
| } | |
| }; | |
| $scope.zoomOut = function() { | |
| var zoom = $scope.currentZoom -= .1; | |
| if($scope.currentZoom < 1.6 && $scope.currentZoom > .0000006) { | |
| $scope.tools.zoom_style = { | |
| 'transform': 'scale(' + zoom + ')', | |
| '-webkit-transform': 'scale(' + zoom + ')', | |
| '-ms-transform': 'scale(' + zoom + ')', | |
| '-moz-transform': 'scale(' + zoom + ')', | |
| '-o-transform': 'scale(' + zoom + ')', | |
| 'transform-origin': '30vw 30vh', | |
| '-webkit-transform-origin': '30vw 30vh', | |
| '-ms-transform-origin': '30vw 30vh', | |
| '-moz-transform-origin': '30vw 30vh', | |
| '-o-transform-origin': '30vw 30vh' | |
| } | |
| } else { | |
| $scope.currentZoom=1; | |
| zoom=$scope.currentZoom; | |
| $scope.tools.zoom_style={} | |
| } | |
| }; | |
| $scope.numberOfPages=function(){ | |
| if (angular.isDefined($scope.content.reviews)) { | |
| return Math.ceil($scope.content.reviews.length / $scope.pageSize); | |
| } | |
| }; | |
| $scope.getReviewsForStudent = function(activity_id, openscreen) { | |
| $scope.loading_reviews = true; | |
| var params = { | |
| activity_id:activity_id, | |
| type_variation:'producao_texto', | |
| user_id:data_form.user_id | |
| }; | |
| AutoriaService.getReviewsForStudent(params) | |
| .then(function(rtn){ | |
| if(rtn.status) { | |
| $scope.currentPage = 0; | |
| $scope.pageSize = 5; | |
| $scope.content.reviews = []; | |
| for (var i in rtn.reviews) { | |
| if(rtn.reviews[i].version != null) { | |
| var k = i; | |
| rtn.reviews[i].version.extra_1 = $rootScope.loadTextQuillVersioned(rtn.reviews[i].version.extra_1); | |
| $scope.content.reviews.push(rtn.reviews[i]); | |
| } | |
| } | |
| if (typeof k !== 'undefined') { | |
| $scope.current_version = rtn.reviews[k]; | |
| $scope.change_version = rtn.reviews[k].version.version_number; | |
| } | |
| if ($scope.current_version > 5) { | |
| $scope.pageSize = 4; | |
| if($scope.is_mobile) { | |
| $scope.pageSize = 2; | |
| } | |
| } | |
| var newSize = $scope.numberOfPages(); | |
| $scope.loading_reviews = false; | |
| if ($scope.content.reviews.length > $scope.pageSize) { | |
| $scope.currentPage = newSize - 1 ; | |
| } | |
| $scope.is_versioned=rtn.is_versioned; | |
| if($scope.is_versioned) { | |
| //POR PADRÃO CARREGA A TELA ABERTA DE REVISÕES QUANDO HOUVER REVISÃO | |
| if(openscreen) { | |
| $scope.tools.show_revisoes = true; | |
| } | |
| } else { | |
| //POR PADRÃO CARREGA A TELA ABERTA DE PROPOSTA QUANDO NÃO HOUVER REVISÃO | |
| $scope.tools.show_proposta = true; | |
| } | |
| } | |
| },function(){ | |
| $scope.loading_reviews = false; | |
| }); | |
| }; | |
| $scope.saveClick = function() { | |
| $scope.active_drop_menu=false; | |
| $scope.stopAutoSaveAutoria(); | |
| $scope.permissionAutoSaveAutoria = false; | |
| $scope.saveAutoria(true, $scope.params_autoria.editor, $scope.params_autoria.autoria_id,false); | |
| }; | |
| $scope.sendTeacher = function() { | |
| if ($scope.is_published && !$rootScope.hasChangesProducaoTexto) { | |
| $rootScope.toastMessage("warning","Atenção","Faça uma alteração no texto caso deseje enviar uma nova versão ao professor!", 8000); | |
| } else { | |
| $rootScope.confirmMessageInfo("Atenção! Salvaremos as alterações antes de publicar. Depois de publicada, você não poderá realizar alterações nessa versão e ela será submetida à correção do professor.", function () { | |
| if ($rootScope.hasChangesProducaoTexto) { | |
| $scope.stopAutoSaveAutoria(); | |
| $scope.permissionAutoSaveAutoria = false; | |
| $scope.saveAutoria(true, $scope.params_autoria.editor, $scope.params_autoria.autoria_id, false, true); | |
| } else { | |
| sendTeacherAvailable($scope.params_autoria.editor); | |
| } | |
| }, "Publicar para o professor", null, { | |
| cancel:'Cancelar', | |
| ok:'Confirmar' | |
| }); | |
| } | |
| }; | |
| function sendTeacherAvailable(advancedEditor, callBackAlternative) { | |
| var data = { | |
| autoria: JSON.stringify(advancedEditor.getContents()), | |
| activity_id: $scope.requestParams.activity_id, | |
| type_variation:'producao_texto', | |
| user_id:data_form.user_id | |
| }; | |
| loadingOn('Aguarde, estamos enviando sua produção de texto para o professor revisar...'); | |
| AutoriaService.saveVersionAutoria(data) | |
| .then(function (rtn) { | |
| if (rtn.status) { | |
| $scope.is_versioned = rtn.is_versioned; | |
| $scope.is_published = true; | |
| $scope.getReviewsForStudent($scope.requestParams.activity_id, false); | |
| $rootScope.toastMessage('success', 'Sucesso', 'A publicação foi realizada com sucesso!', 4000); | |
| data_form.start_game=false; | |
| if(angular.isDefined(callBackAlternative)) { | |
| callBackAlternative(); | |
| } | |
| loadingOff(); | |
| } | |
| }, function () { | |
| loadingOff(); | |
| }); | |
| } | |
| $scope.downloadAutoria = function(advancedEditor, autoria_id) { | |
| $(document).on('click','.download-pdf', function(){ | |
| $scope.active_drop_menu=false; | |
| $scope.downloadFile(advancedEditor.getContents()); | |
| }); | |
| }; | |
| $(function(){ | |
| if ($scope.is_mobile || $scope.is_mobile_320 || $scope.is_mobile_400) { | |
| $('a, button:not(.toggle-btn-drop-mobile)').on('click', function(){ | |
| $scope.active_drop_menu = false; | |
| }); | |
| } | |
| }); | |
| function uploadImage() { | |
| $(document).on("click", ".add-image-uploader", function(){ | |
| $scope.stopAutoSaveAutoria(); | |
| var pic = $('#uploads').contents().find('#link').attr("link"); | |
| // | |
| if (typeof pic == "undefined"){ | |
| $rootScope.alertMessageInfo("Você deve fazer upload de alguma imagem antes de adicioná-la!"); | |
| } else { | |
| var obj = { | |
| url: pic, | |
| transform: "matrix(1, 0, 0, 1, 0, 0)" | |
| }; | |
| $rootScope.hasChangesProducaoTexto = true; | |
| addImage(obj); | |
| hideUploader(); | |
| //$(".images").append('<img ondragstart="return false;" class="img-'+img_index+' image" src="'+dataURL+'" style="max-width:850px; max-height:650px; position:absolute; top:0px; left:0px; pointer-events: all; transform: matrix(1, 0, 0, 1, 0, 0);" />'); | |
| } | |
| }); | |
| // $("#upload_menu").on("click", function() { | |
| // //alert("been here"); | |
| // document.getElementById("myinput").click(); | |
| // //$("#myinput").trigger("click"); | |
| // }); | |
| } | |
| $scope.setVersion = function(item) { | |
| $scope.change_version = item.version.version_number; | |
| $scope.current_version = item; | |
| }; | |
| $scope.toTrusted = function(someHTML) { | |
| var compiledVal = $compile(someHTML)($scope); | |
| var compiledHTML = $sce.trustAsHtml(compiledVal[0].outerHTML); | |
| return compiledHTML; | |
| }; | |
| $scope.convertTextToHTML = function(pre_text) { | |
| pre_text = $rootScope.setLinkUrl(pre_text); | |
| return pre_text.replace(/\n/gim, "<br />"); | |
| } | |
| $scope.postData = function() { | |
| loadingOn(''); | |
| $scope.read_only = false; | |
| $scope.dataRequest = { | |
| activity_id:$scope.requestParams.activity_id, | |
| section_id:$scope.requestParams.section_id | |
| }; | |
| $scope.loading_producao_texto = true; | |
| $(document).on('click', '.revision-text [data-id]', function(e){ | |
| e.stopImmediatePropagation(); | |
| var id = $(this).data('id'); | |
| var color = $(this).data('color'); | |
| var category = $(this).data('category'); | |
| var comment = $(this).data('note'); | |
| var html = '<h4 class="title-revision text-color-'+color+'">'+category.name+'</h4>'; | |
| html += '<p>Comentário: '+comment+'</p>'; | |
| $rootScope.alertMessageHTML(html,"Correção do professor"); | |
| }); | |
| ProducaoService.getEditorProducaoTexto($scope.dataRequest) | |
| .then(function (rtn) { | |
| if (rtn.status) { | |
| $scope.loading_producao_texto = false; | |
| loadingOff(''); | |
| $scope.content = { | |
| userId: data_form.user_id, | |
| text: $scope.convertTextToHTML(rtn.data.data_activity.person_name), | |
| data_activity: rtn.data.data_activity, | |
| data_autoria: rtn.data.data_autoria, | |
| reviews:[], | |
| revised_teacher:null | |
| }; | |
| $scope.data_autoria = rtn.data.data_autoria; | |
| $scope.data_activity = rtn.data.data_activity; | |
| var advancedEditor, autoria_id = $scope.autoria_id; | |
| var updateAutoria = false; | |
| $scope.hasQuill = false; | |
| if(!!Quill) { | |
| $scope.getQuillEditor(advancedEditor, function(editor) { | |
| if (angular.isDefined(editor)) { | |
| $scope.hasQuill = true; | |
| $scope.quillEditor = editor; | |
| $('[contenteditable]').attr("spellcheck",false) | |
| .removeAttr("data-gramm") | |
| .removeAttr("data-gramm_editor") | |
| .removeAttr("data-gramm_id"); | |
| var callback = function (result) { | |
| autoria_id = result; | |
| $('.save-drawing-cloud-text').attr('disabled', false); | |
| $scope.saveAutoriaDefine(editor, autoria_id); | |
| //TRÁS AS REVISÕES DO PROFESSOR POR PADRÃO | |
| if ($scope.is_version_enable) { | |
| $scope.getReviewsForStudent($scope.dataRequest.activity_id, true); | |
| } | |
| // $('.cust-clear-bold').click(function(ev) { | |
| // var range = editor.getSelection(); | |
| // if($(this).hasClass('ql-active')) { | |
| // if (range.length ===0) { | |
| // let leaf, offset = editor.getLeaf(range.index); | |
| // editor.removeFormat(range.index - offset, range.index + leaf.domNode.length); | |
| // } else { | |
| // editor.removeFormat(range.index, range.length); | |
| // } | |
| // } | |
| // }); | |
| }; | |
| $scope.getAutoriaForUser(editor, callback, $scope.requestParams); | |
| toggleWindowActivity(); | |
| toggleWindowRevision($scope.is_revised); | |
| scrollerProp(); | |
| uploadImage(); | |
| $scope.displayLightBoxImage(); | |
| $scope.downloadAutoria(editor, autoria_id); | |
| zoomPage(); | |
| } | |
| }); | |
| } | |
| } else { | |
| $scope.on_error=true; | |
| $scope.loading_producao_texto = false; | |
| loadingOff(); | |
| $rootScope.alertMessageInfo("Não existe uma atividade com estes parâmetros", "Atenção", 'atencao', function() { | |
| $location.path('/home'); | |
| }); | |
| } | |
| }).catch(function(e){ | |
| $scope.on_error=true; | |
| console.log(e); | |
| $rootScope.alertMessageInfo("Não existe uma atividade com estes parâmetros", "Atenção", 'atencao', function() { | |
| $location.path('/home'); | |
| }); | |
| // $window.location.reload(); | |
| //throw e; // rethrow to not marked as handled, | |
| // in $q it's better to `return $q.reject(e)` here | |
| }); | |
| }; | |
| $scope.publishCall = function(callback) { | |
| if ($rootScope.hasChangesProducaoTexto) { | |
| $scope.stopAutoSaveAutoria(); | |
| $scope.permissionAutoSaveAutoria = false; | |
| $scope.saveAutoria(true, $scope.params_autoria.editor, $scope.params_autoria.autoria_id, false, true); | |
| callback(); | |
| } else { | |
| sendTeacherAvailable($scope.params_autoria.editor, callback); | |
| } | |
| }; | |
| function matchStyles(node, delta) { | |
| const formats = {}; | |
| const style = node.style || {}; | |
| if (style.fontStyle === 'italic') { | |
| formats.italic = true; | |
| } | |
| if (style.textDecoration === 'underline') { | |
| formats.underline = true; | |
| } | |
| if (style.textDecoration === 'line-through') { | |
| formats.strike = true; | |
| } | |
| if ( | |
| style.fontWeight.startsWith('bold') || | |
| parseInt(style.fontWeight, 10) >= 700 | |
| ) { | |
| formats.bold = true; | |
| } | |
| if (Object.keys(formats).length > 0) { | |
| delta = applyFormat(delta, formats); | |
| } | |
| if (parseFloat(style.textIndent || 0) > 0) { | |
| // Could be 0.5in | |
| return new Delta().insert('\t').concat(delta); | |
| } | |
| return delta; | |
| } | |
| $scope.display_dialog_publish=false; | |
| $rootScope.confirmPublish = function(current, e) { | |
| $(document).find('.resize-item,.size-display-number').remove(); | |
| // console.log('current',current); | |
| // console.log('pre',pre); | |
| if (!$scope.is_published && !$rootScope.hasChangesProducaoTexto && !$scope.display_dialog_publish && !$scope.on_error) { | |
| $scope.display_dialog_publish=true; | |
| e.preventDefault(); | |
| $rootScope.checkIsPublich.display_dialog = true; | |
| $rootScope.confirmMessageInfo("Você ainda não publicou seu trabalho para o professor avaliar, deseja publicá-lo agora? Depois de publicado você não poderá realizar mais alterações nessa versão e ela será submetida a correção do professor. Salvaremos as alterações antes de enviar.",function(){ | |
| $scope.publishCall(function() { | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $rootScope.is_confirmed_published = true; | |
| $location.path(current.substring($location.absUrl().length - $location.url().length)); | |
| }); | |
| }, "Atenção", null, { | |
| cancel:'Apenas sair', | |
| ok:'Publicar' | |
| }, | |
| function(){ | |
| $location.path(current.substring($location.absUrl().length - $location.url().length)); | |
| // $location.path(current); | |
| }); | |
| } | |
| }; | |
| function confirmPublish(e, current, pre) { | |
| $rootScope.confirmPublish(current, e); | |
| } | |
| function confirmSave(e, current, pre) { | |
| $(document).find('.rule-actions').addClass('ng-hide'); | |
| $(document).find('.resize-item,.size-display-number').remove(); | |
| if ($rootScope.hasChangesProducaoTexto) { | |
| $scope.display_dialog_publish=true; | |
| e.preventDefault(); | |
| $rootScope.editorQuill = true; | |
| $timeout(function() { | |
| $rootScope.confirmMessageInfo("Se você sair agora desta atividade, perderá o que fez. Salve antes seu trabalho. Deseja realmente sair?",function(){ | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.stopAutoSaveAutoria(); | |
| $scope.forceLeave = true; | |
| $interval.cancel($scope.currentGame); | |
| data_form.start_game = false; | |
| $(".add-image-uploader").unbind('click'); | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $location.path(current.substring($location.absUrl().length - $location.url().length)); | |
| }, "Atenção", null, { | |
| cancel:'Cancelar', | |
| ok:'Sair' | |
| }, function(){ | |
| $(document).find('.rule-actions').removeClass('ng-hide'); | |
| $rootScope.editorQuill=true; | |
| }); | |
| }); | |
| } | |
| } | |
| $scope.$on('$locationChangeStart', confirmSave); | |
| $scope.$on('$locationChangeStart', confirmPublish); | |
| // $scope.backCaderno2 = function () { | |
| // var secao = $routeParams.secao; | |
| // | |
| // if ($rootScope.hasChangesProducaoTexto) { | |
| // | |
| // $rootScope.confirmMessageInfo("Se você sair agora desta atividade, perderá o que fez. Salve antes seu trabalho. Deseja realmente sair?", | |
| // function(){ | |
| // $scope.stopAutoSaveAutoria(); | |
| // $scope.forceLeave = true; | |
| // $rootScope.hasChangesProducaoTexto = false; | |
| // $interval.cancel($scope.currentGame); | |
| // $location.path('/caderno-atividades/' + secao + '/caderno'); | |
| // // window.location.href='/webapp/caderno-atividades/' + secao + '/caderno'; | |
| // }, "ATENÇÃO"); | |
| // } else { | |
| // if(!$scope.is_published && !$scope.is_new_production) { | |
| // $scope.display_dialog_publish=true; | |
| // $rootScope.confirmMessageInfo("Você ainda não publicou seu trabalho para o professor avaliar, deseja publicá-lo agora? Depois de publicado você não poderá realizar mais alterações nessa versão e ela será submetida a correção do professor. Salvaremos as alterações antes de enviar.", | |
| // function(){ | |
| // | |
| // $scope.publishCall(function() { | |
| // $scope.stopAutoSaveAutoria(); | |
| // $interval.cancel($scope.currentGame); | |
| // $location.path('/caderno-atividades/' + secao + '/caderno'); | |
| // }); | |
| // // window.location.href='/webapp/caderno-atividades/' + secao + '/caderno'; | |
| // }, "ATENÇÃO", null, { | |
| // cancel:'Apenas sair', | |
| // ok:'Publicar' | |
| // }, function(){ | |
| // $scope.stopAutoSaveAutoria(); | |
| // $interval.cancel($scope.currentGame); | |
| // $location.path('/caderno-atividades/' + secao + '/caderno'); | |
| // }); | |
| // } else { | |
| // $scope.stopAutoSaveAutoria(); | |
| // $interval.cancel($scope.currentGame); | |
| // $location.path('/caderno-atividades/' + secao + '/caderno'); | |
| // } | |
| // } | |
| // | |
| // }; | |
| $scope.backCaderno = function(){ | |
| var secao = $routeParams.secao; | |
| $scope.stopAutoSaveAutoria(); | |
| $interval.cancel($scope.currentGame); | |
| if( localStorage.getItem('_origin_pt') == 'gallery') { | |
| localStorage.removeItem('_origin_pt'); | |
| $location.path('/minhas-producoes/'); | |
| } else { | |
| $location.path('/caderno-atividades/' + secao + '/caderno'); | |
| } | |
| } | |
| $scope.active_drop_menu = false; | |
| $scope.toggleActiveDropMenuMobile = function() { | |
| $scope.active_drop_menu=!$scope.active_drop_menu; | |
| }; | |
| $scope.setFullscreen = function () { | |
| if ($($window).width() < 1366 || $($window).height() < 768 || $rootScope.fullscreen) { | |
| $scope.fullscreenWindow(); | |
| } else { | |
| $rootScope.fullscreen = false; | |
| $('.content-app-webapp2').removeClass('fullscreen'); | |
| $('#close_btn_fullscreen').hide(); | |
| $('.btn-maximize').show(); | |
| } | |
| }; | |
| $scope.fullscreenWindow = function () { | |
| $rootScope.fullscreen = true; | |
| $('.content-app-webapp2').addClass('fullscreen'); | |
| $('#close_btn_fullscreen').show(); | |
| if($('.content-app-webapp2').find('#close_btn_fullscreen').length==0) { | |
| var tk_os = checkCookies('tk_os'), toggle = 'data-toggle="tooltip" title="Fechar tela cheia" '; | |
| if (isTouch() || (tk_os == 'iphone' || tk_os == 'android')) { | |
| toggle = ""; | |
| } | |
| $('.content-app-webapp2').append('<button '+toggle+'id="close_btn_fullscreen" onclick="closeFullscreen()" ng-click="closeFullscreen()" class="close-fullscreen"><i class="fa fa-search-minus" aria-hidden="true"></i></button>'); | |
| } | |
| var $el = $('#close_btn_fullscreen'); | |
| $('body').addClass('full-iframe-window'); | |
| $('.btn-maximize').hide(); | |
| $compile($el)($scope); | |
| }; | |
| $scope.setTimeAutoria = function (data_return) { | |
| $interval.cancel($scope.currentGame); | |
| $scope.currentGame = $interval(function () { | |
| //console.log("passou "+ $scope.seconds); | |
| $scope.seconds++; | |
| }, 1000); | |
| } | |
| $scope.removeTooltipMobile = function() { | |
| if (!$scope.is_mobile) { | |
| $timeout(function () { | |
| $('[data-toggle="tooltip"]').tooltip(); | |
| }, 2000); | |
| } else { | |
| $timeout(function () { | |
| $('[title]').removeAttr('title'); | |
| $('[data-toggle="tooltip"]') | |
| .removeAttr('title') | |
| .tooltip('disable'); | |
| }, 2000); | |
| } | |
| $('[contenteditable="true"]').on('focus', function(e) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px. | |
| }); | |
| } | |
| $scope.init = function () { | |
| $('[data-quill]').remove(); | |
| $rootScope.addScriptQuillProducaoTexto = true; | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.$parent.init(); | |
| $scope.postData(); | |
| $scope.seconds = 0; | |
| $rootScope.autosave_producao_texto = true; | |
| // $scope.setFullscreen(); | |
| $scope.getSizeOptions(); | |
| $scope.leaveEdition(); | |
| $scope.setTimeAutoria(); | |
| $scope.verifyIsMobile(); | |
| // $scope.removeTooltipMobile(); | |
| }; | |
| var doc = $(document), body_class = '.producao-texto-view-index '; | |
| doc.ready(function () { | |
| $scope.init(); | |
| $(document).on('mouseover mouseup mouseout touchstart', '.content-text-review [data-id], .dialog-tooltip', function(e){ | |
| var _self = $(this); | |
| _self.removeAttr('title'); | |
| // console.log(e.type); | |
| var id = $(this).data('id'), text = $(this).data('note'), title = $(this).data('text') | |
| if (e.type == 'mouseover' || e.type == 'mouseup' || e.type == 'mouseenter' || e.type == 'touchstart') { | |
| $('.dialog-tooltip').remove(); | |
| if ($('.dialog-tooltip').length < 1) { | |
| text = text.replace(/\n/gim, '<br>'); | |
| _self.parent().prepend( | |
| '<div id="comment_tooltip_' + id + '" class="dialog-tooltip">\ | |
| <div class="dialog"><h2>Comentário:</h2>\ | |
| <p>' + text + '</p>\ | |
| </div>\ | |
| </div>'); | |
| } | |
| } else { | |
| // console.log(_self.hasClass('dialog-tooltip'),_self.hasClass('color')) | |
| $('#comment_tooltip_' + id) | |
| .finish().fadeOut('slow', function () { | |
| $(this).remove(); | |
| }); | |
| } | |
| }); | |
| // $(document).on('click', '.content-text-review [data-id]',function(e){ | |
| // var $_this = $(this); | |
| // var message = $_this.data('note'); | |
| // $rootScope.alertMessageInfo(message, 'Revisão do professor'); | |
| // | |
| // }); | |
| doc.on('click', body_class+'#busca, .producao-texto-view #busca', function (e) { | |
| loadingOff(''); | |
| e.stopImmediatePropagation(); | |
| // console.log('click-busca-false', $rootScope.hasChangesProducaoTexto); | |
| $(body_class+'#busca, .producao-texto-view #busca').blur(); | |
| if ($rootScope.hasChangesProducaoTexto) { | |
| // console.log('click-busca-true', $rootScope.hasChangesProducaoTexto); | |
| $rootScope.confirmMessageInfo("Se realizar uma busca agora, você sairá desta atividade e perderá o que fez. Salve antes seu trabalho. Deseja realmente buscar?", | |
| function () { | |
| $(body_class+'#busca, .producao-texto-view #busca').focus(); | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.forceLeave = true; | |
| data_form.start_game = false; | |
| // doc.on('click', body_class+'.search-go', function () { | |
| // $rootScope.hasChangesProducaoTexto = false; | |
| // $scope.stopAutoSaveAutoria(); | |
| // $scope.forceLeave = true; | |
| // data_form.start_game = false; | |
| // $interval.cancel($scope.currentGame); | |
| // }); | |
| }, "Atenção", null, {cancel: 'Cancelar', ok: 'Buscar'}); | |
| return; | |
| } | |
| }) | |
| .on('click', body_class+'.search-go', function (e) { | |
| loadingOff(''); | |
| e.stopImmediatePropagation(); | |
| // console.log('click-busca', $rootScope.hasChangesProducaoTexto); | |
| $(body_class+'#busca').blur(); | |
| if ($rootScope.hasChangesProducaoTexto) { | |
| $rootScope.confirmMessageInfo("Se realizar uma busca agora, você sairá desta atividade e perderá o que fez. Salve antes seu trabalho. Deseja realmente buscar?", | |
| function () { | |
| // $(body_class+'#busca').focus(); | |
| $rootScope.hasChangesProducaoTexto = false; | |
| $scope.stopAutoSaveAutoria(); | |
| $scope.forceLeave = true; | |
| data_form.start_game = false; | |
| $interval.cancel($scope.currentGame); | |
| $timeout(function() { | |
| $(body_class+'.search-go').trigger('click'); | |
| }); | |
| }, "Atenção", null, {cancel: 'Cancelar', ok: 'Buscar'}); | |
| return; | |
| } | |
| }); | |
| var checkQuill = $interval(function() { | |
| if (angular.isDefined($scope.quillEditor)) { | |
| if ($scope.is_new_production) { | |
| // $scope.quillEditor.focus(); | |
| $interval.cancel(checkQuill); | |
| } | |
| } | |
| // var editor = document.getElementsByTagName('div.ql-editor')[0]; | |
| // editor.focus(); | |
| }, 500); | |
| }); | |
| $(function(){ | |
| //MÉTODO QUE DELETA A IMAGEM PEGANDO A ID POR REFERÊNCIA | |
| $scope.current_image_selected = null; | |
| $(document).on('click','.ql-editor .the-imagem', function(){ | |
| $scope.current_image_selected = '#'+this.id; | |
| // var id = $(this).attr('id'); | |
| // $(this).wrap('<p id="resize_img_'+id+'" class="resizing"></p>'); | |
| // $('#resize_img_'+id).resizable({ | |
| // alsoResize: "#resize_img_"+id+" img" | |
| // }); | |
| // $(document.body).append('<div class="btns-pallete" style="position: absolute; z-index: 600; padding: 10px; backgroud: #fff; border: 1px solid #000; left: '+$(this).position().left+'px; top:'+$(this).position().top+'px"><button>esquerda</button> <button>direita</button></div>'); | |
| var delkey=46, | |
| cdmDelKey=8; | |
| $(document).keydown(function(event) { | |
| if ($rootScope.selectedTab == 'producao-texto' && $scope.current_image_selected != null) { | |
| var e = event || window.event; | |
| var code = e.keyCode || e.which; | |
| if (code == delkey || code == cdmDelKey) { | |
| $($scope.current_image_selected).remove(); | |
| } | |
| } | |
| }); | |
| }); | |
| }); | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment