Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var id = $(this).attr('id');
  2.                     var dayNumber = $(this).parent().attr('id');
  3.                     var d = $(daysLabels[dayNumber]).text().split(".");
  4.                     var moduleId = $(this).parent().parent().attr('id');
  5.                     var elem = {
  6.                         id: id,
  7.                         moduleId: moduleId,
  8.                         hoursAmount: 0,
  9.                         date: d[2] + "-" + d[1] + "-" + d[0]
  10.                     };
  11.                     if (id != -1) {
  12.                         debugger;
  13.                         elem = atoms[id];
  14.                     }
  15.                     var dialogContent = $('<div id="add-project-content"></div>').
  16.                         append($('<div class="row"><span class="label">Hours amount:</span><span class="field"><input id="hoursAmount" value="' + elem.hoursAmount + '"  data-val-id=""/></span></div>'));
  17.                     var confirmDialog = new ConfirmDialog({
  18.                         title: 'Add hours amount to module',
  19.                         content: dialogContent,
  20.                         width: 350,
  21.                         height: 'auto',
  22.                         onOk: function () {
  23.                             var content = confirmDialog.settings.content;
  24.                             var hoursAmount = content.find('#hoursAmount').val();
  25.                             elem.hoursAmount = hoursAmount;
  26.                             $.ajax({
  27.                                 url: '/TimeAccounting/AddOrEditAtom',
  28.                                 type: 'POST',
  29.                                 data: elem,
  30.                                 success: function (data) {
  31.                                     if (data.success) {
  32.                                         atoms[id] = elem;
  33.                                         $.jGrowl('Saved.');
  34.                                         confirmDialog.close();
  35.                                         initDate();
  36.                                     } else {
  37.                                         if (data.error) {
  38.                                             $.jGrowl("Error.");
  39.                                         }
  40.                                         else {
  41.                                             $.jGrowl('Error occurred.<br/>' + data.message);
  42.                                         }
  43.                                     }
  44.                                 }
  45.                             }).fail(function () { $.jGrowl('Unknown error occurred'); });
  46.                         }
  47.                     });
  48.                     confirmDialog.show();
  49.                     confirmDialog.settings.content.find('#hoursAmount').focus();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement