demo.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. "use strict";
  2. $().ready(function(){
  3. var $sidebar = $('.sidebar');
  4. var $sidebar_img_container = $sidebar.find('.sidebar-background');
  5. var $full_page = $('.full-page');
  6. var $sidebar_responsive = $('body > .navbar-collapse');
  7. var window_width = $(window).width();
  8. var fixed_plugin_open = $('.sidebar .sidebar-wrapper .nav li.active a p').html();
  9. if( window_width > 767 && fixed_plugin_open === 'Dashboard' ){
  10. if($('.fixed-plugin .dropdown').hasClass('show-dropdown')){
  11. $('.fixed-plugin .dropdown').addClass('open');
  12. }
  13. }
  14. $('.fixed-plugin a').on('click',function(event){
  15. // Alex if we click on switch, stop propagation of the event, so the dropdown will not be hide, otherwise we set the section active
  16. if($(this).hasClass('switch-trigger')){
  17. if(event.stopPropagation){
  18. event.stopPropagation();
  19. }
  20. else if(window.event){
  21. window.event.cancelBubble = true;
  22. }
  23. }
  24. });
  25. $('.fixed-plugin .active-color span').on('click',function(){
  26. var $topbar_background = $('.navbar');
  27. var new_color = $(this).data('color');
  28. $topbar_background.attr('data-topbar-color',new_color);
  29. /*
  30. $full_page_background = $('.full-page-background');
  31. $(this).siblings().removeClass('active');
  32. $(this).addClass('active');
  33. var new_color = $(this).data('color');
  34. if($sidebar.length != 0){
  35. $sidebar.attr('data-active-color',new_color);
  36. }
  37. if($full_page.length != 0){
  38. $full_page.attr('filter-color',new_color);
  39. }
  40. if($sidebar_responsive.length != 0){
  41. $sidebar_responsive.attr('data-color',new_color);
  42. }
  43. */
  44. });
  45. $('.fixed-plugin .background-color span').on('click',function(){
  46. $(this).siblings().removeClass('active');
  47. $(this).addClass('active');
  48. var new_color = $(this).data('color');
  49. if($sidebar.length != 0){
  50. $sidebar.attr('data-background-color',new_color);
  51. }
  52. });
  53. $('.fixed-plugin .img-holder').on('click',function(){
  54. $full_page_background = $('.full-page-background');
  55. $(this).parent('li').siblings().removeClass('active');
  56. $(this).parent('li').addClass('active');
  57. var new_image = $(this).find("img").attr('src');
  58. if( $sidebar_img_container.length !=0 && $('.switch-sidebar-image input:checked').length != 0 ){
  59. $sidebar_img_container.fadeOut('fast', function(){
  60. $sidebar_img_container.css('background-image','url("' + new_image + '")');
  61. $sidebar_img_container.fadeIn('fast');
  62. });
  63. }
  64. if($full_page_background.length != 0 && $('.switch-sidebar-image input:checked').length != 0 ) {
  65. var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src');
  66. $full_page_background.fadeOut('fast', function(){
  67. $full_page_background.css('background-image','url("' + new_image_full_page + '")');
  68. $full_page_background.fadeIn('fast');
  69. });
  70. }
  71. if( $('.switch-sidebar-image input:checked').length === 0 ){
  72. var new_image = $('.fixed-plugin li.active .img-holder').find("img").attr('src');
  73. var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src');
  74. $sidebar_img_container.css('background-image','url("' + new_image + '")');
  75. $full_page_background.css('background-image','url("' + new_image_full_page + '")');
  76. }
  77. if($sidebar_responsive.length != 0){
  78. $sidebar_responsive.css('background-image','url("' + new_image + '")');
  79. }
  80. });
  81. $('.switch-sidebar-image input').change(function(){
  82. var $full_page_background = $('.full-page-background');
  83. var $input = $(this);
  84. var background_image;
  85. if($input.is(':checked')){
  86. if($sidebar_img_container.length != 0){
  87. $sidebar_img_container.fadeIn('fast');
  88. $sidebar.attr('data-image','#');
  89. }
  90. if($full_page_background.length != 0){
  91. $full_page_background.fadeIn('fast');
  92. $full_page.attr('data-image','#');
  93. }
  94. background_image = true;
  95. } else {
  96. if($sidebar_img_container.length != 0){
  97. $sidebar.removeAttr('data-image');
  98. $sidebar_img_container.fadeOut('fast');
  99. }
  100. if($full_page_background.length != 0){
  101. $full_page.removeAttr('data-image','#');
  102. $full_page_background.fadeOut('fast');
  103. }
  104. background_image = false;
  105. }
  106. });
  107. $('.switch-sidebar-mini input').change(function(){
  108. var $body = $('body');
  109. var $input = $(this);
  110. if(md.misc.sidebar_mini_active === true){
  111. $('body').removeClass('sidebar-mini');
  112. md.misc.sidebar_mini_active = false;
  113. $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar();
  114. }else{
  115. $('.sidebar .collapse').collapse('hide').on('hidden.bs.collapse',function(){
  116. $(this).css('height','auto');
  117. });
  118. $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar('destroy');
  119. setTimeout(function(){
  120. $('body').addClass('sidebar-mini');
  121. $('.sidebar .collapse').css('height','auto');
  122. md.misc.sidebar_mini_active = true;
  123. },300);
  124. }
  125. // we simulate the window Resize so the charts will get updated in realtime.
  126. var simulateWindowResize = setInterval(function(){
  127. window.dispatchEvent(new Event('resize'));
  128. },180);
  129. // we stop the simulation of Window Resize after the animations are completed
  130. setTimeout(function(){
  131. clearInterval(simulateWindowResize);
  132. },1000);
  133. });
  134. });
  135. var type = ['','info','success','warning','danger'];
  136. var demo = {
  137. initCirclePercentage: function(){
  138. $('#chartDashboard, #chartOrders, #chartNewVisitors, #chartSubscriptions').easyPieChart({
  139. lineWidth: 6,
  140. size: 160,
  141. scaleColor: false,
  142. trackColor: 'rgba(255,255,255,.25)',
  143. barColor: '#FFFFFF',
  144. animate: ({duration: 5000, enabled: true})
  145. });
  146. },
  147. initPickColor: function(){
  148. $('.pick-class-label').on('click',function(){
  149. var new_class = $(this).attr('new-class');
  150. var old_class = $('#display-buttons').attr('data-class');
  151. var display_div = $('#display-buttons');
  152. if(display_div.length) {
  153. var display_buttons = display_div.find('.btn');
  154. display_buttons.removeClass(old_class);
  155. display_buttons.addClass(new_class);
  156. display_div.attr('data-class', new_class);
  157. }
  158. });
  159. },
  160. checkFullPageBackgroundImage: function(){
  161. var $page = $('.full-page');
  162. var image_src = $page.data('image');
  163. if(image_src !== undefined){
  164. var image_container = '<div class="full-page-background" style="background-image: url(' + image_src + ') "/>'
  165. $page.append(image_container);
  166. }
  167. },
  168. initFormExtendedSliders: function(){
  169. // Sliders for demo purpose in refine cards section
  170. if($('#slider-range').length != 0){
  171. $( "#slider-range" ).slider({
  172. range: true,
  173. min: 0,
  174. max: 500,
  175. values: [ 75, 300 ],
  176. });
  177. }
  178. if($('#refine-price-range').length != 0){
  179. $( "#refine-price-range" ).slider({
  180. range: true,
  181. min: 0,
  182. max: 999,
  183. values: [ 100, 850 ],
  184. slide: function( event, ui ) {
  185. min_price = ui.values[0];
  186. max_price = ui.values[1];
  187. $(this).siblings('.price-left').html('&euro; ' + min_price);
  188. $(this).siblings('.price-right').html('&euro; ' + max_price)
  189. }
  190. });
  191. }
  192. if($('#slider-default').length != 0 || $('#slider-default2').length != 0){
  193. $( "#slider-default, #slider-default2" ).slider({
  194. value: 70,
  195. orientation: "horizontal",
  196. range: "min",
  197. animate: true
  198. });
  199. }
  200. },
  201. initDocExtendedDatetimepickers: function(){
  202. $('.datetimepicker').datetimepicker({
  203. icons: {
  204. time: "fa fa-clock-o",
  205. date: "fa fa-calendar",
  206. up: "fa fa-chevron-up",
  207. down: "fa fa-chevron-down",
  208. previous: 'fa fa-chevron-left',
  209. next: 'fa fa-chevron-right',
  210. today: 'fa fa-screenshot',
  211. clear: 'fa fa-trash',
  212. close: 'fa fa-remove',
  213. inline: true
  214. }
  215. });
  216. },
  217. initFormExtendedDatetimepickers: function(){
  218. $('.datetimepicker').datetimepicker({
  219. icons: {
  220. time: "fa fa-clock-o",
  221. date: "fa fa-calendar",
  222. up: "fa fa-chevron-up",
  223. down: "fa fa-chevron-down",
  224. previous: 'fa fa-chevron-left',
  225. next: 'fa fa-chevron-right',
  226. today: 'fa fa-screenshot',
  227. clear: 'fa fa-trash',
  228. close: 'fa fa-remove',
  229. inline: true
  230. }
  231. });
  232. $('.datepicker').datetimepicker({
  233. format: 'MM/DD/YYYY',
  234. icons: {
  235. time: "fa fa-clock-o",
  236. date: "fa fa-calendar",
  237. up: "fa fa-chevron-up",
  238. down: "fa fa-chevron-down",
  239. previous: 'fa fa-chevron-left',
  240. next: 'fa fa-chevron-right',
  241. today: 'fa fa-screenshot',
  242. clear: 'fa fa-trash',
  243. close: 'fa fa-remove',
  244. inline: true
  245. }
  246. });
  247. $('.timepicker').datetimepicker({
  248. // format: 'H:mm', // use this format if you want the 24hours timepicker
  249. format: 'h:mm A', //use this format if you want the 12hours timpiecker with AM/PM toggle
  250. icons: {
  251. time: "fa fa-clock-o",
  252. date: "fa fa-calendar",
  253. up: "fa fa-chevron-up",
  254. down: "fa fa-chevron-down",
  255. previous: 'fa fa-chevron-left',
  256. next: 'fa fa-chevron-right',
  257. today: 'fa fa-screenshot',
  258. clear: 'fa fa-trash',
  259. close: 'fa fa-remove',
  260. inline: true
  261. }
  262. });
  263. },
  264. initMaterialWizard: function(){
  265. // Code for the Validator
  266. var $validator = $('.wizard-card form').validate({
  267. rules: {
  268. firstname: {
  269. required: true,
  270. minlength: 3
  271. },
  272. lastname: {
  273. required: true,
  274. minlength: 3
  275. },
  276. email: {
  277. required: true,
  278. minlength: 3,
  279. }
  280. },
  281. errorPlacement: function(error, element) {
  282. $(element).parent('div').addClass('has-error');
  283. }
  284. });
  285. // Wizard Initialization
  286. $('.wizard-card').bootstrapWizard({
  287. 'tabClass': 'nav nav-pills',
  288. 'nextSelector': '.btn-next',
  289. 'previousSelector': '.btn-previous',
  290. onNext: function(tab, navigation, index) {
  291. var $valid = $('.wizard-card form').valid();
  292. if(!$valid) {
  293. $validator.focusInvalid();
  294. return false;
  295. }
  296. },
  297. onInit : function(tab, navigation, index){
  298. //check number of tabs and fill the entire row
  299. var $total = navigation.find('li').length;
  300. var $width = 100/$total;
  301. var $wizard = navigation.closest('.wizard-card');
  302. var $display_width = $(document).width();
  303. if($display_width < 600 && $total > 3){
  304. $width = 50;
  305. }
  306. navigation.find('li').css('width',$width + '%');
  307. var $first_li = navigation.find('li:first-child a').html();
  308. var $moving_div = $('<div class="moving-tab">' + $first_li + '</div>');
  309. $('.wizard-card .wizard-navigation').append($moving_div);
  310. refreshAnimation($wizard, index);
  311. $('.moving-tab').css('transition','transform 0s');
  312. },
  313. onTabClick : function(tab, navigation, index){
  314. var $valid = $('.wizard-card form').valid();
  315. if(!$valid){
  316. return false;
  317. } else{
  318. return true;
  319. }
  320. },
  321. onTabShow: function(tab, navigation, index) {
  322. var $total = navigation.find('li').length;
  323. var $current = index+1;
  324. var $wizard = navigation.closest('.wizard-card');
  325. // If it's the last tab then hide the last button and show the finish instead
  326. if($current >= $total) {
  327. $($wizard).find('.btn-next').hide();
  328. $($wizard).find('.btn-finish').show();
  329. } else {
  330. $($wizard).find('.btn-next').show();
  331. $($wizard).find('.btn-finish').hide();
  332. }
  333. var button_text = navigation.find('li:nth-child(' + $current + ') a').html();
  334. setTimeout(function(){
  335. $('.moving-tab').text(button_text);
  336. }, 150);
  337. var checkbox = $('.footer-checkbox');
  338. if( !index === 0 ){
  339. $(checkbox).css({
  340. 'opacity':'0',
  341. 'visibility':'hidden',
  342. 'position':'absolute'
  343. });
  344. } else {
  345. $(checkbox).css({
  346. 'opacity':'1',
  347. 'visibility':'visible'
  348. });
  349. }
  350. refreshAnimation($wizard, index);
  351. }
  352. });
  353. // Prepare the preview for profile picture
  354. $("#wizard-picture").change(function(){
  355. readURL(this);
  356. });
  357. $('[data-toggle="wizard-radio"]').on('click',function(){
  358. wizard = $(this).closest('.wizard-card');
  359. wizard.find('[data-toggle="wizard-radio"]').removeClass('active');
  360. $(this).addClass('active');
  361. $(wizard).find('[type="radio"]').removeAttr('checked');
  362. $(this).find('[type="radio"]').attr('checked','true');
  363. });
  364. $('[data-toggle="wizard-checkbox"]').on('click',function(){
  365. if( $(this).hasClass('active')){
  366. $(this).removeClass('active');
  367. $(this).find('[type="checkbox"]').removeAttr('checked');
  368. } else {
  369. $(this).addClass('active');
  370. $(this).find('[type="checkbox"]').attr('checked','true');
  371. }
  372. });
  373. $('.set-full-height').css('height', 'auto');
  374. //Function to show image before upload
  375. function readURL(input) {
  376. if (input.files && input.files[0]) {
  377. var reader = new FileReader();
  378. reader.onload = function (e) {
  379. $('#wizardPicturePreview').attr('src', e.target.result).fadeIn('slow');
  380. }
  381. reader.readAsDataURL(input.files[0]);
  382. }
  383. }
  384. $(window).resize(function(){
  385. $('.wizard-card').each(function(){
  386. $wizard = $(this);
  387. index = $wizard.bootstrapWizard('currentIndex');
  388. refreshAnimation($wizard, index);
  389. $('.moving-tab').css({
  390. 'transition': 'transform 0s'
  391. });
  392. });
  393. });
  394. function refreshAnimation($wizard, index){
  395. var total_steps = $wizard.find('li').length;
  396. var move_distance = $wizard.width() / total_steps;
  397. var step_width = move_distance;
  398. move_distance *= index;
  399. var $current = index + 1;
  400. if($current === 1){
  401. move_distance -= 8;
  402. } else if($current === total_steps){
  403. move_distance += 8;
  404. }
  405. $wizard.find('.moving-tab').css('width', step_width);
  406. $('.moving-tab').css({
  407. 'transform':'translate3d(' + move_distance + 'px, 0, 0)',
  408. 'transition': 'all 0.5s cubic-bezier(0.29, 1.42, 0.79, 1)'
  409. });
  410. }
  411. },
  412. showSwal: function(type){
  413. if(type === 'basic'){
  414. swal({
  415. title: "Here's a message!",
  416. buttonsStyling: false,
  417. confirmButtonClass: "btn btn-success"
  418. }).catch(swal.noop);
  419. }else if(type === 'title-and-text'){
  420. swal({
  421. title: "Here's a message!",
  422. text: "It's pretty, isn't it?",
  423. buttonsStyling: false,
  424. confirmButtonClass: "btn btn-info"
  425. }).catch(swal.noop);
  426. }else if(type === 'success-message'){
  427. swal({
  428. title: "Good job!",
  429. text: "You clicked the button!",
  430. buttonsStyling: false,
  431. confirmButtonClass: "btn btn-success",
  432. type: "success"
  433. }).catch(swal.noop);
  434. }else if(type === 'warning-message-and-confirmation'){
  435. swal({
  436. title: 'Are you sure?',
  437. text: "You won't be able to revert this!",
  438. type: 'warning',
  439. showCancelButton: true,
  440. confirmButtonClass: 'btn btn-success',
  441. cancelButtonClass: 'btn btn-danger',
  442. confirmButtonText: 'Yes, delete it!',
  443. buttonsStyling: false
  444. }).then(function() {
  445. swal({
  446. title: 'Deleted!',
  447. text: 'Your file has been deleted.',
  448. type: 'success',
  449. confirmButtonClass: "btn btn-success",
  450. buttonsStyling: false
  451. }).catch(swal.noop);
  452. },function(dismiss){
  453. });
  454. }else if(type === 'warning-message-and-cancel'){
  455. swal({
  456. title: 'Are you sure?',
  457. text: 'You will not be able to recover this imaginary file!',
  458. type: 'warning',
  459. showCancelButton: true,
  460. confirmButtonText: 'Yes, delete it!',
  461. cancelButtonText: 'No, keep it',
  462. confirmButtonClass: "btn btn-success",
  463. cancelButtonClass: "btn btn-danger",
  464. buttonsStyling: false
  465. }).then(function() {
  466. swal({
  467. title: 'Deleted!',
  468. text: 'Your imaginary file has been deleted.',
  469. type: 'success',
  470. confirmButtonClass: "btn btn-success",
  471. buttonsStyling: false
  472. }).catch(swal.noop);
  473. }, function(dismiss) {
  474. // dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
  475. if (dismiss === 'cancel') {
  476. swal({
  477. title: 'Cancelled',
  478. text: 'Your imaginary file is safe :)',
  479. type: 'error',
  480. confirmButtonClass: "btn btn-info",
  481. buttonsStyling: false
  482. }).catch(swal.noop);
  483. }
  484. })
  485. }else if(type === 'custom-html'){
  486. swal({
  487. title: 'HTML example',
  488. buttonsStyling: false,
  489. confirmButtonClass: "btn btn-success",
  490. html:
  491. 'You can use <b>bold text</b>, ' +
  492. '<a href="http://github.com">links</a> ' +
  493. 'and other HTML tags'
  494. }).catch(swal.noop);
  495. }else if(type === 'auto-close'){
  496. swal({ title: "Auto close alert!",
  497. text: "I will close in 2 seconds.",
  498. timer: 2000,
  499. showConfirmButton: false
  500. }).catch(swal.noop);
  501. } else if(type === 'input-field'){
  502. swal({
  503. title: 'Input something',
  504. html: '<div class="form-group">' +
  505. '<input id="input-field" type="text" class="form-control" />' +
  506. '</div>',
  507. showCancelButton: true,
  508. confirmButtonClass: 'btn btn-success',
  509. cancelButtonClass: 'btn btn-danger',
  510. buttonsStyling: false
  511. }).then(function(result) {
  512. swal({
  513. type: 'success',
  514. html: 'You entered: <strong>' +
  515. $('#input-field').val() +
  516. '</strong>',
  517. confirmButtonClass: 'btn btn-success',
  518. buttonsStyling: false
  519. }).catch(swal.noop);
  520. }).catch(swal.noop)
  521. }
  522. },
  523. initVectorMap: function(){
  524. var mapData = {
  525. "AU": 760,
  526. "BR": 550,
  527. "CA": 120,
  528. "DE": 1300,
  529. "FR": 540,
  530. "GB": 690,
  531. "GE": 200,
  532. "IN": 200,
  533. "RO": 600,
  534. "RU": 300,
  535. "US": 2920,
  536. };
  537. $('#worldMap').vectorMap({
  538. map: 'world_mill_en',
  539. backgroundColor: "transparent",
  540. zoomOnScroll: false,
  541. regionStyle: {
  542. initial: {
  543. fill: '#e4e4e4',
  544. "fill-opacity": 0.9,
  545. stroke: 'none',
  546. "stroke-width": 0,
  547. "stroke-opacity": 0
  548. }
  549. },
  550. series: {
  551. regions: [{
  552. values: mapData,
  553. scale: ["#AAAAAA","#444444"],
  554. normalizeFunction: 'polynomial'
  555. }]
  556. },
  557. });
  558. },
  559. initGoogleMaps: function(){
  560. var myLatlng = new google.maps.LatLng(40.748817, -73.985428);
  561. var mapOptions = {
  562. zoom: 13,
  563. center: myLatlng,
  564. scrollwheel: false, //we disable de scroll over the map, it is a really annoing when you scroll through page
  565. styles: [{"featureType":"water","stylers":[{"saturation":43},{"lightness":-11},{"hue":"#0088ff"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"hue":"#ff0000"},{"saturation":-100},{"lightness":99}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#808080"},{"lightness":54}]},{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"color":"#ece2d9"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#ccdca1"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#767676"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]},{"featureType":"poi","stylers":[{"visibility":"off"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#b8cb93"}]},{"featureType":"poi.park","stylers":[{"visibility":"on"}]},{"featureType":"poi.sports_complex","stylers":[{"visibility":"on"}]},{"featureType":"poi.medical","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","stylers":[{"visibility":"simplified"}]}]
  566. }
  567. var map = new google.maps.Map(document.getElementById("map"), mapOptions);
  568. var marker = new google.maps.Marker({
  569. position: myLatlng,
  570. title:"Hello World!"
  571. });
  572. // To add the marker to the map, call setMap();
  573. marker.setMap(map);
  574. },
  575. initSmallGoogleMaps: function(){
  576. // Regular Map
  577. var myLatlng = new google.maps.LatLng(40.748817, -73.985428);
  578. var mapOptions = {
  579. zoom: 8,
  580. center: myLatlng,
  581. scrollwheel: false, //we disable de scroll over the map, it is a really annoing when you scroll through page
  582. }
  583. var map = new google.maps.Map(document.getElementById("regularMap"), mapOptions);
  584. var marker = new google.maps.Marker({
  585. position: myLatlng,
  586. title:"Regular Map!"
  587. });
  588. marker.setMap(map);
  589. },
  590. initFullCalendar: function(){
  591. var $calendar = $('#fullCalendar');
  592. var today = new Date();
  593. var y = today.getFullYear();
  594. var m = today.getMonth();
  595. var d = today.getDate();
  596. $calendar.fullCalendar({
  597. viewRender: function(view, element) {
  598. // We make sure that we activate the perfect scrollbar when the view isn't on Month
  599. if (view.name != 'month'){
  600. $(element).find('.fc-scroller').perfectScrollbar();
  601. }
  602. },
  603. header: {
  604. left: 'title',
  605. center: 'month,agendaWeek,agendaDay',
  606. right: 'prev,next,today'
  607. },
  608. defaultDate: today,
  609. selectLongPressDelay: 10,
  610. selectable: true,
  611. selectHelper: true,
  612. views: {
  613. month: { // name of view
  614. titleFormat: 'MMMM YYYY'
  615. // other view-specific options here
  616. },
  617. week: {
  618. titleFormat: " MMM D YYYY"
  619. },
  620. day: {
  621. titleFormat: 'D MMM, YYYY'
  622. }
  623. },
  624. select: function(start, end) {
  625. // on select we show the Sweet Alert modal with an input
  626. swal({
  627. title: 'Create an Event',
  628. html: '<div class="form-group">' +
  629. '<input class="form-control" placeholder="Event Title" id="input-field">' +
  630. '</div>',
  631. showCancelButton: true,
  632. confirmButtonClass: 'btn btn-success',
  633. cancelButtonClass: 'btn btn-danger',
  634. buttonsStyling: false
  635. }).then(function(result) {
  636. var eventData;
  637. event_title = $('#input-field').val();
  638. if (event_title) {
  639. eventData = {
  640. title: event_title,
  641. start: start,
  642. end: end
  643. };
  644. $calendar.fullCalendar('renderEvent', eventData, true); // stick? = true
  645. }
  646. $calendar.fullCalendar('unselect');
  647. },function(dismiss){
  648. });
  649. },
  650. editable: true,
  651. eventLimit: true, // allow "more" link when too many events
  652. // color classes: [ event-blue | event-azure | event-green | event-orange | event-red ]
  653. events: [
  654. {
  655. title: 'All Day Event',
  656. start: new Date(y, m, 1),
  657. className: 'event-default'
  658. },
  659. {
  660. id: 999,
  661. title: 'Repeating Event',
  662. start: new Date(y, m, d-4, 6, 0),
  663. allDay: false,
  664. className: 'event-rose'
  665. },
  666. {
  667. id: 999,
  668. title: 'Repeating Event',
  669. start: new Date(y, m, d+3, 6, 0),
  670. allDay: false,
  671. className: 'event-rose'
  672. },
  673. {
  674. title: 'Meeting',
  675. start: new Date(y, m, d-1, 10, 30),
  676. allDay: false,
  677. className: 'event-green'
  678. },
  679. {
  680. title: 'Lunch',
  681. start: new Date(y, m, d+7, 12, 0),
  682. end: new Date(y, m, d+7, 14, 0),
  683. allDay: false,
  684. className: 'event-red'
  685. },
  686. {
  687. title: 'Amaze Launch',
  688. start: new Date(y, m, d-2, 12, 0),
  689. allDay: true,
  690. className: 'event-azure'
  691. },
  692. {
  693. title: 'Birthday Party',
  694. start: new Date(y, m, d+1, 19, 0),
  695. end: new Date(y, m, d+1, 22, 30),
  696. allDay: false,
  697. className: 'event-azure'
  698. },
  699. {
  700. title: 'Click for Urban UI',
  701. start: new Date(y, m, 21),
  702. end: new Date(y, m, 22),
  703. url: 'http://www.urbanui.com/',
  704. className: 'event-orange'
  705. },
  706. {
  707. title: 'Click for Google',
  708. start: new Date(y, m, 21),
  709. end: new Date(y, m, 22),
  710. url: 'http://www.google.com/',
  711. className: 'event-orange'
  712. }
  713. ]
  714. });
  715. },
  716. showNotification: function(from, align){
  717. type = ['','info','success','warning','danger','rose','primary'];
  718. var color = Math.floor((Math.random() * 6) + 1);
  719. $.notify({
  720. icon: "notifications",
  721. message: "Welcome to <b>Material Dashboard</b> - a beautiful freebie for every web developer."
  722. },{
  723. type: type[color],
  724. timer: 3000,
  725. placement: {
  726. from: from,
  727. align: align
  728. }
  729. });
  730. }
  731. }