Scribe.js/static/js/directives/block.js

90 lines
2.1 KiB
JavaScript
Raw Normal View History

2014-11-11 21:20:33 +01:00
(function () {
'use strict';
2014-11-13 21:33:37 +01:00
/**
* Block directives
*
* Blocks ar used in home, folder and dates view
* to display folder name, dates and file name
*/
2014-12-15 22:01:33 +01:00
var colors = [
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#f39c12",
"#d35400",
"#c0392b",
"#7f8c8d"
];
2014-11-11 21:20:33 +01:00
window.app.directive('block', [function () {
return {
scope : {
2014-11-13 21:33:37 +01:00
/**
* type
*
* @type {String} 'dates' or anything else
*/
2014-11-11 21:20:33 +01:00
type : "=",
2014-11-13 21:33:37 +01:00
/**
* message
*
* Main message. If top and bottom messages,
* main message goes in middle
*
* @type {String}
*/
2014-11-11 21:20:33 +01:00
message : "=",
2014-11-13 21:33:37 +01:00
/**
* messageTop
*
* @type {String}
*/
2014-11-11 21:20:33 +01:00
messageTop : "=",
2014-11-13 21:33:37 +01:00
/**
* messageBottom
*
* @type {String}
*/
2014-11-11 21:20:33 +01:00
messageBottom : "=",
2014-11-13 21:33:37 +01:00
/**
* forceFile
*
* If true, the block won't be a square
* but with be full-wifth in order to contain a file name
*
* @type {Boolean}
*/
2014-11-11 21:20:33 +01:00
forceFile : "="
2014-11-13 21:33:37 +01:00
2014-11-11 21:20:33 +01:00
},
2014-11-13 21:33:37 +01:00
restrict : "E",
2014-11-11 21:20:33 +01:00
templateUrl : 'partials/elements/blocks.html',
2014-12-15 22:01:33 +01:00
replace : true,
controller : ['$scope', function ($scope) {
/**
* $scope.color
*
* @return {String} A radom haxa color from `colors`
*/
$scope.color = function () {
2014-12-17 13:17:42 +01:00
return colors[Math.floor(Math.random() * colors.length)];
2014-12-15 22:01:33 +01:00
};
}]
2014-11-11 21:20:33 +01:00
};
}]);
}());