diff options
Diffstat (limited to 'src/main/resources/webapp')
7 files changed, 395 insertions, 7 deletions
diff --git a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx index edb00d7..7121fe1 100755 --- a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx +++ b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx @@ -24,11 +24,12 @@ <script type="text/javascript"> head.js( {jquery: "/external/jquery-1.8.3/jquery-1.8.3.js"}, - {angularjs: "/external/angular-1.0.3/angular.js"}, - {angularjsResource: "/external/angular-1.0.3/angular-resource.js"}, - {angularUiNgGrid: "/external/angular-ui/ng-grid-1.6.0/ng-grid-1.6.0.debug.js"}, + {angular: "/external/angular-1.0.3/angular.js"}, + {angularResource: "/external/angular-1.0.3/angular-resource.js"}, + {ngGrid: "/external/angular-ui/ng-grid-1.6.0/ng-grid-1.6.0.debug.js"}, {underscore: "/external/underscore-1.4.3/underscore.js"}, {datejs: "/external/datejs-Alpha1/date.js"}, + {spin: "/external/spin-1.2.7/spin.js"}, {app: "/apps/app.js"}, {PagingTableService: "/apps/core/PagingTableService.js"} ); diff --git a/src/main/resources/webapp/apps/app.js b/src/main/resources/webapp/apps/app.js index f74206c..8896d33 100755 --- a/src/main/resources/webapp/apps/app.js +++ b/src/main/resources/webapp/apps/app.js @@ -107,3 +107,31 @@ directives.directive('dogtagxl', function () { templateUrl: '/apps/dogtagBig.html' } }); + +directives.directive('spinner', function () { + return function($scope, element, attr) { + var opts = { + lines: 13, // The number of lines to draw + length: 7, // The length of each line + width: 4, // The line thickness + radius: 10, // The radius of the inner circle + corners: 1, // Corner roundness (0..1) + rotate: 0, // The rotation offset + color: '#000', // #rgb or #rrggbb + speed: 1, // Rounds per second + trail: 60, // Afterglow percentage + shadow: false, // Whether to render a shadow + hwaccel: false, // Whether to use hardware acceleration + className: attr.spinnerClass || 'spinner', // The CSS class to assign to the spinner + zIndex: 2e9, // The z-index (defaults to 2000000000) + top: attr.spinnerTop || 'auto', // Top position relative to parent in px + left: attr.spinnerLeft || 'auto' // Left position relative to parent in px + }; + + console.log("attr.spinnerTop =", attr.spinnerTop, "attr.spinnerLeft =", attr.spinnerLeft); + + var target = element[0]; + new Spinner(opts).spin(target); + return target; + } +}); diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js index f38b6f1..86d08f1 100755 --- a/src/main/resources/webapp/apps/core/PagingTableService.js +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -7,15 +7,29 @@ function PagingTableService() { query: "", startIndex: options.startIndex || 0, count: options.count || 10, - currentlySearching: false + currentlySearching: false, + queryStart: 0 }; var update = function(){ self.currentlySearching = true; + self.queryStart = new Date().getTime(); + + // This will update the spinner if the user want to show it. + var interval = setInterval(function () { + $scope.$apply(); + }, 500); + fetchCallback(self.startIndex, self.count, self.query, function(data) { + var now = new Date().getTime(); + console.log("Query took " + (now - self.queryStart) + "ms"); + + clearInterval(interval); + self.rows = data.rows; watcher(); self.currentlySearching = false; + self.queryStart = 0; }); }; @@ -56,6 +70,20 @@ function PagingTableService() { update(); }; + /* + * UI State queries + * + * TODO: the results should only be shown if the last query was successful. Add an 'error' state too. + */ + + self.showSpinner = function () { + return self.currentlySearching && new Date().getTime() - self.queryStart > 500; + }; + + self.showResults = function () { + return !self.currentlySearching; + }; + self.showPrev = function () { return self.startIndex > 0; }; diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index 9e507b4..def1e67 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -71,13 +71,13 @@ function BadgeCtrl($scope, $routeParams, Badge) { } function PersonListCtrl($scope, Person, PagingTableService) { - var groupSize = 4; + var groupSize = 4, rows = 6; var personsWatcher = function () { $scope.personGroups = groupBy($scope.persons.rows, groupSize); }; $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), - {count: groupSize * 6, watcher: personsWatcher}); + {count: groupSize * rows, watcher: personsWatcher}); console.log("$scope.persons.searchText", $scope.persons.searchText); console.log("$scope.persons.rows", $scope.persons.rows); diff --git a/src/main/resources/webapp/apps/frontPageApp/personList.html b/src/main/resources/webapp/apps/frontPageApp/personList.html index 2c14b01..9f977ee 100755 --- a/src/main/resources/webapp/apps/frontPageApp/personList.html +++ b/src/main/resources/webapp/apps/frontPageApp/personList.html @@ -33,7 +33,15 @@ <div class="row"> <div class="span12"> - <div class="row" ng-repeat="group in personGroups"> + <div class="row" ng-show="persons.showSpinner()"> + <div class="span12"> + <div style="height: 100px"> + <div spinner spinner-class="wat" spinner-left="564px" spinner-top="50%"></div> + </div> + </div> + </div> + + <div class="row" ng-repeat="group in personGroups" ng-show="persons.showResults()"> <div class="span3" ng-repeat="person in group" style="padding-bottom: 1em"> <div class="row"> <person-avatar person="person.person"></person-avatar> @@ -45,6 +53,7 @@ </div> </div> </div> + <ul class="pager"> <li ng-show="persons.showPrev()" class="previous {{{true: 'disabled', false: ''}[persons.prevDisabled()]}}"> <a ng-click="persons.prev()">← Prev</a> diff --git a/src/main/resources/webapp/external/spin-1.2.7/spin.js b/src/main/resources/webapp/external/spin-1.2.7/spin.js new file mode 100644 index 0000000..64ccfa7 --- /dev/null +++ b/src/main/resources/webapp/external/spin-1.2.7/spin.js @@ -0,0 +1,320 @@ +//fgnass.github.com/spin.js#v1.2.7 +!function(window, document, undefined) { + + /** + * Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de] + * Licensed under the MIT license + */ + + var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */ + , animations = {} /* Animation rules keyed by their name */ + , useCssAnimations + + /** + * Utility function to create elements. If no tag name is given, + * a DIV is created. Optionally properties can be passed. + */ + function createEl(tag, prop) { + var el = document.createElement(tag || 'div') + , n + + for(n in prop) el[n] = prop[n] + return el + } + + /** + * Appends children and returns the parent. + */ + function ins(parent /* child1, child2, ...*/) { + for (var i=1, n=arguments.length; i<n; i++) + parent.appendChild(arguments[i]) + + return parent + } + + /** + * Insert a new stylesheet to hold the @keyframe or VML rules. + */ + var sheet = function() { + var el = createEl('style', {type : 'text/css'}) + ins(document.getElementsByTagName('head')[0], el) + return el.sheet || el.styleSheet + }() + + /** + * Creates an opacity keyframe animation rule and returns its name. + * Since most mobile Webkits have timing issues with animation-delay, + * we create separate rules for each line/segment. + */ + function addAnimation(alpha, trail, i, lines) { + var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-') + , start = 0.01 + i/lines*100 + , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha) + , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase() + , pre = prefix && '-'+prefix+'-' || '' + + if (!animations[name]) { + sheet.insertRule( + '@' + pre + 'keyframes ' + name + '{' + + '0%{opacity:' + z + '}' + + start + '%{opacity:' + alpha + '}' + + (start+0.01) + '%{opacity:1}' + + (start+trail) % 100 + '%{opacity:' + alpha + '}' + + '100%{opacity:' + z + '}' + + '}', sheet.cssRules.length) + + animations[name] = 1 + } + return name + } + + /** + * Tries various vendor prefixes and returns the first supported property. + **/ + function vendor(el, prop) { + var s = el.style + , pp + , i + + if(s[prop] !== undefined) return prop + prop = prop.charAt(0).toUpperCase() + prop.slice(1) + for(i=0; i<prefixes.length; i++) { + pp = prefixes[i]+prop + if(s[pp] !== undefined) return pp + } + } + + /** + * Sets multiple style properties at once. + */ + function css(el, prop) { + for (var n in prop) + el.style[vendor(el, n)||n] = prop[n] + + return el + } + + /** + * Fills in default values. + */ + function merge(obj) { + for (var i=1; i < arguments.length; i++) { + var def = arguments[i] + for (var n in def) + if (obj[n] === undefined) obj[n] = def[n] + } + return obj + } + + /** + * Returns the absolute page-offset of the given element. + */ + function pos(el) { + var o = { x:el.offsetLeft, y:el.offsetTop } + while((el = el.offsetParent)) + o.x+=el.offsetLeft, o.y+=el.offsetTop + + return o + } + + var defaults = { + lines: 12, // The number of lines to draw + length: 7, // The length of each line + width: 5, // The line thickness + radius: 10, // The radius of the inner circle + rotate: 0, // Rotation offset + corners: 1, // Roundness (0..1) + color: '#000', // #rgb or #rrggbb + speed: 1, // Rounds per second + trail: 100, // Afterglow percentage + opacity: 1/4, // Opacity of the lines + fps: 20, // Frames per second when using setTimeout() + zIndex: 2e9, // Use a high z-index by default + className: 'spinner', // CSS class to assign to the element + top: 'auto', // center vertically + left: 'auto', // center horizontally + position: 'relative' // element position + } + + /** The constructor */ + var Spinner = function Spinner(o) { + if (!this.spin) return new Spinner(o) + this.opts = merge(o || {}, Spinner.defaults, defaults) + } + + Spinner.defaults = {} + + merge(Spinner.prototype, { + spin: function(target) { + this.stop() + var self = this + , o = self.opts + , el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex}) + , mid = o.radius+o.length+o.width + , ep // element position + , tp // target position + + if (target) { + target.insertBefore(el, target.firstChild||null) + tp = pos(target) + ep = pos(el) + css(el, { + left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px', + top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px' + }) + } + + el.setAttribute('aria-role', 'progressbar') + self.lines(el, self.opts) + + if (!useCssAnimations) { + // No CSS animation support, use setTimeout() instead + var i = 0 + , fps = o.fps + , f = fps/o.speed + , ostep = (1-o.opacity) / (f*o.trail / 100) + , astep = f/o.lines + + ;(function anim() { + i++; + for (var s=o.lines; s; s--) { + var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity) + self.opacity(el, o.lines-s, alpha, o) + } + self.timeout = self.el && setTimeout(anim, ~~(1000/fps)) + })() + } + return self + }, + + stop: function() { + var el = this.el + if (el) { + clearTimeout(this.timeout) + if (el.parentNode) el.parentNode.removeChild(el) + this.el = undefined + } + return this + }, + + lines: function(el, o) { + var i = 0 + , seg + + function fill(color, shadow) { + return css(createEl(), { + position: 'absolute', + width: (o.length+o.width) + 'px', + height: o.width + 'px', + background: color, + boxShadow: shadow, + transformOrigin: 'left', + transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)', + borderRadius: (o.corners * o.width>>1) + 'px' + }) + } + + for (; i < o.lines; i++) { + seg = css(createEl(), { + position: 'absolute', + top: 1+~(o.width/2) + 'px', + transform: o.hwaccel ? 'translate3d(0,0,0)' : '', + opacity: o.opacity, + animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite' + }) + + if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'})) + + ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)'))) + } + return el + }, + + opacity: function(el, i, val) { + if (i < el.childNodes.length) el.childNodes[i].style.opacity = val + } + + }) + + ///////////////////////////////////////////////////////////////////////// + // VML rendering for IE + ///////////////////////////////////////////////////////////////////////// + + /** + * Check and init VML support + */ + ;(function() { + + function vml(tag, attr) { + return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr) + } + + var s = css(createEl('group'), {behavior: 'url(#default#VML)'}) + + if (!vendor(s, 'transform') && s.adj) { + + // VML support detected. Insert CSS rule ... + sheet.addRule('.spin-vml', 'behavior:url(#default#VML)') + + Spinner.prototype.lines = function(el, o) { + var r = o.length+o.width + , s = 2*r + + function grp() { + return css( + vml('group', { + coordsize: s + ' ' + s, + coordorigin: -r + ' ' + -r + }), + { width: s, height: s } + ) + } + + var margin = -(o.width+o.length)*2 + 'px' + , g = css(grp(), {position: 'absolute', top: margin, left: margin}) + , i + + function seg(i, dx, filter) { + ins(g, + ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}), + ins(css(vml('roundrect', {arcsize: o.corners}), { + width: r, + height: o.width, + left: o.radius, + top: -o.width>>1, + filter: filter + }), + vml('fill', {color: o.color, opacity: o.opacity}), + vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change + ) + ) + ) + } + + if (o.shadow) + for (i = 1; i <= o.lines; i++) + seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)') + + for (i = 1; i <= o.lines; i++) seg(i) + return ins(el, g) + } + + Spinner.prototype.opacity = function(el, i, val, o) { + var c = el.firstChild + o = o.shadow && o.lines || 0 + if (c && i+o < c.childNodes.length) { + c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild + if (c) c.opacity = val + } + } + } + else + useCssAnimations = vendor(s, 'animation') + })() + + if (typeof define == 'function' && define.amd) + define(function() { return Spinner }) + else + window.Spinner = Spinner + +}(window, document); diff --git a/src/main/resources/webapp/external/spin-1.2.7/spin.min.js b/src/main/resources/webapp/external/spin-1.2.7/spin.min.js new file mode 100644 index 0000000..942980c --- /dev/null +++ b/src/main/resources/webapp/external/spin-1.2.7/spin.min.js @@ -0,0 +1,2 @@ +//fgnass.github.com/spin.js#v1.2.7 +!function(e,t,n){function o(e,n){var r=t.createElement(e||"div"),i;for(i in n)r[i]=n[i];return r}function u(e){for(var t=1,n=arguments.length;t<n;t++)e.appendChild(arguments[t]);return e}function f(e,t,n,r){var o=["opacity",t,~~(e*100),n,r].join("-"),u=.01+n/r*100,f=Math.max(1-(1-e)/t*(100-u),e),l=s.substring(0,s.indexOf("Animation")).toLowerCase(),c=l&&"-"+l+"-"||"";return i[o]||(a.insertRule("@"+c+"keyframes "+o+"{"+"0%{opacity:"+f+"}"+u+"%{opacity:"+e+"}"+(u+.01)+"%{opacity:1}"+(u+t)%100+"%{opacity:"+e+"}"+"100%{opacity:"+f+"}"+"}",a.cssRules.length),i[o]=1),o}function l(e,t){var i=e.style,s,o;if(i[t]!==n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(o=0;o<r.length;o++){s=r[o]+t;if(i[s]!==n)return s}}function c(e,t){for(var n in t)e.style[l(e,n)||n]=t[n];return e}function h(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]===n&&(e[i]=r[i])}return e}function p(e){var t={x:e.offsetLeft,y:e.offsetTop};while(e=e.offsetParent)t.x+=e.offsetLeft,t.y+=e.offsetTop;return t}var r=["webkit","Moz","ms","O"],i={},s,a=function(){var e=o("style",{type:"text/css"});return u(t.getElementsByTagName("head")[0],e),e.sheet||e.styleSheet}(),d={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"},v=function m(e){if(!this.spin)return new m(e);this.opts=h(e||{},m.defaults,d)};v.defaults={},h(v.prototype,{spin:function(e){this.stop();var t=this,n=t.opts,r=t.el=c(o(0,{className:n.className}),{position:n.position,width:0,zIndex:n.zIndex}),i=n.radius+n.length+n.width,u,a;e&&(e.insertBefore(r,e.firstChild||null),a=p(e),u=p(r),c(r,{left:(n.left=="auto"?a.x-u.x+(e.offsetWidth>>1):parseInt(n.left,10)+i)+"px",top:(n.top=="auto"?a.y-u.y+(e.offsetHeight>>1):parseInt(n.top,10)+i)+"px"})),r.setAttribute("aria-role","progressbar"),t.lines(r,t.opts);if(!s){var f=0,l=n.fps,h=l/n.speed,d=(1-n.opacity)/(h*n.trail/100),v=h/n.lines;(function m(){f++;for(var e=n.lines;e;e--){var i=Math.max(1-(f+e*v)%h*d,n.opacity);t.opacity(r,n.lines-e,i,n)}t.timeout=t.el&&setTimeout(m,~~(1e3/l))})()}return t},stop:function(){var e=this.el;return e&&(clearTimeout(this.timeout),e.parentNode&&e.parentNode.removeChild(e),this.el=n),this},lines:function(e,t){function i(e,r){return c(o(),{position:"absolute",width:t.length+t.width+"px",height:t.width+"px",background:e,boxShadow:r,transformOrigin:"left",transform:"rotate("+~~(360/t.lines*n+t.rotate)+"deg) translate("+t.radius+"px"+",0)",borderRadius:(t.corners*t.width>>1)+"px"})}var n=0,r;for(;n<t.lines;n++)r=c(o(),{position:"absolute",top:1+~(t.width/2)+"px",transform:t.hwaccel?"translate3d(0,0,0)":"",opacity:t.opacity,animation:s&&f(t.opacity,t.trail,n,t.lines)+" "+1/t.speed+"s linear infinite"}),t.shadow&&u(r,c(i("#000","0 0 4px #000"),{top:"2px"})),u(e,u(r,i(t.color,"0 0 1px rgba(0,0,0,.1)")));return e},opacity:function(e,t,n){t<e.childNodes.length&&(e.childNodes[t].style.opacity=n)}}),function(){function e(e,t){return o("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',t)}var t=c(o("group"),{behavior:"url(#default#VML)"});!l(t,"transform")&&t.adj?(a.addRule(".spin-vml","behavior:url(#default#VML)"),v.prototype.lines=function(t,n){function s(){return c(e("group",{coordsize:i+" "+i,coordorigin:-r+" "+ -r}),{width:i,height:i})}function l(t,i,o){u(a,u(c(s(),{rotation:360/n.lines*t+"deg",left:~~i}),u(c(e("roundrect",{arcsize:n.corners}),{width:r,height:n.width,left:n.radius,top:-n.width>>1,filter:o}),e("fill",{color:n.color,opacity:n.opacity}),e("stroke",{opacity:0}))))}var r=n.length+n.width,i=2*r,o=-(n.width+n.length)*2+"px",a=c(s(),{position:"absolute",top:o,left:o}),f;if(n.shadow)for(f=1;f<=n.lines;f++)l(f,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(f=1;f<=n.lines;f++)l(f);return u(t,a)},v.prototype.opacity=function(e,t,n,r){var i=e.firstChild;r=r.shadow&&r.lines||0,i&&t+r<i.childNodes.length&&(i=i.childNodes[t+r],i=i&&i.firstChild,i=i&&i.firstChild,i&&(i.opacity=n))}):s=l(t,"animation")}(),typeof define=="function"&&define.amd?define(function(){return v}):e.Spinner=v}(window,document);
\ No newline at end of file |