
see: https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub The files are now grouped by view / component. Tests are located beside tested js files. The Grunt build will be responsible for only distributing actual files without the tests. Each partial is at the same level as the js files related to it. Ideally css files should be at the same level, maybe I'll refactor this later. Moves all non-bower plugins to app/vendor. Moves all images to app/images and styles to app/styles. Merges the test and non-test jshintrc files. Adds all the Jamstash contributors to the package.json file while I was refactoring. Conflicts: app/app.js app/images/vgrabber.gif app/images/vgrabber2-active.gif app/images/vgrabber2-normal.gif app/index.html
134 lines
No EOL
3.7 KiB
JavaScript
134 lines
No EOL
3.7 KiB
JavaScript
'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: 'common/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();
|
|
}
|
|
});
|
|
};
|
|
}); |