Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function(){
- $("#add-clinic").on('click', function(){
- $("#clinic-form").openModal();
- var $sliders = $('.range-slider');
- // create sliders
- App.Slider.createSliders($sliders);
- // grey out row after toggle checkbox
- $(document).on('click', ':checkbox', function(e) {
- if ($(this).is(':checked')) {
- $(this).closest('.range-day').removeClass('range-day-disabled');
- } else {
- $(this).closest('.range-day').addClass('range-day-disabled');
- }
- App.Slider.updateValues($sliders);
- });
- $('[data-behavior~=fancySelect]').fancySelect();
- // preselect user timezone
- var getTimezone = function() {
- var currentTime = new Date();
- var currentTimezone = currentTime.getTimezoneOffset();
- currentTimezone = (currentTimezone / 60) * -1;
- var doubleDigit = ("0" + Math.abs(currentTimezone)).slice(-2);
- if (currentTimezone == 0) return '+00:00';
- if (currentTimezone < 0) {
- return '-' + doubleDigit + ':00';
- } else {
- return '+' + doubleDigit + ':00';
- }
- };
- $('[data-offset~=' + '"' + getTimezone() + '"' + ']').first().attr('selected', true);
- $('[data-behavior~=fancySelect]').trigger('update.fs');
- $('#clinic-form').on('submit', function(e){
- e.preventDefault();
- var params = $('form').serializeJSON();
- $.ajax({
- method: 'post',
- url: '/user',
- data: params,
- datatype: 'json',
- success: function(data){
- $('tbody').append("<tr><td>"+data.id+"</td><td>"+data.name+"</td><td>"+data.phone+"</td><td>"+data.email+"</td><td><a href=\"/admin/reports/"+data.id+"\">reports</a></td><td><a href=\"/admin/calllogs/"+data.id+"\">calllogs</a></td></tr>")
- },
- error: function(data){
- alert("Did not add");
- }
- });
- });
- });
- $('.switch').on("click", 'input', function(){
- id = $(this).closest('tr').find('td').eq(0).text().trim();
- if($(this).is(':checked')) {
- admin = 1
- }else{
- admin = 0
- }
- params = {id: id, admin: admin}
- $.ajax({
- method: 'post',
- url: 'user/admin_edit',
- data: params,
- datatype: 'json',
- success: function(data){
- console.log(data)
- },
- error: function(data){
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement