| 1 |
function SFTutorials() |
| 2 |
{ |
| 3 |
this.IsOpen=false; |
| 4 |
this.ContextTutorialsDictionary={}; |
| 5 |
this.ContextTutorialLoaded=false; |
| 6 |
var self=this; |
| 7 |
rnJQuery('.sfHelpIconContainer').click(function() |
| 8 |
{ |
| 9 |
self.ToggleTutorialScreen(); |
| 10 |
}); |
| 11 |
|
| 12 |
var self=this; |
| 13 |
rnJQuery('#btnHelpSearch').click(function(){self.ExecuteSearch()}); |
| 14 |
rnJQuery('#tbHelpSearch').keypress(function(e) |
| 15 |
{ |
| 16 |
if(e.which == 13) { |
| 17 |
self.ExecuteSearch(); |
| 18 |
} |
| 19 |
}); |
| 20 |
|
| 21 |
this.$VideoDialog=rnJQuery( |
| 22 |
'<div class="modal fade" style="display: none;z-index: 100000;">'+ |
| 23 |
'<div class="modal-dialog" style="width: 80%;max-width: 900px;">'+ |
| 24 |
'<div class="modal-content">'+ |
| 25 |
'<div class="modal-body">'+ |
| 26 |
'<div class="embed-responsive embed-responsive-16by9 video-container">'+ |
| 27 |
'</div>'+ |
| 28 |
'</div>'+ |
| 29 |
'<div class="modal-footer">'+ |
| 30 |
'<table style="width: 100%;">' + |
| 31 |
'<tr>' + |
| 32 |
'<td>'+ |
| 33 |
'<h1 style="margin: 0;text-align: left;" class="title"></h1>'+ |
| 34 |
'</td>'+ |
| 35 |
'<td>'+ |
| 36 |
'<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>'+ |
| 37 |
'</td>'+ |
| 38 |
'</tr>'+ |
| 39 |
'</div>'+ |
| 40 |
'</div>'+ |
| 41 |
'</div>'+ |
| 42 |
'</div>' |
| 43 |
); |
| 44 |
|
| 45 |
this.$VideoDialog.on('hidden.bs.modal',function() |
| 46 |
{ |
| 47 |
self.$VideoDialog.find('.video').removeAttr('src'); |
| 48 |
}); |
| 49 |
|
| 50 |
var $container=rnJQuery('<div class="bootstrap-wrapper"></div>'); |
| 51 |
$container.append(this.$VideoDialog); |
| 52 |
rnJQuery('body').append($container); |
| 53 |
|
| 54 |
self.LoadContextTutorials(); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
//this.$VideoDialog.modal('show'); |
| 59 |
} |
| 60 |
|
| 61 |
SFTutorials.prototype.LoadContextTutorials=function() |
| 62 |
{ |
| 63 |
var self=this; |
| 64 |
}; |
| 65 |
|
| 66 |
SFTutorials.prototype.ContextTutorialRequested=function(contextId) |
| 67 |
{ |
| 68 |
if(this.IsOpen) |
| 69 |
return; |
| 70 |
if(!this.ContextTutorialLoaded||typeof this.ContextTutorialsDictionary['c'+contextId]=='undefined') |
| 71 |
return; |
| 72 |
this.FillTutorialsList(this.ContextTutorialsDictionary['c'+contextId]); |
| 73 |
rnJQuery('.videoList').css('display','block'); |
| 74 |
this.BlinkHelperIcon(rnJQuery('.sfHelpIconContainer').find('span'),5); |
| 75 |
}; |
| 76 |
|
| 77 |
SFTutorials.prototype.BlinkHelperIcon=function($helperIcon,times) |
| 78 |
{ |
| 79 |
var self=this; |
| 80 |
$helperIcon.animate({ |
| 81 |
color:'red' |
| 82 |
},1000,function(){ |
| 83 |
$helperIcon.animate({ |
| 84 |
color:'#444' |
| 85 |
},1000,function() |
| 86 |
{ |
| 87 |
if(times>0) |
| 88 |
{ |
| 89 |
self.BlinkHelperIcon($helperIcon,times-1); |
| 90 |
} |
| 91 |
}); |
| 92 |
} |
| 93 |
|
| 94 |
); |
| 95 |
|
| 96 |
|
| 97 |
}; |
| 98 |
|
| 99 |
SFTutorials.prototype.ExecuteSearch=function() |
| 100 |
{ |
| 101 |
rnJQuery('.waitPanel').show('slide',{direction:"up"}); |
| 102 |
var searchCriteria=rnJQuery('#tbHelpSearch').val(); |
| 103 |
var self=this; |
| 104 |
|
| 105 |
|
| 106 |
}; |
| 107 |
|
| 108 |
SFTutorials.prototype.TutorialsLoaded=function(data) |
| 109 |
{ |
| 110 |
rnJQuery('.waitPanel').hide('slide',{direction:"up"}); |
| 111 |
if(data.success!=true) |
| 112 |
{ |
| 113 |
alert('An error occurred, please try again later'); |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
var self=this; |
| 118 |
rnJQuery('.videoList').hide('slide',{direction:"left"},function(){ |
| 119 |
rnJQuery('.videoList').empty(); |
| 120 |
if(data.data.Tutorials.length==0) |
| 121 |
{ |
| 122 |
rnJQuery('.videoList').append('<span>Sorry, there are no tutorials for this topic</span>') |
| 123 |
}else{ |
| 124 |
self.FillTutorialsList(data.data.Tutorials); |
| 125 |
} |
| 126 |
rnJQuery('.videoList').show('slide',{direction:"left"}); |
| 127 |
}); |
| 128 |
}; |
| 129 |
|
| 130 |
SFTutorials.prototype.FillTutorialsList=function(tutorials) |
| 131 |
{ |
| 132 |
rnJQuery('.videoList').empty(); |
| 133 |
for(var i=0;i<tutorials.length;i++) |
| 134 |
rnJQuery('.videoList').append(this.CreateTutorialItem(tutorials[i])); |
| 135 |
}; |
| 136 |
|
| 137 |
SFTutorials.prototype.CreateTutorialItem=function(tutorial) |
| 138 |
{ |
| 139 |
var item; |
| 140 |
if(tutorial.type=='v') |
| 141 |
item= rnJQuery('<a href="'+tutorial.link+'" class="list-group-item"><span class="glyphicon glyphicon-facetime-video" style="vertical-align: top;"></span>'+RedNaoEscapeHtml(tutorial.title)+'</a>'); |
| 142 |
else |
| 143 |
item= rnJQuery('<a href="'+tutorial.link+'" class="list-group-item" target="_blank"><span class="glyphicon glyphicon-globe" style="vertical-align: top;"></span>'+RedNaoEscapeHtml(tutorial.title)+'</a>'); |
| 144 |
|
| 145 |
this.OpenVideoPopUp(item,tutorial); |
| 146 |
return item; |
| 147 |
}; |
| 148 |
|
| 149 |
SFTutorials.prototype.OpenVideoPopUp=function(item,tutorial) |
| 150 |
{ |
| 151 |
var self=this; |
| 152 |
if(tutorial.type=='v') |
| 153 |
item.click(function(e) |
| 154 |
{ |
| 155 |
e.preventDefault(); |
| 156 |
self.$VideoDialog.find('.title').text(tutorial.title); |
| 157 |
self.$VideoDialog.find('.video').attr('src',tutorial.link+'?autoplay=1'); |
| 158 |
self.$VideoDialog.modal('show'); |
| 159 |
}); |
| 160 |
|
| 161 |
}; |
| 162 |
|
| 163 |
SFTutorials.prototype.ToggleTutorialScreen=function() |
| 164 |
{ |
| 165 |
var newWidth=0; |
| 166 |
if(!this.IsOpen) |
| 167 |
newWidth=400; |
| 168 |
|
| 169 |
rnJQuery('.sfHelpContent').animate( |
| 170 |
{ |
| 171 |
width:newWidth |
| 172 |
},{ |
| 173 |
duration:1000, |
| 174 |
easing:'easeInOutExpo' |
| 175 |
} |
| 176 |
); |
| 177 |
this.IsOpen=!this.IsOpen; |
| 178 |
}; |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
rnJQuery(function() |
| 184 |
{ |
| 185 |
new SFTutorials(); |
| 186 |
}); |