PageSourceSearch

https://floram.org/javascripts/site.js?v=1790944462

js floram.org collected 2026-10-02 12:34:30 UTC 142,151 bytes, 3,569 lines download raw bytes

1// JavaScript Document
2/*To Minify :: http://javascript-minifier.com/ */
3
4$(document).foundation();
5/* STARTING FUNCTIONS
6=======================================
7¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
8$(window).load(function() {
9    EC_checkPlaceholder();
10    EC_journalPage_Behaviours();
11    EC_EditInPlace();
12    EC_archiveShowMore();
13});
14
15$(document).ready(function(){
16    EC_gotTopScrolling();
17    EC_searchButtonActions();
18    EC_topbarUserLinks();
19});
20
21
22/* GENERAL FUNCTIONS
23=======================================
24¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
25    //Setting base PHP vars
26    function setPHPVars(yiiBaseURL, userID, clientMongoID, userPreview, userJournal, currentLanguage, hasDomain){
27        window.yiiBaseURL = yiiBaseURL;
28        window.userID = userID;
29        window.clientMongoID = clientMongoID;
30        window.userJournal = userJournal;
31        window.currentLanguage = currentLanguage;
32        window.hasDomain = hasDomain;
33    }
34
35    //check placeholder_support
36    function EC_checkPlaceholder(){
37       var _debug = false;
38        var _placeholderSupport = function() {
39            var t = document.createElement("input");
40            t.type = "text";
41            return (typeof t.placeholder !== "undefined");
42        }();
43    }
44
45    //go top actions
46    function EC_gotTopScrolling(){
47        $(window).scroll(function() {
48            if($('body').scrollTop() <= 100){
49                $('#bigScreen-go-top').fadeOut();
50            }else{
51                $('#bigScreen-go-top').fadeIn();
52            }
53        });
54
55        $(window).scroll(function() {
56            if($('body').scrollTop() <= 50){
57                $('#faqPage-button').addClass('hide-top');
58            }else{
59                $('#faqPage-button').removeClass('hide-top');
60            }
61        });
62
63        $('#bigScreen-go-top').click(function(){
64            $("html, body").animate({ scrollTop: 0 }, 300);
65            return false;
66        })
67    }
68
69    //archive - "show more" link
70    function EC_archiveShowMore(){
71        $('.to_see a').click(function(){
72            height = $('.to_show').height();
73            $('hr.custom').hide();
74            $(this).hide();
75            $(".to_hide").css("overflow","visible").animate({height:height+520},800);
76        });
77    }
78
79        //make all columns have the same height
80        // $('.yearBlock2').css({'transition':'all 0.4s ease'});
81        // $(document).ready(function() {
82        //     var maxHeight = -1;
83        //     $('.yearBlock2').each(function() {
84        //         maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
85        //     });
86        //     $('.yearBlock2').each(function() {
87        //         $(this).css('min-height', maxHeight+15);
88        //     });
89        // });
90
91        // $(window).load(function() {
92        //     var maxHeight = -1;
93        //     $('.yearBlock2').each(function() {
94        //         maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
95        //     });
96        //     $('.yearBlock2').each(function() {
97        //         $(this).css('min-height', maxHeight+15);
98        //     });
99        // });
100
101        // $('.yearBlock').css({'transition':'all 0.4s ease'});
102        // $(document).ready(function() {
103        //     var maxHeight = -1;
104        //     $('.yearBlock').each(function() {
105        //         maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
106        //     });
107        //     $('.yearBlock').each(function() {
108        //         $(this).css('min-height', maxHeight+25);
109        //     });
110
111        //       var aHeight = $('#journals-list .row').height();
112        //     console.log(aHeight);
113        //     if(aHeight >= 440 && aHeight <= 850){
114        //         $('#journals-list ').css('min-height', aHeight+240+'px');
115        //     }
116        // });
117
118        // $(window).load(function() {
119        //     var maxHeight = -1;
120        //     $('.yearBlock').each(function() {
121        //         maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
122        //     });
123        //     $('.yearBlock').each(function() {
124        //         $(this).css('min-height', maxHeight+25);
125        //     });
126        // });
127
128
129
130    //friendly console log
131    function journalConsoleLog(isGuest, isOwner, jName, userName){
132        var consoleJTitle = "font-size: 14px; background:#efefef; padding: 0 10px; border-bottom:1px dashed #000";
133        var consoleBoolean = "color:blue";
134        var date = new Date();
135        var n = date.toDateString();
136        var time = date.toLocaleTimeString();
137
138        console.log("%c"+jName, consoleJTitle);
139        console.log("Welcome "+userName);
140        console.log("We hope you enjoy your stay! ◕‿◕");
141        console.log("");
142
143        if(isGuest == "true"){
144            if(isOwner == "true"){
145                console.log("- Can you edit this journal? %c"+"yes" , "color:green");
146            }else{
147                console.log("- Can you edit this journal? %c"+"no :(" , "color:red");
148            }
149            console.log('');
150        }
151
152        console.log('%c'+n + ' ' + time , 'background: #666; color: yellow; padding:0px 5px; border-radius:100px;');
153    }
154
155    //search button actions
156    function EC_searchButtonActions(){
157        $('#btnSearch').click(function(){
158            $('#searchForm').submit();
159        });
160
161        $('#btnSearchSidebar').click(function(){
162            $('#searchFormSidebar').submit();
163        });
164
165        $('#btnSearchFooter').click(function(){
166            $('#searchFormFooter').submit();
167        });
168    }
169
170    // Journal page actions
171    function EC_journalPage_Behaviours(){
172        $('#m-nav-journal-current-link').click(function(){
173            if($(this).hasClass('opened')){
174                $(this).removeClass('opened');
175                $('#m-journal-links-area').slideUp();
176
177            }else{
178                $(this).addClass('opened');
179                $('#m-journal-links-area').slideDown();
180            }
181        })
182
183        $(".show-all").click(function(){
184            $("#about-area").css("max-height","initial");
185            $(this).hide();
186        })
187    }
188
189    //tabs behaviour
190    function EC_tabsGeneral(page){
191        $('body').on('click','.tabs li', function(){
192            var target = '#'+$(this).children().attr('data-target');
193
194            $('.tabs li').removeClass('active');
195            $(this).addClass('active');
196
197            $('.tabs-content .content').removeClass('active');
198
199            if(page == "form-issue"){
200                 $($(this).children().attr('data-href')).addClass('active');
201             }else{
202                $(target).addClass('active');
203             }
204        });
205    }
206
207    //tabs behaviour
208    function EC_languageTabs(page){
209        $('body').on('click','.language-tabs li', function(){
210            var target = '#'+$(this).children().attr('data-target');
211
212            $('.language-tabs li').removeClass('active');
213            $(this).addClass('active');
214
215            $('.tabs-content .content').removeClass('active');
216
217            if(page == "form-issue"){
218                 $($(this).children().attr('data-href')).addClass('active');
219             }else{
220                $(target).addClass('active');
221             }
222        });
223    }
224
225    //verify if is the first time and start system tour
226    function EC_journalFirstTime(first_time){
227        if(first_time == 1){
228            $('#myModal').foundation('reveal', 'open');
229            $('.joyride-modal-bg-custom').show();
230
231            var tour = $('#my-tour-id').tourbus( {} );
232            tour.trigger('depart.tourbus');
233
234            $('body').on('click','#tourbus-leg-0-6 .tourbus-leg-inner a', function(){
235                $('.joyride-modal-bg-custom').fadeOut();
236            });
237        }
238    }
239
240    // remove first_tume flag from client
241    function EC_removeFirstAccess(clientID, jshortname, jfullname, jID){
242        var urlRequest = window.yiiBaseURL+"/clients/firstTime";
243         $.ajax({
244            type: "POST",
245            url: urlRequest,
246            data: {"clientID":clientID, "jAbbr":jshortname, "jName":jfullname, "jID":jID},
247            success:function(response) {
248                if(response == "1"){
249                    alert("site publicado");
250                    console.log("your site is now published");
251                }
252            }
253        });
254    }
255
256    function EC_showSweetAlert(){
257        $('#site-footer').hide();
258        setTimeout(function(){
259            if(window.currentLanguage == "pt"){
260                swal({
261                    title: "Salvando",
262                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
263                    showConfirmButton: false
264                });
265            }else{
266                swal({
267                    title: "Saving",
268                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
269                    showConfirmButton: false
270                });
271            }
272        },100);
273    }
274
275    function EC_showSweetAlertS3(){
276        $('#site-footer').hide();
277        setTimeout(function(){
278            if(window.currentLanguage == "pt"){
279                swal({
280                    title: "Enviando",
281                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
282                    showConfirmButton: false
283                });
284            }else{
285                swal({
286                    title: "Uploading",
287                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
288                    showConfirmButton: false
289                });
290            }
291        },100);
292    }
293
294    function EC_simplePlanUpdate(plan){
295        var urlRequest = window.yiiBaseURL+"/admin/updatePlanHistory";
296        $.ajax({
297            url: urlRequest,
298            type: 'POST',
299            data: {"plan": plan},
300            async:true,
301            error: function(message){
302                console.log('error');
303                console.log(message);
304                EC_closeSweetAlert('error');
305                console.log("plan not updated");
306            },
307            success: function(response){
308                console.log(response);
309                console.log("plan updated");
310                if(window.currentLanguage == "pt"){
311                    swal({
312                        title: "Plano atualizado.",
313                        type: "success",
314                        closeOnConfirm: true,
315                    }, function(isConfirm){
316                        if (isConfirm) {
317                            location.reload();
318
319                        } else {
320                            location.reload();
321                            event.preventDefault();
322                        }
323                    });
324                }else{
325                    swal({
326                        title: "Plan Updated.",
327                        type: "success",
328                        showConfirmButton: true,
329                        closeOnConfirm: true,
330                    }, function(isConfirm){
331                        if (isConfirm) {
332                            location.reload();
333
334                        } else {
335                            location.reload();
336                            event.preventDefault();
337                        }
338                    });
339                }
340            }
341        })
342    }
343
344    function EC_simplePasswordUpdate(password){
345        var urlRequest = window.yiiBaseURL+"/admin/updatePassword";
346
347        $.ajax({
348            url: urlRequest,
349            type: 'POST',
350            data: {"password": password},
351            async:true,
352            error: function(message){
353                console.log('error');
354                console.log(message);
355                EC_closeSweetAlert('error');
356                console.log("password not updated");
357            },
358            success: function(response){
359                console.log(response);
360                console.log("password updated");
361                if(window.currentLanguage == "pt"){
362                    swal({
363                        title: "Password atualizado.",
364                        type: "success",
365                        closeOnConfirm: true,
366                    }, function(isConfirm){
367                        if (isConfirm) {
368
369                        } else {
370
371                        }
372                    });
373                }else{
374                    swal({
375                        title: "Password Updated.",
376                        type: "success",
377                        showConfirmButton: true,
378                        closeOnConfirm: true,
379                    }, function(isConfirm){
380                        if (isConfirm) {
381
382                        } else {
383
384                        }
385                    });
386                }
387            }
388        })
389    }
390
391    function EC_simpleEmailUpdate(email){
392         if(window.currentLanguage == "pt"){
393            swal({
394                title: "Enviando solicitação",
395                imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
396                showConfirmButton: false
397            });
398        }else{
399            swal({
400                title: "Sending request",
401                imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
402                showConfirmButton: false
403            });
404        }
405
406        var urlRequest = window.yiiBaseURL+"/admin/updateEmail";
407
408        $.ajax({
409            url: urlRequest,
410            type: 'POST',
411            data: {"email": email},
412            async:true,
413            error: function(message){
414                swal.close();
415                console.log('error');
416                console.log(message);
417                EC_closeSweetAlert('error');
418                console.log("email not updated");
419            },
420            success: function(response){
421                console.log(response);
422                swal.close();
423                if(response == 1){
424                    if(window.currentLanguage == "pt"){
425                        console.log('email enviado');
426                    }else{
427                        console.log('email sent');
428                    }
429
430                    $('.email-input-area').hide();
431                    $('.email-confirmation-info').fadeIn();
432                }
433            }
434        })
435    }
436
437
438    function EC_paymentStatusUpdate(id, field, value){
439        var urlRequest = window.yiiBaseURL+"/admin/updatePaymentStatus";
440        var data = new FormData();
441        $.ajax({
442            url: urlRequest,
443            type: 'POST',
444            data: {"id": id, "field":field, "value": value},
445            async:true,
446            error: function(message){
447                console.log('error');
448                console.log(message);
449                EC_closeSweetAlert('error');
450            },
451            success: function(response){
452                // console.log(response);
453                // console.log('saved');
454                $('.sweet-overlay').remove();
455                EC_closeSweetAlert();
456                setTimeout(function(){
457                    location.reload();
458                },1500);
459
460            }
461        })
462    }
463
464    function EC_simpleAddPayment(plan){
465        var urlRequest = window.yiiBaseURL+"/admin/addPlanPayment";
466        $.ajax({
467            url: urlRequest,
468            type: 'POST',
469            data: {"plan": plan},
470            async:true,
471            error: function(message){
472                console.log('error');
473                console.log(message);
474                console.log("payment not added");
475            },
476            success: function(response){
477                console.log(response);
478                console.log("payment added");
479            }
480        })
481    }
482
483    function EC_showSweetAlertUpdatePlan(plan, planOption){
484        $('#site-footer').hide();
485            if(window.currentLanguage == "pt"){
486                swal({
487                    title: "Atualizar plano.",
488                    text: "Tem certeza que deseja atualizar o seu plano<br /> para o plano: <strong>"+plan+"</strong> ?",
489                    type: "warning",
490                    html: true,
491                    showConfirmButton: true,
492                    showCancelButton: true,
493                    confirmButtonText: "Sim, atualizar meu plano",
494                    cancelButtonText: "Não!"
495                }, function(isConfirm){
496                    if (isConfirm) {
497                        if(planOption == "plan_0"){
498                            console.log('plano FREE');
499
500                        }else if(planOption == "plan_1-month"){
501                            console.log("plano 1 mensal");
502                             window.open('http://mpago.la/2Eu8SG', '_blank');
503
504                        }else if(planOption == "plan_1-year"){
505                            console.log("plano 1 anual");
506                            window.open('http://mpago.la/3SknWt', '_blank');
507
508                        }else if(planOption == "plan_2-month"){
509                            console.log("plano 2 mensal");
510                            window.open('http://mpago.la/3fsuvh', '_blank');
511
512                        }else if(planOption == "plan_2-year"){
513                            console.log("plano 2 anual");
514                            window.open('http://mpago.la/3H9TBb', '_blank');
515
516                        }else if(planOption == "plan_3-month"){
517                            console.log("plano 3 mensal");
518                            window.open('http://mpago.la/1FDjCC', '_blank');
519
520                        }else if(planOption == "plan_3-year"){
521                            console.log("plano 3 anual");
522                            window.open('http://mpago.la/14sX8o', '_blank');
523
524                        }else if(planOption == "plan_3"){
525                            console.log("Action not allowed");
526                            event.preventDefault();
527                        }
528
529                        if(planOption !== "plan_3"){
530                            EC_simplePlanUpdate(planOption);
531                            EC_clientSimpleUpdate('clientStatus',planOption, true);
532
533                            var timestamp = Math.floor(Date.now() / 1000);
534                            EC_clientSimpleUpdate('planUpdated',parseInt(timestamp), true);
535
536                            if(planOption == "plan_1-year" || planOption == "plan_2-year" || planOption == "plan_3-year"){
537                                EC_simpleAddPayment(planOption);
538                            }
539                        }
540
541                        $('#site-footer').show();
542                    } else {
543                        event.preventDefault();
544                    }
545                });
546            }else{
547                swal({
548                    title: "Update plan.",
549                    text: "Do you really want to update your plan to: <strong>"+plan+"</strong> ?",
550                    type: "warning",
551                    html: true,
552                    showConfirmButton: true,
553                    showCancelButton: true,
554                    confirmButtonText: "Sim, atualizar meu plano",
555                    cancelButtonText: "Não!"
556                }, function(isConfirm){
557                    if (isConfirm) {
558                        if(planOption == "plan_0"){
559                            console.log('plano FREE');
560
561                        }else if(planOption == "plan_1-month"){
562                            console.log("plano 1 mensal");
563                            // window.open('http://mpago.la/cc1w', '_blank'); // OLD LINK
564                             window.open('http://mpago.la/iccR', '_blank');
565
566                        }else if(planOption == "plan_1-year"){
567                            console.log("plano 1 anual");
568                            window.open('http://mpago.la/Zmqw', '_blank');
569
570                        }else if(planOption == "plan_2-month"){
571                            console.log("plano 2 mensal");
572                            window.open('http://mpago.la/R9xv', '_blank');
573
574                        }else if(planOption == "plan_2-year"){
575                            console.log("plano 2 anual");
576                            window.open('http://mpago.la/SdQB', '_blank');
577
578                        }else if(planOption == "plan_10-month"){
579                            console.log("Gerenciado 1 mensal");
580                            window.open('http://mpago.la/mdw6', '_blank');
581
582                        }else if(planOption == "plan_10-year"){
583                            console.log("Gerenciado 1 anual");
584                            window.open('http://mpago.la/yXC7', '_blank');
585
586                        }else if(planOption == "plan_11-month"){
587                            console.log("Gerenciado 2 mensal");
588                            window.open('http://mpago.la/F0o6', '_blank');
589
590                        }else if(planOption == "plan_11-year"){
591                            console.log("Gerenciado 2 anual");
592                            window.open('http://mpago.la/YRIN', '_blank');
593                        }
594
595                        EC_simplePlanUpdate(planOption);
596                        EC_clientSimpleUpdate('clientStatus',planOption);
597
598                        var timestamp = Math.floor(Date.now() / 1000);
599                        EC_clientSimpleUpdate('planUpdated',parseInt(timestamp), true);
600
601                        if( (planOption == "plan_1-year") || (planOption == "plan_2-year") || (planOption == "plan_10-year") || (planOption == "plan_11-year")   ){
602                            EC_simpleAddPayment(planOption);
603                        }
604
605                        $('#site-footer').show();
606                    } else {
607                        event.preventDefault();
608                    }
609                });
610            }
611
612    }
613
614    function EC_closeSweetAlertS3(error){
615        if(error){
616            setTimeout(function(){
617                if(window.currentLanguage == "pt"){
618                    swal({
619                        title: "Erro",
620                        type:"error",
621                        text: "Por favor, tente novamente mais tarde. Caso o erro continue, entre em contato com o suporte: [email protected]",
622                        // showConfirmButton: false
623                    });
624                }else{
625                    swal({
626                        title: "Error",
627                        text: "Please, try again later. If the error continues, please contact the admin.",
628                        type:"error",
629                        // showConfirmButton: false
630                    });
631                }
632            },500);
633        }else{
634            setTimeout(function(){
635                if(window.currentLanguage == "pt"){
636                    swal({
637                        title: "Arquivo Enviado!",
638                        type:"success",
639                        showConfirmButton: false
640                    });
641                }else{
642                    swal({
643                        title: "File Uploaded!",
644                        type:"success",
645                        showConfirmButton: false
646                    });
647                }
648            },500);
649
650            setTimeout(function(){
651                $('#site-footer').show();
652                swal.close();
653            },1500);
654        }
655    }
656
657    function EC_closeSweetAlert(error){
658        if(error){
659            setTimeout(function(){
660                if(window.currentLanguage == "pt"){
661                    swal({
662                        title: "Erro",
663                        type:"error",
664                        text: "Por favor, tente novamente mais tarde. Caso o erro continue, entre em contato com o suporte: [email protected]",
665                        // showConfirmButton: false
666                    });
667                }else{
668                    swal({
669                        title: "Error",
670                        text: "Please, try again later. If the error continues, please contact the admin.",
671                        type:"error",
672                        // showConfirmButton: false
673                    });
674                }
675            },500);
676        }else{
677            setTimeout(function(){
678                if(window.currentLanguage == "pt"){
679                    swal({
680                        title: "Atualizado",
681                        type:"success",
682                        showConfirmButton: false
683                    });
684                }else{
685                    swal({
686                        title: "Updated",
687                        type:"success",
688                        showConfirmButton: false
689                    });
690                }
691            },500);
692
693            setTimeout(function(){
694                $('#site-footer').show();
695                swal.close();
696            },1500);
697        }
698    }
699
700
701/*COUNTER :: Dwonloads Counter
702===============================
703¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
704    $('body').on('click', '#ec-downloads a.pdfType1',function(){
705        updateCounter();
706    })
707
708    $('body').on('click', '#mobile-download-area a.pdfType1',function(){
709        updateCounter();
710    })
711
712    function updateCounter(){
713        var modelID = $('#invisible-id').text();
714        var modelClass = $('#invisible-class').text();
715        var urlRequest = window.yiiBaseURL+"/articles/downloadCounter?modelID="+modelID+"&modelClass="+modelClass;
716        $.ajax({
717            type: "GET",
718            url: urlRequest,
719            success:function(response) {
720                console.log(response);
721            }
722        });
723    }
724
725
726/*  FUNCTIONS ::  Draw Article Summary
727=======================================
728¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
729function drawSummary(){
730    var summaryCount = 0;
731    var consoleJTitle = "font-size: 14px; background:#efefef; padding: 0 10px; border-bottom:1px dashed #000";
732    console.log("%cPage Summary", consoleJTitle);
733     $('#ec-summary-link').click(function(){
734        $('#ec-summary').toggle();
735        $('#ec-downloads').removeClass('open');
736        $('#ec-share').removeClass('open');
737    });
738
739    $('#ec-downloads-link').click(function(){
740        $('#ec-downloads').toggle();
741        $('#ec-summary').removeClass('open');
742        $('#ec-share').removeClass('open');
743    });
744
745    $('#ec-share-link').click(function(){
746        $('#ec-share').toggle();
747        $('#ec-downloads').removeClass('open');
748        $('#ec-summary').removeClass('open');
749    });
750
751    $('body').click(function(){
752        $('#ec-summary').removeClass('open');
753        $('#ec-downloads').removeClass('open');
754        $('#ec-share').removeClass('open');
755    });
756
757    $("#journal-main-area h1, #journal-main-area h2").each(function(i) {
758        var attr = $(this).attr('data-ec-summary');
759        $(this).attr('id', 'nav'+i);
760
761        if($(this).hasClass('summary-ignore')|| $(this).text().length == 0){
762
763        }else{
764            summaryCount++;
765
766            if ((typeof attr !== 'undefined') && (attr !== false) && (attr !== "")) {
767                if ( $(this).is( "h1" ) ) {
768                    $('#ec-summary ul').append('<li class="heading1"><a href="#'+$(this).attr('id')+'">'+$(this).attr('data-ec-summary')+'</a></li>');
769                    console.log(attr);
770                }else{
771                    $('#ec-summary ul').append('<li class="heading2"><a href="#'+$(this).attr('id')+'">'+$(this).attr('data-ec-summary')+'</a></li>');
772                    console.log("- " + attr);
773                }
774            }else{
775                if ( $(this).is( "h1" ) ) {
776                    $('#ec-summary ul').append('<li class="heading1"><a href="#nav'+i+'">'+$(this).text()+'</a></li>');
777                    console.log($(this).html());
778                }else{
779                    $('#ec-summary ul').append('<li class="heading2"><a href="#nav'+i+'">'+$(this).text()+'</a></li>');
780                    console.log("- " + $(this).html());
781                }
782            }
783        }
784
785    });
786
787
788    $(function() {
789      $('a[href*=#]:not([href=#])').click(function() {
790        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
791          var target = $(this.hash);
792          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
793          if (target.length) {
794            if($('#shadow-article-actions').length){
795                if($('#shadow-article-actions').hasClass('fixed')){
796                    $('html,body').animate({
797                      scrollTop: target.offset().top-60
798                    }, 1000);
799
800                }else{
801                    $('html,body').animate({
802                      scrollTop: target.offset().top-130
803                    }, 1000);
804                }
805            }else{
806                if($('#summary-sidebar').hasClass('fixed')){
807                    $('html,body').animate({
808                      scrollTop: target.offset().top-0
809                    }, 1000);
810
811                }else{
812                    $('html,body').animate({
813                      scrollTop: target.offset().top-0
814                    }, 1000);
815                }
816            }
817            window.location.hash = target.selector;
818            $('#ec-summary').removeClass('open');
819            $('#ec-share').removeClass('open');
820            $('#ec-downloads').removeClass('open');
821
822            return false;
823          }
824        }
825      });
826    });
827}
828
829$(window).load(function(){
830    var target = '#'+window.location.hash.substr(1);
831    target = $(target);
832    if (target.length) {
833        if($('#shadow-article-actions').length){
834            $('html,body').animate({
835              scrollTop: target.offset().top-130
836            }, 1000);
837        }else{
838            $('html,body').animate({
839              scrollTop: target.offset().top-0
840            }, 1000);
841        }
842    }
843
844    $('#Articles_doi').on('keyup keypress blur change', function(e) {
845        // var doiRegex = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'])\S)+)\b/;
846        // var doiRegex = /^10.\d{4,9}/[-._;()/:A-Z0-9]+$/i;
847        var doiRegex = /^\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'])\S)+)\b/;
848
849        var doiResult = doiRegex.test($(this).val());
850
851        if( (doiResult == false)){
852            if($(this).val() == ""){
853                $(this).css({'border-color': '#ddd'});
854                $('#doi-error-message').hide();
855            }else{
856                $(this).style('border-color', 'red','important');
857                $('#doi-error-message').show();
858            }
859        }else{
860            $(this).css({'border-color': '#ddd'});
861            $('#doi-error-message').hide();
862        }
863    });
864
865    $('#Articles_elocation').on('keyup keypress blur change', function(e) {
866        var elRegex = /^[A-Za-z0-9]+$/;
867
868        var elResult = elRegex.test($(this).val());
869
870        if( (elResult == false)){
871            if($(this).val() == ""){
872                $(this).css({'border-color': '#ddd'});
873                $('#elocation-error-message').hide();
874            }else{
875                $(this).style('border-color', 'red','important');
876                $('#elocation-error-message').show();
877            }
878        }else{
879            $(this).css({'border-color': '#ddd'});
880            $('#elocation-error-message').hide();
881        }
882    });
883
884
885    $('body').on('click','.makeNewTour',function(){
886        EC_clientSimpleUpdate('first_access','1');
887    });
888});
889
890
891
892/* FUNCTIONS :: MENU EVENTS
893=======================================
894¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
895function EC_topbarUserLinks(){
896$(document).on("mouseover",".top-bar-menu",function(event) {
897    event.stopPropagation();
898
899    //reset all
900    $('.top-bar-menu-links').hide();
901    $('.loginArrow').addClass('fa-caret-down');
902    $('.loginArrow').removeClass('fa-caret-up');
903
904    $(this).find('.top-bar-menu-links').show();
905    $(this).find('.loginArrow').removeClass('fa-caret-down').addClass('fa-caret-up');
906})
907
908$(document).on("mouseout",".top-bar-menu",function(event) {
909    event.stopPropagation();
910
911    //reset all
912    $('.top-bar-menu-links').hide();
913    $('.loginArrow').addClass('fa-caret-down');
914    $('.loginArrow').removeClass('fa-caret-up');
915})
916
917
918
919    //open clicked menu and close others
920    $(document).on("click","#header-logo-user img",function(event) {
921        event.stopPropagation();
922        $('.loginArrow').addClass('fa-caret-down');
923        $('.loginArrow').removeClass('fa-caret-up');
924
925        if($('#topbar-host-links').attr('class') == 'active'){
926            $('#header-logo-user').removeClass('active');
927            $('#topbar-host-links').removeClass('active');
928        }else{
929            $('#user-actions-button').removeClass('active');
930            $('#user-actions-area').removeClass('active');
931             $('#journal-name-top').removeClass('active');
932            $('#topbar-journal-links').removeClass('active');
933            $('#header-logo-user').addClass('active');
934            $('#topbar-host-links').addClass('active');
935        }
936    })
937
938    $(document).on("click","#user-actions-button",function(event) {
939        event.stopPropagation();
940        $('.loginArrow').addClass('fa-caret-down');
941        $('.loginArrow').removeClass('fa-caret-up');
942
943        if($('#user-actions-area').attr('class') == 'active'){
944            $(this).removeClass('active');
945            $('#user-actions-area').removeClass('active');
946        }else{
947            $(this).addClass('active');
948            $('#header-logo-user').removeClass('active');
949            $('#topbar-host-links').removeClass('active');
950            $('#journal-name-top').removeClass('active');
951            $('#topbar-journal-links').removeClass('active');
952            $('#user-actions-area').addClass('active');
953            $('#user-actions-button .loginArrow').addClass('fa-caret-up');
954            $('#user-actions-button .loginArrow').removeClass('fa-caret-down');
955        }
956    })
957
958    $(document).on('click', '.m-userAction', function(event){
959        event.stopPropagation();
960
961        if( $(this).parent().find('.m-user-action-area').hasClass('m-active')  ){
962            $(this).parent().find('.m-user-action-area').removeClass('m-active')
963        }else{
964            $(this).parent().find('.m-user-action-area').addClass('m-active')
965        }
966    });
967}
968
969/* FUNCTIONS :: Edit in place
970==========================================
971¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
972function EC_EditInPlace(){
973    $('.ec-edit-in-place input[type="text"]').keydown(resizeInput).each(resizeInput);
974
975    EC_EditInPlace_start();
976    EC_EditInPlace_end();
977}
978
979function EC_EditInPlace_start(){
980    $(".ec-eip-button").click(function(){
981        var dataType = $(this).closest('.ec-edit-in-place').find('.ec-eip-button').attr('data-type');
982        var fieldHeight = $(this).closest('.ec-edit-in-place').find('.static-information').height();
983        var fontFamily = $(this).closest('.ec-edit-in-place').find('.static-information').css('font-family');
984        var fontSize = $(this).closest('.ec-edit-in-place').find('.static-information').css('font-size');
985        var fontColor = $(this).closest('.ec-edit-in-place').find('.static-information').css('color');
986        var fontWeight = $(this).closest('.ec-edit-in-place').find('.static-information').css('font-weight');
987
988        $(this).closest('.ec-edit-in-place').find('.data-information').children().height(fieldHeight);
989        $(this).closest('.ec-edit-in-place').find('.data-information').children().css('font-family', fontFamily);
990        $(this).closest('.ec-edit-in-place').find('.data-information').children().css('font-size', fontSize);
991        $(this).closest('.ec-edit-in-place').find('.data-information').children().css('color', fontColor);
992        $(this).closest('.ec-edit-in-place').find('.data-information').children().css('font-weight', fontWeight);
993
994        $(this).closest('.ec-edit-in-place').find('.data-information').fadeIn();
995        $(this).closest('.ec-edit-in-place').find('.static-information').hide();
996        $(this).closest('.ec-edit-in-place').find('.ec-eip-button').hide();
997        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-close').show();
998        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-save').show();
999
1000        if(dataType == 'textarea'){
1001            var editHeight = $(this).closest('.ec-edit-in-place').find('.cke_wysiwyg_frame').contents().height();
1002
1003            console.log(editHeight);
1004            $(".show-all").hide();
1005            $(this).closest('.ec-edit-in-place').find('.data-information').css('display', 'inline-block');
1006
1007            $(this).closest('.ec-edit-in-place').find('.cke_wysiwyg_frame').css('min-height',editHeight);
1008            $(this).closest('.ec-edit-in-place').find('.data-information').find('.cke_contents').css('min-height',editHeight);
1009
1010
1011        }else{
1012            $(this).closest('.ec-edit-in-place').find('.data-information').children().focus();
1013        }
1014    })
1015}
1016
1017function EC_EditInPlace_end(){
1018    $(document).on('click', '.ec-eip-button-save', function (event) {
1019        $(this).closest('.ec-edit-in-place').find('.static-information').fadeIn();
1020        $(this).closest('.ec-edit-in-place').find('.ec-eip-button').fadeIn();
1021        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-close').hide();
1022        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-save').hide();
1023        $(this).closest('.ec-edit-in-place').find('.data-information').hide();
1024        $(".show-all").show();
1025
1026        var dataType = $(this).closest('.ec-edit-in-place').find('.ec-eip-button').attr('data-type');
1027        if(dataType == "textarea"){
1028            var field = $(this).closest('.ec-edit-in-place').find('textarea').attr('id');
1029            var editor = CKEDITOR.instances[field];
1030            var value = editor.getData();
1031            // event.preventDefault();
1032
1033        }else{
1034            var field = $(this).closest('.ec-edit-in-place').find('.data-information').children().attr('id');
1035            var value = $(this).closest('.ec-edit-in-place').find('.data-information').children().val();
1036        }
1037
1038        console.log('Updating Information');
1039        console.log('--------------------');
1040        console.log('Saving field: ' + field);
1041        console.log('With value: ' + value);
1042        console.log('---');
1043
1044        jid = window.userJournal;
1045
1046        if($(this).parent().hasClass('issn')){
1047            var issnReg = /^\d{4}\-\d{3}[\dxX]$/;
1048            if(issnReg.test($(this).parent().find('input').val()) || $(this).parent().find('input').val() == ""){
1049                EC_EditInPlace_updateData(jid, field, value, dataType);
1050            }else{
1051                alert('issn inválido');
1052            }
1053        }else{
1054            EC_EditInPlace_updateData(jid, field, value, dataType);
1055        }
1056    });
1057
1058    $(".ec-eip-button-close").click(function(){
1059        $(this).closest('.ec-edit-in-place').find('.data-information').hide();
1060        $(this).closest('.ec-edit-in-place').find('.static-information').show();
1061        $(this).closest('.ec-edit-in-place').find('.ec-eip-button').show();
1062        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-close').hide();
1063        $(this).closest('.ec-edit-in-place').find('.ec-eip-button-save').hide();
1064
1065        //reseta os valores originais
1066        var dataType = $(this).closest('.ec-edit-in-place').find('.ec-eip-button').attr('data-type');
1067        if(dataType == "textarea"){
1068            $(this).closest('.ec-edit-in-place').find('.data-information').find('textarea').val($(this).closest('.ec-edit-in-place').find('.static-information').html())
1069
1070        }else if(dataType == "input"){
1071            $(this).closest('.ec-edit-in-place').find('.data-information').children().val($(this).closest('.ec-edit-in-place').find('.static-information').html());
1072
1073        }else{
1074            $(this).closest('.ec-edit-in-place').find('select option').filter(function() {
1075                return ($(this).text() == $(this).closest('.ec-edit-in-place').find('.static-information').html()); //To select Blue
1076            }).prop('selected', true);
1077        }
1078    })
1079}
1080
1081function EC_EditInPlace_updateData(jid, field, value, dataType){
1082    var url = window.location;
1083    if(hasDomain !== ""){
1084        // console.log('Custom Domain: true');
1085        var urlRequest = "site/updateData";
1086    }else{
1087        url = url.href.split('journal/');
1088        url = url[0];
1089        var urlRequest = url+"site/updateData";
1090        // console.log('Custom Domain: false');
1091    }
1092
1093    $.ajax({
1094        type: "POST",
1095        url: urlRequest,
1096        async: false,
1097        data: {"jid":jid, "field": field, "value": value},
1098        success:function(data) {
1099            console.log(data);
1100            $('#progressBar-area').html('');
1101            $('#progressBar-area').load(url+"siteJournal/checkProgress");
1102
1103            if((dataType == "input")) {
1104                $('#'+field).val(data);
1105                $('#'+field).closest('.ec-edit-in-place').find('.static-information').html(data);
1106
1107            }else if(dataType == "textarea"){
1108                $('#'+field).val(data);
1109                $('#'+field).closest('.ec-edit-in-place').find('.static-information').html(data);
1110
1111             }else if(dataType == "select"){
1112                $('#'+field).val(data);
1113                $('#'+field).closest('.ec-edit-in-place').find('.static-information').html($('#'+field+' option:selected').text());
1114
1115            }else{
1116                console.log('error :: missing dataType (input, textarea, etc...');
1117            }
1118        }
1119
1120    });
1121}
1122
1123function resizeInput() {
1124    $(this).attr('size', $(this).val().length);
1125}
1126
1127/* FUNCTIONS :: FORM :: Issues
1128==========================================
1129¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1130function EC_issuesForm() {
1131    if($('input[type=radio]:checked').val() == 1){
1132         $('#linkArea').show();
1133    }else{
1134        $('#linkArea').hide();
1135    }
1136
1137     $('body').on('change','input[type=radio]', function(){
1138        if($(this).val() == 1){
1139            $('#linkArea').slideDown();
1140        }else{
1141            $('#linkArea').slideUp();
1142        }
1143    });
1144
1145    // Inputs mirrorwing
1146    $('#preview_inputs input').blur(function() {
1147        var value = $(this).val();
1148        var preview = $(this).attr('data-preview');
1149
1150        $('input[data-preview='+preview+']').each(function(){
1151            $(this).val(value);
1152        });
1153
1154        if(value == ""){
1155            // console.log($(this).attr('data-preview')+': vazio');
1156            $('.'+$(this).attr('data-preview')+'-preview').html(value);
1157            $('.'+$(this).attr('data-preview')+'-preview-m').html(value);
1158        }else{
1159            if( ($(this).attr('data-preview') == 'title_pt') || ($(this).attr('data-preview') == 'title_en') || ($(this).attr('data-preview') == 'title_es')){
1160                console.log($(this).attr('data-preview')+': ' + value);
1161                $('.'+$(this).attr('data-preview')+'-preview').html('('+value+')');
1162
1163            } else if( ($(this).attr('data-preview') == 'issue')){
1164                console.log($(this).attr('data-preview')+': ' + value);
1165                $('.'+$(this).attr('data-preview')+'-preview').html('Número '+ value+', ');
1166                $('.'+$(this).attr('data-preview')+'-preview-m').html('('+value+'), ');
1167
1168            }else{
1169                console.log($(this).attr('data-preview')+': ' + value);
1170                $('.'+$(this).attr('data-preview')+'-preview').html(value);
1171            }
1172        }
1173    });
1174
1175    $('body').on('change','input[type=date]', function(){
1176        var value = $(this).val();
1177
1178        $('input[type=date]').each(function(){
1179            $(this).val(value);
1180        });
1181    });
1182
1183    $('body').on('change','input[data-preview=link]', function(){
1184        var value = $(this).val();
1185
1186        $('input[data-preview=link]').each(function(){
1187            $(this).val(value);
1188        });
1189    });
1190
1191    $("input[data-preview=isActive]").change(function() {
1192        if(this.checked) {
1193            $('input[data-preview=isActive]').each(function(){
1194                $(this).prop('checked', true);
1195            });
1196        }else{
1197            $('input[data-preview=isActive]').each(function(){
1198                $(this).prop('checked', false);
1199            });
1200        }
1201    });
1202
1203    $('body').on('change','input[data-preview=isActive]', function(){
1204        var value = $(this).val();
1205
1206        $('input[data-preview=isActive').each(function(){
1207            $(this).val(value);
1208        });
1209    });
1210
1211    // re-build preview on page load
1212    $('#preview_inputs input').each(function() {
1213        var value = $(this).val();
1214
1215        if(value == ""){
1216            // console.log($(this).attr('data-preview')+': vazio');
1217            $('.'+$(this).attr('data-preview')+'-preview').html(value);
1218            $('.'+$(this).attr('data-preview')+'-preview-m').html(value);
1219        }else{
1220            if( ($(this).attr('data-preview') == 'title_pt') || ($(this).attr('data-preview') == 'title_en') || ($(this).attr('data-preview') == 'title_es')){
1221                console.log($(this).attr('data-preview')+': ' + value);
1222                $('.'+$(this).attr('data-preview')+'-preview').html('('+value+')');
1223
1224            } else if( ($(this).attr('data-preview') == 'issue')){
1225                console.log($(this).attr('data-preview')+': ' + value);
1226                $('.'+$(this).attr('data-preview')+'-preview').html('Número '+ value+', ');
1227                $('.'+$(this).attr('data-preview')+'-preview-m').html('('+value+'), ');
1228
1229            }else{
1230                console.log($(this).attr('data-preview')+': ' + value);
1231                $('.'+$(this).attr('data-preview')+'-preview').html(value);
1232            }
1233        }
1234    });
1235}
1236
1237
1238/* FUNCTIONS :: FORM :: Articles
1239==========================================
1240¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1241function EC_articlesForm(currentJournal){
1242    $(document).on("change","#ArticleJournalID",function() {
1243        var selectedJournal = $("#ArticleJournalID" ).val();
1244        if(selectedJournal == ""){
1245            $("#ArticleJournalID" ).css({'border-color': 'red', 'box-shadow': '0 0 15px 0 red'});
1246            event.preventDefault();
1247        }else{
1248            $("#ArticleJournalID" ).css({'border-color': '#ccc', 'box-shadow': 'none'});
1249            updateEditions(selectedJournal);
1250        }
1251    });
1252
1253    $(".articlePDF input[type=file]").change(function (){
1254        $('.removePDF-message').slideDown();
1255        var inputID = $(this).attr('id');
1256
1257        var fileName =  $(this)[0].files[0].name;
1258        var fileType =  $(this)[0].files[0].type;
1259        var fileSize =  $(this)[0].files[0].size;
1260        var maxFilzeSie = 32000000;
1261        console.log("");
1262        console.log(fileType+", "+fileSize+" bytes (Max "+maxFilzeSie+")");
1263
1264        $(this).parent().parent().find('.pdf-name').remove();
1265        $(this).parent().parent().find('.fileName').remove();
1266        $(this).parent().parent().find('.errorMessage').remove();
1267
1268        $(this).parent().parent().append('<span class="pdf-name"><strong>Novo PDF</strong>: '+fileName+'</span>');
1269
1270        if(fileType != "application/pdf"){
1271            $(this).parent().parent().append('<div class="errorMessage" style="display:block;">- Somente arquivos .pdf são permitidos.</div>');
1272            console.log('Error: Only PDF files are allowed');
1273        }
1274        if(fileSize > maxFilzeSie){
1275            $(this).parent().parent().append('<div class="errorMessage" style="display:block;">- Arquivo muito grande. Máximo de 32MB. </div>');
1276            console.log('Error: The file is too big. Max 32 MB.');
1277        }
1278        $(this).parent().find('.removePDF-btn').show();
1279        $(this).parent().parent().find('.pdf-name').show();
1280    });
1281
1282    $('body').on('change', '.articleXML input[type=file]', function(){
1283        //used in upload
1284        var files = event.target.files;
1285
1286        //used in validation
1287        var fileName =  $('#Articles_xml')[0].files[0].name;
1288        var fileType =  $('#Articles_xml')[0].files[0].type;
1289
1290        $('.fileName').remove();
1291        $(".errorMessage").remove();
1292        $('#Articles_xml').parent().append('<span class="fileName"><strong>Novo XML</strong>: '+fileName+'</span>');
1293
1294        if(fileType != "text/xml"){
1295            $('#Articles_xml').parent().append('<div class="errorMessage" style="display:block;">- Somente arquivos .pdf são permitidos.</div>');
1296            console.log('Error: Only XML files are allowed');
1297            event.preventDefault();
1298        }
1299        EC_importXML(files);
1300    })
1301
1302    $('body').on('submit', '#articles-form', function(event){
1303        // validate Journal, Type and Area
1304        var selectedJournal = $("#ArticleJournalID" ).val();
1305        var selectedType = $("#Articles_type" ).val();
1306        var selectedTypeName = $('#Articles_type option:selected').text()
1307        var selectedAreaName = $('#Articles_area option:selected').text()
1308        var selectedArea = $("#Articles_area" ).val();
1309
1310        var primaryType = $('.typesArea #yw0_tab_0 input').val();
1311        var secondaryType = $('.typesArea #yw0_tab_1 input').val();
1312
1313        if(secondaryType === ""){
1314            $('.typesArea #yw0_tab_1 input').val(primaryType);
1315            secondaryType = primaryType;
1316        }
1317
1318        if(selectedJournal === ""){
1319            $("#ArticleJournalID" ).css({'border-color': 'red', 'box-shadow': '0 0 15px 0 red'});
1320            window.scrollTo(0, 150);
1321            event.preventDefault();
1322        }else{
1323            $("#ArticleJournalID" ).css({'border-color': '#cccccc', 'box-shadow': 'none'});
1324        }
1325
1326        if(selectedType === "" || selectedType === "selectType"){
1327            $("#Articles_type" ).css({'border-color': 'red', 'box-shadow': '0 0 15px 0 red'});
1328            window.scrollTo(0, 150);
1329            event.preventDefault();
1330        }else{
1331            $("#Articles_type" ).css({'border-color': '#cccccc', 'box-shadow': 'none'});
1332        }
1333
1334        if(selectedArea === "" || selectedArea === "selectArea"){
1335            $("#Articles_area" ).css({'border-color': 'red', 'box-shadow': '0 0 15px 0 red'});
1336            window.scrollTo(0, 150);
1337            event.preventDefault();
1338        }else{
1339            $("#Articles_area" ).css({'border-color': '#cccccc', 'box-shadow': 'none'});
1340        }
1341
1342        // //validate PDF Upload
1343        // $(".errorMessage").remove();
1344        // var file = $("#Articles_pdf").val();
1345        // if(file != ""){
1346        //     var fileType =  $(this).find('#Articles_pdf')[0].files[0].type;
1347        //     var fileSize = $(this).find('#Articles_pdf')[0].files[0].size;
1348        //     var maxFilzeSie = 32000000;
1349        //     console.log("");
1350        //     console.log(fileType+", "+fileSize+" bytes (Max "+maxFilzeSie+")");
1351
1352        //     if(fileType != "application/pdf"){
1353        //         $('#Articles_pdf').parent().append('<div class="errorMessage" style="display:block;">- Somente arquivos .pdf são permitidos.</div>');
1354        //         console.log('Error: Only PDF files are allowed');
1355        //         event.preventDefault();
1356        //     }
1357        //     if(fileSize > maxFilzeSie){
1358        //         $('#Articles_pdf').parent().append('<div class="errorMessage" style="display:block;">- Arquivo muito grande. Máximo de 32MB. </div>');
1359        //         console.log('Error: The file is too big. Max 32 MB.');
1360        //         event.preventDefault();
1361        //     }
1362        // }else{
1363        //     console.log("OK: no file found, going on")
1364        // }
1365    });
1366
1367    $(document).ready(function(){
1368        console.log($("#ArticleJournalID").val());
1369
1370        if($("#ArticleJournalID").val() == ""){
1371            $("#ArticleJournalID").val(currentJournal);
1372            updateEditions(currentJournal);
1373        }
1374    });
1375
1376    function updateEditions(selectedJournal){
1377        var urlRequest = window.yiiBaseURL+"/articles/updateEdition?journalID="+selectedJournal;
1378         $.ajax({
1379            type: "GET",
1380            dataType: 'json',
1381            url: urlRequest,
1382            success:function(response) {
1383                var $el = $("#Articles_issueID");
1384                $el.empty(); // remove old options
1385                $el.append($(response));
1386
1387            }
1388        });
1389    }
1390
1391    $(window).load(function(){
1392        $('.pdf-name').each(function(){
1393                $(this).parent().find('.removePDF-btn').show();
1394
1395            // if($(this).html == ""){
1396            //     $(this).parent().find('.articlePDF').find('removePDF-btn').hide();
1397            // }else{
1398
1399            // }
1400        })
1401    })
1402}
1403
1404function showTranslation1(translation){
1405    $(".ui-tabs-nav li[aria-controls='trans_title_0'] a").text(translation).parent().fadeIn();
1406    $(".ui-tabs-nav li[aria-controls='trans_keywords_0'] a").text(translation).parent().fadeIn();
1407    $(".ui-tabs-nav li[aria-controls='trans_abstract_0'] a").text(translation).parent().fadeIn();
1408    $("#articlePdfTrans1").show();
1409}
1410
1411function hideTranslation1(){
1412    $(".ui-tabs-nav li[aria-controls='trans_title_0']").fadeOut();
1413    $(".ui-tabs-nav li[aria-controls='trans_keywords_0']").fadeOut();
1414    $(".ui-tabs-nav li[aria-controls='trans_abstract_0']").fadeOut();
1415    $("#articlePdfTrans1").hide();
1416}
1417
1418function showTranslation2(translation){
1419    $(".ui-tabs-nav li[aria-controls='trans_title_1'] a").text(translation).parent().fadeIn();
1420    $(".ui-tabs-nav li[aria-controls='trans_keywords_1'] a").text(translation).parent().fadeIn();
1421    $(".ui-tabs-nav li[aria-controls='trans_abstract_1'] a").text(translation).parent().fadeIn();
1422    $("#articlePdfTrans2").show();
1423}
1424
1425function hideTranslation2(){
1426    $(".ui-tabs-nav li[aria-controls='trans_title_1']").fadeOut();
1427    $(".ui-tabs-nav li[aria-controls='trans_keywords_1']").fadeOut();
1428    $(".ui-tabs-nav li[aria-controls='trans_abstract_1']").fadeOut();
1429    $("#articlePdfTrans2").hide();
1430}
1431
1432function triggerOriginalLanguage(){
1433    $(".ui-tabs-nav li[aria-controls='article_title'] a").trigger("click");
1434    $(".ui-tabs-nav li[aria-controls='article_keywords'] a").trigger("click");
1435    $(".ui-tabs-nav li[aria-controls='article_abstract'] a").trigger("click");
1436};
1437/* FUNCTIONS :: FORM :: Clients
1438==========================================
1439¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1440function EC_clientsForm(){
1441    // TYPES
1442    //Construct a new type data
1443    $(document).on("click","#btnAddType",function() {
1444        $('#btnAddType').css('box-shadow', 'none');
1445        $('#articleType_area').append('<div class="row articleTypeRow"> <div class="medium-6 columns left"> <label class="required">Name (portuguese)*</label> <input id="Clients_ArtilcleType['+$('#articleType_area .row').length+']_nameBr" required="required" class="type_nameBR" placeholder="Nome do Tipo" name="Clients[articleTypes]['+$('#articleType_area .row').length+'][nameBR]" type="text"> </div> <div class="medium-5 columns left"> <label class="required">Name (english)*</label> <input id="Clients_ArtilcleType['+$('#articleType_area .row').length+']_nameEn" required="required" class="type_nameBRP" placeholder="Type Name" name="Clients[articleTypes]['+$('#articleType_area .row').length+'][nameEN]" type="text"> </div> <div class="medium-3 columns left" style="display:none;"> <label class="required">Original Type*</label> <select id="Clients_ArtilcleType['+$('#articleType_area .row').length+']"  class="type_nameOriginal" name="Clients[articleTypes]['+$('#articleType_area .row').length+'][typeName]"> <option value="research-article">research-article</option> </select> </div> <div class="medium-1 columns right"> <a class="admin-icon list remove btnRemoveType" title="Remover"><i class="fa fa-trash-o"></i></a> </div></div> ');
1446    });
1447
1448    //Remove a type line
1449    $(document).on("click",".btnRemoveType",function() {
1450        if (confirm("Remove this article type?") == true) {
1451            $(this).parent().parent().remove();
1452
1453            //Re-index types after removing the line
1454            var nRows = $('#articleType_area .row').length;
1455            var iAux = 0;
1456            $('#articleType_area .row').each(function(){
1457                $(this).children().children('input.type_nameBR').attr({'id':'Clients_ArtilcleType['+iAux+']_nameBr', 'name':'Clients[articleTypes]['+iAux+'][nameBR]'});
1458                $(this).children().children('input.type_nameBRP').attr({'id':'Clients_ArtilcleType['+iAux+']_pluralNameBR', 'name':'Clients[articleTypes]['+iAux+'][pluralNameBR]'});
1459                $(this).children().children('input.type_nameEN').attr({'id':'Clients_ArtilcleType['+iAux+']_nameEn', 'name':'Clients[articleTypes]['+iAux+'][nameEN]'});
1460                $(this).children().children('input.type_nameENP').attr({'id':'Clients_ArtilcleType['+iAux+']_pluralNameEN', 'name':'Clients[articleTypes]['+iAux+'][pluralNameEN]'});
1461                $(this).children().children('select.type_nameOriginal').attr({'id':'Clients_ArtilcleType['+iAux+']', 'name':'Clients[articleTypes]['+iAux+'][typeName]'});
1462                iAux++;
1463            });
1464        }
1465    });
1466
1467    // AREAS
1468    //Construct a new area data
1469    $(document).on("click","#btnAddArea",function() {
1470        $('#btnAddArea').css('box-shadow', 'none');
1471        $('#articleArea_area').append('<div class="row articleTypeRow"><div class="medium-6 columns left"><label class="required">Name (portuguese)*</label><input id="Clients_ArtilcleArea['+$('#articleArea_area .row').length+']_nameBr" required="required" placeholder="Nome da Área" class="area_nameBR" name="Clients[articleAreas]['+$('#articleArea_area .row').length+'][nameBR]" type="text"></div><div class="medium-5 columns left"><label class="required">Name (english)*</label><input id="Clients_ArtilcleArea['+$('#articleArea_area .row').length+']_nameEn" required="required" placeholder="Area Name" class="area_nameEN" name="Clients[articleAreas]['+$('#articleArea_area .row').length+'][nameEN]" type="text"></div><div class="medium-5 columns left" style="display:none;"><label class="required">Original Area*</label><select id="Clients_ArtilcleArea['+$('#articleArea_area .row').length+']" class="area_nameOriginal" name="Clients[articleAreas]['+$('#articleArea_area .row').length+'][areaName]"><option value="General">General</option> </select> </div> <div class="medium-1 columns right"> <a class="admin-icon list remove btnRemoveArea" title="Remover"><i class="fa fa-trash-o"></i></a> </div> <hr> </div>');
1472    });
1473}
1474
1475/* FUNCTIONS :: FORM :: Journals
1476==========================================
1477¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1478function EC_journalsForm(){
1479    //check issn status at page load
1480    $('.issn-box input[type=text]').keyup(function() {
1481        var issnReg = /^\d{4}\-\d{3}[\dxX]$/;
1482        var issnResult = issnReg.test($(this).val());
1483        var checkIssn = 0;
1484
1485        // console.log(issnResult);
1486
1487        if( (issnResult == false)){
1488            $(this).style('border-color', 'red','important');
1489            $('.issn-box strong').show();
1490        }else{
1491            $(this).css({'border-color': '#ddd'});
1492        }
1493
1494        $('.issn-box input[type=text]').each(function(){
1495            var checkbox = $(this).closest('.issn-box').parent().find('.issn-check input').is(":checked")
1496
1497            if(checkbox == true){
1498                if( issnReg.test($(this).val()) == false ){
1499                    checkIssn = checkIssn +1;
1500                }
1501            }
1502        });
1503
1504        if(checkIssn == 0){
1505            $('.issn-box strong').hide();
1506        }
1507    });
1508
1509
1510
1511    $('.form-issn-area input[type="text"]').each(function(){
1512        if($(this).val() == ""){
1513            $(this).parents(".row").children().children('input[type=text]').attr("disabled", true);
1514        }else{
1515            $(this).parents(".row").children().children('input[type=checkbox]').prop( "checked", true );
1516        }
1517    })
1518
1519    //disable or anable text field when checkbox is clicked
1520    $('.form-issn-area input[type="checkbox"]').change(function(){
1521        var issnReg = /^\d{4}\-\d{3}[\dxX]$/;
1522        var issnResult = issnReg.test($(this).val());
1523        var checkIssn = 0;
1524
1525        if($(this).is(":checked")){
1526            $('.issn-box input[type=text]').each(function(){
1527                var checkbox = $(this).closest('.issn-box').parent().find('.issn-check input').is(":checked")
1528
1529                if(checkbox == true){
1530                    if( issnReg.test($(this).val()) == false ){
1531                        checkIssn = checkIssn +1;
1532                        $(this).style('border-color', 'red','important');
1533                    }
1534                }
1535            });
1536
1537            if(checkIssn == 0){
1538                $('.issn-box strong').hide();
1539            }else{
1540
1541                $('.issn-box strong').show();
1542            }
1543
1544
1545            $(this).parents(".row").children().children('input[type=text]').removeAttr("disabled");
1546        }else{
1547            $(this).closest('.row').find('.issn-box input').css({'border-color': '#ddd'});
1548            $('.issn-box input[type=text]').each(function(){
1549                var checkbox = $(this).closest('.issn-box').parent().find('.issn-check input').is(":checked")
1550
1551                if(checkbox == true){
1552                    if( issnReg.test($(this).val()) == false ){
1553                        checkIssn = checkIssn +1;
1554                    }
1555                }
1556            });
1557
1558            if(checkIssn == 0){
1559                $('.issn-box strong').hide();
1560            }
1561            $(this).parents(".row").children().children('input[type=text]').attr("disabled", true);
1562        }
1563    })
1564
1565
1566}
1567
1568
1569/* FUNCTIONS :: FORM :: Users
1570==========================================
1571¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1572function EC_usersForm(){
1573    $('#issues-form').submit(function(event){
1574        if ($("#pass_check").length ) {
1575            validateEmail($('#User_email').val());
1576            if($('#User_password').val() !== $('#pass_check').val()){
1577                alert('senha != de confirmação');
1578                event.preventDefault();
1579            }
1580            if(response == 1){
1581                alert('email já existente');
1582                event.preventDefault();
1583            }
1584        }else{
1585
1586        }
1587    });
1588
1589    function validateEmail(email){
1590        var urlRequest = window.yiiBaseURL+"/site/validateEmail?email="+email;
1591        $.ajax({
1592            type: "GET",
1593            url: urlRequest,
1594            async: false,
1595            success:function(data) {
1596                window.response = data;
1597            }
1598        });
1599    }
1600}
1601
1602/* FUNCTIONS :: FORM :: Languages
1603==========================================
1604¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1605function EC_languagesFormLoad(){
1606    $('#Clients_default_language').html("");
1607    var langCount = 0;
1608    $("#site-languages-form input[type='checkbox']").each(function(){
1609        if(this.checked) {
1610            langCount++;
1611            $('#Clients_default_language').append('<option value="'+$(this).attr('ec-data-language')+'">'+$(this).attr('ec-data-label')+'</option>')
1612        }
1613    });
1614    if(langCount == 1){
1615        var value = $("#site-languages-form input:checked").attr('ec-data-language');
1616        // EC_clientSimpleUpdate('default_language', value);
1617        $('#Clients_default_language').val(value);
1618    }
1619
1620    if(($('#Clients_languagePT:checked').length > 0) || ($('#Clients_languageEN:checked').length > 0) || ($('#Clients_languageES:checked').length > 0)  ){
1621    }else{
1622        $('#Clients_languagePT').attr('checked', 'checked');
1623        $('#Clients_default_language').append('<option value="pt">Português</option>')
1624    }
1625
1626    if(($('#Clients_articleLangPT:checked').length > 0) || ($('#Clients_articleLangEN:checked').length > 0) || ($('#Clients_articleLangES:checked').length > 0)  ){
1627    }else{
1628        $('#Clients_articleLangPT').attr('checked', 'checked');
1629    }
1630}
1631
1632// Languages Form :: Site Languages Update
1633$("#site-languages-form input[type='checkbox']").click(function(event){
1634    if(  ($('#Clients_languagePT:checked').length > 0) || ($('#Clients_languageEN:checked').length > 0) || ($('#Clients_languageES:checked').length > 0)  ){
1635        var langCount = 0;
1636            $('#Clients_default_language').html('');
1637        $("#site-languages-form input[type='checkbox']").each(function(){
1638            if(this.checked) {
1639                langCount++;
1640                $('#Clients_default_language').append('<option value="'+$(this).attr('ec-data-language')+'">'+$(this).attr('ec-data-label')+'</option>')
1641            }
1642        });
1643        if(langCount == 1){
1644            var value = $("#site-languages-form input:checked").attr('ec-data-language');
1645            EC_clientSimpleUpdate('default_language', value);
1646            $('#Clients_default_language').val(value);
1647        }
1648
1649        var field = $(this).parent().attr('id');
1650        if(this.checked) {
1651            var value = '1';
1652        }else{
1653            var value = '0';
1654        }
1655        EC_clientSimpleUpdate(field, value);
1656
1657    }else{
1658        EC_closeSweetAlert();
1659        console.log('PRECISA ESCOLHER UM IDIOMA');
1660        event.preventDefault();
1661    }
1662});
1663
1664// Languages Form :: Article Languages Update
1665$("#articles-languages-form input[type='checkbox']").click(function(event){
1666    EC_showSweetAlert();
1667
1668    if(($('#Clients_articleLangPT:checked').length > 0) || ($('#Clients_articleLangEN:checked').length > 0) || ($('#Clients_articleLangES:checked').length > 0)  ){
1669        var field = $(this).parent().attr('id');
1670        if(this.checked) {
1671            var value = '1';
1672        }else{
1673            var value = '0';
1674        }
1675        EC_clientSimpleUpdate(field, value);
1676    }else{
1677        EC_closeSweetAlert();
1678        console.log('PRECISA ESCOLHER UM IDIOMA');
1679        event.preventDefault();
1680    }
1681});
1682
1683/* FUNCTIONS :: CLIENT SETUP
1684==========================================
1685¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
1686function EC_userSetup(){
1687    //USER :: REGISTRATION STEPS
1688    console.log('REGISTRATION STEPS');
1689    console.log('welcome');
1690    console.log('---');
1691    getClientIds();
1692
1693    $('#User_journalId').focus();
1694    var url = new URL(window.location.href);
1695    var idParam = url.searchParams.get("id");
1696
1697    if((idParam !== "") && (idParam !== null) ){
1698        idParam = removeDiacritics(idParam);
1699        idParam = idParam.replace(/[^a-zA-Z ]|[0-9]/g, "");
1700        idParam = $.trim(idParam);
1701        idParam = idParam.substring(0, 15);
1702
1703        $('#User_journalId').val(idParam);
1704        $('#show-id').html(idParam);
1705        validateClientId(idParam);
1706    }
1707
1708    /* FUNCTIONS
1709    ===================================================================================== */
1710     //FUNCTION :: Email Validation
1711    function validateEmail(email){
1712        var urlRequest = window.yiiBaseURL+"/site/validateEmail";
1713        $.ajax({
1714            type: 'POST',
1715            data: {"email": email},
1716            url: urlRequest,
1717            async: false,
1718            success:function(data) {
1719                window.response = data;
1720            }
1721        });
1722    }
1723
1724    
1725
1726    //FUNCTION :: JOurnalID Validation
1727    function getClientIds(){
1728        var urlRequest = window.yiiBaseURL+"/site/getClientIds";
1729        $.ajax({
1730            type: "GET",
1731            url: urlRequest,
1732            dataType: "json",
1733            async: false,
1734            success:function(response) {
1735                window.clientIDs = [];
1736                $.each(response, function(){
1737                    window.clientIDs.push(this.journalID);
1738                });
1739            }
1740        });
1741    }
1742
1743    //FUNCTION :: JOurnalID Validation
1744    function validateClientId(clientId){
1745        window.validID = 0;
1746        if($('input#User_journalId').val().length <1){
1747            window.validID = 0;
1748            $('.status-id .status').hide();
1749            $('.status-id .status-off').show();
1750            $('.notMinLength').hide();
1751            $('.valid').hide();
1752            $('.notValid').hide();
1753        }else if($('input#User_journalId').val().length <2){
1754            window.validID = 0;
1755            $('.status-id .status').hide();
1756            $('.status-id .status-error').show();
1757            $('.notMinLength').show();
1758            $('.valid').hide();
1759            $('.notValid').hide();
1760        }else if($.inArray($('input#User_journalId').val(), window.clientIDs) != -1){
1761            window.validID = 0;
1762            $('.status-id .status').hide();
1763            $('.status-id .status-error').show();
1764            $('.notMinLength').hide();
1765            $('.valid').hide();
1766            $('.notValid').show();
1767        }else{
1768            if($("input#User_journalId").val() == ""){
1769                $('.status-id .status').hide();
1770                $('.status-id .status-off').show();
1771                window.validID = 0;
1772                $('.notMinLength').hide();
1773                $('.valid').hide();
1774                $('.notValid').hide();
1775            }else{
1776                window.validID = 1;
1777                $('.status-id .status').hide();
1778                $('.status-id .status-ok').show();
1779                // $('.valid').show();
1780                $('.notMinLength').hide();
1781                $('.notValid').hide();
1782            }            
1783        }
1784    }
1785
1786    /* Code
1787    ===================================================================================== */
1788    //UPDATE ID :: dinamically validate and update ID preview while user is typing
1789    $('input#User_journalId').keyup(function() {
1790        var clientId = $('input#User_journalId').val();
1791        validateClientId(clientId);
1792        $('#show-id').html(clientId);
1793        $('input#User_journalId').focus();
1794    });
1795
1796    $('input#User_journalId').blur(function() {
1797        var clientId = $('input#User_journalId').val();
1798        
1799        if(clientId !== null && clientId !== ""){
1800            validateClientId(clientId);
1801            $('#show-id').html(clientId);
1802
1803            EC_validateDomain(clientId);
1804            if(window.isValidDomain == 1){
1805                if(clientId.length <1){
1806                    $('.status-id .status').hide();
1807                    $('.status-id .status-off').show();
1808                    $('.notMinLength').hide();
1809                    $('.valid').hide();
1810                    $('.notValid').hide();
1811                }else if(clientId.length <2){
1812                    $('.status-id .status').hide();
1813                    $('.status-id .status-error').show();
1814                    $('.notMinLength').show();
1815                    $('.valid').hide();
1816                    $('.notValid').hide();
1817                }else if($.inArray(clientId, window.clientIDs) != -1){
1818                    $('.status-id .status').hide();
1819                    $('.status-id .status-error').show();
1820                    $('.notMinLength').hide();
1821                    $('.valid').hide();
1822                    $('.notValid').show();
1823                }else{
1824                    if(clientId == ""){
1825                        $('.status-id .status').hide();
1826                        $('.status-id .status-off').show();
1827                            $('.notMinLength').hide();
1828                        $('.valid').hide();
1829                        $('.notValid').hide();
1830                    }else{
1831                        $('.status-id .status').hide();
1832                        $('.status-id .status-ok').show();
1833                        $('.notMinLength').hide();
1834                        $('.notValid').hide();
1835                    }            
1836                }
1837            }else{
1838                $('.status-id .status').hide();
1839                $('.status-id .status-error').show();
1840                $('.notMinLength').hide();
1841                $('.valid').hide();
1842                $('.notValid').show();
1843            }
1844        }
1845    });
1846
1847    $('input#User_journalId').blur(function() {
1848        getClientIds();
1849    });
1850
1851    //validate Name
1852    //-------------------------------------------------
1853    $('input#User_first_name').keyup(function() {
1854        if($('input#User_first_name').val().length <1){
1855            $('.status-name .status').hide();
1856            $('.status-name .status-error').show();
1857        }else{
1858            $('.status-name .status').hide();
1859            $('.status-name .status-ok').show();
1860        }
1861    });
1862
1863    //Email Live Check
1864    //-------------------------------------------------
1865    $('input#User_email').keyup(function() {
1866        var email = $('input#User_email').val();
1867        
1868        if($('input#User_email').val().length <1){
1869            $('.status-email .status').hide();
1870            $('.status-email .status-error').show();
1871        }else{
1872            var emailRegex = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*");
1873            if(emailRegex.test(email)){
1874                $('.error-email-validation').hide();
1875                validateEmail(email);
1876                if(response == 1){
1877                    $('.error-email').show();
1878                    $('.status-email .status').hide();
1879                    $('.status-email .status-error').show();
1880                }else{
1881                    $('.error-email').hide();
1882                    $('.status-email .status').hide();
1883                    $('.status-email .status-ok').show();
1884                }
1885            }else{
1886                $('.error-email-validation').show();
1887                $('.status-email .status').hide();
1888                $('.status-email .status-error').show();
1889            }           
1890        }
1891    });
1892
1893    //Password - Live Check
1894    //-------------------------------------------------
1895    $('input#User_password').keyup(function() {
1896        if($('input#User_password').val().length <6){
1897            $('.status-pass .status').hide();
1898            $('.status-pass .status-error').show();
1899            $('.passMinLength').show();
1900        }else{
1901            $('.status-pass .status').hide();
1902            $('.passMinLength').hide();
1903            $('.status-pass .status-ok').show();
1904        }
1905    });
1906
1907    //Password Confirmation - Live Check
1908    //-------------------------------------------------
1909    $('input#pass_check').keyup(function() {
1910        if($('input#pass_check').val() !== $('input#User_password').val()){
1911            $('.passDifference').show();
1912            $('.status-pass2 .status').hide();
1913            $('.status-pass2 .status-error').show();
1914        }else{
1915            $('.passDifference').hide();
1916            $('.status-pass2 .status').hide();
1917            $('.status-pass2 .status-ok').show();
1918        }
1919    });
1920
1921    /* Cleaning Journal ID
1922    ====================== */
1923    $('#User_journalId').keypress(function(key) {
1924        try{var element = key.which}catch(er){};
1925        try{var element = event.keyCode }catch(er){};
1926        if (String.fromCharCode(element).search(/[a-z]|[0-9]/gi) == -1){ return false}
1927        $('#User_journalId').val(removeDiacritics($('#User_journalId').val()));
1928    });
1929
1930    $('#User_journalId').keyup(function(key) {
1931        idParam = $('#User_journalId').val();
1932        idParam = removeDiacritics(idParam);
1933        idParam = idParam.replace(/[^a-zA-Z ]|[0-9]/g, "");
1934        $('#User_journalId').val(idParam);
1935        $('#show-id').html(idParam);
1936        $('#User_journalId').val(removeDiacritics($('#User_journalId').val()));
1937    });
1938
1939    // $('#User_journalId').keyup(function(key) {
1940    //     var idVal = $('#User_journalId').val().replace(/[^a-zA-Z ]|[0-9]/g, "");
1941    //     $('#User_journalId').val(removeDiacritics(idVal));
1942    // });
1943
1944
1945
1946    
1947    //SUBMIT ACTION :: Validate and submit
1948    $('#reg-form').submit(function(event){
1949        var testID = false;
1950        var testDomain = false;
1951        var testEmail = false;
1952        var testPassword = false;
1953        var testRecaptcha = false;
1954
1955        validateClientId($('#User_journalId').val());
1956        if(window.validID == 1){
1957            testID = true;
1958        }else{
1959            testID = false;
1960        }
1961
1962        EC_validateDomain($('#User_journalId').val(), true);
1963        if(window.isValidDomain == 1){
1964            testDomain = true;            
1965        }else{
1966            testDomain = false;            
1967        }
1968
1969        if((testID == true) && (testDomain == true)){
1970            $('.status-id .status').hide();
1971            $('.status-id .status-ok').show();
1972            $('.notMinLength').hide();
1973            $('.notValid').hide();
1974        }else{
1975            $('.status-id .status').hide();
1976            $('.status-id .status-error').show();
1977            $('.notMinLength').hide();
1978            $('.valid').hide();
1979            $('.notValid').show();
1980        }
1981
1982        validateEmail($('#User_email').val());
1983        if(response == 1){
1984            testEmail = false;
1985        }else{
1986            testEmail = true;
1987        }
1988
1989        if($('input#pass_check').val() !== $('input#User_password').val()){
1990            testPassword = false;
1991        }else{
1992            testPassword = true;
1993        }
1994
1995        EC_validateRecaptcha();
1996        if(window.isHuman == 0 || typeof window.isHuman == "undefined"){
1997            testRecaptcha = false;
1998            $('.status-recaptcha .error').show();
1999        }else{
2000            testRecaptcha = true;
2001            $('.status-recaptcha .error').hide();
2002        }
2003
2004        console.log("- ID: "+testID);
2005        console.log("- Domain: "+testDomain);
2006        console.log("- Email: "+testEmail);
2007        console.log("- Password: "+testPassword);
2008        console.log("- Recaptcha: "+testRecaptcha);
2009
2010        if((testID == true) && (testDomain == true) && (testEmail == true) && (testPassword == true) && (testRecaptcha == true)){
2011            console.log("PASS: Registration allowed");
2012            $('#site-footer').hide();
2013            if(currentLanguage == "pt"){
2014                swal({
2015                    title: "Criando seu site",
2016                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2017                    showConfirmButton: false
2018                });
2019            }else{
2020                swal({
2021                    title: "Creating your site",
2022                    imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2023                    showConfirmButton: false
2024                });
2025            }
2026
2027        }else{
2028            setTimeout(function(){
2029                $('#site-footer').show();
2030                swal.close();
2031            },500);
2032            console.log("FAIL: Preventing registration");
2033            grecaptcha.reset();
2034            event.preventDefault();
2035        }
2036    });   
2037}
2038
2039
2040/* FUNCTIONS :: ARTICLES FORM :: Import XML
2041==========================================
2042¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2043function formatAbstract(abstract){
2044    //if no abstract tag is found, use body tag instead
2045    if(abstract === undefined || abstract == ""){
2046        console.log('not found');
2047        $('#Articles_xml').parent().append('<div class="errorMessage" style="display:block;">- "abstract" não encontrado, usando "body"</div>');
2048        var xmlbody = $(xml).find('body').html();
2049        abstract = xmlbody;
2050        abstract = abstract.replace(/<title\/>/g, "");
2051        abstract = abstract.replace(/<title>/g, "<br /><span class='abstract-title'>");
2052        abstract = abstract.replace(/<\/title>/g,"</span><br />");
2053        abstract = abstract.replace(/<p>/g, "");
2054        abstract = abstract.replace(/<\/p>/g,"<br /><br />");
2055        abstract = abstract.replace(/<italic>/g, "<em>");
2056        abstract = abstract.replace(/<\/italic>/g,"</em>");
2057        abstract = abstract.replace(/<bold>/g, "<strong>");
2058        abstract = abstract.replace(/<\/bold>/g,"</strong>");
2059    }else{
2060    	// console.log('found!');
2061
2062        //if abstract tag is found use it
2063        abstract = abstract.replace(/<title\/>/g, "");
2064        abstract = abstract.replace(/<title>/g, "<span class='abstract-title'>");
2065        abstract = abstract.replace(/<\/title>/g,":</span> ");
2066        abstract = abstract.replace(/<p>/g, "");
2067        abstract = abstract.replace(/<\/p>/g,"");
2068        abstract = abstract.replace(/<br>/g, " ");
2069        abstract = abstract.replace(/<italic>/g, "<em>");
2070        abstract = abstract.replace(/<\/italic>/g,"</em>");
2071        abstract = abstract.replace(/<bold>/g, "<strong>");
2072        abstract = abstract.replace(/<\/bold>/g,"</strong>");
2073    }
2074    return abstract;
2075}
2076
2077function formatTransAbstract(transAbstract){
2078	// console.log(transAbstract);
2079    transAbstract = transAbstract.replace('<trans-abstract xml:lang="en">', "");
2080    transAbstract = transAbstract.replace('<trans-abstract xml:lang="pt">', "");
2081    transAbstract = transAbstract.replace('<trans-abstract xml:lang="es">', "");
2082    transAbstract = transAbstract.replace('</trans-abstract>', "");
2083    transAbstract = transAbstract.replace(/<title\/>/g, "");
2084    transAbstract = transAbstract.replace(/<title>/g, "<span class='abstract-title'>");
2085    transAbstract = transAbstract.replace(/<\/title>/g,":</span> ");
2086    transAbstract = transAbstract.replace(/<p>/g, "");
2087    transAbstract = transAbstract.replace(/<\/p>/g,"");
2088    transAbstract = transAbstract.replace(/<italic>/g, "<em>");
2089    transAbstract = transAbstract.replace(/<\/italic>/g,"</em>");
2090    transAbstract = transAbstract.replace(/<bold>/g, "<strong>");
2091    transAbstract = transAbstract.replace(/<\/bold>/g,"</strong>");
2092    return transAbstract;
2093}
2094
2095
2096$('body').on('click','#scielo-import-button', function(){    
2097    var link = $('#scielo_url').val();
2098  var hasPid = link.indexOf("pid=");
2099  var isScielo = link.indexOf("scielo");
2100
2101  if (link == "" || isScielo == -1) {
2102    if (window.currentLanguage == "pt") {
2103      showErrorAlert("Link SciELO invalido");
2104    } else {
2105      showErrorAlert("Invalid SciELO Link");
2106    }
2107    return;
2108  }
2109
2110    var urlRequest = window.yiiBaseURL+"/articles/getXMLFromSciELO";
2111
2112    $.ajax({
2113        type: "POST",
2114        url: urlRequest,
2115        async: false,
2116        data: {"link":link},
2117
2118        error: function(message){
2119            console.log(message);
2120            if(window.currentLanguage == "pt"){
2121                showErrorAlert("Esse Tipo de Artigo ainda não é suportado.  Por favor envie o link que tentou para [email protected]");
2122            }else{
2123                showErrorAlert("This Article Type is not yet supported.  Please send the link you tried to [email protected]");
2124            }
2125            
2126        },
2127        success: function(file){
2128      fillFormFromJsonData(file);
2129    }
2130
2131    });
2132});
2133
2134function EC_importXML(files) {
2135  // console.log(files);
2136  var urlRequest = window.yiiBaseURL + "/articles/importXML";
2137
2138  // START A LOADING SPINNER HERE
2139  $('#spinner').show();
2140
2141  // Create a formdata object and add the files
2142  var data = new FormData();
2143  $.each(files, function(key, value) {
2144    data.append(key, value);
2145  });
2146
2147  $.ajax({
2148    url: urlRequest,
2149    type: 'POST',
2150    data: data,
2151    cache: false,
2152    // dataType: 'json',
2153    processData: false,
2154    contentType: false,
2155    error: function(message) {
2156      console.log(message);
2157    },
2158    success: function(file) {
2159      fillFormFromJsonData(file);
2160    }
2161  });
2162}
2163
2164function fillFormFromJsonData(jsonData) {
2165  $('#spinner').hide();
2166  // console.log("OK");
2167
2168  //getting data
2169  article = $.parseJSON(jsonData);
2170  // console.log(article);
2171  var i = 0;
2172  var lang = [];
2173  var title = [];
2174  var abstract = [];
2175  var main_abstract = "";
2176  var keywords = [];
2177  var authors = article['authors'];
2178  var doi = article['doi'];
2179  var fpage = article['fpage'];
2180  var lpage = article['lpage'];
2181  var elocation = article['elocation'];
2182  var article_type = article['article_type'];
2183  var references = article['references'];
2184  references = references.replace(/<mixed-citation>/g, "");
2185  references = references.replace(/<\/mixed-citation>/g, "<br /><br />");
2186  $.each(article['title'], function(index, value) { title[index] = value; lang[i] = index; i++ });
2187  $.each(article['abstract'], function(index, value) { abstract[index] = value; });
2188  $.each(article['keywords'], function(index, value) { keywords[index] = value; });
2189  main_abstract = formatAbstract(abstract[lang[0]]);
2190
2191  //clean fields
2192  $('#articles-form').trigger("reset");
2193  $('#ArticleTranslations_t0').val("");
2194  $('#ArticleTranslations_t1').val("");
2195  $('#ArticleTitleGroup_trans_title_group_0').val("");
2196  $('#ArticleTitleGroup_trans_title_group_0_trans_title').val("");
2197  $('.typesArea #yw0_tab_0 input').val("");
2198  $('.typesArea #yw0_tab_1 input').val("");
2199  $('#ArticleKeywordsGroup_trans_keywords_group_0').val("");
2200  $('#ArticleKeywordsGroup_trans_keywords_group_0_trans_keywords').val("");
2201  $('#ArticleTitleGroup_trans_title_group_1').val("");
2202  $('#ArticleTitleGroup_trans_title_group_1_trans_title').val("");
2203  $('#ArticleKeywordsGroup_trans_keywords_group_1').val("");
2204  $('#ArticleKeywordsGroup_trans_keywords_group_1_trans_keywords').val("");
2205  EC_articlesForm(window.userJournal);
2206
2207  //fill fields
2208  // $('#ArticleTitleGroup_article_title').val(title[lang[0]]);
2209  // $('#ArticleKeywordsGroup_article_keywords').val(keywords[lang[0]]);
2210  CKEDITOR.instances['ArticleTitleGroup_article_title'].setData(title[lang[0]]);
2211  CKEDITOR.instances['ArticleAbstractGroup_article_abstract'].setData(main_abstract);
2212  CKEDITOR.instances['ArticleKeywordsGroup_article_keywords'].setData(keywords[lang[0]]);
2213  $('#Articles_authors').val(authors);
2214  CKEDITOR.instances['Articles_references'].setData(references);
2215  $("#Articles_lang").val(lang[0]);
2216  $('#Articles_doi').val(doi);
2217  $('#Articles_first_page').val(fpage);
2218  $('#Articles_last_page').val(lpage);
2219  $('#Articles_elocation').val(elocation);
2220  $('.typesArea #yw0_tab_0 input').val(article_type);
2221  $('.typesArea #yw0_tab_1 input').val(article_type);
2222
2223  setTimeout(function() {
2224    $('#Articles_lang').change();
2225    $('#ArticleTranslations_t0').change();
2226    $('#ArticleTranslations_t1').change();
2227  }, 500);
2228
2229
2230  // console.log(lang.length);
2231  if (lang.length === 1) {
2232    if ($(".ui-tabs-nav li[aria-controls='trans_title_0']").length) {
2233      CKEDITOR.instances['ArticleAbstractGroup_trans_abstract_group_0'].setData("");
2234    }
2235
2236    if ($(".ui-tabs-nav li[aria-controls='trans_title_1']").length) {
2237      CKEDITOR.instances['ArticleAbstractGroup_trans_abstract_group_1'].setData("");
2238    }
2239  }
2240
2241  if (lang.length === 2) {
2242    $('#ArticleTranslations_t0').val(lang[1]);
2243    abstract_t0 = formatTransAbstract(abstract[lang[1]]);
2244    if ($(".ui-tabs-nav li[aria-controls='trans_title_0']").length) {
2245      CKEDITOR.instances['ArticleAbstractGroup_trans_abstract_group_0'].setData(abstract_t0);
2246      CKEDITOR.instances['ArticleTitleGroup_trans_title_group_0'].setData(title[lang[1]]);
2247      CKEDITOR.instances['ArticleKeywordsGroup_trans_keywords_group_0'].setData(keywords[lang[1]]);
2248      // CKEDITOR.instances['ArticleTitleGroup_trans_title_group_0_trans_title'].setData(title[lang[1]]);
2249      // CKEDITOR.instances['ArticleKeywordsGroup_trans_keywords_group_0_trans_keywords'].setData(keywords[lang[1]]);
2250      // console.log(keywords[lang[1]]);
2251    }
2252    // $('#ArticleTitleGroup_trans_title_group_0').val(title[lang[1]]);
2253    // $('#ArticleTitleGroup_trans_title_group_0_trans_title').val(title[lang[1]]);
2254    // $('#ArticleKeywordsGroup_trans_keywords_group_0').val(keywords[lang[1]]);
2255    // $('#ArticleKeywordsGroup_trans_keywords_group_0_trans_keywords').val(keywords[lang[1]]);
2256  }
2257
2258  if (lang.length === 3) {
2259    $('#ArticleTranslations_t0').val(lang[1]);
2260    $('#ArticleTranslations_t1').val(lang[2]);
2261
2262    CKEDITOR.instances['ArticleTitleGroup_trans_title_group_0'].setData(title[lang[1]]);
2263    CKEDITOR.instances['ArticleTitleGroup_trans_title_group_0'].setData(title[lang[2]]);
2264
2265    CKEDITOR.instances['ArticleKeywordsGroup_trans_keywords_group_0'].setData(keywords[lang[1]]);
2266    CKEDITOR.instances['ArticleKeywordsGroup_trans_keywords_group_0'].setData(keywords[lang[2]]);
2267
2268    abstract_t0 = formatTransAbstract(abstract[lang[1]]);
2269    CKEDITOR.instances['ArticleAbstractGroup_trans_abstract_group_0'].setData(abstract_t0);
2270
2271    abstract_t1 = formatTransAbstract(abstract[lang[2]]);
2272    CKEDITOR.instances['ArticleAbstractGroup_trans_abstract_group_1'].setData(abstract_t1);
2273    // $('#ArticleTitleGroup_trans_title_group_0').val(title[lang[1]]);
2274    // $('#ArticleTitleGroup_trans_title_group_0_trans_title').val(title[lang[1]]);
2275    // $('#ArticleKeywordsGroup_trans_keywords_group_0').val(keywords[lang[1]]);
2276    // $('#ArticleKeywordsGroup_trans_keywords_group_0_trans_keywords').val(keywords[lang[1]]);
2277    // $('#ArticleTitleGroup_trans_title_group_1').val(title[lang[2]]);
2278    // $('#ArticleTitleGroup_trans_title_group_1_trans_title').val(title[lang[2]]);
2279    // $('#ArticleKeywordsGroup_trans_keywords_group_1').val(keywords[lang[2]]);
2280    // $('#ArticleKeywordsGroup_trans_keywords_group_1_trans_keywords').val(keywords[lang[2]]);
2281  }
2282
2283  if (window.currentLanguage == "pt") {
2284    swal("Informações importadas");
2285  } else {
2286    swal("Data imported");
2287  }
2288
2289}
2290
2291
2292/* FUNCTIONS :: FORM ::  Auto-save & Upload Functions
2293=======================================================
2294¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2295//appearance form
2296function EC_formAppearanceImages(bucket, files, imageType){
2297    var urlRequest = window.yiiBaseURL+"/clients/formAppearanceImages?jid="+window.userJournal+"&clientID="+window.clientMongoID+"&type="+imageType;
2298    var data = new FormData();
2299    $('#spinner_'+imageType).show();
2300    $.each(files, function(key, value){
2301        data.append(key, value);
2302    });
2303
2304    $.ajax({
2305        url: urlRequest,
2306        type: 'POST',
2307        data: data,
2308        cache: false,
2309        processData: false,
2310        contentType: false,
2311        error: function(message){
2312            console.log('error');
2313            console.log(message);
2314            $('#spinner_'+imageType).hide();
2315        },
2316        success: function(file){
2317            // var fileURL = 'http://s3.amazonaws.com/host-client-assets/files/'+window.userJournal+'/'+file;
2318            var fileURL = bucket+'/files/'+window.userJournal+'/'+file;
2319            var capitalizeType = imageType.substr(0,1).toUpperCase()+imageType.substr(1);
2320            // $('.client-'+imageType+' .file-upload-button').css({'background': 'rgba(0,0,0,0.03) url('+fileURL+') left center no-repeat', 'background-size':'auto 100%'});
2321            setTimeout(function(){
2322                var timestamp = Number(new Date());
2323                // console.log(timestamp);
2324                // console.log(imageType);
2325                $('.client-'+imageType+' .file-upload-button img').attr({'src': fileURL+"?t="+timestamp});
2326                $('#spinner_'+imageType).hide();
2327                $('.deleteImage.'+imageType).css('visibility','visible');
2328            }, 2500);
2329
2330            $("#Clients_client"+capitalizeType).val(file);
2331        }
2332    });
2333}
2334
2335//appearance form
2336function EC_formAppearanceInfo(imageType, option){
2337    EC_showSweetAlert();
2338    var urlRequest = window.yiiBaseURL+"/clients/formAppearanceInfo?jid="+window.userJournal+"&clientID="+window.clientMongoID+"&type="+imageType+"&option="+option;
2339    var data = new FormData();
2340    $.ajax({
2341         url: urlRequest,
2342        type: 'POST',
2343        data: data,
2344        cache: false,
2345        processData: false,
2346        contentType: false,
2347        error: function(message){
2348            console.log('error');
2349            console.log(message);
2350            EC_closeSweetAlert('error');
2351        },
2352        success: function(response){
2353        // console.log(response);
2354            console.log('saved');
2355            EC_closeSweetAlert();
2356        }
2357    })
2358}
2359
2360//languages form
2361function EC_clientSimpleUpdate(field, value, stayOpen){
2362    // console.log(field);
2363
2364    if((field !== "templateSize") && (field !== "templateLogo")){
2365        EC_showSweetAlert();
2366    }
2367    var urlRequest = window.yiiBaseURL+"/clients/formLanguagesUpdate?jid="+window.userJournal+"&clientID="+window.clientMongoID;
2368    var data = new FormData();
2369    $.ajax({
2370        url: urlRequest,
2371        type: 'POST',
2372        data: {"field": field, "value": value},
2373        async:true,
2374        error: function(message){
2375            console.log('error');
2376            console.log(message);
2377            EC_closeSweetAlert('error');
2378        },
2379        success: function(response){
2380            // console.log(response);
2381            console.log('saved');
2382            if(field == "admin_language"){
2383                setTimeout(function(){
2384                    location.reload();
2385                }, 1200);
2386            }
2387            if((field == "journalScopePT") || (field == "journalScopeEN") || (field == "journalAboutPT") || (field == "journalAboutEN") || (field == "journalBoardPT") || (field == "journalBoardEN") || (field == "journalInstructionsPT") || (field == "journalInstructionsEN") || (field == "journalContactPT") || (field == "journalContactEN") || (field == "journalCurrentPT") || (field == "journalCurrentEN") || (field == "journalArchivePT") || (field == "journalArchiveEN")){
2388                window.oldData = CKEDITOR.instances[window.textareaID].getData();
2389                // $('.submit-status').fadeIn();
2390                // setTimeout(function(){
2391                //     $('.submit-status').fadeOut()
2392                // }, 3000);
2393            }
2394
2395            if(field == "analyticsID" || field == "tawktoCode" || field == "sjrCode" || field == "trendMDCode"){
2396                setTimeout(function(){
2397                    location.reload();
2398                }, 1200);
2399            }
2400            if(stayOpen != true){
2401                EC_closeSweetAlert();
2402            }
2403
2404             if(field == "first_access"){
2405                setTimeout(function(){
2406                    window.location.replace('http://app.periodikos.com.br/');
2407                }, 1200);
2408            }
2409        }
2410    })
2411}
2412
2413//languages form
2414function EC_pageSimpleUpdate(field, value, stayOpen){
2415    // console.log(field);
2416
2417    var urlRequest = window.yiiBaseURL+"/clients/formLanguagesUpdate?jid="+window.userJournal+"&clientID="+window.clientMongoID;
2418    var data = new FormData();
2419    $.ajax({
2420        url: urlRequest,
2421        type: 'POST',
2422        data: {"field": field, "value": value},
2423        async:true,
2424        error: function(message){
2425            console.log('error');
2426            console.log(message);
2427            EC_closeSweetAlert('error');
2428        },
2429        success: function(response){
2430            // console.log(response);
2431            console.log('saved');
2432
2433        }
2434    })
2435}
2436
2437
2438
2439//languages form
2440function EC_userSimpleUpdate(field, value){
2441    EC_showSweetAlert();
2442    var urlRequest = window.yiiBaseURL+"/admin/updateUser";
2443    var data = new FormData();
2444    $.ajax({
2445        url: urlRequest,
2446        type: 'POST',
2447        data: {"userID":userID, "field": field, "value": value},
2448        async:true,
2449        error: function(message){
2450            console.log('error');
2451            console.log(message);
2452            EC_closeSweetAlert('error');
2453        },
2454        success: function(response){
2455            // console.log(response);
2456            // console.log(response);
2457            EC_closeSweetAlert();
2458
2459            if(field="first_name"){
2460                $('.client-logout strong').text(value);
2461
2462            }
2463        }
2464    })
2465}
2466
2467function EC_pageStatusUpdate(id, collection){
2468    if(collection == "Pages"){
2469        var urlRequest = window.yiiBaseURL+"/pages/updateStatus";
2470
2471    }else if(collection == "Clients"){
2472        var urlRequest = window.yiiBaseURL+"/clients/updatePageStatus";
2473    }
2474    var data = new FormData();
2475    $.ajax({
2476        url: urlRequest,
2477        type: 'POST',
2478        data: {"id": id},
2479        async:true,
2480        error: function(message){
2481            console.log('error');
2482            console.log(message);
2483            EC_closeSweetAlert('error');
2484        },
2485        success: function(response){
2486            console.log('updated');
2487            console.log(response);
2488
2489
2490            if(response == 'notPublished'){
2491                if(window.currentLanguage == "pt"){
2492                    var pageStatusLinkText = "Clique aqui para Publicar esta página";
2493                }else{
2494                    var pageStatusLinkText = "Click here to Publish this page";
2495                }
2496                $(".action-pageStatus[ec-link-data='"+id+"']").attr('title', pageStatusLinkText);
2497                $(".action-pageStatus[ec-link-data='"+id+"']").addClass('notPublished');
2498                $(".action-pageStatus[ec-link-data='"+id+"']").removeClass('published');
2499                $(".action-pageStatus[ec-link-data='"+id+"']").closest( "tr" ).addClass('notPublished');
2500                $(".action-pageStatus[ec-link-data='"+id+"']").closest( "tr" ).removeClass('published');
2501            }else{
2502                if(window.currentLanguage == "pt"){
2503                    var pageStatusLinkText = "Clique aqui para Desativar esta página";
2504                }else{
2505                    var pageStatusLinkText = "Click here to Deactivate this page";
2506                }
2507                $(".action-pageStatus[ec-link-data='"+id+"']").attr('title', pageStatusLinkText);
2508                $(".action-pageStatus[ec-link-data='"+id+"']").addClass('published');
2509                $(".action-pageStatus[ec-link-data='"+id+"']").removeClass('notPublished');
2510                $(".action-pageStatus[ec-link-data='"+id+"']").closest( "tr" ).addClass('published');
2511                $(".action-pageStatus[ec-link-data='"+id+"']").closest( "tr" ).removeClass('notPublished');
2512            }
2513        }
2514    })
2515}
2516
2517
2518function EC_getUserSHA(inputValue, password, msgErrorPass, msgErrorPassInfo){
2519    var urlRequest = window.yiiBaseURL+"/admin/getSHA";
2520    var data = new FormData();
2521    $.ajax({
2522        url: urlRequest,
2523        type: 'POST',
2524        data: {"inputValue":inputValue},
2525        async:true,
2526        error: function(message){
2527            console.log('error');
2528            console.log(message);
2529            EC_closeSweetAlert('error');
2530        },
2531        success: function(sha){
2532            var value = sha.split(' - ');
2533            if(value[0] == value[1]){
2534                $('#User_password').val("");
2535                $('#pass_check').val("");
2536                EC_simplePasswordUpdate(password);
2537
2538            }else{
2539                swal(msgErrorPass, msgErrorPassInfo);
2540            }
2541        }
2542    })
2543}
2544
2545//appearance form
2546function EC_formAppearanceRemoveImage(imageType){
2547    var capitalizeType = imageType.substr(0,1).toUpperCase()+imageType.substr(1);
2548    var urlRequest = window.yiiBaseURL+"/clients/removeImage?jid="+window.userJournal+"&clientID="+window.clientMongoID+"&type="+imageType;
2549    var data = new FormData();
2550    $('#Clients_client'+capitalizeType).val("");
2551    $('#spinner_'+imageType).show();
2552
2553    if(window.currentLanguage == "pt"){
2554        swal({
2555            title: "Removendo Imagem",
2556            imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2557            showConfirmButton: false
2558        });
2559    }else{
2560        swal({
2561            title: "Removing Image",
2562            imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2563            showConfirmButton: false
2564        });
2565    }
2566
2567    $.ajax({
2568         url: urlRequest,
2569        type: 'POST',
2570        data: data,
2571        cache: false,
2572        processData: false,
2573        contentType: false,
2574        error: function(message){
2575            console.log('error');
2576            console.log(message);
2577        },
2578        success: function(response){
2579            $('#spinner_'+imageType).hide();
2580            swal.close();
2581            var date = new Date();
2582            var noImageUrl = window.yiiBaseURL+"/images/system/no-image.png?"+date.getTime();
2583            var imageUpdate = '.'+imageType+'.admin-upload-image-preview';
2584            $('.client-'+imageType+' .file-upload-button').css('background', 'rgba(0,0,0,0.03)');
2585            $(imageUpdate).attr('src',noImageUrl);
2586            $('.deleteImage.'+imageType).css('visibility','hidden');
2587            console.log(noImageUrl);
2588
2589        }
2590    })
2591}
2592
2593//issues form
2594function EC_formIssuesRemoveImage(issueID){
2595    var urlRequest = window.yiiBaseURL+"/issues/removeImage?jid="+window.userJournal+"&issueID="+issueID;
2596    var data = new FormData();
2597    $('#spinner_cover').show();
2598
2599    if(window.currentLanguage == "pt"){
2600        swal({
2601            title: "Removendo Imagem",
2602            imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2603            showConfirmButton: false
2604        });
2605    }else{
2606        swal({
2607            title: "Removing Image",
2608            imageUrl: window.yiiBaseURL+"/images/system/ajax-loader.gif",
2609            showConfirmButton: false
2610        });
2611    }
2612
2613    $.ajax({
2614         url: urlRequest,
2615        type: 'POST',
2616        data: data,
2617        cache: false,
2618        processData: false,
2619        contentType: false,
2620        error: function(message){
2621            console.log('error');
2622            console.log(message);
2623        },
2624        success: function(response){
2625            if(response == 1){
2626                $('#spinner_cover').hide();
2627                $('.issue-cover .file-upload-button').css('background', 'rgba(0,0,0,0.03)');
2628                $('#Issues_cover').val("");
2629                console.log("Image removed");
2630            }else{
2631                console.log(response);
2632                console.log("Success - But ERROR!");
2633            }
2634
2635            var date = new Date();
2636            var noImageUrl = window.yiiBaseURL+"/images/system/no-image.png?"+date.getTime();
2637            var imageUpdate = '.admin-upload-image-preview';
2638            $(imageUpdate).attr('src',noImageUrl);
2639            $('.deleteImage').css('visibility','hidden');
2640            swal.close();
2641        }
2642    })
2643}
2644
2645
2646
2647/* FUNCTIONS :: COVER ::  Cover Preview functions
2648=======================================================
2649¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2650function showCover(journalName, volume, issue, year, coverPath, description){
2651    if(!document.getElementById("shadowCloak")){
2652        var shadowCloak = document.createElement("div");
2653        var shadowBox = document.createElement("div");
2654        var boxHeader = document.createElement("div");
2655        var boxBody = document.createElement("div");
2656        var boxBodyCover = document.createElement("div");
2657        var boxBodyCoverImage = document.createElement("img");
2658        var boxBodyDescription = document.createElement("div");
2659        var description = description.replace(/(\r\n|\n|\r)/gm,"");
2660        shadowCloak.setAttribute("id", "shadowCloak");''
2661        shadowBox.setAttribute("id", "shadowBox");
2662        boxHeader.setAttribute("id", "boxHeader");
2663        boxBody.setAttribute("id", "boxBody");
2664        boxBodyCover.setAttribute("id", "boxBody-cover");
2665        boxBodyCoverImage.setAttribute("id", "boxBody-cover-image");
2666        boxBodyCoverImage.setAttribute("src", coverPath);
2667        boxBodyDescription.setAttribute("id", "boxBody-description");
2668
2669        document.body.insertBefore(shadowCloak, document.body.firstChild);
2670        shadowCloak.appendChild(shadowBox);
2671        shadowBox.appendChild(boxHeader);
2672        shadowBox.appendChild(boxBody);
2673        boxBody.appendChild(boxBodyCover);
2674        boxBodyCover.appendChild(boxBodyCoverImage);
2675        if(description == "" || description == "<p><br /></p>"){
2676            boxBodyCover.style.width = "100%";
2677            shadowBox.style.maxWidth = boxBodyCoverImage.offsetWidth+554+'px';
2678            shadowBox.style.minWidth = boxBodyCoverImage.offsetWidth+554+'px';
2679        }else{
2680            boxBody.appendChild(boxBodyDescription);
2681        }
2682
2683        boxHeader.innerHTML = '<strong>'+journalName+'</strong> - volume '+volume+' issue '+issue+', '+year;
2684        boxBodyDescription.innerHTML = description;
2685        shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+843+'px';
2686
2687        $( window ).resize(function() {
2688            if($( window ).width() > 640){
2689                shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2690            }else{
2691                $('#shadowCloak').remove();
2692            }
2693
2694        });
2695    }
2696}
2697
2698function showHomeCover(journalName, coverPath){
2699    if(!document.getElementById("shadowCloak")){
2700        var shadowCloak = document.createElement("div");
2701        var shadowBox = document.createElement("div");
2702        var boxHeader = document.createElement("div");
2703        var boxBody = document.createElement("div");
2704        var boxBodyCover = document.createElement("div");
2705        var boxBodyCoverImage = document.createElement("img");
2706        var boxBodyDescription = document.createElement("div");
2707        shadowCloak.setAttribute("id", "shadowCloak");''
2708        shadowBox.setAttribute("id", "shadowBox");
2709        boxHeader.setAttribute("id", "boxHeader");
2710        boxBody.setAttribute("id", "boxBody");
2711        boxBodyCover.setAttribute("id", "boxBody-cover");
2712        boxBodyCoverImage.setAttribute("id", "boxBody-cover-image");
2713        boxBodyCoverImage.setAttribute("src", coverPath);
2714        boxBodyCover.appendChild(boxBodyCoverImage);
2715
2716        document.body.insertBefore(shadowCloak, document.body.firstChild);
2717        shadowCloak.appendChild(shadowBox);
2718        shadowBox.appendChild(boxHeader);
2719        shadowBox.appendChild(boxBody);
2720        boxBody.appendChild(boxBodyCover);
2721
2722        boxBodyCover.style.width = "100%";
2723        shadowBox.style.maxWidth = boxBodyCoverImage.offsetWidth+100+'px';
2724        shadowBox.style.minWidth = boxBodyCoverImage.offsetWidth+100+'px';
2725
2726        if(window.currentLanguage == "pt"){
2727            boxHeader.innerHTML = '<strong>
2727'+journalName+'</strong> - Imagem em destaque';
2728            shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2729        }else{
2730            boxHeader.innerHTML = '<strong>'+journalName+'</strong> - Highlight';
2731            shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2732        }
2733
2734        $( window ).resize(function() {
2735            if($( window ).width() > 640){
2736                shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2737            }else{
2738                $('#shadowCloak').remove();
2739            }
2740
2741        });
2742    }
2743}
2744
2745
2746/* FUNCTIONS :: COVER ::  Cover Preview functions
2747=======================================================
2748¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2749function showImagePreview(imagePath){
2750    if(!document.getElementById("shadowCloak")){
2751
2752        var shadowCloak = document.createElement("div");
2753        var shadowBox = document.createElement("div");
2754        var boxHeader = document.createElement("div");
2755        var boxBody = document.createElement("div");
2756        var boxBodyCover = document.createElement("div");
2757        var boxBodyCoverImage = document.createElement("img");
2758        shadowCloak.setAttribute("id", "shadowCloak");''
2759        shadowBox.setAttribute("id", "shadowBox");
2760        boxHeader.setAttribute("id", "boxHeader");
2761        boxBody.setAttribute("id", "boxBody");
2762        boxBodyCover.setAttribute("id", "boxBody-cover");
2763        boxBodyCoverImage.setAttribute("id", "boxBody-cover-image");
2764        boxBodyCoverImage.setAttribute("src", imagePath);
2765
2766        document.body.insertBefore(shadowCloak, document.body.firstChild);
2767        shadowCloak.appendChild(shadowBox);
2768        shadowBox.appendChild(boxHeader);
2769        shadowBox.appendChild(boxBody);
2770        boxBody.appendChild(boxBodyCover);
2771        boxBodyCover.appendChild(boxBodyCoverImage);
2772
2773        boxBodyCover.style.width = "100%";
2774        shadowBox.style.maxWidth = boxBodyCoverImage.offsetWidth+100+'px';
2775        shadowBox.style.minWidth = boxBodyCoverImage.offsetWidth+100+'px';
2776
2777
2778        boxHeader.innerHTML = '<strong>Preview</strong>';
2779        shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2780
2781        $( window ).resize(function() {
2782            if($( window ).width() > 640){
2783                shadowBox.style.maxHeight = boxBodyCoverImage.offsetHeight+170+'px';
2784            }else{
2785                $('#shadowCloak').remove();
2786            }
2787
2788        });
2789    }
2790}
2791
2792/* FUNCTIONS :: UPLOAD MANAGER ::  Remove File
2793=======================================================
2794¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2795function EC_removeFromS3(filepath, instance){
2796    var urlRequest = window.yiiBaseURL+"/clients/removeFromS3?filepath="+filepath;
2797    var data = new FormData();
2798
2799    instance.addClass("removed");
2800    instance.animate({height:40},800);
2801
2802    $.ajax({
2803        url: urlRequest,
2804        type: 'POST',
2805        data: data,
2806        cache: false,
2807        processData: false,
2808        contentType: false,
2809        error: function(message){
2810            console.log('error');
2811            console.log(message);
2812        },
2813        success: function(file){
2814            console.log('File removed: '+file);
2815            instance.css({'background':'#C6FF00', 'opacity':1});
2816            if(window.currentLanguage == "pt"){
2817                instance.html("<strong>Arquivo \""+file+"\" Removido!</strong>");
2818            }else{
2819                instance.html("<strong>File \""+file+"\" Removed!</strong>");
2820            }
2821
2822            setTimeout(function(){
2823                instance.prev('hr').remove();
2824                instance.fadeOut();
2825            }, 2000);
2826        }
2827    })
2828}
2829
2830function EC_removeBannerFromS3(filepath, instance, fileID){
2831    var urlRequest = window.yiiBaseURL+"/banners/removeFromS3?filepath="+filepath+'&id='+fileID;
2832    var data = new FormData();
2833
2834    instance.addClass("removed");
2835    instance.css({'background':'#C6FF00', 'opacity':1,'clear':'left','width':'100%','line-height':'30px','padding':'0 10px','box-shadow':'0 0 15px rgba(0,0,0,0.3) inset'});
2836    instance.animate({height:30},800);
2837
2838    $.ajax({
2839        url: urlRequest,
2840        type: 'POST',
2841        data: data,
2842        cache: false,
2843        processData: false,
2844        contentType: false,
2845        error: function(message){
2846            console.log('error');
2847            console.log(message);
2848        },
2849        success: function(file){
2850            console.log('File removed: '+file);
2851
2852            if(window.currentLanguage == "pt"){
2853                instance.html("<strong>Banner Removido!</strong>");
2854            }else{
2855                instance.html("<strong>Banner Removed!</strong>");
2856            }
2857
2858            setTimeout(function(){
2859                instance.prev('hr').remove();
2860                instance.fadeOut();
2861            }, 2000);
2862        }
2863    })
2864}
2865
2866/* FUNCTIONS :: UPLOAD MANAGER ::  Upload File
2867=======================================================
2868¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
2869function EC_uploadToS3(files){
2870    var urlRequest = window.yiiBaseURL+"/clients/uploadToS3?jid="+window.userJournal;
2871    var data = new FormData();
2872    $('#spinner').show();
2873    EC_showSweetAlertS3();
2874    $.each(files, function(key, value){
2875        data.append(key, value);
2876    });
2877
2878    $.ajax({
2879        url: urlRequest,
2880        type: 'POST',
2881        data: data,
2882        cache: false,
2883        processData: false,
2884        contentType: false,
2885        error: function(message){
2886            console.log('error');
2887            EC_closeSweetAlertS3();
2888
2889            if(message.responseText == "Not a valid extension"){
2890                $('#spinner').hide();
2891                $('#filetype-error').hide();
2892                $('#FilemanagerError_messages').slideDown();
2893            }
2894            if(message.responseText == "no space"){
2895                $('#spinner').hide();
2896                $('#filetype-error').hide();
2897                $('#filesize-error').show();
2898                $('#FilemanagerError_messages').slideDown();
2899            }
2900        },
2901        success: function(file){
2902            console.log(file)
2903            var fileURL = 'http://host-client-uploaded-assets.s3-website-us-east-1.amazonaws.com/files/'+window.userJournal+'/'+file;
2904            $('#spinner').hide();
2905            EC_closeSweetAlertS3();
2906            $('.file-upload-button strong').css({'opacity':0});
2907            setTimeout(function(){
2908                if(window.currentLanguage == "pt"){
2909                    $('.file-upload-button strong').html('<i class="fa fa-check-circle"></i> Arquivo enviado!');
2910                }else{
2911                    $('.file-upload-button strong').html('<i class="fa fa-check-circle"></i> File uploaded!');
2912                }
2913                $('.file-upload-button strong').css({'color':'green', 'opacity':1});
2914            }, 500);
2915
2916             setTimeout(function(){
2917               location.reload();
2918            }, 1000);
2919        }
2920    });
2921}
2922
2923if( $('.submit-status').length  ){
2924    setTimeout(function(){
2925        $('.submit-status').fadeOut()
2926    }, 3000);
2927}
2928
2929function EC_uploadBannerToS3(files, bannerPosition){
2930    var urlRequest = window.yiiBaseURL+"/banners/uploadToS3?jid="+window.userJournal+"&position="+bannerPosition;
2931    var data = new FormData();
2932
2933    var spinnerTarget = '.spinner-'+bannerPosition;
2934    console.log(spinnerTarget);
2935    $(spinnerTarget).show();
2936    $.each(files, function(key, value){
2937        data.append(key, value);
2938    });
2939
2940    $.ajax({
2941        url: urlRequest,
2942        type: 'POST',
2943        data: data,
2944        cache: false,
2945        processData: false,
2946        contentType: false,
2947        error: function(message){
2948            console.log('error');
2949            console.log(message);
2950        },
2951        success: function(file){
2952            console.log(file)
2953            var fileURL = 'http://host-client-uploaded-assets.s3-website-us-east-1.amazonaws.com/files/'+window.userJournal+'/'+file;
2954            $(spinnerTarget).hide();
2955            var target = '.'+bannerPosition+'-banner-button strong';
2956            $(target).css({'opacity':0});
2957            setTimeout(function(){
2958                console.log(target);
2959
2960                if(window.currentLanguage == "pt"){
2961                    $(target).html('<i class="fa fa-check-circle"></i> Arquivo enviado!');
2962                }else{
2963                    $(target).html('<i class="fa fa-check-circle"></i> File uploaded!');
2964                }
2965                $(target).css({'color':'green', 'opacity':1});
2966            }, 500);
2967
2968             setTimeout(function(){
2969               location.reload();
2970            }, 1000);
2971        }
2972    });
2973}
2974
2975if( $('.submit-status').length  ){
2976    setTimeout(function(){
2977        $('.submit-status').fadeOut()
2978    }, 3000);
2979
2980}
2981
2982
2983$(document).click(function(event) {
2984    var image = $(event.target);
2985    if(!image.hasClass('coverPreview')){
2986         if(!$(event.target).closest('#shadowBox').length) {
2987            if($('#shadowBox').is(":visible")) {
2988                $('#shadowCloak').fadeOut().remove();;
2989            }
2990        }
2991    }
2992})
2993
2994
2995
2996window.tmpMainLang = '';
2997window.tmpSecLang = '';
2998
2999$('body').on('change', '#Articles_lang', function(){
3000    window.tmpMainLang =  $(this).val();
3001    $(".ui-tabs-nav li[aria-controls='article_title'] a").text($('#Articles_lang option:selected').text());
3002    $(".ui-tabs-nav li[aria-controls='article_keywords'] a").text($('#Articles_lang option:selected').text());
3003    $(".ui-tabs-nav li[aria-controls='article_abstract'] a").text($('#Articles_lang option:selected').text());
3004
3005    $('#ArticleTranslations_t0 option').each(function(a){
3006        if($(this).val() ==  window.tmpMainLang){
3007            $(this).attr('disabled', true);
3008            if($(this).is(':selected')){
3009                $('#ArticleTranslations_t0').val('');
3010                hideTranslation1();
3011                triggerOriginalLanguage();
3012
3013            }
3014        }else{
3015            $(this).attr('disabled', false);
3016        }
3017    });
3018
3019    $('#ArticleTranslations_t1 option').each(function(a){
3020        if($(this).val() ==  window.tmpMainLang){
3021            $(this).attr('disabled', true);
3022            if($(this).is(':selected')){
3023                $('#ArticleTranslations_t1').val('');
3024                hideTranslation2();
3025                triggerOriginalLanguage();
3026            }
3027        }else{
3028            $(this).attr('disabled', false);
3029        }
3030    });
3031});
3032
3033$('body').on('change', '#ArticleTranslations_t0', function(){
3034    if( $(this).val() == '' ){
3035        hideTranslation1();
3036        triggerOriginalLanguage();
3037
3038    }else{
3039        showTranslation1($('#ArticleTranslations_t0 option:selected').text());
3040    }
3041
3042    window.tmpSecLang = $(this).val();
3043    $('#ArticleTranslations_t1 option').each(function(a){
3044        if($(this).val() ==  window.tmpMainLang || $(this).val() ==  window.tmpSecLang){
3045            if($(this).val() !== ""){
3046                $(this).attr('disabled', true);
3047            }
3048            if($(this).is(':selected')){
3049                $('#ArticleTranslations_t1').val('');
3050                hideTranslation2();
3051                triggerOriginalLanguage();
3052            }
3053        }else{
3054            $(this).attr('disabled', false);
3055        }
3056    });
3057})
3058
3059$('body').on('change', '#ArticleTranslations_t1', function(){
3060    if( $(this).val() == '' ){
3061        hideTranslation2();
3062        triggerOriginalLanguage();
3063
3064    }else{
3065        showTranslation2($('#ArticleTranslations_t1 option:selected').text());
3066    }
3067})
3068
3069$('body').on('click','.form-collapse h2.sheet-title', function(){
3070    if( $(this).closest('.form-collapse').hasClass('closed')){
3071        $(this).closest('.form-collapse').removeClass('closed');
3072        $(this).children('i').removeClass('fa-plus').addClass('fa-minus');
3073    }else{
3074        $(this).closest('.form-collapse').addClass('closed');
3075        $(this).children('i').removeClass('fa-minus').addClass('fa-plus');
3076    }
3077});
3078
3079
3080function refreshTimeout(timeout){
3081    console.log(timeout);
3082    console.log('User: I\'m alive');
3083    var urlRequest = window.yiiBaseURL+"/user/imAlive";
3084     $.ajax({
3085        type: "POST",
3086        url: urlRequest,
3087        success:function(response) {
3088            if(response == "1"){
3089                console.log('System: ok');
3090                window.timeout = timeout;
3091                var date = new Date(null);
3092                date.setSeconds(window.timeout); // specify value for SECONDS here
3093                var newTime = date.toISOString().substr(14, 5);
3094
3095                if(window.currentLanguage == "pt'"){
3096                    var textSession = "Tempo restante da sua sessão: <strong>";
3097                    var textMinutes = " minutos</strong>";
3098
3099                }else{
3100                    var textSession = "Remaining time in current session: <strong>";
3101                    var textMinutes = " minutes</strong>";
3102                }
3103
3104                $("#timeout").html(textSession + newTime + textMinutes).css('background','orange');
3105                window.keypressCount = 0;
3106            }else{
3107                console.log('weird response');
3108            }
3109        }
3110    });
3111}
3112
3113// Appearance Form
3114function EC_templatePreview(value){
3115    // select thumbnail
3116    $('.layouts_area img').removeClass('active');
3117    $('.layouts_area img').each(function( i ) {
3118        if ( $(this).attr('ec-data-template') == value ) {
3119          $(this).addClass('active');
3120        }
3121    });
3122
3123    // option selecting animation
3124    if(value == "layout1" || value == "layout3" ){
3125        $('.previewBar1').removeClass('small-4').addClass('small-8');
3126        $('.previewBar2').removeClass('small-8').addClass('small-4');
3127    }else{
3128        $('.previewBar1').removeClass('small-8').addClass('small-4');
3129        $('.previewBar2').removeClass('small-4').addClass('small-8');
3130    }
3131
3132    //option if cover
3133    if(value == "layout1" || value == "layout2"){
3134        $('#box1').show();
3135        $('#box3').show();
3136
3137    }else if(value == "layout3"){
3138        $('#box1').show();
3139        $('#box3').hide();
3140    }else{
3141        $('#box1').hide();
3142        $('#box3').show();
3143    }
3144
3145    //updating texts
3146    if(value == "layout1" || value == "layout3"){
3147        $('#box1').html(textScope);
3148        $('#box2').html(textArticles);
3149        $('#box3').html(textCover);
3150        $('#box4').html(textInfo);
3151    }else{
3152        $('#box1').html(textCover);
3153        $('#box2').html(textInfo);
3154        $('#box3').html(textScope);
3155        $('#box4').html(textArticles);
3156    }
3157
3158    $('#Clients_templateOption').val(value);
3159};
3160
3161
3162function updatePreview(){
3163    $('.customTheme').each(function(){
3164        if( $(this).is(':checked') ){
3165            var themeType = $(this).val();
3166            if(themeType == 0){ // Predefined Themes
3167                var type = $('select[ec-data-imageType=theme] option:selected').val();
3168                if(type == "theme-default"){
3169                    var customColor1 = '#46B6D1';
3170                    var customColor2 = '#618DA3';
3171
3172                }else if(type == "theme-summer"){
3173                    var customColor1 = '#9bc127';
3174                    var customColor2 = '#333';
3175
3176                }else{
3177                    var customColor1 = '#E26910';
3178                    var customColor2 = '#333';
3179                }
3180
3181                $('.preview-area .theme-preview h1').each(function(){
3182                    $(this).style('color', customColor1,'important');
3183                });
3184
3185                $('.preview-area .theme-preview h2').each(function(){
3186                    $(this).style('color', customColor1,'important');
3187                });
3188
3189                $('.preview-area .theme-preview h3').each(function(){
3190                    $(this).style('color', customColor2,'important');
3191                });
3192
3193                $('.preview-area .theme-preview .title a').each(function(){
3194                    $(this).style('color', customColor2, 'important');
3195                });
3196
3197            }else{ // custom theme
3198                var customColor1 = $('#Clients_clientThemeCustomColor1').val();
3199                var customColor2 = $('#Clients_clientThemeCustomColor2').val();
3200                var customFont = $('#Clients_clientThemeCustomFont').val();
3201
3202                $('.preview-area .theme-preview h1').each(function(){
3203                    $(this).style('color', '#'+customColor1, 'important');
3204                    $(this).style('font-family', customFont);
3205                });
3206
3207                $('.preview-area .theme-preview .title a').each(function(){
3208                    $(this).style('color', '#'+customColor1, 'important');
3209                });
3210
3211                $('.preview-area .theme-preview h2').each(function(){
3212                    $(this).style('color', '#'+customColor2, 'important');
3213                    $(this).style('font-family', customFont);
3214                });
3215
3216                $('.preview-area .theme-preview h3').each(function(){
3217                    $(this).style('color', '#'+customColor2, 'important');
3218                    $(this).style('font-family', customFont);
3219                });
3220            }
3221        }
3222    });
3223}
3224
3225
3226function EC_createSubdomain(journalID){
3227    var urlRequest = window.yiiBaseURL+"/user/createClientSubdomain";
3228    $.ajax({
3229        type: "POST",
3230        url: urlRequest,
3231        data: {"journalID":journalID},
3232        async:false,
3233        error: function(response){
3234            console.log('Error: ' + response.toSource());
3235        },
3236        success:function(response) {
3237            console.log('Success: ' + response);
3238
3239        }
3240    });
3241}
3242
3243function EC_removeSubdomain(journalID){
3244    var urlRequest = window.yiiBaseURL+"/user/removeClientSubdomain";
3245    $.ajax({
3246        type: "POST",
3247        url: urlRequest,
3248        data: {"journalID":journalID},
3249        async:false,
3250        error: function(response){
3251            console.log('Error: ' + response.toSource());
3252        },
3253        success:function(response) {
3254            console.log('Success: ' + response);
3255
3256        }
3257    });
3258}
3259
3260function EC_validateDomain(jID, stayOpen){
3261    if(stayOpen !== true){
3262        EC_showVerifyAlert()
3263    }
3264    var urlRequest = window.yiiBaseURL+"/user/verifyClientAppDomain";
3265    $.ajax({
3266       type: "POST",
3267        url: urlRequest,
3268        data: {"journalID":jID},
3269        async:false,
3270        error: function(response){
3271            console.log('Error: ' + response.toSource());
3272        },
3273        success:function(response) {
3274            var response = $.parseJSON(response);
3275            window.isValidDomain = response.isAvailable;
3276
3277            if(response.isAvailable){
3278                console.log("Domain is avaliable");
3279                if(stayOpen !== true){
3280                    setTimeout(function(){
3281                    $('#site-footer').show();
3282                        swal.close();
3283                    },500);
3284                }
3285            }else{
3286                setTimeout(function(){
3287                    $('#site-footer').show();
3288                    swal.close();
3289                },500);
3290                console.log("Domain in use. Choose another domain");
3291            }
3292            
3293        }
3294    });
3295}
3296
3297function EC_validateRecaptcha(){
3298    var urlRequest = window.yiiBaseURL+"/site/validateRecaptcha";
3299    $.ajax({
3300        type: "POST",
3301        url: urlRequest,
3302        data: {captcha: grecaptcha.getResponse()},
3303        async:false,
3304        error: function(recaptchaResponse){  
3305            console.log('Error: ' + recaptchaResponse.toSource());
3306        },
3307        success: function(recaptchaResponse) {
3308            window.isHuman = recaptchaResponse;
3309        }
3310    });
3311}
3312
3313// jQuery Style helper function
3314(function($) {
3315  if ($.fn.style) {
3316    return;
3317  }
3318
3319  // Escape regex chars with \
3320  var escape = function(text) {
3321    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
3322  };
3323
3324  // For those who need them (< IE 9), add support for CSS functions
3325  var isStyleFuncSupported = !!CSSStyleDeclaration.prototype.getPropertyValue;
3326  if (!isStyleFuncSupported) {
3327    CSSStyleDeclaration.prototype.getPropertyValue = function(a) {
3328      return this.getAttribute(a);
3329    };
3330    CSSStyleDeclaration.prototype.setProperty = function(styleName, value, priority) {
3331      this.setAttribute(styleName, value);
3332      var priority = typeof priority != 'undefined' ? priority : '';
3333      if (priority != '') {
3334        // Add priority manually
3335        var rule = new RegExp(escape(styleName) + '\\s*:\\s*' + escape(value) +
3336            '(\\s*;)?', 'gmi');
3337        this.cssText =
3338            this.cssText.replace(rule, styleName + ': ' + value + ' !' + priority + ';');
3339      }
3340    };
3341    CSSStyleDeclaration.prototype.removeProperty = function(a) {
3342      return this.removeAttribute(a);
3343    };
3344    CSSStyleDeclaration.prototype.getPropertyPriority = function(styleName) {
3345      var rule = new RegExp(escape(styleName) + '\\s*:\\s*[^\\s]*\\s*!important(\\s*;)?',
3346          'gmi');
3347      return rule.test(this.cssText) ? 'important' : '';
3348    }
3349  }
3350
3351  // The style function
3352  $.fn.style = function(styleName, value, priority) {
3353    // DOM node
3354    var node = this.get(0);
3355    // Ensure we have a DOM node
3356    if (typeof node == 'undefined') {
3357      return this;
3358    }
3359    // CSSStyleDeclaration
3360    var style = this.get(0).style;
3361    // Getter/Setter
3362    if (typeof styleName != 'undefined') {
3363      if (typeof value != 'undefined') {
3364        // Set style property
3365        priority = typeof priority != 'undefined' ? priority : '';
3366        style.setProperty(styleName, value, priority);
3367        return this;
3368      } else {
3369        // Get style property
3370        return style.getPropertyValue(styleName);
3371      }
3372    } else {
3373      // Get CSSStyleDeclaration
3374      return style;
3375    }
3376  };
3377})(jQuery);
3378
3379function getAbstract(id, field, listlang, currentlang){
3380    var urlRequest = window.yiiBaseURL+"/articles/getAbstract";
3381    $.ajax({
3382        url: urlRequest,
3383        type: 'POST',
3384        data: {"id":id, "listlang":listlang, "currentlang":currentlang},
3385        async:true,
3386        error: function(message){
3387            console.log('error');
3388            console.log(message);
3389        },
3390        success: function(response){
3391           var abstractID = '#abstract_'+id;
3392           $(abstractID).html(response);
3393        }
3394    });
3395}
3396
3397$('body').on('click','.articles_summary_abstract_link', function(){
3398    var id = $(this).attr('ec-data-id');;
3399    var field = $(this).attr('ec-data-field');
3400    var listlang = $(this).attr('ec-data-listlang');
3401    var currentlang = window.currentLanguage;
3402
3403    // console.log(id);
3404    // console.log(field);
3405    // console.log(listlang);
3406    // console.log(currentlang);
3407
3408    var abstractContainer = $(this).next('.articles_summary_abstract_content');
3409    if(abstractContainer.hasClass('active')){
3410        $(this).removeClass('active');
3411        abstractContainer.removeClass('active');
3412    }else{
3413        $(this).addClass('active');
3414        abstractContainer.addClass('active');
3415    }
3416
3417    getAbstract(id, field, listlang, currentlang);
3418});
3419
3420
3421$('body').on('click','#quicklinksAbstract', function(){
3422    var abstractContainer = $(this).next('.articles_summary_abstract_content');
3423    if(abstractContainer.hasClass('active')){
3424        $('.articles_summary_abstract_link_preview').removeClass('active');
3425        abstractContainer.removeClass('active');
3426    }else{
3427        $('.articles_summary_abstract_link_preview').addClass('active');
3428        abstractContainer.addClass('active');
3429    }
3430});
3431
3432
3433// JOURNAL ID ACCENT CLEANER
3434var defaultDiacriticsRemovalMap = [
3435    {'base':'A', 'letters':'\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'},
3436    {'base':'AA','letters':'\uA732'},
3437    {'base':'AE','letters':'\u00C6\u01FC\u01E2'},
3438    {'base':'AO','letters':'\uA734'},
3439    {'base':'AU','letters':'\uA736'},
3440    {'base':'AV','letters':'\uA738\uA73A'},
3441    {'base':'AY','letters':'\uA73C'},
3442    {'base':'B', 'letters':'\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181'},
3443    {'base':'C', 'letters':'\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E'},
3444    {'base':'D', 'letters':'\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0'},
3445    {'base':'DZ','letters':'\u01F1\u01C4'},
3446    {'base':'Dz','letters':'\u01F2\u01C5'},
3447    {'base':'E', 'letters':'\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E'},
3448    {'base':'F', 'letters':'\u0046\u24BB\uFF26\u1E1E\u0191\uA77B'},
3449    {'base':'G', 'letters':'\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E'},
3450    {'base':'H', 'letters':'\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D'},
3451    {'base':'I', 'letters':'\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197'},
3452    {'base':'J', 'letters':'\u004A\u24BF\uFF2A\u0134\u0248'},
3453    {'base':'K', 'letters':'\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2'},
3454    {'base':'L', 'letters':'\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780'},
3455    {'base':'LJ','letters':'\u01C7'},
3456    {'base':'Lj','letters':'\u01C8'},
3457    {'base':'M', 'letters':'\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C'},
3458    {'base':'N', 'letters':'\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4'},
3459    {'base':'NJ','letters':'\u01CA'},
3460    {'base':'Nj','letters':'\u01CB'},
3461    {'base':'O', 'letters':'\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C'},
3462    {'base':'OI','letters':'\u01A2'},
3463    {'base':'OO','letters':'\uA74E'},
3464    {'base':'OU','letters':'\u0222'},
3465    {'base':'OE','letters':'\u008C\u0152'},
3466    {'base':'oe','letters':'\u009C\u0153'},
3467    {'base':'P', 'letters':'\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754'},
3468    {'base':'Q', 'letters':'\u0051\u24C6\uFF31\uA756\uA758\u024A'},
3469    {'base':'R', 'letters':'\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782'},
3470    {'base':'S', 'letters':'\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u
3470015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784'},
3471    {'base':'T', 'letters':'\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786'},
3472    {'base':'TZ','letters':'\uA728'},
3473    {'base':'U', 'letters':'\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244'},
3474    {'base':'V', 'letters':'\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245'},
3475    {'base':'VY','letters':'\uA760'},
3476    {'base':'W', 'letters':'\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72'},
3477    {'base':'X', 'letters':'\u0058\u24CD\uFF38\u1E8A\u1E8C'},
3478    {'base':'Y', 'letters':'\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE'},
3479    {'base':'Z', 'letters':'\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762'},
3480    {'base':'a', 'letters':'\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250'},
3481    {'base':'aa','letters':'\uA733'},
3482    {'base':'ae','letters':'\u00E6\u01FD\u01E3'},
3483    {'base':'ao','letters':'\uA735'},
3484    {'base':'au','letters':'\uA737'},
3485    {'base':'av','letters':'\uA739\uA73B'},
3486    {'base':'ay','letters':'\uA73D'},
3487    {'base':'b', 'letters':'\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253'},
3488    {'base':'c', 'letters':'\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184'},
3489    {'base':'d', 'letters':'\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A'},
3490    {'base':'dz','letters':'\u01F3\u01C6'},
3491    {'base':'e', 'letters':'\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD'},
3492    {'base':'f', 'letters':'\u0066\u24D5\uFF46\u1E1F\u0192\uA77C'},
3493    {'base':'g', 'letters':'\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F'},
3494    {'base':'h', 'letters':'\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265'},
3495    {'base':'hv','letters':'\u0195'},
3496    {'base':'i', 'letters':'\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131'},
3497    {'base':'j', 'letters':'\u006A\u24D9\uFF4A\u0135\u01F0\u0249'},
3498    {'base':'k', 'letters':'\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3'},
3499    {'base':'l', 'letters':'\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747'},
3500    {'base':'lj','letters':'\u01C9'},
3501    {'base':'m', 'letters':'\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F'},
3502    {'base':'n', 'letters':'\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5'},
3503    {'base':'nj','letters':'\u01CC'},
3504    {'base':'o', 'letters':'\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275'},
3505    {'base':'oi','letters':'\u01A3'},
3506    {'base':'ou','letters':'\u0223'},
3507    {'base':'oo','letters':'\uA74F'},
3508    {'base':'p','letters':'\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755'},
3509    {'base':'q','letters':'\u0071\u24E0\uFF51\u024B\uA757\uA759'},
3510    {'base':'r','letters':'\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783'},
3511    {'base':'s','letters':'\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B'},
3512    {'base':'t','letters':'\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u02
35121B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787'},
3513    {'base':'tz','letters':'\uA729'},
3514    {'base':'u','letters': '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289'},
3515    {'base':'v','letters':'\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C'},
3516    {'base':'vy','letters':'\uA761'},
3517    {'base':'w','letters':'\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73'},
3518    {'base':'x','letters':'\u0078\u24E7\uFF58\u1E8B\u1E8D'},
3519    {'base':'y','letters':'\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF'},
3520    {'base':'z','letters':'\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763'}
3521];
3522
3523var diacriticsMap = {};
3524for (var i=0; i < defaultDiacriticsRemovalMap .length; i++){
3525    var letters = defaultDiacriticsRemovalMap [i].letters;
3526    for (var j=0; j < letters.length ; j++){
3527        diacriticsMap[letters[j]] = defaultDiacriticsRemovalMap [i].base;
3528    }
3529}
3530
3531// "what?" version ... http://jsperf.com/diacritics/12
3532function removeDiacritics (str) {
3533    return str.replace(/[^\u0000-\u007E]/g, function(a){ 
3534       return diacriticsMap[a] || a; 
3535    });
3536}    
3537
3538
3539function OrderBy(a,b,n) {
3540    if (n) return a-b;
3541    if (a < b) return -1;
3542    if (a > b) return 1;
3543    return 0;
3544}
3545$('table.sortable th a').click(function() {
3546    var $th = $(this).closest('th');
3547    $th.toggleClass('selected');
3548    var isSelected = $th.hasClass('selected');
3549    var isInput= $th.hasClass('input');
3550    var column = $th.index();
3551    var $table = $th.closest('table');
3552    var isNum= $table.find('tbody > tr').children('td').eq(column).hasClass('num');
3553    var rows = $table.find('tbody > tr').get();
3554    rows.sort(function(rowA,rowB) {
3555        if (isInput) {
3556            var keyA = $(rowA).children('td').eq(column).children('input').val().toUpperCase();
3557            var keyB = $(rowB).children('td').eq(column).children('input').val().toUpperCase();
3558        } else {
3559            var keyA = $(rowA).children('td').eq(column).text().toUpperCase();
3560            var keyB = $(rowB).children('td').eq(column).text().toUpperCase();
3561        }
3562        if (isSelected) return OrderBy(keyA,keyB,isNum);
3563        return OrderBy(keyB,keyA,isNum);
3564    });
3565    $.each(rows, function(index,row) {
3566        $table.children('tbody').append(row);
3567    });
3568    return false;
3569});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.