Further separates services, directives and filters into individual files for a better organization.
Conflicts: js/app.js js/service.js js/services/utils-service.js test/services/model-service_test.js
This commit is contained in:
parent
a2747a633d
commit
3164f01407
14 changed files with 618 additions and 704 deletions
134
js/directives/directives.js
Normal file
134
js/directives/directives.js
Normal file
|
@ -0,0 +1,134 @@
|
|||
'use strict';
|
||||
|
||||
var jamstash = angular.module('JamStash');
|
||||
|
||||
jamstash.directive('sortable', function () {
|
||||
return {
|
||||
link: function (scope, elm, attrs) {
|
||||
elm.sortable({
|
||||
start: scope.dragStart,
|
||||
update: scope.dragEnd
|
||||
});
|
||||
elm.disableSelection();
|
||||
}
|
||||
};
|
||||
});
|
||||
/*
|
||||
jamstash.directive('split', function () {
|
||||
return {
|
||||
link: function (scope, elm, attrs) {
|
||||
elm.splitPane();
|
||||
}
|
||||
};
|
||||
});
|
||||
*/
|
||||
jamstash.directive('fancybox', function ($compile) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
replace: false,
|
||||
link: function($scope, element, attrs) {
|
||||
$scope.fancyboxOpen = function() {
|
||||
var el = angular.element(element.html()),
|
||||
compiled = $compile(el);
|
||||
$.fancybox.open(el);
|
||||
compiled($scope);
|
||||
};
|
||||
$scope.fancyboxOpenUrl = function () {
|
||||
var el = angular.element(element.html()),
|
||||
compiled = $compile(el);
|
||||
$.fancybox.open(el);
|
||||
compiled($scope);
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('songpreview', function ($compile, subsonic) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'js/partials/songs.html',
|
||||
replace: false,
|
||||
// pass these two names from attrs into the template scope
|
||||
scope: {
|
||||
song: '@'
|
||||
},
|
||||
link: function (scope, element, attrs) {
|
||||
subsonic.getSongTemplate(function (data) {
|
||||
scope.song = data;
|
||||
//var el = angular.element(element.html()),
|
||||
//var el = element.html(),
|
||||
//compiled = $compile(el);
|
||||
$.fancybox.open(element);
|
||||
//compiled($scope);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('stopEvent', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
element.bind(attr.stopEvent, function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('ngEnter', function () {
|
||||
return {
|
||||
scope: { onEnter: '&' },
|
||||
link: function (scope, element) {
|
||||
console.log(scope);
|
||||
element.bind("keydown keypress", function (event) {
|
||||
if (event.which === 13) {
|
||||
scope.onEnter();
|
||||
scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('ngDownload', function ($compile) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: { data: '=' },
|
||||
link: function (scope, elm, attrs) {
|
||||
function getUrl() {
|
||||
return URL.createObjectURL(new Blob([JSON.stringify(scope.data)], { type: "application/json" }));
|
||||
}
|
||||
|
||||
elm.append($compile(
|
||||
'<a class="button" download="backup.json"' +
|
||||
'href="' + getUrl() + '">' +
|
||||
'Download' +
|
||||
'</a>'
|
||||
)(scope));
|
||||
|
||||
scope.$watch(scope.data, function () {
|
||||
elm.children()[0].href = getUrl();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('stopEvent', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
element.bind(attr.stopEvent, function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
jamstash.directive('ngEnter', function () {
|
||||
return function (scope, element, attrs) {
|
||||
element.bind("keydown keypress", function (event) {
|
||||
if (event.which === 13) {
|
||||
scope.$apply(function () {
|
||||
scope.$eval(attrs.ngEnter);
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue