forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							328 lines
						
					
					
						
							10 KiB
						
					
					
				
			
		
		
	
	
							328 lines
						
					
					
						
							10 KiB
						
					
					
				 evoapp.factory('plugins', function($rootScope, utils, $timeout) {
 | 
						|
 | 
						|
    var me = this;
 | 
						|
 | 
						|
	$.extend({
 | 
						|
 | 
						|
		scrollToTop: function() {
 | 
						|
 | 
						|
			var _isScrolling = false;
 | 
						|
 | 
						|
			// Append Button
 | 
						|
			$("body").append($("<a />")
 | 
						|
							.addClass("scroll-to-top")
 | 
						|
							.attr({
 | 
						|
								"href": "#",
 | 
						|
								"id": "scrollToTop"
 | 
						|
							})
 | 
						|
							.append(
 | 
						|
								$("<i />")
 | 
						|
									.addClass("glyphicon glyphicon-chevron-up icon-white")
 | 
						|
							));
 | 
						|
 | 
						|
			$("#scrollToTop").click(function(e) {
 | 
						|
 | 
						|
				e.preventDefault();
 | 
						|
				$("body, html").animate({scrollTop : 0}, 500);
 | 
						|
				return false;
 | 
						|
 | 
						|
			});
 | 
						|
 | 
						|
			// Show/Hide Button on Window Scroll event.
 | 
						|
			$(window).scroll(function() {
 | 
						|
 | 
						|
				if(!_isScrolling) {
 | 
						|
 | 
						|
					_isScrolling = true;
 | 
						|
 | 
						|
					if($(window).scrollTop() > 150) {
 | 
						|
 | 
						|
						$("#scrollToTop").stop(true, true).addClass("visible");
 | 
						|
						_isScrolling = false;
 | 
						|
 | 
						|
					} else {
 | 
						|
 | 
						|
						$("#scrollToTop").stop(true, true).removeClass("visible");
 | 
						|
						_isScrolling = false;
 | 
						|
 | 
						|
					}
 | 
						|
 | 
						|
				}
 | 
						|
 | 
						|
			});
 | 
						|
        }
 | 
						|
    });
 | 
						|
 | 
						|
    var setDefaults = function(){
 | 
						|
 | 
						|
 | 
						|
    };
 | 
						|
 | 
						|
    // Inject in the html of the loaded module, all the bootstrap plugin Behaviour
 | 
						|
    var setBootstrap = function(){
 | 
						|
 | 
						|
        window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
 | 
						|
            messages: {
 | 
						|
                // parsley //////////////////////////////////////
 | 
						|
                defaultMessage: "Este valor parece estar inválido."
 | 
						|
                , type: {
 | 
						|
                    email:      "Este valor deve ser um e-mail válido."
 | 
						|
                , url:        "Este valor deve ser uma URL válida."
 | 
						|
                , urlstrict:  "Este valor deve ser uma URL válida."
 | 
						|
                , number:     "Este valor deve ser um número válido."
 | 
						|
                , digits:     "Este valor deve ser um dígito válido."
 | 
						|
                , dateIso:    "Este valor deve ser uma data válida (YYYY-MM-DD)."
 | 
						|
                , alphanum:   "Este valor deve ser alfanumérico."
 | 
						|
                , phone:      "Este valor deve ser um número telefone válido."
 | 
						|
                }
 | 
						|
                , notnull:        "Este valor não deve ser nulo."
 | 
						|
                , notblank:       "Este valor não deve ser branco."
 | 
						|
                , required:       "Este valor é obrigatório."
 | 
						|
                , regexp:         "Este valor parece estar inválido."
 | 
						|
                , min:            "Este valor deve ser maior ou igual a %s."
 | 
						|
                , max:            "Este valor deve ser menor ou igual a %s."
 | 
						|
                , range:          "Este valor deve estar entre %s e %s."
 | 
						|
                , minlength:      "Este valor é muito pequeno. Ele deve ter %s caracteres ou mais."
 | 
						|
                , maxlength:      "Este valor é muito grande. Ele deve ter %s caracteres ou menos."
 | 
						|
                , rangelength:    "O tamanho deste valor é inválido. Ele deve possuir entre %s e %s caracteres."
 | 
						|
                , mincheck:       "Você deve selecionar pelo menos %s opções."
 | 
						|
                , maxcheck:       "Você deve selecionar %s opções ou menos."
 | 
						|
                , rangecheck:     "Você deve selecionar entre %s e %s opções."
 | 
						|
                , equalto:        "Este valor deve ser o mesmo."
 | 
						|
                // parsley.extend ///////////////////////////////
 | 
						|
                , minwords:       "Este valor deve possuir no mínimo %s palavras."
 | 
						|
                , maxwords:       "Este valor deve possuir no máximo %s palavras."
 | 
						|
                , rangewords:     "Este valor deve possuir entre %s e %s palavras."
 | 
						|
                , greaterthan:    "Este valor deve ser maior que %s."
 | 
						|
                , lessthan:       "Este valor deve ser menor que %s."
 | 
						|
                , beforedate:     "Esta data deve ser anterior a %s."
 | 
						|
                , afterdate:      "Esta data deve ser posterior a %s."
 | 
						|
            }
 | 
						|
        });
 | 
						|
 | 
						|
        $.datepicker.regional['pt'] = {
 | 
						|
		    closeText: 'Fechar',
 | 
						|
		    prevText: '<Anterior',
 | 
						|
		    nextText: 'Seguinte',
 | 
						|
		    currentText: 'Hoje',
 | 
						|
		    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
 | 
						|
		    'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
 | 
						|
		    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
 | 
						|
		    'Jul','Ago','Set','Out','Nov','Dez'],
 | 
						|
		    dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'],
 | 
						|
		    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
 | 
						|
		    dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
 | 
						|
		    weekHeader: 'Sem',
 | 
						|
		    dateFormat: 'dd/mm/yy',
 | 
						|
		    firstDay: 0,
 | 
						|
		    isRTL: false,
 | 
						|
		    showMonthAfterYear: false,
 | 
						|
		    yearSuffix: ''
 | 
						|
        };
 | 
						|
	    $.datepicker.setDefaults($.datepicker.regional['pt']);
 | 
						|
 | 
						|
 | 
						|
        ////Add hover support for touch devices
 | 
						|
        //$('.btn').bind('touchstart', function() {
 | 
						|
        //    $(this).addClass('hover');
 | 
						|
        //}).bind('touchend', function() {
 | 
						|
        //    $(this).removeClass('hover');
 | 
						|
        //});
 | 
						|
 | 
						|
        //Activate tooltips
 | 
						|
        $("[data-toggle='tooltip']").tooltip();
 | 
						|
 | 
						|
        ///*     
 | 
						|
        // * Add collapse and remove events to boxes
 | 
						|
        // */
 | 
						|
        //$("[data-widget='collapse']").click(function() {
 | 
						|
        //    //Find the box parent        
 | 
						|
        //    var box = $(this).parents(".box").first();
 | 
						|
        //    //Find the body and the footer
 | 
						|
        //    var bf = box.find(".box-body, .box-footer");
 | 
						|
        //    if (!box.hasClass("collapsed-box")) {
 | 
						|
        //        box.addClass("collapsed-box");
 | 
						|
        //        bf.slideUp();
 | 
						|
        //    } else {
 | 
						|
        //        box.removeClass("collapsed-box");
 | 
						|
        //        bf.slideDown();
 | 
						|
        //    }
 | 
						|
        //});
 | 
						|
 | 
						|
        ///*
 | 
						|
        // * INITIALIZE BUTTON TOGGLE
 | 
						|
        // * ------------------------
 | 
						|
        // */
 | 
						|
        //$('.btn-group[data-toggle="btn-toggle"]').each(function() {
 | 
						|
 | 
						|
        //    var group = $(this);
 | 
						|
 | 
						|
        //    $(this).find(".btn").click(function(e) {
 | 
						|
        //        group.find(".btn.active").removeClass("active");
 | 
						|
        //        $(this).addClass("active");
 | 
						|
        //        e.preventDefault();
 | 
						|
        //    });
 | 
						|
        //});
 | 
						|
 | 
						|
        //$("[data-widget='remove']").click(function() {
 | 
						|
        //    //Find the box parent        
 | 
						|
        //    var box = $(this).parents(".box").first();
 | 
						|
        //    box.slideUp();
 | 
						|
        //});
 | 
						|
 | 
						|
		// Scroll to Top Button.
 | 
						|
		$.scrollToTop();
 | 
						|
    };
 | 
						|
 | 
						|
    var buildSideMenu = function(options){
 | 
						|
 | 
						|
		// Append Button
 | 
						|
		$('#main-panel').append($("<a />")
 | 
						|
		.addClass("form-side-menu")
 | 
						|
		.attr({
 | 
						|
			"href": "#",
 | 
						|
			"id": "formSideMenu"
 | 
						|
		})
 | 
						|
		.append(
 | 
						|
			$("<i />").addClass("glyphicon glyphicon-picture")
 | 
						|
		));
 | 
						|
 | 
						|
		$("#formSideMenu").click(function(e) {
 | 
						|
 | 
						|
			e.preventDefault();            
 | 
						|
			
 | 
						|
            if(options.onItemClick)
 | 
						|
            {
 | 
						|
                options.onItemClick(e);
 | 
						|
            }
 | 
						|
 | 
						|
			return false;
 | 
						|
		});
 | 
						|
 | 
						|
		$("#formSideMenu").stop(true, true).addClass("visible");
 | 
						|
 | 
						|
        return $("#formSideMenu");
 | 
						|
    };
 | 
						|
 | 
						|
    var hideSideMenu = function(){
 | 
						|
 | 
						|
        $('#formSideMenu').remove();
 | 
						|
    };
 | 
						|
 | 
						|
    var buildFloatingSideMenu = function(options){
 | 
						|
 | 
						|
        var wrapper = $('<div class="floating-side-menu"></div>');
 | 
						|
 | 
						|
        options.title = options.title ? options.title : '';
 | 
						|
 | 
						|
        var h4 = $('<h4><strong>' + options.title + '</strong></h4>');
 | 
						|
        var cogs = $('<a href="#"><i class="glyphicon glyphicon-th-list"></i></a>');
 | 
						|
 | 
						|
        cogs.click(function(e){
 | 
						|
 | 
						|
            e.preventDefault();
 | 
						|
 | 
						|
            if(wrapper.hasClass('active'))
 | 
						|
            {
 | 
						|
				wrapper.animate({
 | 
						|
					left: "-" + wrapper.width() + "px"
 | 
						|
				}, 300).removeClass("active");
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
				wrapper.animate({
 | 
						|
					left: "0"
 | 
						|
				}, 300).addClass("active");
 | 
						|
            }
 | 
						|
        });
 | 
						|
 | 
						|
        h4.append(cogs);
 | 
						|
 | 
						|
        wrapper.append(h4);
 | 
						|
 | 
						|
        var innerWrapper = $('<div></div>');
 | 
						|
 | 
						|
        wrapper.append(innerWrapper);
 | 
						|
 | 
						|
        //var links = menuItems.find('a');
 | 
						|
        //links.each(function(index) {     
 | 
						|
            
 | 
						|
        //    $(links[index]).click(function(e){
 | 
						|
 | 
						|
    	//        wrapper.animate({
 | 
						|
		//	        left: "-" + wrapper.width() + "px"
 | 
						|
		//        }, 300).removeClass("active");               
 | 
						|
        //    });
 | 
						|
        //});
 | 
						|
 | 
						|
        if(options.scrollspyItems)
 | 
						|
        {
 | 
						|
        	var links = options.scrollspyItems.find('li');
 | 
						|
        	links.each(function(index) {
 | 
						|
        		
 | 
						|
        		if(index == 0)
 | 
						|
        		{
 | 
						|
        			$(this).addClass("active"); 
 | 
						|
        		}
 | 
						|
        		else
 | 
						|
        		{
 | 
						|
            		if($(this).hasClass("active"))
 | 
						|
            		{
 | 
						|
            			$(this).removeClass("active");    
 | 
						|
            		}        			
 | 
						|
        		}
 | 
						|
        	});
 | 
						|
        	
 | 
						|
            wrapper.append(options.scrollspyItems);
 | 
						|
        }
 | 
						|
 | 
						|
        var btnOpenDocuments = $(
 | 
						|
            '<div class="buttons-area">' + 
 | 
						|
                '<button type="button" class="btn btn-primary btn-xs">                      ' + 
 | 
						|
			      '<span class="glyphicon glyphicon-folder-open m-r-5"></span> ' + 
 | 
						|
			      '<span>Documentos</span> ' + 
 | 
						|
			      '<span class="badge documents-badge">6</span>' + 
 | 
						|
                '</button>                                                                  ' + 
 | 
						|
            '</div>'
 | 
						|
        );
 | 
						|
 | 
						|
        if(options.documentclick)
 | 
						|
        {
 | 
						|
            $(btnOpenDocuments).click(function(e){
 | 
						|
                
 | 
						|
                options.documentclick();
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        wrapper.append(btnOpenDocuments);
 | 
						|
 | 
						|
        $('#main-panel').append(wrapper);
 | 
						|
 | 
						|
        $timeout(function () {
 | 
						|
 | 
						|
            if(angular.isFunction(options.afterrender))
 | 
						|
            {
 | 
						|
            	if(options.scrollspyItems){
 | 
						|
            		$('body').scrollspy('refresh');
 | 
						|
            	}           	
 | 
						|
            	
 | 
						|
                options.afterrender();
 | 
						|
            }
 | 
						|
        });
 | 
						|
    };
 | 
						|
 | 
						|
    var hideFloatingSideMenu = function(){
 | 
						|
 | 
						|
        $('.floating-side-menu').remove();
 | 
						|
    };
 | 
						|
 | 
						|
    return {
 | 
						|
        setDefaults: setDefaults,
 | 
						|
        setBootstrap: setBootstrap,
 | 
						|
        buildSideMenu: buildSideMenu,
 | 
						|
        hideSideMenu: hideSideMenu,
 | 
						|
 | 
						|
        buildFloatingSideMenu: buildFloatingSideMenu,
 | 
						|
        hideFloatingSideMenu: hideFloatingSideMenu
 | 
						|
    };
 | 
						|
}); |