Skip to content

Commit

Permalink
Merge pull request #10 from BATraining/develop
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
JeromeLam committed Jun 22, 2015
2 parents d266d2a + 34ba4d4 commit bd4a754
Show file tree
Hide file tree
Showing 14 changed files with 4,787 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "src/plugins",
"registry": "http://adapt-bower-repository.herokuapp.com/"
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.10
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,80 @@
# adapt-embeddedLink
adapt-embeddedLink

A graphical Component

##Installation

First, be sure to install the [Adapt Command Line Interface](https://github.com/adaptlearning/adapt-cli), then from the command line run:-

adapt install adapt-embeddedLink

This component can also be installed by adding the component to the adapt.json file before running `adapt install`:

"adapt-embeddedLink": "*"

##Usage

To Be Updated

##Settings overview

An complete example of this components settings can be found in the [example.json](https://github.com/BATraining/adapt-embeddedLink/blob/master/example.json) file. A description of the core settings can be found at: [Core model attributes](https://github.com/adaptlearning/adapt_framework/wiki/Core-model-attributes)

Further settings for this component are:

####_component

This value must be: `embeddedLink`

####_classes

You can use this setting to add custom classes to your template and LESS file.

####_layout

This defines the position of the component in the block. Values can be `full`, `left` or `right`.

####_page

This is text block which contains contains `title`, `body`, `audioSrc`, `audioTypes`

####title

This is title of description

####body

This is body of description

####audioSrc

It is source of the audio which play when description is inview or audio button is clicked

####audioTypes

It is type of audio to load and contains `type` and `codec`

####type

Type of audio

####codec

Codec of audio

####_source

This is source of media which will be displayed in iFrame

####_imageSource

This can have url for any other link which will appears on click of image

####_isLightBox

This can be `true` if user want to open media in lightBox else `false`





17 changes: 17 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "adapt-embeddedLink",
"version": "1.0.0",
"homepage": "https://github.com/BATraining/adapt-embeddedLink",
"author": [
"Amruta Thakur <amruta.thakur@exultcorp.com>"
],
"displayName" : "Embedded Link",
"component" : "embeddedLink",
"description": "A basic Adapt Embedded Link component.",
"main": "/js/adapt-embeddedLink.js",
"keywords": [
"adapt-plugin",
"adapt-component"
],
"license": "GPLv3"
}
61 changes: 61 additions & 0 deletions example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//If there is image to load
{
"_id":"c-10",
"_parentId":"b-05",
"_type":"component",
"_component":"embeddedLink",
"_classes":"",
"_layout":"full",
"title":"",
"displayTitle": "Embedded Link",
"body": "",
"instruction": "",
"_page":{
"title":"",
"body":"With the advent of modern browsers, frameworks, developments in HTML 5 and responsive design approaches we're now able to create engaging learning that will work, regardless of the device being used.",
"audioSrc": "course/en/audio/hot-graphic1",
"audioTypes": [
{
"type": "mp3",
"codec": "audio/mpeg"
}
]
},
"_source": "course/en/images/CS1_CS3_4911_003.jpg",
"_imageSource":"course/en/embed/Wikipedia.html",
"_pageLevelProgress": {
"_isEnabled": true
}
},


//other Media

{
"_id":"c-10",
"_parentId":"b-05",
"_type":"component",
"_component":"embeddedLink",
"_classes":"",
"_layout":"full",
"title":"",
"body": "",
"_page":{
"title":"",
"body":"With the advent of modern browsers, frameworks, developments in HTML 5 and responsive design approaches we're now able to create engaging learning that will work, regardless of the device being used.",
"audioSrc": "course/en/audio/hot-graphic1",
"audioTypes": [
{
"type": "mp3",
"codec": "audio/mpeg"
}
]
},

"_height":800,
"_source": "course/en/pdf/adapt-framework-prototypes-buttons.pdf",
"_isLightBox":false
"_pageLevelProgress": {
"_isEnabled": true
}
}
206 changes: 206 additions & 0 deletions js/adapt-embeddedLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*
* adapt-embeddedLink
* Copyright (C) 2015 Bombardier Inc. (www.batraining.com)
* https://github.com/BATraining/adapt-embeddedLink/blob/master/LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(function(require) {

var ComponentView = require("coreViews/componentView");
var Adapt = require("coreJS/adapt");
var mep = require('components/adapt-embeddedLink/js/mediaelement-and-player.min');
var lightBox = require('components/adapt-embeddedLink/js/jquery.jsmodal');

var EmbeddedLink = ComponentView.extend({

events: {
'click .embeddedLink-zoomin-button':'onClickZoomInButton',
'click .embeddedLink-graphic-pin': 'onClickAudioButton',
'click .embeddedLink-image':'onClickImage'
},

preRender: function() {
var videoExtensionsList = ["mp4","ogv","ogg"];
var imageExtensionsList = ["jpg","png","jpeg","svg","gif","bmp"];
var extension = this.model.get("_source").split(".")[1];

_.each(videoExtensionsList, function(videoExtension,index){
if(extension == videoExtension){
this.model.set("_isVideo",true);
}
},this);
_.each(imageExtensionsList, function(imageExtension,index){
if(extension == imageExtension){
this.model.set("_isImage",true);
}
},this);

},

postRender: function() {
//alert(Adapt.device.browser);

this.$('.embeddedLink-description').on('inview', _.bind(this.inview, this));
var $self = this;
this.$('.embeddedLink-iframe').ready(function() {
$self.setReadyStatus();
});

if($('html').hasClass('ie8')) {
var audioObject=new MediaElementPlayer(this.$('audio')[0]);
this.model.set('_audioObjectForIE',audioObject);
}
this.$('.mejs-container').addClass('display-none');
this.$('audio').on('ended', _.bind(this.onAudioEnded, this));
},

inview: function(event, visible) {
var addedMute = this.$('.embeddedLink-graphic-pin-icon').hasClass('icon-sound-mute');
this.stopCurrentAudio();
this.stopAudio();
if (visible && !addedMute) {
var audioElement;
if($('html').hasClass('ie8')) {
audioElement=this.model.get('_audioObjectForIE');
}
else{
audioElement = this.$("audio")[0];

}
this.playAudioForElement(audioElement);
this.setCompletionStatus();
}
else{
this.stopCurrentAudio();
this.stopAudio();
}
},

stopAudio: function () {
var audioObject = this.model.get('_audioObjectForIE');

if(audioObject) {
audioObject.setCurrentTime(0);
audioObject.pause();
this.model.set("_audioObjectForIE", '');
this.$('.embeddedLink-graphic-pin-icon').addClass('icon-sound-mute');
}
},

stopCurrentAudio:function(){
var audioElement = this.model.get("_currentAudioElement");

if (audioElement) {
if (!audioElement.paused && audioElement.pause) {
audioElement.pause();
}
if (audioElement.currentTime != 0) {
audioElement.currentTime = 0.0;
}
this.model.set("_currentAudioElement", '');
this.$('.embeddedLink-graphic-pin-icon').addClass('icon-sound-mute');
}
},

playAudioForElement:function(audioElement){

if (audioElement) {
if(!$('html').hasClass('ie8')){
this.stopCurrentAudio();
this.model.set("_currentAudioElement", audioElement);
}
if(audioElement.play) audioElement.play();
}
},

onAudioEnded: function(event) {

if($('html').hasClass('ie8')) {
this.stopAudio();
} else {
this.model.get("_currentAudioElement").currentTime = 0.0;
this.model.set("_currentAudioElement", '');
}
this.$('.embeddedLink-graphic-pin-icon').addClass('icon-sound-mute');
},

onClickAudioButton:function(event){
if(event && event.preventDefault) event.preventDefault();

var audioElement;
var isIE8 = $('html').hasClass('ie8');

if(isIE8){
audioElement = this.model.get("_audioObjectForIE");
}
else{
audioElement = this.model.get("_currentAudioElement");
}
if(audioElement==''){
if(isIE8){
audioElement=new MediaElementPlayer(this.$('.embeddedLink-item-audio audio')[0]);
}
else{
audioElement = this.$('.embeddedLink-item-audio audio')[0];
}
this.playAudioForElement(audioElement);
this.$('.embeddedLink-graphic-pin-icon').removeClass('icon-sound-mute');
}
else {
if(isIE8) {
this.stopAudio();
} else {
this.stopCurrentAudio();
}
this.$('.embeddedLink-graphic-pin-icon').addClass('icon-sound-mute');
}
},

onClickZoomInButton:function(event){
event.preventDefault();
var browser = Adapt.device.browser;
if(browser == 'ipad'){
this.$(".embeddedLink-lightBox-iframe-parent").css({'overflow':'auto' , '-webkit-overflow-scrolling':'touch'});
}
var isLightBox=this.model.get("_isLightBox");
var source = this.model.get("_source");

//Pause all the videos on popout button clicked
var videoPause=$("video");
for(var i=0;i<videoPause.length;i++){
videoPause[i].pause();
}

if(isLightBox){
this.$('.embeddedLink-lightBox-popup-container').modal();
}
else{
window.open(source,'_blank','width=1024,height=768,left=100,top=100');
}
},
onClickImage:function(event){
event.preventDefault();

var imageSource = this.model.get("_imageSource");
window.open(imageSource,'_blank','width=1024,height=768,left=100,top=100');
}

});

Adapt.register("embeddedLink", EmbeddedLink);

return EmbeddedLink;

});
Loading

0 comments on commit bd4a754

Please sign in to comment.