Guest User

Untitled

a guest
Jun 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.80 KB | None | 0 0
  1. var $tv = {
  2.  
  3. edit : {
  4.  
  5. init : function() {
  6.  
  7. },// end initialise
  8.  
  9.  
  10.  
  11. deleteNode : function(node,elem) {
  12. //alert();
  13. var req=new Ajax.Updater('status', '/DeleteNode', {
  14. evalScripts: true,
  15. method: 'post',
  16. parameters: {
  17. q:node
  18. },
  19. onSuccess : function(d) {
  20. var data=d.responseText.evalJSON();
  21. alert(data);
  22. if(data.Error=="No") {
  23. // $tv.modals.success({fade:true,string:"Element Removed!"});
  24. $(elem).up(1).remove();
  25. return;
  26. }
  27. if(data.Error=="Yes") {
  28. thetvars.showError(data.ErrorMessage);
  29.  
  30.  
  31. if(data.Refresh==1) {
  32. setTimeout(function() { document.location.href=document.location.href; },1500);
  33. } else {}// end refresh
  34. } else {}
  35. } // end onSuccess
  36. });
  37. req=null;
  38.  
  39. // alert(this);
  40. // alert(node);
  41. // ajax request it
  42. }, // end delete node
  43. add : {
  44.  
  45. education : function(event) {
  46. // alert(this);
  47. // alert(event); // we now have the shizniz
  48.  
  49.  
  50. var cvid=$('cvid').value;
  51. var req=new Ajax.Updater('status', '/AddEducation', {
  52. evalScripts: true,
  53. method: 'post',
  54. parameters:
  55. {
  56. cv_id:cvid
  57. },
  58. onSuccess : function(d) {
  59. var data=d.responseText.evalJSON();
  60. alert(data);
  61. if(data.Error=="No") {
  62.  
  63. if(data.Refresh==1) {
  64. // Build a Message handler - can parse event now of even offsets
  65. $tv.modals.success({fade: true, string :"Education Added Successfully <br /> Please wait for a page refresh"});
  66. setTimeout(function() { document.location.href=document.location.href; },1500);
  67. }
  68. //alert($(data.ELEMENT).id);
  69. return;
  70. }
  71. if(data.Error=="Yes") {
  72. thetvars.showError(data.ErrorMessage);
  73. if(data.Refresh==1) {
  74. setTimeout(function() { document.location.href=document.location.href; },1500);
  75. }
  76. }
  77. }
  78. });
  79. req=null;
  80. }, // end education
  81. areas : function(event) {
  82. var cvid=$('cvid').value;
  83. var req=new Ajax.Updater('status', '/AddAreas', {
  84. evalScripts: true,
  85. method: 'post',
  86. parameters:
  87. {
  88. cv_id:cvid
  89. },
  90. onSuccess : function(d) {
  91. var data=d.responseText.evalJSON();
  92. alert(data);
  93. if(data.Error=="No") {
  94.  
  95. if(data.Refresh==1) {
  96. // Build a Message handler - can parse event now of even offsets
  97. $tv.modals.success({fade: true, string :"New Area Added Successfully <br /> Please wait for a page refresh"});
  98. setTimeout(function() {
  99. //alert('refreshing');
  100. document.location.href=document.location.href; },1500);
  101. }
  102. //alert($(data.ELEMENT).id);
  103. return;
  104. }
  105. if(data.Error=="Yes") {
  106. thetvars.showError(data.ErrorMessage);
  107. if(data.Refresh==1) {
  108. setTimeout(function() { document.location.href=document.location.href; },1500);
  109. }
  110. }
  111. }
  112. });
  113. req=null;
  114. }, // end Adding Areas
  115. sectors : function(event) {
  116. var cvid=$('cvid').value;
  117. var req=new Ajax.Updater('status', '/AddSectors', {
  118. evalScripts: true,
  119. method: 'post',
  120. parameters:
  121. {
  122. cv_id:cvid
  123. },
  124. onSuccess : function(d) {
  125. var data=d.responseText.evalJSON();
  126. alert(data);
  127. if(data.Error=="No") {
  128.  
  129. if(data.Refresh==1) {
  130. // Build a Message handler - can parse event now of even offsets
  131. $tv.modals.success({fade: true, string :"New Sector Added Successfully <br /> Please wait for a page refresh"});
  132. setTimeout(function() { document.location.href=document.location.href; },1500);
  133. }
  134. //alert($(data.ELEMENT).id);
  135. return;
  136. }
  137. if(data.Error=="Yes") {
  138. thetvars.showError(data.ErrorMessage);
  139. if(data.Refresh==1) {
  140. setTimeout(function() { document.location.href=document.location.href; },1500);
  141. }
  142. }
  143. }
  144. });
  145. req=null;
  146. }, // end sectors
  147. /*
  148. language : function(event) {
  149. var cvid=$('cvid').value;
  150. var req=new Ajax.Updater('status', '/AddLanguage', {
  151. evalScripts: true,
  152. method: 'post',
  153. parameters:
  154. {
  155. cv_id:cvid
  156. },
  157. onSuccess : function(d) {
  158. var data=d.responseText.evalJSON();
  159. alert(data);
  160. if(data.Error=="No") {
  161.  
  162. if(data.Refresh==1) {
  163. // Build a Message handler - can parse event now of even offsets
  164. $tv.modals.success({fade: true, string :"New Language Added Successfully <br /> Please wait for a page refresh"});
  165. setTimeout(function() { document.location.href=document.location.href; },1500);
  166. }
  167. //alert($(data.ELEMENT).id);
  168. return;
  169. }
  170. if(data.Error=="Yes") {
  171. thetvars.showError(data.ErrorMessage);
  172. if(data.Refresh==1) {
  173. setTimeout(function() { document.location.href=document.location.href; },1500);
  174. }
  175. }
  176. }
  177. });
  178. req=null;
  179. }, // end language
  180. */
  181. licence : function(event) {
  182. var cvid=$('cvid').value;
  183. var req=new Ajax.Updater('status', '/AddLicence', {
  184. evalScripts: true,
  185. method: 'post',
  186. parameters:
  187. {
  188. cv_id:cvid
  189. },
  190. onSuccess : function(d) {
  191. var data=d.responseText.evalJSON();
  192. alert(data);
  193. if(data.Error=="No") {
  194.  
  195. if(data.Refresh==1) {
  196. // Build a Message handler - can parse event now of even offsets
  197. $tv.modals.success({fade: true, string :"New Licence Added Successfully <br /> Please wait for a page refresh"});
  198. setTimeout(function() { document.location.href=document.location.href; },1500);
  199. }
  200. //alert($(data.ELEMENT).id);
  201. return;
  202. }
  203. if(data.Error=="Yes") {
  204. thetvars.showError(data.ErrorMessage);
  205. if(data.Refresh==1) {
  206. setTimeout(function() { document.location.href=document.location.href; },1500);
  207. }
  208. }
  209. }
  210. });
  211. req=null;
  212. } // end licenecce
  213.  
  214. }// end add node
  215. },
  216. // end edit
  217. modals : {
  218. success : function(opts) {
  219. if(opts.show===false) {
  220. return;
  221. }
  222. // alert(event);
  223. // var elem=Event.element(event);
  224. // alert(elem);
  225. if(opts.fade===true) {
  226. $tv.modals.fade();
  227. }
  228. var text=opts.string;
  229. if(text=='') { return; }
  230. // we can add checks for scrollOffset
  231. // (opts.element.viewportOffset.top > 0) ? topOffset=opts.element.viewportOffset.top : topOffset=0;
  232. // alert(topOffset);
  233. if($('modalsuccess')) { $('modalsuccess').remove(); }
  234. if($('overlay')) {$('overlay').remove();}
  235. var dims=document.body.getDimensions();
  236. var minheight=70;
  237. var overlayheight=(dims.height+20);
  238. var overlaywidth=dims.width;
  239. var l = Math.floor( ( ( dims.width - 300 ) /2) );
  240. var t = Math.floor( ( ( dims.height - 300 ) /2 ) );
  241. var overlay=new Element('div',{'id':'overlay','class':'overlay','style':'height:'+overlayheight+'px;width:'+overlaywidth+'px;z-index:10'});
  242. $$('body')[0].insert(overlay);
  243. var tipelement=new Element('div',{'id':'modalsuccess','class':'modalsuccess tip','style':'position:absolute;width:300px;min-height:'+minheight+'px;background:window;left:'+l+'px;top:'+t+'px;z-index:20;'});
  244. $$('body')[0].insert(tipelement); // should be insterted into the overlay
  245. $('modalsuccess').update('<div class="modalinner"><div style="text-align:center;color:green;font-weight:bold;font-size:15px;margin-bottom:4px;font-family:verdana;"><img src="/resources/includes/images/forms/tick24.png" /><br />Success!</div>'+text+'<br /><br /><br /><em style="font-size:10px;">(To close this message please click anywhere on the page)</em></div>');
  246. Effect.ScrollTo('modalsuccess',{offset: -150}); // offsets half the height
  247. if($('overlay')) {
  248. setTimeout(function() { Effect.Shake('modalsuccess');}, 1000);
  249. }
  250. $('overlay').observe('click',function() {
  251. $('modalsuccess').remove();
  252. $('overlay').remove();
  253. });
  254.  
  255.  
  256. },// end success
  257. error : {
  258. // change showError
  259.  
  260. }, // end error
  261. fade : function() {
  262. setTimeout(function(){ if($('overlay')) { Effect.Fade('overlay'); } },5000);
  263. setTimeout(function(){
  264. if($('overlay')) {
  265. $$('.tip').each(function(e) { $(e).remove();});$('overlay').remove();}},5100);
  266.  
  267. }
  268. }
  269. }; // end $tv
Add Comment
Please, Sign In to add comment