mirror of
https://github.com/sismics/docs.git
synced 2024-11-14 10:27:55 +01:00
Angular UI Bootstrap migration
This commit is contained in:
parent
0e99f06310
commit
85aa16afba
@ -5,8 +5,8 @@
|
||||
*/
|
||||
var App = angular.module('docs',
|
||||
// Dependencies
|
||||
['ui.state', 'ui.route', 'ui.bootstrap', 'ui.keypress', 'ui.validate',
|
||||
'ui.sortable', 'restangular', 'ngSanitize', 'ngMobile', 'colorpicker.module']
|
||||
['ui.router', 'ui.route', 'ui.bootstrap', 'ui.keypress', 'ui.validate', 'dialog',
|
||||
'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module']
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,6 @@ App.controller('Document', function($scope, $timeout, $state, Restangular) {
|
||||
.then(function (data) {
|
||||
$scope.documents = data.documents;
|
||||
$scope.totalDocuments = data.total;
|
||||
$scope.numPages = Math.ceil(data.total / $scope.limit);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -5,5 +5,7 @@
|
||||
*/
|
||||
App.controller('DocumentDefault', function($scope, $state, Restangular) {
|
||||
// Load app data
|
||||
$scope.app = Restangular.one('app').get();
|
||||
Restangular.one('app').get().then(function(data) {
|
||||
$scope.app = data;
|
||||
});
|
||||
});
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Document view controller.
|
||||
*/
|
||||
App.controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, Restangular) {
|
||||
App.controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular) {
|
||||
// Load data from server
|
||||
Restangular.one('document', $stateParams.id).get().then(function(data) {
|
||||
$scope.document = data;
|
||||
@ -56,16 +56,14 @@ App.controller('DocumentView', function ($scope, $state, $stateParams, $location
|
||||
{result: 'ok', label: 'OK', cssClass: 'btn-primary'}
|
||||
];
|
||||
|
||||
$dialog.messageBox(title, msg, btns)
|
||||
.open()
|
||||
.then(function (result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('document', document.id).remove().then(function () {
|
||||
$scope.loadDocuments();
|
||||
$state.transitionTo('document.default');
|
||||
});
|
||||
}
|
||||
$dialog.messageBox(title, msg, btns, function (result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('document', document.id).remove().then(function () {
|
||||
$scope.loadDocuments();
|
||||
$state.transitionTo('document.default');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -79,31 +77,28 @@ App.controller('DocumentView', function ($scope, $state, $stateParams, $location
|
||||
{result: 'ok', label: 'OK', cssClass: 'btn-primary'}
|
||||
];
|
||||
|
||||
$dialog.messageBox(title, msg, btns)
|
||||
.open()
|
||||
.then(function (result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('file', file.id).remove().then(function () {
|
||||
$scope.loadFiles();
|
||||
});
|
||||
}
|
||||
$dialog.messageBox(title, msg, btns, function (result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('file', file.id).remove().then(function () {
|
||||
$scope.loadFiles();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the share dialog.
|
||||
*/
|
||||
$scope.share = function () {
|
||||
$dialog.dialog({
|
||||
keyboard: true,
|
||||
$modal.open({
|
||||
templateUrl: 'partial/docs/document.share.html',
|
||||
controller: function ($scope, dialog) {
|
||||
controller: function ($scope, $modalInstance) {
|
||||
$scope.name = '';
|
||||
$scope.close = function (name) {
|
||||
dialog.close(name);
|
||||
$modalInstance.close(name);
|
||||
}
|
||||
}
|
||||
}).open().then(function (name) {
|
||||
}).result.then(function (name) {
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
@ -140,17 +135,15 @@ App.controller('DocumentView', function ($scope, $state, $stateParams, $location
|
||||
{result: 'close', label: 'Close'}
|
||||
];
|
||||
|
||||
$dialog.messageBox(title, msg, btns)
|
||||
.open()
|
||||
.then(function (result) {
|
||||
if (result == 'unshare') {
|
||||
// Unshare this document and update the local shares
|
||||
Restangular.one('share', share.id).remove().then(function () {
|
||||
$scope.document.shares = _.reject($scope.document.shares, function(s) {
|
||||
return share.id == s.id;
|
||||
});
|
||||
});
|
||||
}
|
||||
$dialog.messageBox(title, msg, btns, function (result) {
|
||||
if (result == 'unshare') {
|
||||
// Unshare this document and update the local shares
|
||||
Restangular.one('share', share.id).remove().then(function () {
|
||||
$scope.document.shares = _.reject($scope.document.shares, function(s) {
|
||||
return share.id == s.id;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
@ -3,10 +3,9 @@
|
||||
/**
|
||||
* File view controller.
|
||||
*/
|
||||
App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
var dialog = $dialog.dialog({
|
||||
keyboard: true,
|
||||
dialogClass: 'modal modal-fileview',
|
||||
App.controller('FileView', function($modal, $state, $stateParams) {
|
||||
var modal = $modal.open({
|
||||
windowClass: 'modal modal-fileview',
|
||||
templateUrl: 'partial/docs/file.view.html',
|
||||
controller: function($scope, $state, $stateParams, Restangular, dialog) {
|
||||
// Load files
|
||||
@ -65,7 +64,7 @@ App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
dialog.close();
|
||||
};
|
||||
|
||||
// Close the dialog when the user exits this state
|
||||
// Close the modal when the user exits this state
|
||||
var off = $scope.$on('$stateChangeStart', function(event, toState){
|
||||
if (dialog.isOpen()) {
|
||||
dialog.close(toState.name == 'document.view.file' ? {} : null);
|
||||
@ -76,7 +75,7 @@ App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
});
|
||||
|
||||
// Returns to document view on file close
|
||||
dialog.open().then(function(result) {
|
||||
modal.result.then(function(result) {
|
||||
if (result == null) {
|
||||
$state.transitionTo('document.view', { id: $stateParams.id });
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ App.controller('Login', function($scope, $rootScope, $state, $dialog, User) {
|
||||
var msg = 'Username or password invalid';
|
||||
var btns = [{result:'ok', label: 'OK', cssClass: 'btn-primary'}];
|
||||
|
||||
$dialog.messageBox(title, msg, btns).open();
|
||||
$dialog.messageBox(title, msg, btns);
|
||||
});
|
||||
};
|
||||
});
|
@ -50,18 +50,16 @@ App.controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParam
|
||||
var msg = 'Do you really want to delete this user? All associated documents, files and tags will be deleted';
|
||||
var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}];
|
||||
|
||||
$dialog.messageBox(title, msg, btns)
|
||||
.open()
|
||||
.then(function(result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('user', $stateParams.username).remove().then(function() {
|
||||
$scope.loadUsers();
|
||||
$state.transitionTo('settings.user');
|
||||
}, function () {
|
||||
$state.transitionTo('settings.user');
|
||||
});
|
||||
}
|
||||
});
|
||||
$dialog.messageBox(title, msg, btns, function(result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('user', $stateParams.username).remove().then(function() {
|
||||
$scope.loadUsers();
|
||||
$state.transitionTo('settings.user');
|
||||
}, function () {
|
||||
$state.transitionTo('settings.user');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
@ -55,9 +55,7 @@ App.controller('Tag', function($scope, $dialog, $state, Tag, Restangular) {
|
||||
{result: 'ok', label: 'OK', cssClass: 'btn-primary'}
|
||||
];
|
||||
|
||||
$dialog.messageBox(title, msg, btns)
|
||||
.open()
|
||||
.then(function(result) {
|
||||
$dialog.messageBox(title, msg, btns, function(result) {
|
||||
if (result == 'ok') {
|
||||
Restangular.one('tag', tag.id).remove().then(function() {
|
||||
$scope.tags = _.reject($scope.tags, function(t) {
|
||||
|
@ -23,6 +23,8 @@
|
||||
<script src="lib/underscore.js" type="text/javascript"></script>
|
||||
<script src="lib/colorpicker.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.js" type="text/javascript"></script>
|
||||
<script src="lib/angular-sanitize.js" type="text/javascript"></script>
|
||||
<script src="lib/angular-touch.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-router.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-bootstrap.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-utils.js" type="text/javascript"></script>
|
||||
|
13
docs-web/src/main/webapp/lib/angular-sanitize.js
vendored
Normal file
13
docs-web/src/main/webapp/lib/angular-sanitize.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
AngularJS v1.2.8
|
||||
(c) 2010-2014 Google, Inc. http://angularjs.org
|
||||
License: MIT
|
||||
*/
|
||||
(function(p,h,q){'use strict';function E(a){var e=[];s(e,h.noop).chars(a);return e.join("")}function k(a){var e={};a=a.split(",");var d;for(d=0;d<a.length;d++)e[a[d]]=!0;return e}function F(a,e){function d(a,b,d,g){b=h.lowercase(b);if(t[b])for(;f.last()&&u[f.last()];)c("",f.last());v[b]&&f.last()==b&&c("",b);(g=w[b]||!!g)||f.push(b);var l={};d.replace(G,function(a,b,e,c,d){l[b]=r(e||c||d||"")});e.start&&e.start(b,l,g)}function c(a,b){var c=0,d;if(b=h.lowercase(b))for(c=f.length-1;0<=c&&f[c]!=b;c--);
|
||||
if(0<=c){for(d=f.length-1;d>=c;d--)e.end&&e.end(f[d]);f.length=c}}var b,g,f=[],l=a;for(f.last=function(){return f[f.length-1]};a;){g=!0;if(f.last()&&x[f.last()])a=a.replace(RegExp("(.*)<\\s*\\/\\s*"+f.last()+"[^>]*>","i"),function(b,a){a=a.replace(H,"$1").replace(I,"$1");e.chars&&e.chars(r(a));return""}),c("",f.last());else{if(0===a.indexOf("\x3c!--"))b=a.indexOf("--",4),0<=b&&a.lastIndexOf("--\x3e",b)===b&&(e.comment&&e.comment(a.substring(4,b)),a=a.substring(b+3),g=!1);else if(y.test(a)){if(b=a.match(y))a=
|
||||
a.replace(b[0],""),g=!1}else if(J.test(a)){if(b=a.match(z))a=a.substring(b[0].length),b[0].replace(z,c),g=!1}else K.test(a)&&(b=a.match(A))&&(a=a.substring(b[0].length),b[0].replace(A,d),g=!1);g&&(b=a.indexOf("<"),g=0>b?a:a.substring(0,b),a=0>b?"":a.substring(b),e.chars&&e.chars(r(g)))}if(a==l)throw L("badparse",a);l=a}c()}function r(a){if(!a)return"";var e=M.exec(a);a=e[1];var d=e[3];if(e=e[2])n.innerHTML=e.replace(/</g,"<"),e="textContent"in n?n.textContent:n.innerText;return a+e+d}function B(a){return a.replace(/&/g,
|
||||
"&").replace(N,function(a){return"&#"+a.charCodeAt(0)+";"}).replace(/</g,"<").replace(/>/g,">")}function s(a,e){var d=!1,c=h.bind(a,a.push);return{start:function(a,g,f){a=h.lowercase(a);!d&&x[a]&&(d=a);d||!0!==C[a]||(c("<"),c(a),h.forEach(g,function(d,f){var g=h.lowercase(f),k="img"===a&&"src"===g||"background"===g;!0!==O[g]||!0===D[g]&&!e(d,k)||(c(" "),c(f),c('="'),c(B(d)),c('"'))}),c(f?"/>":">"))},end:function(a){a=h.lowercase(a);d||!0!==C[a]||(c("</"),c(a),c(">"));a==d&&(d=!1)},chars:function(a){d||
|
||||
c(B(a))}}}var L=h.$$minErr("$sanitize"),A=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,z=/^<\s*\/\s*([\w:-]+)[^>]*>/,G=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,K=/^</,J=/^<\s*\//,H=/\x3c!--(.*?)--\x3e/g,y=/<!DOCTYPE([^>]*?)>/i,I=/<!\[CDATA\[(.*?)]]\x3e/g,N=/([^\#-~| |!])/g,w=k("area,br,col,hr,img,wbr");p=k("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr");q=k("rp,rt");var v=h.extend({},q,p),t=h.extend({},p,k("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")),
|
||||
u=h.extend({},q,k("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")),x=k("script,style"),C=h.extend({},w,t,u,v),D=k("background,cite,href,longdesc,src,usemap"),O=h.extend({},D,k("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,target,title,type,valign,value,vspace,width")),
|
||||
n=document.createElement("pre"),M=/^(\s*)([\s\S]*?)(\s*)$/;h.module("ngSanitize",[]).provider("$sanitize",function(){this.$get=["$$sanitizeUri",function(a){return function(e){var d=[];F(e,s(d,function(c,b){return!/^unsafe/.test(a(c,b))}));return d.join("")}}]});h.module("ngSanitize").filter("linky",["$sanitize",function(a){var e=/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/,d=/^mailto:/;return function(c,b){function g(a){a&&m.push(E(a))}function f(a,c){m.push("<a ");h.isDefined(b)&&
|
||||
(m.push('target="'),m.push(b),m.push('" '));m.push('href="');m.push(a);m.push('">');g(c);m.push("</a>")}if(!c)return c;for(var l,k=c,m=[],n,p;l=k.match(e);)n=l[0],l[2]==l[3]&&(n="mailto:"+n),p=l.index,g(k.substr(0,p)),f(n,l[0].replace(d,"")),k=k.substring(p+l[0].length);g(k);return a(m.join(""))}}])})(window,window.angular);
|
12
docs-web/src/main/webapp/lib/angular-touch.js
vendored
Normal file
12
docs-web/src/main/webapp/lib/angular-touch.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
AngularJS v1.2.8
|
||||
(c) 2010-2014 Google, Inc. http://angularjs.org
|
||||
License: MIT
|
||||
*/
|
||||
(function(y,v,z){'use strict';function t(g,a,b){q.directive(g,["$parse","$swipe",function(l,n){var r=75,h=0.3,d=30;return function(p,m,k){function e(e){if(!u)return!1;var c=Math.abs(e.y-u.y);e=(e.x-u.x)*a;return f&&c<r&&0<e&&e>d&&c/e<h}var c=l(k[g]),u,f;n.bind(m,{start:function(e,c){u=e;f=!0},cancel:function(e){f=!1},end:function(a,f){e(a)&&p.$apply(function(){m.triggerHandler(b);c(p,{$event:f})})}})}}])}var q=v.module("ngTouch",[]);q.factory("$swipe",[function(){function g(a){var b=a.touches&&a.touches.length?
|
||||
a.touches:[a];a=a.changedTouches&&a.changedTouches[0]||a.originalEvent&&a.originalEvent.changedTouches&&a.originalEvent.changedTouches[0]||b[0].originalEvent||b[0];return{x:a.clientX,y:a.clientY}}return{bind:function(a,b){var l,n,r,h,d=!1;a.on("touchstart mousedown",function(a){r=g(a);d=!0;n=l=0;h=r;b.start&&b.start(r,a)});a.on("touchcancel",function(a){d=!1;b.cancel&&b.cancel(a)});a.on("touchmove mousemove",function(a){if(d&&r){var m=g(a);l+=Math.abs(m.x-h.x);n+=Math.abs(m.y-h.y);h=m;10>l&&10>n||
|
||||
(n>l?(d=!1,b.cancel&&b.cancel(a)):(a.preventDefault(),b.move&&b.move(m,a)))}});a.on("touchend mouseup",function(a){d&&(d=!1,b.end&&b.end(g(a),a))})}}}]);q.config(["$provide",function(g){g.decorator("ngClickDirective",["$delegate",function(a){a.shift();return a}])}]);q.directive("ngClick",["$parse","$timeout","$rootElement",function(g,a,b){function l(a,c,b){for(var f=0;f<a.length;f+=2)if(Math.abs(a[f]-c)<d&&Math.abs(a[f+1]-b)<d)return a.splice(f,f+2),!0;return!1}function n(a){if(!(Date.now()-m>h)){var c=
|
||||
a.touches&&a.touches.length?a.touches:[a],b=c[0].clientX,c=c[0].clientY;1>b&&1>c||l(k,b,c)||(a.stopPropagation(),a.preventDefault(),a.target&&a.target.blur())}}function r(b){b=b.touches&&b.touches.length?b.touches:[b];var c=b[0].clientX,d=b[0].clientY;k.push(c,d);a(function(){for(var a=0;a<k.length;a+=2)if(k[a]==c&&k[a+1]==d){k.splice(a,a+2);break}},h,!1)}var h=2500,d=25,p="ng-click-active",m,k;return function(a,c,d){function f(){q=!1;c.removeClass(p)}var h=g(d.ngClick),q=!1,s,t,w,x;c.on("touchstart",
|
||||
function(a){q=!0;s=a.target?a.target:a.srcElement;3==s.nodeType&&(s=s.parentNode);c.addClass(p);t=Date.now();a=a.touches&&a.touches.length?a.touches:[a];a=a[0].originalEvent||a[0];w=a.clientX;x=a.clientY});c.on("touchmove",function(a){f()});c.on("touchcancel",function(a){f()});c.on("touchend",function(a){var h=Date.now()-t,e=a.changedTouches&&a.changedTouches.length?a.changedTouches:a.touches&&a.touches.length?a.touches:[a],g=e[0].originalEvent||e[0],e=g.clientX,g=g.clientY,p=Math.sqrt(Math.pow(e-
|
||||
w,2)+Math.pow(g-x,2));q&&(750>h&&12>p)&&(k||(b[0].addEventListener("click",n,!0),b[0].addEventListener("touchstart",r,!0),k=[]),m=Date.now(),l(k,e,g),s&&s.blur(),v.isDefined(d.disabled)&&!1!==d.disabled||c.triggerHandler("click",[a]));f()});c.onclick=function(a){};c.on("click",function(b,c){a.$apply(function(){h(a,{$event:c||b})})});c.on("mousedown",function(a){c.addClass(p)});c.on("mousemove mouseup",function(a){c.removeClass(p)})}}]);t("ngSwipeLeft",-1,"swipeleft");t("ngSwipeRight",1,"swiperight")})(window,
|
||||
window.angular);
|
20754
docs-web/src/main/webapp/lib/angular.js
vendored
20754
docs-web/src/main/webapp/lib/angular.js
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -42,7 +42,7 @@
|
||||
</table>
|
||||
|
||||
<div class="text-center">
|
||||
<pagination num-pages="numPages" max-size="5" current-page="currentPage"></pagination>
|
||||
<pagination total-items="totalDocuments" max-size="5" page="currentPage"></pagination>
|
||||
</div>
|
||||
|
||||
<div class="text-right">
|
||||
|
@ -20,6 +20,8 @@
|
||||
<script src="lib/less.js" type="text/javascript"></script>
|
||||
<script src="lib/underscore.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.js" type="text/javascript"></script>
|
||||
<script src="lib/angular-sanitize.js" type="text/javascript"></script>
|
||||
<script src="lib/angular-touch.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-router.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-bootstrap.js" type="text/javascript"></script>
|
||||
<script src="lib/angular.ui-utils.js" type="text/javascript"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user