Revision 3b698137 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/okeanos-ember.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/okeanos-ember.js | ||
---|---|---|
439 | 439 |
/* Controllers for Wizards */ |
440 | 440 |
|
441 | 441 |
Synnefo.CreateController = Ember.ObjectController.extend({ |
442 |
currentStep: undefined,
|
|
442 |
currentStep: 1,
|
|
443 | 443 |
|
444 | 444 |
totalSteps: function() { |
445 | 445 |
return this.get('stepsContent').length; |
446 | 446 |
}.property(), |
447 | 447 |
|
448 |
init: function() { |
|
449 |
this._super(); |
|
450 |
this.set('currentStep', 1) |
|
451 |
}, |
|
452 | 448 |
btnLeftLabel: function(){ |
453 |
return (this.get('currentStep') === 1)?'CANCEL':'PREVIOUS'; |
|
449 |
return (this.get('currentStep') === 1)?'CANCEL':'PREVIOUS';
|
|
454 | 450 |
}.property('currentStep'), |
455 | 451 |
|
456 | 452 |
btnRightLabel: function(){ |
457 |
return (this.get('currentStep') === this.get('totalSteps'))?'CREATE':'NEXT'; |
|
453 |
return (this.get('currentStep') === this.get('totalSteps'))?'CREATE':'NEXT';
|
|
458 | 454 |
}.property('currentStep'), |
459 | 455 |
|
460 | 456 |
onMove: false, |
461 | 457 |
directionMove: undefined, |
462 |
|
|
458 |
init: function() { |
|
459 |
this._super(); |
|
460 |
this.set('currentStep', 1); |
|
461 |
this.set('onMove', false); |
|
462 |
this.set('directionMove', undefined); |
|
463 |
}, |
|
463 | 464 |
actions: { |
464 | 465 |
moveNext: function() { |
466 |
console.log('[CreateController moveNext]'); |
|
465 | 467 |
if(!this.get('onMove')) { |
466 |
var step = this.get('currentStep'); |
|
467 |
if(step=== this.get('totalSteps')) { |
|
468 |
this.init(); |
|
469 |
this.get('target').send('closeWizard'); |
|
468 |
if(this.get('currentStep') === this.get('totalSteps')) |
|
469 |
this.resetClose(); |
|
470 |
else { |
|
471 |
this.set('directionMove', 'next'); |
|
472 |
this.set('onMove', true); |
|
470 | 473 |
} |
471 |
this.set('directionMove', 'next'); |
|
472 |
this.set('onMove', !(this.get('onMove'))); |
|
473 | 474 |
} |
474 | 475 |
}, |
475 | 476 |
moveBack: function() { |
477 |
console.log('[CreateController moveBack]'); |
|
476 | 478 |
if(!this.get('onMove')) { |
477 |
var step = this.get('currentStep'); |
|
478 |
if(step === 1) { |
|
479 |
this.init(); |
|
480 |
this.get('target').send('closeWizard'); |
|
479 |
if(this.get('currentStep') === 1) |
|
480 |
this.resetClose(); |
|
481 |
else { |
|
482 |
this.set('directionMove', 'prev'); |
|
483 |
this.set('onMove', true); |
|
481 | 484 |
} |
482 |
this.set('directionMove', 'prev'); |
|
483 |
this.set('onMove', !(this.get('onMove'))); |
|
484 | 485 |
} |
485 | 486 |
}, |
487 |
}, |
|
488 |
resetClose: function() { |
|
489 |
console.log('[CreateController resetClose]'); |
|
490 |
this.get('target').send('closeWizard'); |
|
491 |
this.init(); |
|
486 | 492 |
} |
487 | 493 |
|
488 | 494 |
}); |
... | ... | |
496 | 502 |
|
497 | 503 |
Ember.View.reopen({ |
498 | 504 |
didInsertElement: function() { |
499 |
this.set('elIsInserted', true); |
|
500 | 505 |
this._super(); |
506 |
this.set('elIsInserted', true); |
|
501 | 507 |
}, |
502 | 508 |
|
503 | 509 |
willDestroyElement: function() { |
504 |
this.set('elIsInserted', false); |
|
505 | 510 |
this._super(); |
511 |
this.set('elIsInserted', false); |
|
506 | 512 |
} |
507 | 513 |
}); |
508 | 514 |
|
... | ... | |
693 | 699 |
viewCurrent.set('isCurrent', false); |
694 | 700 |
viewToDisplay.set('isCurrent', true); |
695 | 701 |
self.get('controller').set('currentStep',viewToDisplay.get('index')); |
702 |
this.get('controller').set('onMove', false); |
|
696 | 703 |
}, this) |
697 | 704 |
}); |
698 | 705 |
} |
699 |
this.get('controller').set('onMove', false); |
|
700 | 706 |
} |
701 | 707 |
} |
702 | 708 |
}.observes('controller.onMove'), |
... | ... | |
753 | 759 |
isCurrent: function(){ |
754 | 760 |
if(this.get('isFirst')) return true; |
755 | 761 |
}.property(), |
756 |
click: function() { |
|
762 |
move: function() { |
|
763 |
if(this.get('controller').get('onMove')) { |
|
757 | 764 |
this.get('parentView').removeOtherCurrent(this); |
758 |
this.set('isCurrent', true) |
|
759 |
} |
|
765 |
this.set('isCurrent', true); |
|
766 |
} |
|
767 |
}.observes('controller.onMove') |
|
760 | 768 |
}) |
761 | 769 |
}); |
762 | 770 |
|
Also available in: Unified diff