Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $tv = {
- edit : {
- init : function() {
- },// end initialise
- deleteNode : function(node,elem) {
- //alert();
- var req=new Ajax.Updater('status', '/DeleteNode', {
- evalScripts: true,
- method: 'post',
- parameters: {
- q:node
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- // $tv.modals.success({fade:true,string:"Element Removed!"});
- $(elem).up(1).remove();
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- } else {}// end refresh
- } else {}
- } // end onSuccess
- });
- req=null;
- // alert(this);
- // alert(node);
- // ajax request it
- }, // end delete node
- add : {
- education : function(event) {
- // alert(this);
- // alert(event); // we now have the shizniz
- var cvid=$('cvid').value;
- var req=new Ajax.Updater('status', '/AddEducation', {
- evalScripts: true,
- method: 'post',
- parameters:
- {
- cv_id:cvid
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- if(data.Refresh==1) {
- // Build a Message handler - can parse event now of even offsets
- $tv.modals.success({fade: true, string :"Education Added Successfully <br /> Please wait for a page refresh"});
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- //alert($(data.ELEMENT).id);
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- }
- }
- });
- req=null;
- }, // end education
- areas : function(event) {
- var cvid=$('cvid').value;
- var req=new Ajax.Updater('status', '/AddAreas', {
- evalScripts: true,
- method: 'post',
- parameters:
- {
- cv_id:cvid
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- if(data.Refresh==1) {
- // Build a Message handler - can parse event now of even offsets
- $tv.modals.success({fade: true, string :"New Area Added Successfully <br /> Please wait for a page refresh"});
- setTimeout(function() {
- //alert('refreshing');
- document.location.href=document.location.href; },1500);
- }
- //alert($(data.ELEMENT).id);
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- }
- }
- });
- req=null;
- }, // end Adding Areas
- sectors : function(event) {
- var cvid=$('cvid').value;
- var req=new Ajax.Updater('status', '/AddSectors', {
- evalScripts: true,
- method: 'post',
- parameters:
- {
- cv_id:cvid
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- if(data.Refresh==1) {
- // Build a Message handler - can parse event now of even offsets
- $tv.modals.success({fade: true, string :"New Sector Added Successfully <br /> Please wait for a page refresh"});
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- //alert($(data.ELEMENT).id);
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- }
- }
- });
- req=null;
- }, // end sectors
- /*
- language : function(event) {
- var cvid=$('cvid').value;
- var req=new Ajax.Updater('status', '/AddLanguage', {
- evalScripts: true,
- method: 'post',
- parameters:
- {
- cv_id:cvid
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- if(data.Refresh==1) {
- // Build a Message handler - can parse event now of even offsets
- $tv.modals.success({fade: true, string :"New Language Added Successfully <br /> Please wait for a page refresh"});
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- //alert($(data.ELEMENT).id);
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- }
- }
- });
- req=null;
- }, // end language
- */
- licence : function(event) {
- var cvid=$('cvid').value;
- var req=new Ajax.Updater('status', '/AddLicence', {
- evalScripts: true,
- method: 'post',
- parameters:
- {
- cv_id:cvid
- },
- onSuccess : function(d) {
- var data=d.responseText.evalJSON();
- alert(data);
- if(data.Error=="No") {
- if(data.Refresh==1) {
- // Build a Message handler - can parse event now of even offsets
- $tv.modals.success({fade: true, string :"New Licence Added Successfully <br /> Please wait for a page refresh"});
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- //alert($(data.ELEMENT).id);
- return;
- }
- if(data.Error=="Yes") {
- thetvars.showError(data.ErrorMessage);
- if(data.Refresh==1) {
- setTimeout(function() { document.location.href=document.location.href; },1500);
- }
- }
- }
- });
- req=null;
- } // end licenecce
- }// end add node
- },
- // end edit
- modals : {
- success : function(opts) {
- if(opts.show===false) {
- return;
- }
- // alert(event);
- // var elem=Event.element(event);
- // alert(elem);
- if(opts.fade===true) {
- $tv.modals.fade();
- }
- var text=opts.string;
- if(text=='') { return; }
- // we can add checks for scrollOffset
- // (opts.element.viewportOffset.top > 0) ? topOffset=opts.element.viewportOffset.top : topOffset=0;
- // alert(topOffset);
- if($('modalsuccess')) { $('modalsuccess').remove(); }
- if($('overlay')) {$('overlay').remove();}
- var dims=document.body.getDimensions();
- var minheight=70;
- var overlayheight=(dims.height+20);
- var overlaywidth=dims.width;
- var l = Math.floor( ( ( dims.width - 300 ) /2) );
- var t = Math.floor( ( ( dims.height - 300 ) /2 ) );
- var overlay=new Element('div',{'id':'overlay','class':'overlay','style':'height:'+overlayheight+'px;width:'+overlaywidth+'px;z-index:10'});
- $$('body')[0].insert(overlay);
- 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;'});
- $$('body')[0].insert(tipelement); // should be insterted into the overlay
- $('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>');
- Effect.ScrollTo('modalsuccess',{offset: -150}); // offsets half the height
- if($('overlay')) {
- setTimeout(function() { Effect.Shake('modalsuccess');}, 1000);
- }
- $('overlay').observe('click',function() {
- $('modalsuccess').remove();
- $('overlay').remove();
- });
- },// end success
- error : {
- // change showError
- }, // end error
- fade : function() {
- setTimeout(function(){ if($('overlay')) { Effect.Fade('overlay'); } },5000);
- setTimeout(function(){
- if($('overlay')) {
- $$('.tip').each(function(e) { $(e).remove();});$('overlay').remove();}},5100);
- }
- }
- }; // end $tv
Add Comment
Please, Sign In to add comment