Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#644 #665

Merged
merged 9 commits into from
May 12, 2015
58 changes: 57 additions & 1 deletion frontend/src/core/app/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define(function(require){

return hh + ':' + mm + ':' + ss;
},
if_value_equals: function(value, text, block) {
ifValueEquals: function(value, text, block) {
if (value === text) {
return block.fn(this);
} else {
Expand Down Expand Up @@ -170,7 +170,63 @@ define(function(require){
} else {
return block.inverse(this);
}
},

console: function(context) {
return console.log(context);
},

getAssetFromValue: function(url) {
var urlSplit = url.split('/')
var fileName = urlSplit[urlSplit.length - 1];
// Get courseAsset model
var courseAsset = Origin.editor.data.courseAssets.findWhere({_fieldName: fileName});
var courseAssetId = courseAsset.get('_assetId');

return '/api/asset/serve/' + courseAssetId;

},

getThumbnailFromValue: function(url) {

var urlSplit = url.split('/')
var fileName = urlSplit[urlSplit.length - 1];
// Get courseAsset model
var courseAsset = Origin.editor.data.courseAssets.findWhere({_fieldName: fileName});
if (courseAsset) {
var courseAssetId = courseAsset.get('_assetId');
return '/api/asset/thumb/' + courseAssetId;
} else {
return '/api/asset/thumb/' + url;
}

},

ifAssetIsExternal: function(url, block) {

var urlSplit = url.split('/')
// Could well be a hero image for the course
if (urlSplit.length === 1) {
return block.inverse(this);
}

if (urlSplit[0] != "course" && urlSplit[1] != "assets") {
return block.fn(this);
} else {
return block.inverse(this);
}

},

ifAssetIsHeroImage: function(url, block) {
var urlSplit = url.split('/')
if (urlSplit.length === 1) {
return block.fn(this);
} else {
return block.inverse(this);
}
}

};

for(var name in helpers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@

<div class="asset-management-list-item-icon">
<div class="asset-management-list-item-icon-inner">
{{#if_value_equals assetType "image"}}
{{#ifValueEquals assetType "image"}}
<i class="fa fa-file-image-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "audio"}}
{{#ifValueEquals assetType "audio"}}
<i class="fa fa-file-audio-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "video"}}
{{#ifValueEquals assetType "video"}}
<i class="fa fa-file-video-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "other"}}
{{#ifValueEquals assetType "other"}}
<i class="fa fa-file-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}
</div>
</div>

{{#if_value_equals assetType "image"}}
{{#ifValueEquals assetType "image"}}
<div class="asset-management-list-item-image" data-style="background-image:url(api/asset/thumb/{{_id}})">
</div>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "video"}}
{{#ifValueEquals assetType "video"}}
<div class="asset-management-list-item-image" data-style="background-image:url(api/asset/thumb/{{_id}})">
</div>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "audio"}}
{{#ifValueEquals assetType "audio"}}
<div class="asset-management-list-item-image">
<i class="fa fa-file-audio-o"></i>
</div>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "other"}}
{{#ifValueEquals assetType "other"}}
<div class="asset-management-list-item-image">
<i class="fa fa-file-o"></i>
</div>
{{/if_value_equals}}
{{/ifValueEquals}}

<div class="asset-management-list-item-details">

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<i class="fa fa-magic"></i>Autofill
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<div class="asset-preview-details text-centered">
<div class="asset-preview-details-preview">
{{#if_value_equals assetType "image"}}
{{#ifValueEquals assetType "image"}}
<img src="api/asset/serve/{{_id}}"/>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "video"}}
{{#ifValueEquals assetType "video"}}
<video preload="none" width="640px" height="360px" poster="" style="width:100%; height:100%;">
<source src="api/asset/serve/{{_id}}" type="{{mimeType}}"/>
</video>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "audio"}}
{{#ifValueEquals assetType "audio"}}
<i class="fa fa-file-audio-o"></i>
<audio src="api/asset/serve/{{_id}}" type="{{mimeType}}" controls="controls" style="width:100%;"></audio>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals assetType "other"}}
{{#ifValueEquals assetType "other"}}
<i class="fa fa-file-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}
</div>

<h1 class="asset-preview-title">{{title}}</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE
define(function(require) {

var Origin = require('coreJS/app/origin');
var Backbone = require('backbone');

var AssetManagementModalAutofillView = Backbone.View.extend({

className: 'asset-management-modal-autofill',

tagName: 'button',

events: {
'click': 'onAutofillClicked'
},

initialize: function(options) {
this.options = options;
this.listenTo(Origin, 'modal:closed', this.remove);
this.listenTo(Origin, 'remove:views', this.remove);
this.render();
},

render: function() {
var data = this.options;
var template = Handlebars.templates['assetManagementModalAutofill'];
this.$el.html(template(data)).prependTo('.model-popup-toolbar-buttons');
_.defer(_.bind(this.postRender, this));

return this;
},

postRender: function() {
},

onAutofillClicked: function(event) {
event.preventDefault();
// Sometimes the button can be clicked without selecting an asset
if (this.options.modalView.data) {
this.options.modalView.data._shouldAutofill = true;
Origin.trigger('modal:onUpdate');
} else {
Origin.trigger('modal:onCancel');
}
}

});

return AssetManagementModalAutofillView;

});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define(function(require) {
var AssetManagementPreviewView = require('coreJS/assetManagement/views/assetManagementPreviewView');
var AssetManagementView = require('coreJS/assetManagement/views/assetManagementView');
var AssetManagementModalFiltersView = require('coreJS/assetManagement/views/assetManagementModalFiltersView');
var AssetManagementModelAutofillView = require('coreJS/assetManagement/views/assetManagementModalAutofillView');

var AssetManagementModalView = AssetManagementView.extend({

Expand All @@ -19,6 +20,9 @@ define(function(require) {
postRender: function() {
this.setupSubViews();
this.setupFilterAndSearchView();
if (this.options.assetType === "Asset:image" && Origin.scaffold.getCurrentModel().get('_component') === 'graphic') {
this.setupImageAutofillButton();
}
this.resizeAssetPanels();
},

Expand All @@ -35,6 +39,10 @@ define(function(require) {
new AssetManagementModalFiltersView(this.options);
},

setupImageAutofillButton: function() {
new AssetManagementModelAutofillView({modalView: this});
},

resizeAssetPanels: function() {
var navigationHeight = $('.navigation').outerHeight();
var windowHeight = $(window).height();
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/core/editor/menu/templates/editorMenuItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
</div>

<div class="editor-menu-item-icon {{_type}}">
{{#if_value_equals _type "menu"}}
{{#ifValueEquals _type "menu"}}
<i class="fa fa-folder-o"></i>
{{/if_value_equals}}
{{#if_value_equals _type "page"}}
{{/ifValueEquals}}
{{#ifValueEquals _type "page"}}
<i class="fa fa-file-o"></i>
{{/if_value_equals}}
{{/ifValueEquals}}
</div>
<div class="editor-menu-item-title">
<span class="editor-menu-item-title-text">{{{title}}}</span>
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/core/modal/templates/modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
<h2 class="modal-popup-title-inner">{{title}}</h2>
</div>
{{/if}}
{{#if _shouldShowDoneButton}}
<button href="#" class="modal-popup-done">
<i class="fa fa-check"></i>Done
</button>
{{/if}}
{{#if _shouldShowCancelButton}}
<button href="#" class="modal-popup-close">
<i class="fa fa-times"></i>Cancel
</button>
{{/if}}
<div class="model-popup-toolbar-buttons">
{{#if _shouldShowDoneButton}}
<button href="#" class="modal-popup-done">
<i class="fa fa-check"></i>Done
</button>
{{/if}}
{{#if _shouldShowCancelButton}}
<button href="#" class="modal-popup-close">
<i class="fa fa-times"></i>Cancel
</button>
{{/if}}
</div>
</div>
<div class="modal-popup-inner">
{{#if body}}
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/core/notify/templates/notify.hbs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="notify-popup notify-type-{{_type}} {{_classes}}">
{{#if_value_equals _type "popup"}}
{{#ifValueEquals _type "popup"}}
<div class="notify-popup-toolbar">
<a href="#" class="notify-popup-done">
<div class="notify-popup-icon-close fa fa-times"></div>
</a>
</div>
{{/if_value_equals}}
{{/ifValueEquals}}
<div class="notify-popup-inner">
<div class="notify-popup-content">
<div class="notify-popup-content-inner">
{{#if _showIcon}}
<div class="notify-popup-icon">
<div class="icon{{#if_value_equals _type "prompt"}} icon-question{{/if_value_equals}}{{#if_value_equals _type "alert"}} icon-warning{{/if_value_equals}}">
<div class="icon{{#ifValueEquals _type "prompt"}} icon-question{{/ifValueEquals}}{{#ifValueEquals _type "alert"}} icon-warning{{/ifValueEquals}}">
</div>
</div>
{{/if}}
Expand All @@ -31,15 +31,15 @@
{{#if body}}
<div class="notify-popup-buttons">

{{#if_value_equals _type "alert"}}
{{#ifValueEquals _type "alert"}}
<a href="#" class="notify-popup-button notify-popup-alert-button">{{{confirmText}}}</a>
{{/if_value_equals}}
{{/ifValueEquals}}

{{#if_value_equals _type "prompt"}}
{{#ifValueEquals _type "prompt"}}
{{#each _prompts}}
<a href="#" class="notify-popup-button notify-popup-prompt-button" data-event="{{_callbackEvent}}">{{{promptText}}}</a>
{{/each}}
{{/if_value_equals}}
{{/ifValueEquals}}

</div>
{{/if}}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/core/project/models/projectModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ define(function(require) {

var Backbone = require('backbone');
var Origin = require('coreJS/app/origin');
var EditorModel = require('editorGlobal/models/editorModel');

var ProjectModel = Backbone.Model.extend({
var ProjectModel = EditorModel.extend({

idAttribute: '_id',

Expand Down
26 changes: 26 additions & 0 deletions frontend/src/core/scaffold/less/scaffoldAsset.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.scaffold-asset-preview {
display:block;
margin-bottom: 10px;
transition:color 0.3s;
i {
font-size:60px;
}
&:hover {
color:#15a4fa;
}
}

.scaffold-asset-buttons {
transition:color 0.3s;
i {
transition:inherit;
color:inherit;
&:hover {
color:inherit;
}
}
}

.scaffold-asset-external-input-buttons {
margin-top:10px;
}
Loading