$(document).ready(function(){ /* ---------- Login Box Styles ---------- */ if($(".login-box")) { $("#username").focus(function() { $(this).parent(".input-prepend").addClass("input-prepend-focus"); }); $("#username").focusout(function() { $(this).parent(".input-prepend").removeClass("input-prepend-focus"); }); $("#password").focus(function() { $(this).parent(".input-prepend").addClass("input-prepend-focus"); }); $("#password").focusout(function() { $(this).parent(".input-prepend").removeClass("input-prepend-focus"); }); } /* ---------- Add class .active to current link ---------- */ $('ul.main-menu li a').each(function(){ if($(this).hasClass('submenu')) { if($($(this))[0].href==String(window.location)) { $(this).parent().parent().parent().addClass('active'); } } else { if($($(this))[0].href==String(window.location)) { $(this).parent().addClass('active'); } } }); /* ---------- Acivate Functions ---------- */ $("#overlay").delay(1250).fadeOut(500); template_functions(); init_masonry(); sparkline_charts(); charts(); calendars(); growlLikeNotifications(); widthFunctions(); circle_progess(); }); /* ---------- Masonry Gallery ---------- */ function init_masonry(){ if($('.masonry-gallery')){ var $container = $('.masonry-gallery'); var gutter = 6; var min_width = 250; $container.imagesLoaded( function(){ $container.masonry({ itemSelector : '.masonry-thumb', gutterWidth: gutter, isAnimated: true, columnWidth: function( containerWidth ) { var num_of_boxes = (containerWidth/min_width | 0); var box_width = (((containerWidth - (num_of_boxes-1)*gutter)/num_of_boxes) | 0) ; if (containerWidth < min_width) { box_width = containerWidth; } $('.masonry-thumb').width(box_width); return box_width; } }); }); } } /* ---------- Numbers Sepparator ---------- */ function numberWithCommas(x) { x = x.toString(); var pattern = /(-?\d+)(\d{3})/; while (pattern.test(x)) x = x.replace(pattern, "$1.$2"); return x; } /* ---------- Template Functions ---------- */ function template_functions(){ /* ---------- Submenu ---------- */ $('.dropmenu').click(function(e){ e.preventDefault(); $(this).parent().find('ul').slideToggle(); }); /* ---------- ToDo List Action Buttons ---------- */ if($(".todo-list")) { $(".todo-remove").click(function(){ $(this).parent().parent().fadeTo("slow", 0.00, function(){ //fade $(this).slideUp("slow", function() { //slide up $(this).remove(); //then remove from the DOM }); }); return false; }); } /* ---------- Skill Bars ---------- */ if($(".skill-bar")){ $(".meter > span").each(function() { $(this) .data("origWidth", $(this).width()) .width(0) .animate({ width: $(this).data("origWidth") }, 3000); }); } /* ---------- Disable moving to top ---------- */ $('a[href="#"][data-top!=true]').click(function(e){ e.preventDefault(); }); /* ---------- Text editor ---------- */ if($('.cleditor')) { $('.cleditor').cleditor(); } /* ---------- Datapicker ---------- */ if($('.datepicker')) { $('.datepicker').datepicker(); } /* ---------- Notifications ---------- */ $('.noty').click(function(e){ e.preventDefault(); var options = $.parseJSON($(this).attr('data-noty-options')); noty(options); }); /* ---------- Uniform ---------- */ $("input:checkbox, input:radio, input:file").not('[data-no-uniform="true"],#uniform-is-ajax').uniform(); /* ---------- Choosen ---------- */ $('[data-rel="chosen"],[rel="chosen"]').chosen(); /* ---------- Tabs ---------- */ $('#myTab a:first').tab('show'); $('#myTab a').click(function (e) { e.preventDefault(); $(this).tab('show'); }); /* ---------- Makes elements soratble, elements that sort need to have id attribute to save the result ---------- */ $('.sortable').sortable({ revert:true, cancel:'.btn,.box-content,.nav-header', update:function(event,ui){ //line below gives the ids of elements, you can make ajax call here to save it to the database //console.log($(this).sortable('toArray')); } }); /* ---------- Tooltip ---------- */ $('[rel="tooltip"],[data-rel="tooltip"]').tooltip({"placement":"bottom",delay: { show: 400, hide: 200 }}); /* ---------- Popover ---------- */ $('[rel="popover"],[data-rel="popover"]').popover(); /* ---------- File Manager ---------- */ var elf = $('.file-manager').elfinder({ url : 'misc/elfinder-connector/connector.php' // connector URL (REQUIRED) }).elfinder('instance'); /* ---------- Star Rating ---------- */ $('.raty').raty({ score : 4 //default stars }); /* ---------- Uploadify ---------- */ $('#file_upload').uploadify({ 'swf' : 'misc/uploadify.swf', 'uploader' : 'misc/uploadify.php' // Put your options here }); /* ---------- Fullscreen ---------- */ $('#toggle-fullscreen').button().click(function () { var button = $(this), root = document.documentElement; if (!button.hasClass('active')) { $('#thumbnails').addClass('modal-fullscreen'); if (root.webkitRequestFullScreen) { root.webkitRequestFullScreen( window.Element.ALLOW_KEYBOARD_INPUT ); } else if (root.mozRequestFullScreen) { root.mozRequestFullScreen(); } } else { $('#thumbnails').removeClass('modal-fullscreen'); (document.webkitCancelFullScreen || document.mozCancelFullScreen || $.noop).apply(document); } }); /* ---------- Datable ---------- */ $('.datatable').dataTable({ "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span12'i><'span12 center'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page" } } ); $('.btn-close').click(function(e){ e.preventDefault(); $(this).parent().parent().parent().fadeOut(); }); $('.btn-minimize').click(function(e){ e.preventDefault(); var $target = $(this).parent().parent().next('.box-content'); if($target.is(':visible')) $('i',$(this)).removeClass('icon-chevron-up').addClass('icon-chevron-down'); else $('i',$(this)).removeClass('icon-chevron-down').addClass('icon-chevron-up'); $target.slideToggle(); }); $('.btn-setting').click(function(e){ e.preventDefault(); $('#myModal').modal('show'); }); /* ---------- Progress ---------- */ $(".simpleProgress").progressbar({ value: 89 }); $(".progressAnimate").progressbar({ value: 1, create: function() { $(".progressAnimate .ui-progressbar-value").animate({"width":"100%"},{ duration: 10000, step: function(now){ $(".progressAnimateValue").html(parseInt(now)+"%"); }, easing: "linear" }) } }); $(".progressUploadAnimate").progressbar({ value: 1, create: function() { $(".progressUploadAnimate .ui-progressbar-value").animate({"width":"100%"},{ duration: 20000, easing: 'linear', step: function(now){ $(".progressUploadAnimateValue").html(parseInt(now*40.96)+" Gb"); }, complete: function(){ $(".progressUploadAnimate + .field_notice").html("Upload Finished"); } }) } }); if($(".taskProgress")) { $(".taskProgress").each(function(){ var endValue = parseInt($(this).html()); $(this).progressbar({ value: endValue }); $(this).parent().find(".percent").html(endValue + "%"); }); } if($(".progressBarValue")) { $(".progressBarValue").each(function(){ var endValueHTML = $(this).find(".progressCustomValueVal").html(); var endValue = parseInt(endValueHTML); $(this).find(".progressCustomValue").progressbar({ value: 1, create: function() { $(this).find(".ui-progressbar-value").animate({"width": endValue + "%"},{ duration: 5000, step: function(now){ $(this).parent().parent().find(".progressCustomValueVal").html(parseInt(now)+"%"); }, easing: "linear" }) } }); }); } /* ---------- Custom Slider ---------- */ $(".sliderSimple").slider(); $(".sliderMin").slider({ range: "min", value: 180, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMinLabel" ).html( "$" + ui.value ); } }); $(".sliderMin-1").slider({ range: "min", value: 50, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMin1Label" ).html( "$" + ui.value ); } }); $(".sliderMin-2").slider({ range: "min", value: 100, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMin2Label" ).html( "$" + ui.value ); } }); $(".sliderMin-3").slider({ range: "min", value: 150, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMin3Label" ).html( "$" + ui.value ); } }); $(".sliderMin-4").slider({ range: "min", value: 250, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMin4Label" ).html( "$" + ui.value ); } }); $(".sliderMin-5").slider({ range: "min", value: 350, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderLabel" ).html( "$" + ui.value ); } }); $(".sliderMin-6").slider({ range: "min", value: 450, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderLabel" ).html( "$" + ui.value ); } }); $(".sliderMin-7").slider({ range: "min", value: 550, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderLabel" ).html( "$" + ui.value ); } }); $(".sliderMin-8").slider({ range: "min", value: 650, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderLabel" ).html( "$" + ui.value ); } }); $(".sliderMax").slider({ range: "max", value: 280, min: 1, max: 700, slide: function( event, ui ) { $( ".sliderMaxLabel" ).html( "$" + ui.value ); } }); $( ".sliderRange" ).slider({ range: true, min: 0, max: 500, values: [ 192, 470 ], slide: function( event, ui ) { $( ".sliderRangeLabel" ).html( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); } }); $( "#sliderVertical-1" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 60, }); $( "#sliderVertical-2" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 40, }); $( "#sliderVertical-3" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 30, }); $( "#sliderVertical-4" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 15, }); $( "#sliderVertical-5" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 40, }); $( "#sliderVertical-6" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 80, }); $( "#sliderVertical-7" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 60, }); $( "#sliderVertical-8" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 40, }); $( "#sliderVertical-9" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 30, }); $( "#sliderVertical-10" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 15, }); $( "#sliderVertical-11" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 40, }); $( "#sliderVertical-12" ).slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 80, }); } /* ---------- Circle Progess Bars ---------- */ function circle_progess() { var divElement = $('div'); //log all div elements $(".greenCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#b9e672', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) $(".orangeCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#FA5833', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) $(".lightOrangeCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#f4a70c', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) $(".blueCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#2FABE9', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) $(".yellowCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#e7e572', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) $(".pinkCircle").knob({ 'min':0, 'max':100, 'readOnly': true, 'width': 120, 'height': 120, 'fgColor': '#e42b75', 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin':'tron' }) } /* ---------- Calendars ---------- */ function calendars(){ $('#external-events div.external-event').each(function() { // it doesn't need to have a start or end var eventObject = { title: $.trim($(this).text()) // use the element's text as the event title }; // store the Event Object in the DOM element so we can get to it later $(this).data('eventObject', eventObject); // make the event draggable using jQuery UI $(this).draggable({ zIndex: 999, revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); }); var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#main_calendar').fullCalendar({ header: { left: 'title', right: 'prev,next today,month,agendaWeek,agendaDay' }, editable: true, events: [ { title: 'All Day Event', start: new Date(y, m, 1) }, { title: 'Long Event', start: new Date(y, m, d-5), end: new Date(y, m, d-2) }, { id: 999, title: 'Repeating Event', start: new Date(y, m, d-3, 16, 0), allDay: false }, { id: 999, title: 'Repeating Event', start: new Date(y, m, d+4, 16, 0), allDay: false }, { title: 'Meeting', start: new Date(y, m, d, 10, 30), allDay: false }, { title: 'Lunch', start: new Date(y, m, d, 12, 0), end: new Date(y, m, d, 14, 0), allDay: false }, { title: 'Birthday Party', start: new Date(y, m, d+1, 19, 0), end: new Date(y, m, d+1, 22, 30), allDay: false }, { title: 'Click for Google', start: new Date(y, m, 28), end: new Date(y, m, 29), url: 'http://google.com/' } ] }); $('#main_calendar_phone').fullCalendar({ header: { left: 'title', right: 'prev,next today,month,agendaWeek,agendaDay' }, defaultView: 'agendaDay', editable: true, events: [ { title: 'All Day Event', start: new Date(y, m, 1) }, { title: 'Long Event', start: new Date(y, m, d-5), end: new Date(y, m, d-2) }, { id: 999, title: 'Repeating Event', start: new Date(y, m, d-3, 16, 0), allDay: false }, { id: 999, title: 'Repeating Event', start: new Date(y, m, d+4, 16, 0), allDay: false }, { title: 'Meeting', start: new Date(y, m, d, 10, 30), allDay: false }, { title: 'Lunch', start: new Date(y, m, d, 12, 0), end: new Date(y, m, d, 14, 0), allDay: false }, { title: 'Birthday Party', start: new Date(y, m, d+1, 19, 0), end: new Date(y, m, d+1, 22, 30), allDay: false }, { title: 'Click for Google', start: new Date(y, m, 28), end: new Date(y, m, 29), url: 'http://google.com/' } ] }); $('#calendar').fullCalendar({ header: { left: 'title', right: 'prev,next today,month,agendaWeek,agendaDay' }, editable: true, droppable: true, // this allows things to be dropped onto the calendar !!! drop: function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // is the "remove after drop" checkbox checked? if ($('#drop-remove').is(':checked')) { // if so, remove the element from the "Draggable Events" list $(this).remove(); } } }); } /* ---------- Sparkline Charts ---------- */ function sparkline_charts() { //generate random number for charts randNum = function(){ //return Math.floor(Math.random()*101); return (Math.floor( Math.random()* (1+40-20) ) ) + 20; } var chartColours = ['#2FABE9', '#FA5833', '#b9e672', '#bbdce3', '#9a3b1b', '#5a8022', '#2c7282']; //sparklines (making loop with random data for all 7 sparkline) i=1; for (i=1; i<9; i++) { var data = [[1, 3+randNum()], [2, 5+randNum()], [3, 8+randNum()], [4, 11+randNum()],[5, 14+randNum()],[6, 17+randNum()],[7, 20+randNum()], [8, 15+randNum()], [9, 18+randNum()], [10, 22+randNum()]]; placeholder = '.sparkLineStats' + i; $(placeholder).sparkline(data, { width: 100,//Width of the chart - Defaults to 'auto' - May be any valid css width - 1.5em, 20px, etc (using a number without a unit specifier won't do what you want) - This option does nothing for bar and tristate chars (see barWidth) height: 30,//Height of the chart - Defaults to 'auto' (line height of the containing tag) lineColor: '#2FABE9',//Used by line and discrete charts to specify the colour of the line drawn as a CSS values string fillColor: '#f2f7f9',//Specify the colour used to fill the area under the graph as a CSS value. Set to false to disable fill spotColor: '#467e8c',//The CSS colour of the final value marker. Set to false or an empty string to hide it maxSpotColor: '#b9e672',//The CSS colour of the marker displayed for the maximum value. Set to false or an empty string to hide it minSpotColor: '#FA5833',//The CSS colour of the marker displayed for the mimum value. Set to false or an empty string to hide it spotRadius: 2,//Radius of all spot markers, In pixels (default: 1.5) - Integer lineWidth: 1//In pixels (default: 1) - Integer }); } } /* ---------- Charts ---------- */ function charts() { function randNum(){ return (Math.floor( Math.random()* (1+40-20) ) ) + 20; } /* ---------- Chart with points ---------- */ if($("#stats-chart").length) { var pageviews = [[1, 5+randNum()], [2, 10+randNum()], [3, 15+randNum()], [4, 20+randNum()],[5, 25+randNum()],[6, 30+randNum()],[7, 35+randNum()],[8, 40+randNum()],[9, 45+randNum()],[10, 50+randNum()],[11, 55+randNum()],[12, 60+randNum()],[13, 65+randNum()],[14, 70+randNum()],[15, 75+randNum()],[16, 80+randNum()],[17, 85+randNum()],[18, 90+randNum()],[19, 85+randNum()],[20, 80+randNum()],[21, 75+randNum()],[22, 80+randNum()],[23, 75+randNum()],[24, 70+randNum()],[25, 65+randNum()],[26, 75+randNum()],[27,80+randNum()],[28, 85+randNum()],[29, 90+randNum()], [30, 95+randNum()]]; var visitors = [[1, randNum()-10], [2, randNum()-10], [3, randNum()-10], [4, randNum()],[5, randNum()],[6, 4+randNum()],[7, 5+randNum()],[8, 6+randNum()],[9, 6+randNum()],[10, 8+randNum()],[11, 9+randNum()],[12, 10+randNum()],[13,11+randNum()],[14, 12+randNum()],[15, 13+randNum()],[16, 14+randNum()],[17, 15+randNum()],[18, 15+randNum()],[19, 16+randNum()],[20, 17+randNum()],[21, 18+randNum()],[22, 19+randNum()],[23, 20+randNum()],[24, 21+randNum()],[25, 14+randNum()],[26, 24+randNum()],[27,25+randNum()],[28, 26+randNum()],[29, 27+randNum()], [30, 31+randNum()]]; var plot = $.plot($("#stats-chart"), [ { data: pageviews, label: "pageviews"}, { data: visitors, label: "visitors" } ], { series: { lines: { show: true, lineWidth: 3, fill: true, fillColor: { colors: [ { opacity: 0.08 }, { opacity: 0.01 } ] } }, points: { show: true }, shadowSize: 2 }, grid: { hoverable: true, clickable: true, tickColor: "#eee", borderWidth: 0, }, colors: ["#FA5833", "#2FABE9"], xaxis: {ticks:11, tickDecimals: 0}, yaxis: {ticks:11, tickDecimals: 0}, }); function showTooltip(x, y, contents) { $('