2017-02-09 11:45:42 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
import ng from 'angular';
|
|
|
|
import 'bootstrap';
|
|
|
|
import 'angular-ui-bootstrap';
|
|
|
|
import 'angular-ui-sortable';
|
|
|
|
|
|
|
|
const fm = {
|
2016-10-19 16:25:44 +00:00
|
|
|
URL_PREFIX: location.protocol + "//" + location.host + location.pathname.replace(/[^\/]*$/, "")
|
2014-12-26 03:05:07 +00:00
|
|
|
};
|
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
fm.app = ng.module("facilmap", [ "ui.sortable", "ui.bootstrap" ]);
|
2014-12-26 03:05:07 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
fm.app.config(function($compileProvider, $uibTooltipProvider) {
|
|
|
|
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|javascript):/);
|
2016-10-07 17:43:42 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
$uibTooltipProvider.options({
|
|
|
|
placement: "bottom"
|
2016-10-07 17:43:42 +00:00
|
|
|
});
|
2017-02-09 11:45:42 +00:00
|
|
|
});
|
2014-12-26 03:05:07 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
fm.app.constant("fmSortableOptions", {
|
|
|
|
handle: ".sort-handle",
|
|
|
|
axis: "y",
|
|
|
|
cursor: "move",
|
|
|
|
helper: function(e, ui) { // Source: http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/
|
|
|
|
ui.children().each(function() {
|
|
|
|
$(this).width($(this).width());
|
|
|
|
});
|
|
|
|
return ui;
|
|
|
|
},
|
|
|
|
start: function(e, ui) {
|
|
|
|
var elChildren = ui.item.children();
|
|
|
|
ui.placeholder.children().each(function(i) {
|
|
|
|
$(this).width(elChildren.eq(i).width());
|
|
|
|
$(this).height(elChildren.eq(i).height());
|
|
|
|
});
|
|
|
|
},
|
|
|
|
stop: function(e, ui) {
|
|
|
|
ui.item.children().each(function() {
|
|
|
|
$(this).css("width", "");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-10-05 14:47:50 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
// Properly resolve source maps, see https://github.com/angular/angular.js/issues/5217#issuecomment-257143381
|
|
|
|
fm.app.factory('$exceptionHandler', function() {
|
|
|
|
return function(exception, cause) {
|
|
|
|
console.error(exception.stack || exception);
|
|
|
|
};
|
|
|
|
});
|
2016-10-30 10:36:10 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
fm.app.run(function($rootScope) {
|
|
|
|
$rootScope.confirm = function(msg) { return confirm(msg); };
|
|
|
|
});
|
2016-10-30 15:04:40 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
function wrapApply($scope, f) {
|
|
|
|
return function() {
|
|
|
|
var context = this;
|
|
|
|
var args = arguments;
|
|
|
|
var func = function() { return f.apply(context, args); };
|
2014-12-26 03:05:07 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
if($scope.$$phase || $scope.$root.$$phase)
|
|
|
|
return func();
|
|
|
|
else
|
|
|
|
return $scope.$apply(func);
|
2014-12-26 03:05:07 +00:00
|
|
|
}
|
2017-02-09 11:45:42 +00:00
|
|
|
}
|
2014-12-26 03:05:07 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
Function.prototype.fmWrapApply = function($scope) {
|
|
|
|
return wrapApply($scope, this);
|
|
|
|
};
|
2014-12-26 03:05:07 +00:00
|
|
|
|
2017-02-09 11:45:42 +00:00
|
|
|
export default fm;
|