kirgudu_base 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kirgudu_base/dynamicEvents.js +2 -1
  3. data/app/assets/javascripts/kirgudu_base/jquery.container-management.js +241 -0
  4. data/app/assets/javascripts/kirgudu_base/jquery.fancybox copia.js +2020 -0
  5. data/app/assets/javascripts/kirgudu_base/scripts_nrg.js +300 -383
  6. data/app/controllers/kirgudu_base/admin_controller.rb +1 -44
  7. data/app/controllers/kirgudu_base/application_controller.rb +135 -92
  8. data/app/controllers/kirgudu_base/cabinet_controller.rb +35 -35
  9. data/app/controllers/kirgudu_base/security/authentications_controller.rb +452 -0
  10. data/app/controllers/kirgudu_base/security/email_confirmations_controller.rb +46 -0
  11. data/app/helpers/kirgudu_base/application_helper.rb +25 -0
  12. data/app/helpers/kirgudu_base/authentication_form_builder.rb +76 -0
  13. data/app/helpers/kirgudu_base/controllers/{basic_actions_with_parent.rb → OLD_basic_actions.rb} +39 -54
  14. data/app/helpers/kirgudu_base/controllers/basic_actions.rb +967 -161
  15. data/app/helpers/kirgudu_base/controllers/container_items_management_actions.rb +118 -40
  16. data/app/helpers/kirgudu_base/controllers/container_items_sorting_actions.rb +2 -2
  17. data/app/helpers/kirgudu_base/controllers/dynamic_pages.rb +147 -11
  18. data/app/helpers/kirgudu_base/form_builder.rb +3 -1
  19. data/app/helpers/kirgudu_base/gui_helper.rb +10 -5
  20. data/app/helpers/kirgudu_base/models/exports.rb +122 -122
  21. data/app/helpers/kirgudu_base/models/scopes.rb +5 -0
  22. data/app/mailers/authentications_mailer.rb +53 -0
  23. data/app/models/kirgudu_base/base_model.rb +47 -14
  24. data/app/models/kirgudu_base/dynamic_pages/builder.rb +0 -8
  25. data/app/models/kirgudu_base/dynamic_pages/controller_link.rb +4 -1
  26. data/app/models/kirgudu_base/dynamic_pages/controller_link_builder.rb +2 -1
  27. data/app/models/kirgudu_base/dynamic_pages/controller_link_id.rb +6 -6
  28. data/app/models/kirgudu_base/dynamic_pages/controller_link_id_builder.rb +6 -6
  29. data/app/models/kirgudu_base/dynamic_pages/element.rb +4 -5
  30. data/app/models/kirgudu_base/dynamic_pages/entry_builder.rb +2 -2
  31. data/app/models/kirgudu_base/dynamic_pages/event_if_block_builder.rb +1 -1
  32. data/app/models/kirgudu_base/dynamic_pages/form_builder.rb +2 -2
  33. data/app/models/kirgudu_base/dynamic_pages/list.rb +2 -0
  34. data/app/models/kirgudu_base/dynamic_pages/list_builder.rb +7 -3
  35. data/app/models/kirgudu_base/dynamic_pages/management_settings.rb +30 -0
  36. data/app/models/kirgudu_base/dynamic_pages/management_settings_builder.rb +47 -0
  37. data/app/models/kirgudu_base/dynamic_pages/menu.rb +9 -5
  38. data/app/models/kirgudu_base/dynamic_pages/menu_builder.rb +8 -5
  39. data/app/models/kirgudu_base/dynamic_pages/menu_item.rb +22 -6
  40. data/app/models/kirgudu_base/dynamic_pages/menu_items_block_builder.rb +9 -4
  41. data/app/models/kirgudu_base/dynamic_pages/menu_section.rb +38 -0
  42. data/app/models/kirgudu_base/dynamic_pages/menu_section_builder.rb +36 -0
  43. data/app/models/kirgudu_base/dynamic_pages/page.rb +6 -2
  44. data/app/models/kirgudu_base/dynamic_pages/page_builder.rb +18 -0
  45. data/app/models/kirgudu_base/dynamic_pages/relation.rb +23 -0
  46. data/app/models/kirgudu_base/dynamic_pages/relation_builder.rb +35 -0
  47. data/app/models/kirgudu_base/dynamic_pages/sorting_settings.rb +31 -0
  48. data/app/models/kirgudu_base/dynamic_pages/sorting_settings_builder.rb +48 -0
  49. data/app/models/kirgudu_base/security/autheintication.rb +4 -0
  50. data/app/models/kirgudu_base/security/authentication.rb +6 -7
  51. data/app/models/kirgudu_base/security/email_confirmation.rb +7 -0
  52. data/app/models/kirgudu_base/security/restore_password_code.rb +5 -0
  53. data/app/models/kirgudu_base/security/user.rb +2 -0
  54. data/app/models/kirgudu_base/security.rb +6 -7
  55. data/app/models/kirgudu_base/settings/group.rb +22 -0
  56. data/app/models/kirgudu_base/settings/option.rb +44 -0
  57. data/app/models/kirgudu_base/settings/settings_manager.rb +69 -0
  58. data/app/models/kirgudu_base/settings/value.rb +36 -0
  59. data/app/views/admin_templates/default/admin/layouts/application.html.erb +6 -4
  60. data/app/views/admin_templates/default/admin/system/settings/groups/edit.html.erb +9 -9
  61. data/app/views/admin_templates/default/admin/system/settings/groups/new.html.erb +1 -1
  62. data/app/views/admin_templates/default/admin/system/settings/options/edit.html.erb +1 -1
  63. data/app/views/admin_templates/default/admin/system/settings/options/new.html.erb +1 -1
  64. data/app/views/admin_templates/default/admin/system/settings/values/edit.html.erb +1 -1
  65. data/app/views/admin_templates/default/admin/system/settings/values/new.html.erb +1 -1
  66. data/app/views/admin_templates/erp/admin/shared/_top_nav_bar.html.erb +1 -3
  67. data/app/views/admin_templates/erp/admin/shared/entry_edit_form_renderer.html.erb +1 -1
  68. data/app/views/admin_templates/erp/admin/shared/entry_new_form_renderer.html.erb +1 -1
  69. data/app/views/admin_templates/good/admin/layouts/OLD_application.html.erb +14 -14
  70. data/app/views/admin_templates/good/admin/layouts/application.html.erb +11 -113
  71. data/app/views/admin_templates/good/admin/shared/_left_menu.html.erb +74 -63
  72. data/app/views/admin_templates/good/{zapanel/files/New Adobe Photoshop Image 12.psd → admin/shared/_left_menu_item.html.erb} +0 -0
  73. data/app/views/admin_templates/good/admin/shared/_left_menu_section.html.erb +21 -0
  74. data/app/views/admin_templates/good/admin/shared/render_new_OLD.html.erb +90 -0
  75. data/app/views/admin_templates/good/admin/shared/renderer_edit.html.erb +44 -13
  76. data/app/views/admin_templates/good/admin/shared/renderer_edit_OLD.html.erb +106 -0
  77. data/app/views/admin_templates/good/admin/shared/renderer_entries_list.html.erb +39 -18
  78. data/app/views/admin_templates/good/admin/shared/renderer_entries_list_with_parent.html.erb +4 -4
  79. data/app/views/admin_templates/good/admin/shared/renderer_management.html.erb +164 -0
  80. data/app/views/admin_templates/good/admin/shared/renderer_new.html.erb +40 -10
  81. data/app/views/admin_templates/good/admin/shared/renderer_show.html.erb +170 -58
  82. data/app/views/admin_templates/good/admin/shared/renderer_show_OLD.html.erb +159 -0
  83. data/app/views/admin_templates/good/admin/shared/renderer_sorting.html.erb +30 -0
  84. data/app/views/admin_templates/good/kirgudu_base/authentications/login.html.erb +13 -13
  85. data/app/views/admin_templates/good/kirgudu_base/authentications/register.html.erb +1 -1
  86. data/app/views/admin_templates/good/kirgudu_base/old/login_page.html.erb +7 -7
  87. data/app/views/admin_templates/good_flexy/admin/layouts/application.html.erb +17 -16
  88. data/app/views/admin_templates/good_flexy/admin/shared/_left_menu.html.erb +7 -0
  89. data/app/views/admin_templates/good_flexy/admin/shared/renderer_entries_list.html.erb +25 -17
  90. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_edit.html.erb +34 -13
  91. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_new.html.erb +31 -10
  92. data/app/views/admin_templates/good_flexy/admin/shared/renderer_show.html.erb +67 -52
  93. data/config/locales/kirgudu_base.ru.yml +92 -0
  94. data/config/routes.rb +16 -16
  95. data/db/migrate/20140413134252_create_kirgudu_base_security_authentications.rb +15 -0
  96. data/db/migrate/20140413152144_create_kirgudu_base_security_email_confirmations.rb +17 -0
  97. data/db/migrate/20140413201121_add_confirmations_kirgudu_base_security_users.rb +14 -0
  98. data/db/migrate/20140415093106_create_kirgudu_base_security_restore_password_codes.rb +20 -0
  99. data/lib/kirgudu_base.rb +2 -2
  100. data/test/fixtures/kirgudu_base/kirgudu_base/security/autheintications.yml +11 -0
  101. data/test/fixtures/kirgudu_base/security/applications.yml +21 -0
  102. data/test/fixtures/kirgudu_base/security/autheintications.yml +11 -0
  103. data/test/fixtures/kirgudu_base/security/authentications.yml +11 -0
  104. data/test/fixtures/kirgudu_base/security/email_confirmations.yml +13 -0
  105. data/test/fixtures/kirgudu_base/security/restore_password_codes.yml +13 -0
  106. data/test/models/kirgudu_base/kirgudu_base/security/autheintication_test.rb +9 -0
  107. data/test/models/kirgudu_base/security/application_test.rb +9 -0
  108. data/test/models/kirgudu_base/security/autheintication_test.rb +9 -0
  109. data/test/models/kirgudu_base/security/authentication_test.rb +9 -0
  110. data/test/models/kirgudu_base/security/email_confirmation_test.rb +9 -0
  111. data/test/models/kirgudu_base/security/restore_password_code_test.rb +9 -0
  112. metadata +102 -79
  113. data/app/assets/javascripts/kirgudu_base/jquery.fancybox.pack.js +0 -45
  114. data/app/controllers/kirgudu_base/authentications_controller.rb +0 -157
  115. data/app/views/admin_templates/good/zapanel/404.html +0 -386
  116. data/app/views/admin_templates/good/zapanel/billing.html +0 -550
  117. data/app/views/admin_templates/good/zapanel/blank-page.html +0 -343
  118. data/app/views/admin_templates/good/zapanel/buttons.html +0 -1018
  119. data/app/views/admin_templates/good/zapanel/calendars.html +0 -451
  120. data/app/views/admin_templates/good/zapanel/cart.html +0 -522
  121. data/app/views/admin_templates/good/zapanel/charts.html +0 -611
  122. data/app/views/admin_templates/good/zapanel/collapse.html +0 -555
  123. data/app/views/admin_templates/good/zapanel/contact.php +0 -102
  124. data/app/views/admin_templates/good/zapanel/dashboard.html +0 -985
  125. data/app/views/admin_templates/good/zapanel/dashboard2.html +0 -1091
  126. data/app/views/admin_templates/good/zapanel/dashboard3.html +0 -1079
  127. data/app/views/admin_templates/good/zapanel/data/movies.json +0 -1
  128. data/app/views/admin_templates/good/zapanel/faq.html +0 -435
  129. data/app/views/admin_templates/good/zapanel/file-manager.html +0 -358
  130. data/app/views/admin_templates/good/zapanel/files/index.php +0 -0
  131. data/app/views/admin_templates/good/zapanel/font-awesome/less/bootstrap.less +0 -84
  132. data/app/views/admin_templates/good/zapanel/font-awesome/less/core.less +0 -129
  133. data/app/views/admin_templates/good/zapanel/font-awesome/less/extras.less +0 -93
  134. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome-ie7.less +0 -1953
  135. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome.less +0 -33
  136. data/app/views/admin_templates/good/zapanel/font-awesome/less/icons.less +0 -381
  137. data/app/views/admin_templates/good/zapanel/font-awesome/less/mixins.less +0 -48
  138. data/app/views/admin_templates/good/zapanel/font-awesome/less/path.less +0 -14
  139. data/app/views/admin_templates/good/zapanel/font-awesome/less/variables.less +0 -735
  140. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_bootstrap.scss +0 -84
  141. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_core.scss +0 -129
  142. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_extras.scss +0 -93
  143. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_icons.scss +0 -381
  144. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_mixins.scss +0 -48
  145. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_path.scss +0 -14
  146. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_variables.scss +0 -734
  147. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome-ie7.scss +0 -1953
  148. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome.scss +0 -33
  149. data/app/views/admin_templates/good/zapanel/form.html +0 -790
  150. data/app/views/admin_templates/good/zapanel/gallery.html +0 -392
  151. data/app/views/admin_templates/good/zapanel/grids.html +0 -574
  152. data/app/views/admin_templates/good/zapanel/hosting-dashboard.html +0 -448
  153. data/app/views/admin_templates/good/zapanel/icon.html +0 -722
  154. data/app/views/admin_templates/good/zapanel/inbox.html +0 -375
  155. data/app/views/admin_templates/good/zapanel/index.html +0 -48
  156. data/app/views/admin_templates/good/zapanel/invoice.html +0 -423
  157. data/app/views/admin_templates/good/zapanel/js/proxy/elFinderSupportVer1.js +0 -338
  158. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-close.png +0 -0
  159. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-next.png +0 -0
  160. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-prev.png +0 -0
  161. data/app/views/admin_templates/good/zapanel/notification.html +0 -400
  162. data/app/views/admin_templates/good/zapanel/order-recieved.html +0 -348
  163. data/app/views/admin_templates/good/zapanel/php/MySQLStorage.sql +0 -23
  164. data/app/views/admin_templates/good/zapanel/php/connector.php +0 -44
  165. data/app/views/admin_templates/good/zapanel/php/elFinder.class.php +0 -1103
  166. data/app/views/admin_templates/good/zapanel/php/elFinderConnector.class.php +0 -133
  167. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeDriver.class.php +0 -3370
  168. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeLocalFileSystem.class.php +0 -835
  169. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeMySQL.class.php +0 -896
  170. data/app/views/admin_templates/good/zapanel/php/mime.types +0 -512
  171. data/app/views/admin_templates/good/zapanel/price-table.html +0 -400
  172. data/app/views/admin_templates/good/zapanel/profile.html +0 -387
  173. data/app/views/admin_templates/good/zapanel/progressbar.html +0 -555
  174. data/app/views/admin_templates/good/zapanel/range-slider.html +0 -440
  175. data/app/views/admin_templates/good/zapanel/ribbon-grids.html +0 -491
  176. data/app/views/admin_templates/good/zapanel/sale-purchase-dashboard.html +0 -803
  177. data/app/views/admin_templates/good/zapanel/search.html +0 -370
  178. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-close.png +0 -0
  179. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-loading.gif +0 -0
  180. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-next.png +0 -0
  181. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-pause.png +0 -0
  182. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-play.png +0 -0
  183. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-playvideo.png +0 -0
  184. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-prev.png +0 -0
  185. data/app/views/admin_templates/good/zapanel/slider.html +0 -453
  186. data/app/views/admin_templates/good/zapanel/tables.html +0 -470
  187. data/app/views/admin_templates/good/zapanel/typography.html +0 -746
@@ -1,14 +1,14 @@
1
- function AssignDatePicker(field_id){
1
+ function AssignDatePicker(field_id) {
2
2
  $('#' + field_id).datepicker({
3
- dateFormat:'dd-mm-yy',
3
+ dateFormat: 'dd-mm-yy',
4
4
  date: $('#' + field_id).val(),
5
5
  current: $('#' + field_id).val(),
6
6
  starts: 1,
7
7
  position: 'r',
8
- onBeforeShow: function(){
8
+ onBeforeShow: function () {
9
9
  $('#' + field_id).DatePickerSetDate($('#' + field_id).val(), true);
10
10
  },
11
- onChange: function(formated, dates){
11
+ onChange: function (formated, dates) {
12
12
  $('#' + field_id).val();
13
13
  //$('#' + field_id).DatePickerHide();
14
14
 
@@ -17,19 +17,19 @@ function AssignDatePicker(field_id){
17
17
  }
18
18
 
19
19
 
20
- function AssignDateTimePicker(field_id){
20
+ function AssignDateTimePicker(field_id) {
21
21
  $('#' + field_id).datetimepicker({
22
- dateFormat:'dd-mm-yy',
23
- timeFormat:'hh:mm',
22
+ dateFormat: 'dd-mm-yy',
23
+ timeFormat: 'hh:mm',
24
24
  stepMinute: 10,
25
25
  date: $('#' + field_id).val(),
26
26
  current: $('#' + field_id).val(),
27
27
  starts: 1,
28
28
  position: 'r',
29
- onBeforeShow: function(){
29
+ onBeforeShow: function () {
30
30
  $('#' + field_id).DatePickerSetDate($('#' + field_id).val(), true);
31
31
  },
32
- onChange: function(formated, dates){
32
+ onChange: function (formated, dates) {
33
33
  $('#' + field_id).val(formated);
34
34
  //$('#' + field_id).DatePickerHide();
35
35
 
@@ -38,23 +38,22 @@ function AssignDateTimePicker(field_id){
38
38
  }
39
39
 
40
40
 
41
- function AssignAutocompleteWithId(textFieldId, hiddenFieldId, path){
41
+ function AssignAutocompleteWithId(textFieldId, hiddenFieldId, path) {
42
42
 
43
43
  $('#' + textFieldId).autocomplete({
44
44
  delay: 0,
45
- source: function( request, response ) {
45
+ source: function (request, response) {
46
46
  $.ajax({
47
47
  url: path,
48
48
  dataType: "json",
49
49
  data: {
50
50
  search: request.term
51
51
  },
52
- beforeSend: function(xhr)
53
- {
52
+ beforeSend: function (xhr) {
54
53
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
55
54
  },
56
- success: function( data ) {
57
- response( $.map( data, function( item ) {
55
+ success: function (data) {
56
+ response($.map(data, function (item) {
58
57
  return {
59
58
  label: item.name,
60
59
  value: item.id
@@ -63,13 +62,12 @@ function AssignAutocompleteWithId(textFieldId, hiddenFieldId, path){
63
62
  }
64
63
  });
65
64
  },
66
- search: function(event, ui)
67
- {
65
+ search: function (event, ui) {
68
66
  $('#' + hiddenFieldId).val('');
69
67
 
70
68
  },
71
69
  //minLength: 2,
72
- select: function(event, ui){
70
+ select: function (event, ui) {
73
71
  $('#' + textFieldId).val(ui.item.label);
74
72
  $('#' + hiddenFieldId).val(ui.item.value);
75
73
  $('#' + textFieldId).hide();
@@ -283,18 +281,17 @@ function AssignAutocompleteWithId(textFieldId, hiddenFieldId, path){
283
281
 
284
282
 
285
283
  // Check/Uncheck All Checkboxes
286
- function checkAllItems(allCheckerCss, itemCss)
287
- {
284
+ function checkAllItems(allCheckerCss, itemCss) {
288
285
  //alert("Alert from CheckAllItems")
289
- var checked_status = $( allCheckerCss ).is( ':checked' );
286
+ var checked_status = $(allCheckerCss).is(':checked');
290
287
  //alert("All Items Checked: "+ checked_status)
291
288
  //alert("Item Class: "+ item_class)
292
- $( itemCss ).each( function() {
293
- if(checked_status){
289
+ $(itemCss).each(function () {
290
+ if (checked_status) {
294
291
  //alert('Each: Check');
295
- $( this ).attr('checked', 'checked');
292
+ $(this).attr('checked', 'checked');
296
293
  }
297
- else{
294
+ else {
298
295
  //alert('Each: Uncheck');
299
296
  $(this).removeAttr('checked')
300
297
  }
@@ -303,33 +300,27 @@ function checkAllItems(allCheckerCss, itemCss)
303
300
 
304
301
  // Validates if all checkboxes checked.
305
302
  // if do CheckAll checkbox, if not - unckeck
306
- function validateCheckedItems(allCheckerCss, itemCss)
307
- {
303
+ function validateCheckedItems(allCheckerCss, itemCss) {
308
304
  var checked_all = true
309
- $( itemCss ).each( function() {
310
- if($( this ).is(':checked') == false)
311
- {
305
+ $(itemCss).each(function () {
306
+ if ($(this).is(':checked') == false) {
312
307
  checked_all = false;
313
308
  }
314
309
  });
315
- if(checked_all)
316
- {
310
+ if (checked_all) {
317
311
  $(allCheckerCss).attr('checked', 'checked');
318
312
  }
319
- else
320
- {
313
+ else {
321
314
  $(allCheckerCss).removeAttr('checked')
322
315
  }
323
316
  }
324
317
 
325
318
 
326
-
327
- function CollectCheckedCheckboxes(css_class, id_attr_name)
328
- {
319
+ function CollectCheckedCheckboxes(css_class, id_attr_name) {
329
320
  //alert("Start Collecting Checkbpexs");
330
321
  var checked_items = new Array();
331
- $(css_class).each( function() {
332
- if($(this).is(':checked')){
322
+ $(css_class).each(function () {
323
+ if ($(this).is(':checked')) {
333
324
  checked_items.push($(this).attr(id_attr_name));
334
325
  }
335
326
  });
@@ -338,26 +329,24 @@ function CollectCheckedCheckboxes(css_class, id_attr_name)
338
329
  }
339
330
 
340
331
 
341
- function MassUpdateSelected(request, itemClass, path, message ){
332
+ function MassUpdateSelected(request, itemClass, path, message) {
342
333
  var checked_items = new Array();
343
334
  //alert("MassUpdate for Click")
344
335
  var do_ok = false;
345
336
  fancyConfirm(
346
337
  message,
347
- function(isOk){
348
- if(!isOk) return;
349
- $( itemClass ).each( function() {
350
- if( $ (this).is(':checked')){
338
+ function (isOk) {
339
+ if (!isOk) return;
340
+ $(itemClass).each(function () {
341
+ if ($(this).is(':checked')) {
351
342
  checked_items.push($(this).attr('value'));
352
343
  }
353
344
  });
354
- request = request == undefined || request == null ? new Object() : request;
355
- if(["html","json"].indexOf(request.dataType)< 0)
356
- {
345
+ request = request == undefined || request == null ? new Object() : request;
346
+ if (["html", "json"].indexOf(request.dataType) < 0) {
357
347
  request.dataType = "html";
358
348
  }
359
- if(["get","post","put","delete"].indexOf(request.method)<0)
360
- {
349
+ if (["get", "post", "put", "delete"].indexOf(request.method) < 0) {
361
350
  request.method = "post"
362
351
  }
363
352
  $.ajax({
@@ -369,34 +358,27 @@ function MassUpdateSelected(request, itemClass, path, message ){
369
358
  'value': request.value,
370
359
  'item_ids[]': checked_items
371
360
  },
372
- beforeSend: function(xhr)
373
- {
361
+ beforeSend: function (xhr) {
374
362
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
375
363
  },
376
- success: function( data )
377
- {
378
- try
379
- {
364
+ success: function (data) {
365
+ try {
380
366
  data = $.parseJSON(data);
381
367
  }
382
- catch(e){}
368
+ catch (e) {
369
+ }
383
370
 
384
- if(jQuery.type(data) == "string")
385
- {
371
+ if (jQuery.type(data) == "string") {
386
372
  $('#list_container').html(data);
387
373
  }
388
- else if (jQuery.type(data) == "object")
389
- {
390
- if(data.status == "authenticate")
391
- {
374
+ else if (jQuery.type(data) == "object") {
375
+ if (data.status == "authenticate") {
392
376
  $(location).attr('href', data.result_url);
393
377
  }
394
- else if(data.status == "access_denied")
395
- {
378
+ else if (data.status == "access_denied") {
396
379
  showFancyMessage(data.message);
397
380
  }
398
- else if(data.status == "ok")
399
- {
381
+ else if (data.status == "ok") {
400
382
  //alert("JSON: DATA HTML\r\n " + );
401
383
  $('#list_container').html($("<div/>").html(data.html).text());
402
384
  $('#action_result_message').html($("<div/>").html(data.message).text());
@@ -404,18 +386,15 @@ function MassUpdateSelected(request, itemClass, path, message ){
404
386
  $('.all_items_checker').removeAttr('checked')
405
387
 
406
388
  }
407
- else if(data.status == "error")
408
- {
389
+ else if (data.status == "error") {
409
390
  showFancyMessage(data.message);
410
391
  }
411
- else
412
- {
392
+ else {
413
393
  showFancyMessage("Unexpected Error!!!");
414
394
  }
415
395
  }
416
396
  },
417
- error: function( data )
418
- {
397
+ error: function (data) {
419
398
  showFancyMessage("Unexpected Error!!!");
420
399
  }
421
400
  });
@@ -425,27 +404,24 @@ function MassUpdateSelected(request, itemClass, path, message ){
425
404
  }
426
405
 
427
406
 
428
-
429
- function MassUpdateSelectedNoConfirm(request, itemClass, path ){
407
+ function MassUpdateSelectedNoConfirm(request, itemClass, path) {
430
408
  DoMassUpdateSelected(request, itemClass, path, true);
431
409
  return false;
432
410
  }
433
411
 
434
- function DoMassUpdateSelected(request, itemClass, path, doDownload){
412
+ function DoMassUpdateSelected(request, itemClass, path, doDownload) {
435
413
  var checked_items = new Array();
436
- if(!doDownload) return;
437
- $( itemClass ).each( function() {
438
- if( $ (this).is(':checked')){
414
+ if (!doDownload) return;
415
+ $(itemClass).each(function () {
416
+ if ($(this).is(':checked')) {
439
417
  checked_items.push($(this).attr('value'));
440
418
  }
441
419
  });
442
- request = request == undefined || request == null ? new Object() : request;
443
- if(["html","json"].indexOf(request.dataType)< 0)
444
- {
420
+ request = request == undefined || request == null ? new Object() : request;
421
+ if (["html", "json"].indexOf(request.dataType) < 0) {
445
422
  request.dataType = "html";
446
423
  }
447
- if(["get","post","put","delete"].indexOf(request.method)<0)
448
- {
424
+ if (["get", "post", "put", "delete"].indexOf(request.method) < 0) {
449
425
  request.method = "post"
450
426
  }
451
427
  $.ajax({
@@ -457,28 +433,21 @@ function DoMassUpdateSelected(request, itemClass, path, doDownload){
457
433
  'value': request.value,
458
434
  'item_ids[]': checked_items
459
435
  },
460
- beforeSend: function(xhr)
461
- {
436
+ beforeSend: function (xhr) {
462
437
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
463
438
  },
464
- success: function( data )
465
- {
466
- if(jQuery.type(data) == "string")
467
- {
439
+ success: function (data) {
440
+ if (jQuery.type(data) == "string") {
468
441
  $('#list_container').html(data);
469
442
  }
470
- else if (jQuery.type(data) == "object")
471
- {
472
- if(data.status == "authenticate")
473
- {
443
+ else if (jQuery.type(data) == "object") {
444
+ if (data.status == "authenticate") {
474
445
  $(location).attr('href', data.result_url);
475
446
  }
476
- else if(data.status == "access_denied")
477
- {
447
+ else if (data.status == "access_denied") {
478
448
  showFancyMessage(data.message);
479
449
  }
480
- else if(data.status == "ok")
481
- {
450
+ else if (data.status == "ok") {
482
451
  //alert("JSON: DATA HTML\r\n " + );
483
452
  // $('#list_container').html($("<div/>").html(decode_utf8(base64decode(data.html))).text());
484
453
  // $('#action_result_message').html($("<div/>").html(data.message).text());
@@ -491,30 +460,27 @@ function DoMassUpdateSelected(request, itemClass, path, doDownload){
491
460
  $('.all_items_checker').removeAttr('checked')
492
461
 
493
462
  }
494
- else if(data.status == "error")
495
- {
463
+ else if (data.status == "error") {
496
464
  showFancyMessage(decode_utf8(base64decode(data.message)));
497
465
  }
498
- else
499
- {
466
+ else {
500
467
  showFancyMessage("Unexpected Error!!!");
501
468
  }
502
469
  }
503
470
  },
504
- error: function( data )
505
- {
471
+ error: function (data) {
506
472
  showFancyMessage("Unexpected Error!!!");
507
473
  }
508
474
  });
509
475
  }
510
476
 
511
477
 
512
- function MassActions(newValue, path, itemClass, confirm_message){
478
+ function MassActions(newValue, path, itemClass, confirm_message) {
513
479
  var do_ok = false;
514
480
  fancyConfirm(
515
481
  confirm_message,
516
- function(isOk){
517
- if(!isOk) return;
482
+ function (isOk) {
483
+ if (!isOk) return;
518
484
  $.ajax({
519
485
  url: path,
520
486
  type: 'post',
@@ -524,18 +490,15 @@ function MassActions(newValue, path, itemClass, confirm_message){
524
490
  'value': newValue,
525
491
  'item_ids[]': CollectCheckedCheckboxes(itemClass, "value")
526
492
  },
527
- beforeSend: function(xhr)
528
- {
493
+ beforeSend: function (xhr) {
529
494
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
530
495
  },
531
496
 
532
- success: function( data )
533
- {
497
+ success: function (data) {
534
498
  //alert("Ajax Success");
535
499
  $('#content_container').html(data);
536
500
  },
537
- error: function( data )
538
- {
501
+ error: function (data) {
539
502
  //alert("Ajax Error\r\n" + $.toJSON(data));
540
503
  }
541
504
  });
@@ -545,32 +508,27 @@ function MassActions(newValue, path, itemClass, confirm_message){
545
508
  }
546
509
 
547
510
 
548
-
549
- function DownloadOrders(checkboxClass, checkBoxAttr, messageContainer){
511
+ function DownloadOrders(checkboxClass, checkBoxAttr, messageContainer) {
550
512
 
551
513
  pathes = CollectCheckedCheckboxes(checkboxClass, checkBoxAttr);
552
514
  $(messageContainer).html("");
553
- for(i = 0; i < pathes.length; i++){
515
+ for (i = 0; i < pathes.length; i++) {
554
516
  $.ajax({
555
517
  url: pathes[i],
556
518
  type: 'post',
557
519
  dataType: "json",
558
- data:
559
- {
520
+ data: {
560
521
  'current_url': window.location.href
561
522
  },
562
- beforeSend: function(xhr)
563
- {
523
+ beforeSend: function (xhr) {
564
524
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
565
525
  },
566
526
 
567
- success: function( data )
568
- {
527
+ success: function (data) {
569
528
  $(messageContainer).show();
570
- $(messageContainer).append('<p>'+ decode_utf8(base64decode(data.message)) +'</p>');
529
+ $(messageContainer).append('<p>' + decode_utf8(base64decode(data.message)) + '</p>');
571
530
  },
572
- error: function( data )
573
- {
531
+ error: function (data) {
574
532
  //alert("
575
533
  // Ajax Error\r\n" + $.toJSON(data));
576
534
  }
@@ -579,30 +537,25 @@ function DownloadOrders(checkboxClass, checkBoxAttr, messageContainer){
579
537
  return false;
580
538
  }
581
539
 
582
- function DownloadOrderFromOneSite(path, messageContainer)
583
- {
540
+ function DownloadOrderFromOneSite(path, messageContainer) {
584
541
  $(messageContainer).html("");
585
542
  $.ajax({
586
543
  url: path,
587
544
  type: 'post',
588
545
  dataType: "json",
589
- data:
590
- {
546
+ data: {
591
547
  'current_url': window.location.href
592
548
  },
593
- beforeSend: function(xhr)
594
- {
549
+ beforeSend: function (xhr) {
595
550
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
596
551
  },
597
552
 
598
- success: function( data )
599
- {
553
+ success: function (data) {
600
554
  $(messageContainer).show();
601
- $(messageContainer).append('<p>'+ decode_utf8(base64decode(data.message)) +'</p>');
555
+ $(messageContainer).append('<p>' + decode_utf8(base64decode(data.message)) + '</p>');
602
556
  $(messageContainer).slideDown(300).delay(2000).fadeOut(400);
603
557
  },
604
- error: function( data )
605
- {
558
+ error: function (data) {
606
559
  //alert("
607
560
  // Ajax Error\r\n" + $.toJSON(data));
608
561
  }
@@ -610,24 +563,24 @@ function DownloadOrderFromOneSite(path, messageContainer)
610
563
  return false;
611
564
  }
612
565
 
613
- function fancyConfirm(msg, callback) {
566
+ function fancyConfirm(msg, callback) {
614
567
  var ret;
615
568
  $.fancybox(
616
569
  {
617
- 'modal' : true,
618
- 'content' : "<div style='margin:1px;width:240px;'>"+msg+'<div style="text-align:right;margin-top:10px;"><input id="fancyconfirm_cancel" style="margin:3px;padding:0px;" type="button" value="Cancel"><input id="fancyConfirm_ok" style="margin:3px;padding:0px;" type="button" value="Ok"></div></div>',
619
- afterShow: function() {
620
- $("#fancyconfirm_cancel").click(function() {
570
+ 'modal': true,
571
+ 'content': "<div style='margin:1px;width:240px;'>" + msg + '<div style="text-align:right;margin-top:10px;"><input id="fancyconfirm_cancel" style="margin:3px;padding:0px;" type="button" value="Cancel"><input id="fancyConfirm_ok" style="margin:3px;padding:0px;" type="button" value="Ok"></div></div>',
572
+ afterShow: function () {
573
+ $("#fancyconfirm_cancel").click(function () {
621
574
  ret = false;
622
575
  $.fancybox.close();
623
576
  })
624
- $("#fancyConfirm_ok").click(function() {
577
+ $("#fancyConfirm_ok").click(function () {
625
578
  ret = true;
626
579
  $.fancybox.close();
627
580
  })
628
581
  },
629
- afterClose: function() {
630
- if (typeof callback == 'function'){
582
+ afterClose: function () {
583
+ if (typeof callback == 'function') {
631
584
  callback.call(this, ret);
632
585
  }
633
586
  }
@@ -636,14 +589,12 @@ function fancyConfirm(msg, callback) {
636
589
  }
637
590
 
638
591
 
639
-
640
- function PostSelectedItems(path, item_class)
641
- {
592
+ function PostSelectedItems(path, item_class) {
642
593
 
643
594
  //alert('Path: ' + path + '\r\nItem Class' + item_class)
644
595
  var checked_items = [];
645
- $( item_class ).each( function() {
646
- if( $ (this).is(':checked')){
596
+ $(item_class).each(function () {
597
+ if ($(this).is(':checked')) {
647
598
  checked_items.push(jQuery.parseJSON($(this).attr('id')));
648
599
  }
649
600
  });
@@ -651,16 +602,18 @@ function PostSelectedItems(path, item_class)
651
602
  }
652
603
 
653
604
 
654
- function PostFormWithConfirm(form, message){
655
- if( form == null || form === undefined ) return false;
605
+ function PostFormWithConfirm(form, message) {
606
+ if (form == null || form === undefined) return false;
656
607
 
657
- if( jQuery.type(form) === "string" ){ form = $(form) }
608
+ if (jQuery.type(form) === "string") {
609
+ form = $(form)
610
+ }
658
611
 
659
612
  fancyConfirm(
660
613
  message,
661
- function(isOk){
614
+ function (isOk) {
662
615
 
663
- if(!isOk) return;
616
+ if (!isOk) return;
664
617
  //alert("Form To Confirm: " + jQuery.type(form))
665
618
  form.submit();
666
619
  }
@@ -668,17 +621,10 @@ function PostFormWithConfirm(form, message){
668
621
  }
669
622
 
670
623
 
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
624
  // Функция декодирования строки из base64
679
625
  function base64decode(str) {
680
626
  // Символы для base64-преобразования
681
- var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg'+
627
+ var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg' +
682
628
  'hijklmnopqrstuvwxyz0123456789+/=';
683
629
  var b64decoded = '';
684
630
  var chr1, chr2, chr3;
@@ -686,7 +632,7 @@ function base64decode(str) {
686
632
 
687
633
  str = str.replace(/[^a-z0-9+/=]/gi, '');
688
634
 
689
- for (var i=0; i<str.length;) {
635
+ for (var i = 0; i < str.length;) {
690
636
  enc1 = b64chars.indexOf(str.charAt(i++));
691
637
  enc2 = b64chars.indexOf(str.charAt(i++));
692
638
  enc3 = b64chars.indexOf(str.charAt(i++));
@@ -711,13 +657,13 @@ function base64decode(str) {
711
657
  // Функция кодирования строки в base64
712
658
  function base64encode(str) {
713
659
  // Символы для base64-преобразования
714
- var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg'+
660
+ var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg' +
715
661
  'hijklmnopqrstuvwxyz0123456789+/=';
716
662
  var b64encoded = '';
717
663
  var chr1, chr2, chr3;
718
664
  var enc1, enc2, enc3, enc4;
719
665
 
720
- for (var i=0; i<str.length;) {
666
+ for (var i = 0; i < str.length;) {
721
667
  chr1 = str.charCodeAt(i++);
722
668
  chr2 = str.charCodeAt(i++);
723
669
  chr3 = str.charCodeAt(i++);
@@ -725,8 +671,8 @@ function base64encode(str) {
725
671
  enc1 = chr1 >> 2;
726
672
  enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
727
673
 
728
- enc3 = isNaN(chr2) ? 64:(((chr2 & 15) << 2) | (chr3 >> 6));
729
- enc4 = isNaN(chr3) ? 64:(chr3 & 63);
674
+ enc3 = isNaN(chr2) ? 64 : (((chr2 & 15) << 2) | (chr3 >> 6));
675
+ enc4 = isNaN(chr3) ? 64 : (chr3 & 63);
730
676
 
731
677
  b64encoded += b64chars.charAt(enc1) + b64chars.charAt(enc2) +
732
678
  b64chars.charAt(enc3) + b64chars.charAt(enc4);
@@ -734,22 +680,19 @@ function base64encode(str) {
734
680
  return b64encoded;
735
681
  }
736
682
 
737
- function encode_utf8( s )
738
- {
739
- return unescape( encodeURIComponent( s ) );
683
+ function encode_utf8(s) {
684
+ return unescape(encodeURIComponent(s));
740
685
  }
741
686
 
742
- function decode_utf8( s )
743
- {
744
- return decodeURIComponent( escape( s ) );
687
+ function decode_utf8(s) {
688
+ return decodeURIComponent(escape(s));
745
689
  }
746
690
 
747
691
 
748
-
749
- function InPlaceEdit(id, value){
692
+ function InPlaceEdit(id, value) {
750
693
 
751
694
 
752
- request = request == undefined || request == null ? new Object() : request;
695
+ request = request == undefined || request == null ? new Object() : request;
753
696
  $.ajax({
754
697
  url: path,
755
698
  type: 'post',
@@ -759,28 +702,21 @@ function InPlaceEdit(id, value){
759
702
  'value': value,
760
703
  'id': id
761
704
  },
762
- beforeSend: function(xhr)
763
- {
705
+ beforeSend: function (xhr) {
764
706
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
765
707
  },
766
- success: function( data )
767
- {
768
- if(jQuery.type(data) == "string")
769
- {
708
+ success: function (data) {
709
+ if (jQuery.type(data) == "string") {
770
710
  $('#list_container').html(data);
771
711
  }
772
- else if (jQuery.type(data) == "object")
773
- {
774
- if(data.status == "authenticate")
775
- {
712
+ else if (jQuery.type(data) == "object") {
713
+ if (data.status == "authenticate") {
776
714
  $(location).attr('href', data.result_url);
777
715
  }
778
- else if(data.status == "access_denied")
779
- {
716
+ else if (data.status == "access_denied") {
780
717
  showFancyMessage(data.message);
781
718
  }
782
- else if(data.status == "ok")
783
- {
719
+ else if (data.status == "ok") {
784
720
  //alert("JSON: DATA HTML\r\n " + );
785
721
  // $('#list_container').html($("<div/>").html(decode_utf8(base64decode(data.html))).text());
786
722
  // $('#action_result_message').html($("<div/>").html(data.message).text());
@@ -793,44 +729,35 @@ function InPlaceEdit(id, value){
793
729
  $('.all_items_checker').removeAttr('checked')
794
730
 
795
731
  }
796
- else if(data.status == "error")
797
- {
732
+ else if (data.status == "error") {
798
733
  showFancyMessage(decode_utf8(base64decode(data.message)));
799
734
  }
800
- else
801
- {
735
+ else {
802
736
  showFancyMessage("Unexpected Error!!!");
803
737
  }
804
738
  }
805
739
  },
806
- error: function( data )
807
- {
740
+ error: function (data) {
808
741
  showFancyMessage("Unexpected Error!!!");
809
742
  }
810
743
  });
811
744
  }
812
745
 
813
746
 
814
-
815
-
816
-
817
-
818
747
  //****************************************************/
819
748
  //********************** NEW *************************/
820
749
  //****************************************************/
821
750
 
822
751
 
823
752
  // Processes Mass Action for Records and Print Results to request.onSuccess
824
- function processMassAction(path, itemIds, request){
753
+ function processMassAction(path, itemIds, request) {
825
754
 
826
- request = request == undefined || request == null ? new Object() : request;
755
+ request = request == undefined || request == null ? new Object() : request;
827
756
 
828
- if(["html","json"].indexOf(request.dataType)< 0)
829
- {
757
+ if (["html", "json"].indexOf(request.dataType) < 0) {
830
758
  request.dataType = "html";
831
759
  }
832
- if(["get","post","put","delete"].indexOf(request.method)<0)
833
- {
760
+ if (["get", "post", "put", "delete"].indexOf(request.method) < 0) {
834
761
  request.method = "post"
835
762
  }
836
763
  $.ajax({
@@ -842,181 +769,165 @@ function processMassAction(path, itemIds, request){
842
769
  'value': request.value,
843
770
  'item_ids[]': itemIds
844
771
  },
845
- beforeSend: function(xhr)
846
- {
772
+ beforeSend: function (xhr) {
847
773
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
848
774
  },
849
- success: function( data )
850
- {
851
- if(jQuery.type(data) == "string")
852
- {
775
+ success: function (data) {
776
+ if (jQuery.type(data) == "string") {
853
777
  request.onSuccess(data);
854
778
  }
855
- else if (jQuery.type(data) == "object")
856
- {
857
- if(data.status == "authenticate")
858
- {
779
+ else if (jQuery.type(data) == "object") {
780
+ if (data.status == "authenticate") {
859
781
  $(location).attr('href', data.result_url);
860
782
  }
861
- else if(data.status == "access_denied")
862
- {
783
+ else if (data.status == "access_denied") {
863
784
  showFancyMessage(decode_utf8(base64decode(data.message)));
864
785
  }
865
- else if(data.status == "ok")
866
- {
786
+ else if (data.status == "ok") {
867
787
  request.onSuccess(data);
868
788
  }
869
- else if(data.status == "error")
870
- {
789
+ else if (data.status == "error") {
871
790
  showFancyMessage(decode_utf8(base64decode(data.message)));
872
791
  }
873
- else
874
- {
792
+ else {
875
793
  showFancyMessage("Unexpected Result Format!!!");
876
794
  }
877
795
  }
878
796
  },
879
- error: function( data )
880
- {
797
+ error: function (data) {
881
798
  showFancyMessage("Unexpected Error!!!");
882
799
  }
883
800
  });
884
801
  }
885
802
 
886
803
  // Gets selected value in select
887
- function getSelectedValueForSelect(select_id){
888
- if(select_id.indexOf('#') != 0) select_id = "#" + select_id;
889
- return $( select_id + " :selected").val();
804
+ function getSelectedValueForSelect(select_id) {
805
+ if (select_id.indexOf('#') != 0) select_id = "#" + select_id;
806
+ return $(select_id + " :selected").val();
890
807
  }
891
808
 
892
809
  // Navigates to URL
893
- function navigateToUrl(url){
894
- if(url != undefined && url != "")
895
- {
810
+ function navigateToUrl(url) {
811
+ if (url != undefined && url != "") {
896
812
  window.location.href = url;
897
813
  }
898
814
  }
899
815
  // Navigates to value Selected in SELECT control
900
- function navigateToSelectedInSelect(select_id)
901
- {
816
+ function navigateToSelectedInSelect(select_id) {
902
817
  navigateToUrl(getSelectedValueForSelect(select_id));
903
818
 
904
819
  }
905
820
 
906
821
 
907
- function collectCheckedItems(cssSelector, attrName){
822
+ function collectCheckedItems(cssSelector, attrName) {
908
823
  var checked_items = new Array();
909
- if(!doDownload) return;
910
- $( cssSelector ).each( function() {
911
- if( $ (this).is(':checked')){
824
+ if (!doDownload) return;
825
+ $(cssSelector).each(function () {
826
+ if ($(this).is(':checked')) {
912
827
  checked_items.push($(this).attr(attrName));
913
828
  }
914
829
  });
915
830
  }
916
831
 
917
832
 
918
- function showFancyMessage(message, args){
833
+ function showFancyMessage(message, args) {
919
834
 
920
835
  $.fancybox(
921
836
  message,
922
837
  {
923
- maxWidth : 600,
924
- maxHeight : 300,
925
- fitToView : false,
926
- width : '70%',
927
- height : '70%',
928
- autoSize : false,
929
- autoCenter : true,
930
- closeClick : false,
931
- openEffect : 'none',
932
- closeEffect : 'none'
838
+ maxWidth: 600,
839
+ maxHeight: 300,
840
+ fitToView: false,
841
+ width: '70%',
842
+ height: '70%',
843
+ autoSize: false,
844
+ autoCenter: true,
845
+ closeClick: false,
846
+ openEffect: 'none',
847
+ closeEffect: 'none'
933
848
  }
934
849
  );
935
850
  }
936
851
 
937
- function ShowFancyPage1(page_url){
852
+ function ShowFancyPage1(page_url) {
938
853
  //alert("page Url: " + page_url)
939
854
 
940
855
  $.ajax(page_url, {
941
- type : "POST",
856
+ type: "POST",
942
857
  dataType: "html",
943
- cache : false,
944
- beforeSend: function(xhr)
945
- {
858
+ cache: false,
859
+ beforeSend: function (xhr) {
946
860
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
947
861
  $.blockUI({ message: '<img src="/assets/ajax_loading.gif" />' });
948
862
  },
949
- success: function(data) {
863
+ success: function (data) {
950
864
  //alert("Ajax Success\r\n" + data);
951
865
  $.fancybox(data, {
952
- maxWidth : 600,
953
- maxHeight : 300,
954
- fitToView : false,
955
- width : '70%',
956
- height : '70%',
957
- autoSize : false,
958
- closeClick : false,
959
- openEffect : 'none',
960
- closeEffect : 'none',
961
- 'afterClose' : function() {
866
+ maxWidth: 600,
867
+ maxHeight: 300,
868
+ fitToView: false,
869
+ width: '70%',
870
+ height: '70%',
871
+ autoSize: false,
872
+ closeClick: false,
873
+ openEffect: 'none',
874
+ closeEffect: 'none',
875
+ 'afterClose': function () {
962
876
  parent.location.reload(true);
963
877
  }
964
878
  }); // fancybox
965
879
  }, // success
966
- error: function(data){
880
+ error: function (data) {
967
881
  showFancyMessage("Loading Error");
968
882
  },
969
- complete: function(){
883
+ complete: function () {
970
884
  $.unblockUI();
971
885
  }
972
886
  });// ajax
973
887
  }
974
888
 
975
889
 
976
-
977
- function showFancyPage(page_url, options){
890
+ function showFancyPage(page_url, options) {
978
891
 
979
892
  options = options == null ? {} : options;
980
893
 
981
- options.method = options.method != null && options.method != undefined && ["get","post","put","delete"].indexOf(options.method) > 0 ? options.method : 'get';
982
- options.dataType = options.dataType != null && options.dataType != undefined && ["html","json","xml","csv", "xls"].indexOf(options.dataType) > 0 ? options.dataType : 'html';
894
+ options.method = options.method != null && options.method != undefined && ["get", "post", "put", "delete"].indexOf(options.method) > 0 ? options.method : 'get';
895
+ options.dataType = options.dataType != null && options.dataType != undefined && ["html", "json", "xml", "csv", "xls"].indexOf(options.dataType) > 0 ? options.dataType : 'html';
983
896
  options.layout = options.layout != null && options.layout != undefined ? options.layout : true;
984
897
 
985
898
 
986
-
987
899
  $.ajax(page_url, {
988
- type : options.method,
900
+ type: options.method,
989
901
  dataType: options.dataType,
990
- cache : false,
902
+ cache: false,
991
903
  data: {layout: options.layout },
992
- beforeSend: function(xhr)
993
- {
904
+ beforeSend: function (xhr) {
994
905
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
995
906
  },
996
- success: function(data) {
907
+ success: function (data) {
997
908
  //alert("Ajax Success\r\n" + data);
998
909
  $.fancybox(data, {
999
- maxWidth : 800,
1000
- maxHeight : 600,
1001
- fitToView : false,
1002
- autoSize : false,
1003
- closeClick : false,
1004
- openEffect : 'none',
910
+ maxWidth: 800,
911
+ maxHeight: 600,
912
+ fitToView: false,
913
+ autoSize: false,
914
+ closeClick: false,
915
+ openEffect: 'none',
1005
916
  //type: 'iframe',
1006
- closeEffect : 'none',
1007
- afterClose : function() {
917
+ closeEffect: 'none',
918
+ afterClose: function () {
1008
919
  //parent.location.reload(true);
1009
920
  }
1010
921
  }); // fancybox
1011
922
  }, // success
1012
- error: function(data){
923
+ error: function (data) {
1013
924
  showFancyMessage("Loading Error");
1014
925
  }
1015
926
  });// ajax
1016
927
  }
1017
928
 
1018
929
 
1019
- function makeAjaxCall(url, options){
930
+ function makeAjaxCall(url, options) {
1020
931
  options = options == null ? {} : options;
1021
932
 
1022
933
  options.method = normalizeHttpMethod(options.method);
@@ -1027,20 +938,17 @@ function makeAjaxCall(url, options){
1027
938
  options.data = options.data == null || options.data == undefined ? {} : options.data;
1028
939
 
1029
940
  $.ajax(url, {
1030
- type : options.method,
941
+ type: options.method,
1031
942
  dataType: options.dataType,
1032
- cache : false,
943
+ cache: false,
1033
944
  data: options.data,
1034
- beforeSend: function(xhr)
1035
- {
945
+ beforeSend: function (xhr) {
1036
946
  xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
1037
947
  },
1038
- success: function(data, status, xhr) {
1039
- if(xhr.status == 204)
1040
- {
948
+ success: function (data, status, xhr) {
949
+ if (xhr.status == 204) {
1041
950
  var redirectUrl = $.cookie("RedirectURL");
1042
- if( redirectUrl != undefined && redirectUrl != null)
1043
- {
951
+ if (redirectUrl != undefined && redirectUrl != null) {
1044
952
  makeAjaxCall(redirectUrl,
1045
953
  {
1046
954
  method: 'get',
@@ -1048,28 +956,28 @@ function makeAjaxCall(url, options){
1048
956
  success: options.success,
1049
957
  error: options.error,
1050
958
  complete: options.complete
1051
- } );
959
+ });
1052
960
  return;
1053
961
  }
1054
962
  }
1055
963
 
1056
- if(jQuery.isFunction(options.success)){
964
+ if (jQuery.isFunction(options.success)) {
1057
965
  options.success(data);
1058
966
  }
1059
967
  }, // success
1060
- error: function(data){
968
+ error: function (data) {
1061
969
 
1062
970
  //alert("makeAjaxCall - Error\r\nStatus: " + data.status + "\r\nStatus Text: " + data.statusText + "\r\nResponse Text: " + data.responseText);
1063
- if(jQuery.isFunction(options.error)){
971
+ if (jQuery.isFunction(options.error)) {
1064
972
  options.error(data);
1065
973
  }
1066
974
  },
1067
- complete: function(data, status){
975
+ complete: function (data, status) {
1068
976
  //alert("makeAjaxCall - Complete: " + $.toJSON(xmlHttpRequest));
1069
977
 
1070
978
  //alert("makeAjaxCall - Error\r\nStatus: " + data.status + "\r\nStatus Text: " + data.statusText + "\r\nResponse Text: " + data.responseText);
1071
979
 
1072
- if(jQuery.isFunction(options.complete)){
980
+ if (jQuery.isFunction(options.complete)) {
1073
981
  options.complete(data, status);
1074
982
  }
1075
983
  }
@@ -1078,11 +986,11 @@ function makeAjaxCall(url, options){
1078
986
  }
1079
987
 
1080
988
 
1081
- function serializeToJson(form){
989
+ function serializeToJson(form) {
1082
990
 
1083
991
  var formAsJson = {};
1084
992
  var form_array = form.serializeArray();
1085
- $.each(form_array, function() {
993
+ $.each(form_array, function () {
1086
994
  if (formAsJson[this.name]) {
1087
995
  if (!formAsJson[this.name].push) {
1088
996
  formAsJson[this.name] = [formAsJson[this.name]];
@@ -1095,107 +1003,97 @@ function serializeToJson(form){
1095
1003
  return formAsJson;
1096
1004
  }
1097
1005
 
1098
- function normalizeHttpMethod(method)
1099
- {
1100
- if(method == undefined || method == null){
1006
+ function normalizeHttpMethod(method) {
1007
+ if (method == undefined || method == null) {
1101
1008
  return "get";
1102
1009
  }
1103
- if(["get","post","put","delete"].indexOf(method) > 0)
1104
- {
1010
+ if (["get", "post", "put", "delete"].indexOf(method) > 0) {
1105
1011
  return method;
1106
1012
  }
1107
- else{
1108
- return "get";
1013
+ else {
1014
+ return "get";
1109
1015
  }
1110
1016
  }
1111
1017
 
1112
- function normalizeDataType(dataType)
1113
- {
1114
- if( dataType == undefined || dataType == null )
1115
- {
1018
+ function normalizeDataType(dataType) {
1019
+ if (dataType == undefined || dataType == null) {
1116
1020
  return 'html';
1117
1021
  }
1118
- if(["html","json","xml","csv", "xls", "ajaxhtml"].indexOf(dataType) > 0)
1119
- {
1022
+ if (["html", "json", "xml", "csv", "xls", "ajaxhtml"].indexOf(dataType) > 0) {
1120
1023
  return dataType;
1121
1024
  }
1122
- else
1123
- {
1025
+ else {
1124
1026
  return 'html';
1125
1027
  }
1126
1028
  }
1127
1029
 
1128
1030
 
1129
- (function( $ ) {
1130
- $.fn.simpleImagePicker = function(options) {
1031
+ (function ($) {
1032
+ $.fn.simpleImagePicker = function (options) {
1131
1033
 
1132
1034
  var settings = sanitize_options(options);
1133
1035
 
1134
1036
  //alert("Image Picker Processing");
1135
1037
 
1136
1038
  this.filter("input").each(
1137
- function(){
1039
+ function () {
1138
1040
  //alert("Image Picker Attached");
1139
1041
  var input = $(this);
1140
1042
  var value = input.attr('value');
1141
1043
  var select_label = settings.label;
1142
- if (select_label == null)
1143
- {
1044
+ if (select_label == null) {
1144
1045
  select_label = "Select Image";
1145
1046
  }
1146
- if (settings.label != null)
1147
- {
1047
+ if (settings.label != null) {
1148
1048
  select_label = input.attr('select-label');
1149
1049
  }
1150
1050
  //alert(select_label);
1151
1051
  var content_tag = null;
1152
1052
  var image_tag = $('<img>');
1153
- if(value != null && value != ""){
1053
+ if (value != null && value != "") {
1154
1054
 
1155
1055
  var thumb_url = input.attr('thumb-url');
1156
- if(thumb_url != null)
1157
- {
1056
+ if (thumb_url != null) {
1158
1057
  image_tag.attr('src', thumb_url + "?id=" + value);
1159
1058
  }
1160
1059
  }
1161
1060
 
1162
1061
  content_tag = $('<a>').append(select_label);
1163
- content_tag.click(function(){
1062
+ content_tag.click(function () {
1164
1063
  showDialog(input);
1165
1064
  });
1166
- if(content_tag!=null)
1167
- {
1065
+ if (content_tag != null) {
1168
1066
  input.after(content_tag);
1169
1067
  }
1170
1068
 
1171
1069
  input.after('<br/>');
1172
1070
  input.after(image_tag);
1173
1071
  input.hide();
1174
-
1072
+
1175
1073
  });
1176
1074
 
1177
- function showDialog(input){
1075
+ function showDialog(input) {
1178
1076
 
1179
1077
  var url = input.attr('data-url');
1180
1078
 
1181
- var dialog_escaped = "&lt;div class=&quot;image-select-dialog&quot; id=&quot;image_selector&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot; aria-hidden=&quot;true&quot; &gt;"+
1182
- "&lt;div class=&quot;modal-header&quot;&gt;"+
1183
- "&lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-hidden=&quot;true&quot;&gt;&#215;&lt;/button&gt;"+
1184
- "&lt;h3 id=&quot;myModalLabel&quot;&gt;Image Selector&lt;/h3&gt;"+
1185
- "&lt;/div&gt;"+
1186
- "&lt;div class=&quot;modal-body&quot;&gt;"+
1187
- "&lt;ul class=&quot;thumbnails row-fluid&quot; id=&quot;image_selector_image_list&quot;&gt;"+
1188
- "&lt;/ul&gt;"+
1189
- "&lt;/div&gt;"+
1190
- "&lt;div class=&quot;modal-footer&quot;&gt;"+
1191
- "&lt;div class=&quot;pagination pull-right&quot;&gt;"+
1192
- "&lt;ul&gt;"+
1193
- "&lt;li&gt;&lt;a id=&quot;image_selector_previous_page&quot; class=&#39;previous-page&#39;&gt;Prev&lt;/a&gt;&lt;/li&gt;"+
1194
- "&lt;li&gt;&lt;a id=&quot;image_selector_next_page&quot; class=&#39;next-page&#39;&gt;Next&lt;/a&gt;&lt;/li&gt;"+
1195
- "&lt;/ul&gt;"+
1196
- "&lt;/div&gt;"+
1197
- "&lt;/div&gt;"+
1198
- "&lt;/div&gt;";
1079
+ var dialog_escaped = "&lt;div class=&quot;image-select-dialog&quot; id=&quot;image_selector&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot; aria-hidden=&quot;true&quot; &gt;" +
1080
+ "&lt;div class=&quot;modal-header&quot;&gt;" +
1081
+ "&lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-hidden=&quot;true&quot;&gt;&#215;&lt;/button&gt;" +
1082
+ "&lt;h3 id=&quot;myModalLabel&quot;&gt;Image Selector&lt;/h3&gt;" +
1083
+ "&lt;/div&gt;" +
1084
+ "&lt;div class=&quot;modal-body&quot;&gt;" +
1085
+ "&lt;ul class=&quot;thumbnails row-fluid&quot; id=&quot;image_selector_image_list&quot;&gt;" +
1086
+ "&lt;/ul&gt;" +
1087
+ "&lt;/div&gt;" +
1088
+ "&lt;div class=&quot;modal-footer&quot;&gt;" +
1089
+ "&lt;div class=&quot;pagination pull-right&quot;&gt;" +
1090
+ "&lt;ul&gt;" +
1091
+ "&lt;li&gt;&lt;a id=&quot;image_selector_previous_page&quot; class=&#39;previous-page&#39;&gt;Prev&lt;/a&gt;&lt;/li&gt;" +
1092
+ "&lt;li&gt;&lt;a id=&quot;image_selector_next_page&quot; class=&#39;next-page&#39;&gt;Next&lt;/a&gt;&lt;/li&gt;" +
1093
+ "&lt;/ul&gt;" +
1094
+ "&lt;/div&gt;" +
1095
+ "&lt;/div&gt;" +
1096
+ "&lt;/div&gt;";
1199
1097
 
1200
1098
  var dialog_html = $("<div/>").html(dialog_escaped).text();
1201
1099
 
@@ -1206,24 +1104,22 @@ function normalizeDataType(dataType)
1206
1104
  $.modal(dialog_html, {
1207
1105
  minHeight: 500,
1208
1106
  minWidth: 700,
1209
- containerCss:{
1210
- backgroundColor:"#fff",
1211
- borderColor:"#000",
1212
- padding:0
1107
+ containerCss: {
1108
+ backgroundColor: "#fff",
1109
+ borderColor: "#000",
1110
+ padding: 0
1213
1111
  },
1214
- opacity:80,
1215
- overlayCss: {backgroundColor:"#bbb"},
1112
+ opacity: 80,
1113
+ overlayCss: {backgroundColor: "#bbb"},
1216
1114
  closeClass: 'close',
1217
1115
 
1218
- onClose : function(dialog) {
1219
- if(settings.onClose != null && jQuery.isFunction(settings.onClose))
1220
- {
1116
+ onClose: function (dialog) {
1117
+ if (settings.onClose != null && jQuery.isFunction(settings.onClose)) {
1221
1118
  settings.onClose(selectedImage); //here must be supplied info about selected Image
1222
1119
  }
1223
1120
  $.modal.close();
1224
1121
  },
1225
- onShow : function(dialog)
1226
- {
1122
+ onShow: function (dialog) {
1227
1123
  //console.log("DIALOG");
1228
1124
  //console.log(dialog);
1229
1125
  //alert(this.content);
@@ -1232,9 +1128,8 @@ function normalizeDataType(dataType)
1232
1128
  $("a#image_selector_previous_page", dialog.data).click(function () {
1233
1129
  //alert('Previous Page Click');
1234
1130
  page--;
1235
- if(page<=0)
1236
- {
1237
- page=1;
1131
+ if (page <= 0) {
1132
+ page = 1;
1238
1133
  }
1239
1134
  loadImages(url, page, $("div.image-select-dialog", dialog.data), input);
1240
1135
  return false;
@@ -1254,8 +1149,7 @@ function normalizeDataType(dataType)
1254
1149
 
1255
1150
 
1256
1151
  function sanitize_options(opts) {
1257
- if(opts == null || opts == undefined)
1258
- {
1152
+ if (opts == null || opts == undefined) {
1259
1153
  opts = {}
1260
1154
  }
1261
1155
  var default_options;
@@ -1272,13 +1166,13 @@ function normalizeDataType(dataType)
1272
1166
  function loadImages(url, page, imagesDailog, ui) {
1273
1167
  //alert('Load Images Url: ' + url);
1274
1168
  makeAjaxCall(url, {
1275
- method:'get',
1276
- dataType:'json',
1277
- data:{page: page },
1278
- success:function (data) {
1169
+ method: 'get',
1170
+ dataType: 'json',
1171
+ data: {page: page },
1172
+ success: function (data) {
1279
1173
  //console.log("Images Dialog");
1280
1174
  //console.log(imagesDailog);
1281
- if(imagesDailog){
1175
+ if (imagesDailog) {
1282
1176
 
1283
1177
  //console.log("Images Container");
1284
1178
  //console.log(imagesContainer);
@@ -1288,8 +1182,8 @@ function normalizeDataType(dataType)
1288
1182
 
1289
1183
 
1290
1184
  result +=
1291
- '<li>' +
1292
- ' <a class="thumbnail image-to-select" image-id="'+ item.id +'" image-thumb-url="' + item.url + '">' +
1185
+ '<li>' +
1186
+ ' <a class="thumbnail image-to-select" image-id="' + item.id + '" image-thumb-url="' + item.url + '">' +
1293
1187
  ' <img src="' + item.url + '" alt="" width="100px" height="100px"/>' +
1294
1188
  ' </a>' +
1295
1189
  '</li>'
@@ -1297,14 +1191,13 @@ function normalizeDataType(dataType)
1297
1191
  //alert(result);
1298
1192
  var imagesContainer = imagesDailog.find('ul#image_selector_image_list');
1299
1193
  imagesContainer.html(result);
1300
- $('a.image-to-select', imagesContainer).dblclick(function(){
1194
+ $('a.image-to-select', imagesContainer).dblclick(function () {
1301
1195
 
1302
1196
  var image_id = $(this).attr("image-id");
1303
1197
  var image_thumb_url = $(this).attr("image-thumb-url");
1304
1198
  //alert("Double Click on Image: Onselect: " + settings.onSelect);
1305
1199
  //alert("ImageID: "+ image_id + "\r\nImage Thumb Url: " + image_thumb_url);
1306
- if($.isFunction(settings.on_select))
1307
- {
1200
+ if ($.isFunction(settings.on_select)) {
1308
1201
  settings.on_select(ui, image_id, image_thumb_url);
1309
1202
  }
1310
1203
  $.modal.close();
@@ -1312,20 +1205,19 @@ function normalizeDataType(dataType)
1312
1205
  imagesContainer.show();
1313
1206
  }
1314
1207
  },
1315
- error:function () {
1208
+ error: function () {
1316
1209
  //showFancyMessage("Error of Loading Edit Page with Ajax");
1317
1210
  }
1318
1211
  });
1319
1212
  }
1320
1213
  };
1321
- })( jQuery );
1214
+ })(jQuery);
1322
1215
 
1323
1216
 
1324
- function postFeedbackForm(form)
1325
- {
1217
+ function postFeedbackForm(form) {
1326
1218
 
1327
1219
  if (form == null) return;
1328
- else if( jQuery.type(form) === "string") form = $(form)
1220
+ else if (jQuery.type(form) === "string") form = $(form)
1329
1221
 
1330
1222
  // if(jQuery.browser.msie && jQuery.browser.version == "9.0"){
1331
1223
  // var inputs = form.find('input');
@@ -1354,7 +1246,7 @@ function postFeedbackForm(form)
1354
1246
  url: form.attr('action'),
1355
1247
  dataType: "json",
1356
1248
  data: form.serialize(),
1357
- success: function( data ){
1249
+ success: function (data) {
1358
1250
  showFancyMessage(data);
1359
1251
  },
1360
1252
  error: function (request, status, error) {
@@ -1384,4 +1276,29 @@ function normalizeSelectorsToArray(selectors) {
1384
1276
  });
1385
1277
  }
1386
1278
  return result_selectors;
1279
+ }
1280
+
1281
+ function deleteRecordByUrl(url, redirect_url) {
1282
+ fancyConfirm("Are You Sure You want to delete this Record?",
1283
+ function (result) {
1284
+ if (result == true) {
1285
+ makeAjaxCall(url, {
1286
+ method: 'delete',
1287
+ dataType: 'json',
1288
+ success: function (data) {
1289
+ if (redirect_url != null) {
1290
+ var host = window.location.protocol + '//' + window.location.host;
1291
+ //alert("REDIRECT URL: " + host + redirect_url);
1292
+ window.location = host + redirect_url;
1293
+ }
1294
+ else {
1295
+ showFancyMessage("Record Deleted");
1296
+ }
1297
+ },
1298
+ error: function (response) {
1299
+ showFancyMessage("Failed to Delete Record");
1300
+ }
1301
+ });
1302
+ }
1303
+ });
1387
1304
  }