Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module('pgCore', ['ngSanitize']);
- ;'use strict';
- angular.module('pgCore').factory('config', ['$http','$q', function($http, $q) {
- var configPromise;
- var config = {
- getConfig: function(){
- if(config.loaded) return $q.when(config);
- if(configPromise) return configPromise;
- configPromise = $http.get('./config.json').then(function(data){
- config.loaded = true;
- return _.extend(config, data.data);
- }).finally(function(){
- configPromise = null;
- });
- return configPromise;
- }
- };
- return config;
- }]);
- ;'use strict';
- angular.module('pgCore').factory('events', [function () {
- var events = {
- register: register
- };
- var eventApi = {
- 'loggedIn': 'triggers when the user has loggedin or on first load if the user is logged in',
- 'loggedOut': 'triggers when the user logs out',
- 'currentUserReady': 'when the current user is available',
- 'resize': 'when the window is resized',
- 'menuItemsAdded': 'when a menu item is added to the header menu',
- 'navItemsAdded': 'when a navigation item is added to the header menu',
- };
- createApi();
- function createApi() {
- for (var event in eventApi) {
- if (eventApi.hasOwnProperty(event)) {
- events[event] = apiConstructor();
- }
- }
- }
- function apiConstructor() {
- var callbackRegistry = {};
- return {
- trigger: function(params) {
- for (var id in callbackRegistry) {
- if (callbackRegistry.hasOwnProperty(id)) {
- callbackRegistry[id].apply(this, arguments);
- }
- }
- },
- on: function(on) {
- var id = _.uniqueId('EVENT');
- if (typeof on === 'function') {
- callbackRegistry[id] = on;
- return function() {
- return unregister(id);
- };
- } else {
- throw 'Must be a function passed to .on';
- }
- }
- };
- function unregister(id) {
- delete callbackRegistry[id];
- }
- }
- function register(registry, description){
- if(typeof registry == 'string'){
- eventApi[registry] = description;
- events[registry] = apiConstructor();
- }else if(typeof registry === 'object'){
- _.extend(eventApi, registry);
- for (var event in registry) {
- if (registry.hasOwnProperty(event) && !events.hasOwnProperty(event)) {
- events[event] = apiConstructor();
- }
- }
- }
- }
- window.onresize = function(){
- events.resize.trigger();
- };
- return events;
- }]);
- ;'use strict';
- angular.module('pgCore').factory('features', ['$http', '$q', function ($http, $q) {
- var featuresPromise;
- var features = {
- getFeatures: function () {
- if (features.loaded) return $q.when(features);
- if (featuresPromise) return featuresPromise;
- featuresPromise = $http.get('./features.json').then(function (data) {
- features.loaded = true;
- return _.extend(features, data.data);
- }).finally(function () {
- featuresPromise = null;
- });
- return featuresPromise;
- },
- on: function(featureName) {
- return !!features[featureName];
- }
- };
- return features;
- }]);
- ;'use strict';
- angular.module('pgCore').factory('helpers', [function() {
- var helpers ={
- getUID: function(){
- //UUID generator was taken form joint.js uuid generator to match cuurent style
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = Math.random() * 16|0;
- var v = c == 'x' ? r : (r&0x3|0x8);
- return v.toString(16);
- });
- },
- formatDate: function(date,increment){
- if (!date) return null;
- date = new Date(date);
- date = new Date(date.setDate(date.getDate()+(!!increment && parseInt(increment))));
- return (date.getMonth()+1)+'/'+date.getDate()+'/'+date.getFullYear();
- },
- b64toBlob: function(b64Data, contentType, sliceSize) {
- contentType = contentType || '';
- sliceSize = sliceSize || 512;
- var byteCharacters = atob(b64Data);
- var byteArrays = [];
- for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
- var slice = byteCharacters.slice(offset, offset + sliceSize);
- var byteNumbers = new Array(slice.length);
- for (var i = 0; i < slice.length; i++) {
- byteNumbers[i] = slice.charCodeAt(i);
- }
- var byteArray = new Uint8Array(byteNumbers);
- byteArrays.push(byteArray);
- }
- return new Blob(byteArrays, { type: contentType});
- },
- blob2file: function(blob, name){
- return _.extend(blob, { name: name, lastModified: new Date().getTime(), lastModifiedDate: new Date(), webkitRelativePath: '' });
- },
- b64toFile: function (b64Data, name, contentType, sliceSize){
- return helpers.blob2file(helpers.b64toBlob(b64Data, contentType, sliceSize) ,name)
- },
- refreshMap: function(obj,defaults){
- for (var prop in obj) { if (obj.hasOwnProperty(prop)) { delete obj[prop]; } };
- if(defaults) _.extend(obj,defaults);
- },
- getUniqueProp: function(arr,prop){
- return _.uniq(_.pluck(arr, prop));
- },
- getYoutubeUrlFromText: function (text) {
- var regex = /(http(s)?:\/\/)?(\w+\.)?(youtube\.com\/((watch\?v=(\S){11})|(embed\/(\S){11}))|youtu\.be\/(\S){11})/i
- var url = regex.exec(text);
- return url && url[0];
- },
- getYoutubeIdFromUrl: function (text) {
- var regexReplace = /(http(s)?:\/\/)?(\w+\.)?(youtube\.com\/((watch\?v=)|(embed\/))|youtu\.be\/)/ig
- var url = helpers.getYoutubeUrlFromText(text);
- if (!url || !url.length) return null;
- return url.replace(regexReplace, '');
- }
- }
- return helpers
- }]);
- ;'use strict';
- angular.module('pgCore').factory('i18n', ['$rootScope', '$route', '$http', '$q', '$location', function ($rootScope, $route, $http, $q, $location) {
- var promise;
- var i18n = {};
- var locale = ($route.current.params.lang && $route.current.params.lang.toLowerCase()) || 'en';
- var i18nFactory = {
- locale: locale,
- ready: function () {
- if (i18n.loaded) return $q.when(i18nFactory);
- if (promise) return promise;
- promise = $http.get('./lang/'+locale+'/common.json').then(function (data) {
- i18n.loaded = true;
- _.extend(i18n, data.data);
- return i18nFactory;
- }).catch(function(error){
- i18nFactory.locale = locale = 'en';
- console.error(error);
- return i18nFactory;
- }).finally(function () {
- // promise = null;
- });
- return promise;
- },
- get: function(key){
- return i18n[key];
- }
- };
- $rootScope.$on('$routeChangeStart', function(event,next,curr){
- if(curr && next && curr.params.lang !== next.params.lang){
- location.reload();
- }
- });
- return i18nFactory;
- }]);
- ;'use strict';
- angular.module('pgCore').factory('logger', ['$http', '$q', function ($http, $q) {
- var fakeConsole = {},
- registry = (localStorage.getItem('pgConsole') && JSON.parse(localStorage.getItem('pgConsole'))) || {},
- logger = {
- register: function (service) {
- if (registry[service]) {
- turnOn(service);
- } else {
- turnOff(service);
- }
- return logger[service];
- }
- };
- Object.keys(console).forEach(function (key) {
- fakeConsole[key] = function () { return; };
- })
- registry && registry.general ? turnOn() : turnOff();
- window.pgConsole = {
- on: turnOn,
- off: turnOff,
- isOn: function(service){
- if(service){
- return !!registry[service];
- }else{
- return !!registry.general;
- }
- },
- list: function(){
- return registry;
- }
- }
- function turnOn(service) {
- if(service && service !== 'all'){
- if (!logger[service]) logger[service] = {};
- Object.assign(logger[service], console);
- registry[service] = true;
- }else if(service && service === 'all'){
- Object.assign(logger, console);
- registry.all = true;
- Object.keys(registry).forEach(function(key){
- if (!logger[key]) logger[key] = {};
- Object.assign(logger[key], console);
- registry[key] = true;
- });
- }else{
- Object.assign(logger, console);
- registry.general = true;
- }
- localStorage.setItem('pgConsole', JSON.stringify(registry));
- }
- function turnOff(service){
- if (service && service !== 'all') {
- if (!logger[service]) logger[service] = {};
- Object.assign(logger[service], fakeConsole);
- registry[service] = false;
- } else if (service && service === 'all') {
- Object.assign(logger, fakeConsole);
- registry.all = false;
- Object.keys(registry).forEach(function (key) {
- if (!logger[key]) logger[key] = {};
- Object.assign(logger[key], fakeConsole);
- registry[key] = false;
- });
- } else {
- Object.assign(logger, fakeConsole);
- registry.general = false;
- }
- localStorage.setItem('pgConsole', JSON.stringify(registry));
- }
- return logger;
- }]);
- ;'use strict';
- angular.module('pgCore').factory('pgService', ['$http','$q','config', 'events','helpers', function($http, $q, config, events, helpers) {
- var apiUrl = apiUrl = config && config.apiUrl || '';
- var inactiveLimit = 5400000; // (90 MINS) will log you out if inactive for this long
- var token = localStorage.getItem('PG_Token');
- var tokenTimeout = parseInt(localStorage.getItem('PG_TokenTimeout'));
- var sessionTimeout = parseInt(localStorage.getItem('PG_SessionTimeout'));
- if(token){
- $http.defaults.headers.common['Authorization'] = token;
- }
- config.getConfig().then(function(){
- apiUrl = config && config.apiUrl || '';
- });
- var service = {
- //STORAGE
- currentUserRole: { id: null },
- currentUser: {},
- //APP HELPERS
- login: login,
- logout: logout,
- isLoggedIn: isLoggedIn,
- getApiUrl: getApiUrl,
- getAuthToken: getAuthToken,
- //USERS
- getCurrentUser: getCurrentUser,
- getCurrentUserRole: getCurrentUserRole,
- getUsers: getUsers,
- getUserById: getUserById,
- createUserGroup: createUserGroup,
- updateUserRole: updateUserRole,
- //MEETINGS
- getMeetingById: getMeetingById,
- getUpcomingMeetings: getUpcomingMeetings,
- getPreviousMeetings: getPreviousMeetings,
- getMeetingsByDateRange: getMeetingsByDateRange,
- getMeetingLite: getMeetingLite,
- getMeetingContents: getMeetingContents,
- getMeetingDetails: getMeetingDetails,
- getMeetingTemplate: getMeetingTemplate,
- getMeetingDocument: getMeetingDocument,
- getMeetingSections: getMeetingSections,
- getMeetingSectionItems: getMeetingSectionItems,
- getMeetingSectionMotions: getMeetingSectionMotions,
- getMeetingSectionMinutes: getMeetingSectionMinutes,
- getMeetingSectionActions: getMeetingSectionActions,
- getMeetingSectionNotes: getMeetingSectionNotes,
- getMeetingItemMotions: getMeetingItemMotions,
- getMeetingItemMinutes: getMeetingItemMinutes,
- getMeetingItemActions: getMeetingItemActions,
- getMeetingItemNotes: getMeetingItemNotes,
- getMeetingItemAttachments: getMeetingItemAttachments,
- getSystemItemAttachments: getSystemItemAttachments,
- getMeetingAttendees: getMeetingAttendees,
- getMeetingRoles: getMeetingRoles,
- getMeetingTypes: getMeetingTypes,
- getItemTypes: getItemTypes,
- getMotionTypes: getMotionTypes,
- getItemMotionById: getItemMotionById,
- getSectionMotionById: getSectionMotionById,
- getFormattedMotionTextbyType: getFormattedMotionTextbyType,
- getSectionFormattedMotionTextbyType: getSectionFormattedMotionTextbyType,
- getItemPublicSpeakers: getItemPublicSpeakers,
- createMeeting: createMeeting,
- createSection: createSection,
- createSystemItem: createSystemItem,
- createMeetingItem: createMeetingItem,
- createItemMotion: createItemMotion,
- createSectionMotion: createSectionMotion,
- createItemMinute: createItemMinute,
- createSectionMinute: createSectionMinute,
- createItemAction: createItemAction,
- createSectionAction: createSectionAction,
- createItemNote: createItemNote,
- createSectionNote: createSectionNote,
- createPublicSpeaker: createPublicSpeaker,
- addMeetingTypeAttendee: addMeetingTypeAttendee,
- addAdHocAttendee: addAdHocAttendee,
- updateMeeting: updateMeeting,
- updateMeetingAttendees: updateMeetingAttendees,
- deleteMeeting: deleteMeeting,
- deleteSection: deleteSection,
- deleteMeetingItem: deleteMeetingItem,
- deleteItemMinute: deleteItemMinute,
- deleteSectionMinute: deleteSectionMinute,
- deleteItemAction: deleteItemAction,
- deleteSectionAction: deleteSectionAction,
- deleteItemNote: deleteItemNote,
- deleteSectionNote: deleteSectionNote,
- deleteItemMotion: deleteItemMotion,
- deleteSectionMotion: deleteSectionMotion,
- deletePublicSpeaker: deletePublicSpeaker,
- deleteMeetingTypeUserRole: deleteMeetingTypeUserRole,
- activateSection: activateSection,
- activateItem: activateItem,
- sortItems: sortItems,
- sortSections: sortSections,
- compileAgenda: compileAgenda,
- publishAgenda: publishAgenda,
- meetingSearch: meetingSearch,
- //ATTACHMENTS
- getAttachmentViewerTemplates: getAttachmentViewerTemplates,
- getAttachmentViewerRedactionReasons: getAttachmentViewerRedactionReasons,
- getAttachmentViewerLanguageJson: getAttachmentViewerLanguageJson,
- getAttachmentViewerSearchJson: getAttachmentViewerSearchJson,
- getAttachmentViewerSessionId: getAttachmentViewerSessionId,
- getDownloadItemAttachment: getDownloadItemAttachment,
- getAttachmentDownloadUrl: getAttachmentDownloadUrl,
- getAttachmentPDFDownloadUrl: getAttachmentPDFDownloadUrl,
- uploadAttachment: uploadAttachment,
- loadAttachmentAnnotations: loadAttachmentAnnotations,
- saveAttachmentAnnotations: saveAttachmentAnnotations,
- //COMMITTEES
- getCommittees: getCommittees,
- getCommiteePositions: getCommiteePositions,
- //FORMS
- getFormById: getFormById,
- getFormsByType: getFormsByType,
- //DOCUMENTS
- getDocumentById: getDocumentById,
- getDocumentComments: getDocumentComments,
- getDocumentAttachments: getDocumentAttachments,
- getDocumentAttachmentDownloadUrl: getDocumentAttachmentDownloadUrl,
- downloadDocumentById: downloadDocumentById,
- addDocumentComment: addDocumentComment,
- updateDocumentComment: updateDocumentComment,
- uploadDocumentAttachment: uploadDocumentAttachment,
- convertDocumnetAttachmentToPdf: convertDocumnetAttachmentToPdf,
- deleteDocumentAttachment: deleteDocumentAttachment,
- //WORKFLOW AND TASKS
- getMyWorkflowTasks: getMyWorkflowTasks,
- getAllWorkflowTasks: getAllWorkflowTasks,
- getWorkflowTaskById: getWorkflowTaskById,
- getWorkflowTaskChoices: getWorkflowTaskChoices,
- completeTask: completeTask,
- //YOUTUBE
- youtubeAuthList: youtubeAuthList,
- youtubeAuthById: youtubeAuthById,
- //PUBLIC APIS
- getMeetingTypesPublic: getMeetingTypesPublic,
- getCommitteesPublic: getCommitteesPublic,
- meetingSearchPublic: meetingSearchPublic,
- getUpcomingMeetingsPublic: getUpcomingMeetingsPublic,
- getPreviousMeetingsPublic: getPreviousMeetingsPublic,
- getMeetingsByDateRangePublic: getMeetingsByDateRangePublic,
- getMeetingByDateAndTypePublic: getMeetingByDateAndTypePublic,
- getPublishedDownloadUrl: getPublishedDownloadUrl,
- getMeetingAgendaHtml: getMeetingAgendaHtml,
- getMeetingItemAttachmentsPublic: getMeetingItemAttachmentsPublic,
- getMeetingItemDocumentAttachmentsPublic: getMeetingItemDocumentAttachmentsPublic,
- getPdfDownloadUrlPublic: getPdfDownloadUrlPublic,
- getItemVideoLocationPublic: getItemVideoLocationPublic,
- createPublicSpeakerPublic: createPublicSpeakerPublic,
- getMeetingSectionItemsPublic: getMeetingSectionItemsPublic,
- submitFormPublic: submitFormPublic,
- };
- return service;
- /**
- * ********* APP HELPERS ***********************************************
- */
- function login(username, password) {
- return getAuthToken(username, password).then(function (token) {
- if(token){
- getCurrentUser();
- return {success: true};
- }
- if(!token) return {error:'Login failed'};
- }, function (error) {
- return {error: error}
- });
- }
- function logout(){
- localStorage.removeItem('PG_Token');
- localStorage.removeItem('PG_TokenTimeout');
- localStorage.removeItem('PG_UserName');
- localStorage.removeItem('PG_SessionTimeout');
- helpers.refreshMap(service.currentUser);
- events.loggedOut.trigger();
- return $q.when(false);
- }
- function isLoggedIn(){
- token = localStorage.getItem('PG_Token');
- tokenTimeout = parseInt(localStorage.getItem('PG_TokenTimeout'));
- sessionTimeout = parseInt(localStorage.getItem('PG_SessionTimeout'));
- return !!token && !!sessionTimeout && sessionTimeout > new Date().getTime() - inactiveLimit;
- }
- function getApiUrl(){
- if(apiUrl && apiUrl.length){
- return $q.when(apiUrl);
- }else{
- return config.getConfig().then(function () {
- return apiUrl = config && config.apiUrl || '';
- });
- }
- }
- /**
- * ********* USERS API ***********************************************
- */
- function getCurrentUser(){
- if(service.currentUser.id){
- return $q.when(service.currentUser);
- }else{
- return get('/api/user/getcurrent').then(function(data){
- if(data) data.role = service.currentUserRole;
- events.currentUserReady.trigger(data);
- return _.extend(service.currentUser, data);
- });
- }
- }
- function getCurrentUserRole(meetingTypeId) {
- return get('/api/meetingTypeUserRole/ListForCurrentUser?meetingTypeId=' + meetingTypeId);
- }
- function getUsers(){
- return get('/api/user/list');
- }
- function getUserById(id){
- return get('/api/user/get?userId='+id);
- }
- function createUserGroup(params){
- // params: users, name, description, id
- return post('/api/userGroup/post',params)
- }
- function updateUserRole(id, role){
- return post('/api/meetingTypeUserRole/updateUserRole?id=' + id + '&role=' + role);
- }
- /**
- * ********* MEETINGS API ***********************************************
- */
- function getMeetingById(id) {
- return get('/api/meeting/GetMeetingLite?Id=' + id)
- }
- function getUpcomingMeetings() {
- return get('/api/meeting/listupcoming');
- }
- function getPreviousMeetings() {
- return get('/api/meeting/listprevious');
- }
- function getMeetingsByDateRange(from, to) {
- return get('/api/meeting/search?from=' + from + '&to=' + to + '&_=' + new Date().getTime());
- }
- function getMeetingLite(id) {
- return get('/api/meeting/GetMeetingLite?Id=' + id);
- }
- function getMeetingContents(id) {
- return get('/api/meeting/GetMeetingContents/' + id);
- }
- //overloaded for legacy
- function getMeetingDetails(id){
- return get('/api/meeting/GetMeetingContents/'+id);
- }
- function getMeetingTemplate(id){
- return get('/api/meetingTemplate/list?meetingId='+id);
- }
- function getMeetingDocument(id) {
- return get('/api/compiledMeetingDocument/listForMeeting?meetingId=' + id);
- }
- function getMeetingSections(meeting) {
- return post('/api/meetingsectiontemplate/ListForPreMeetingWithFormatting', {
- id: meeting.id,
- numberingType: meeting.numberingType,
- numberPrefixCharacter: meeting.numberPrefixCharacter,
- numberTrailingCharacter: meeting.numberTrailingCharacter
- });
- }
- function getMeetingSectionItems(section, meetingId) {
- return post('/api/meetingitem/ListForPreMeetingBySection', {
- id: section.id,
- itemHtml: section.itemHtml,
- meetingId: meetingId,
- tabIndent: section.tabIndent,
- numberTrailingCharacter: section.numberTrailingCharacter,
- numberingContinuous: section.numberingContinuous,
- numberingType: section.numberingType,
- numberPrefixCharacter: section.numberPrefixCharacter
- });
- }
- function getMeetingSectionMotions(id) {
- return get('/api/meetingsectionmotion/GetSectionMotionsAndVotesWithFormatting?sectionId=' + id);
- }
- function getMeetingSectionMinutes(id) {
- return get('/api/meetingsectionminutes/GetSectionMinutesWithFormatting?sectionId=' + id);
- }
- function getMeetingSectionActions(id) {
- return get('/api/meetingsectionactions/GetSectionActionswithFormatting?sectionId=' + id);
- }
- function getMeetingSectionNotes(id) {
- return get('/api/meetingsectionnotes/list?itemid=' + id);
- }
- function getMeetingItemMotions(id) {
- return get('/api/meetingitemmotion/GetItemMotionsAndVotesWithFormatting?itemId=' + id);
- }
- function getMeetingItemMinutes(id) {
- return get('/api/meetingitemminutes/GetItemMinuteswithFormatting?itemId=' + id);
- }
- function getMeetingItemActions(id) {
- return get('/api/meetingitemactions/GetItemActionswithFormatting?itemId=' + id);
- }
- function getMeetingItemNotes(id) {
- return get('/api/meetingitemnotes/list?itemid=' + id);
- }
- function getMeetingItemAttachments(id) {
- return get('/api/meetingitemattachment/list?meetingitemid=' + id);
- }
- function getSystemItemAttachments(id) {
- return get('/api/systemitemattachment2/list?itemId=' + id)
- }
- function getMeetingAttendees(id) {
- return get('/api/meetingAttendee/list?meetingId=' + id);
- }
- function getMeetingRoles(meetingTypeId) {
- return get('/api/meetingTypeUserRole/list?meetingTypeId=' + meetingTypeId);
- }
- function getMeetingTypes() {
- return get('/api/meetingtype/list');
- }
- function getItemTypes() {
- return get('/api/systemitemtype/list');
- }
- function getMotionTypes() {
- return get('/api/motionType/List');
- }
- function getItemMotionById(motionId) {
- return get('/api/meetingitemmotion/get/' + motionId);
- }
- function getSectionMotionById(motionId) {
- return get('/api/meetingsectionmotion/get/' + motionId);
- }
- function getFormattedMotionTextbyType(motionTypeId, meetingItemId) {
- return get('/api/motionType/format/' + motionTypeId + '?meetingItemId=' + meetingItemId);
- }
- function getSectionFormattedMotionTextbyType(motionTypeId, meetingSectionId, meetingItemIds) {
- return post('/api/motionType/formatSection/' + motionTypeId + '?meetingSectionId=' + meetingSectionId, { meetingItemIds: meetingItemIds } );
- }
- function getItemPublicSpeakers(meetingId, itemId) {
- return get('/api/publicspeaker/listforitem?meetingid=' + meetingId + '&itemid=' + itemId);
- }
- function createMeeting(params){
- return post('/api/meeting/create', {}, {headers: {'Content-Type': 'application/x-www-form-urlencoded'}, params:params});
- }
- function createSection(params){
- return post('/api/meetingsectiontemplate/create', {}, {headers: {'Content-Type': 'application/x-www-form-urlencoded'}, params:params});
- }
- function createSystemItem(params){
- return post('/api/systemitem/post',params);
- }
- function createMeetingItem(params){
- return post('/api/meetingItem/post',params);
- }
- function createItemMotion(params){
- return post('/api/meetingitemmotion/postAndReturnFormatting', params);
- }
- function createSectionMotion(params){
- return post('/api/meetingsectionmotion/postAndReturnFormatting', params);
- }
- function createItemMinute(params){
- return post('/api/meetingitemminutes/post', params);
- }
- function createSectionMinute(params){
- return post('/api/meetingsectionminutes/post', params);
- }
- function createItemAction(params) {
- return post('/api/meetingitemactions/post', params);
- }
- function createSectionAction(params) {
- return post('/api/meetingsectionactions/post', params);
- }
- function createItemNote(params) {
- return post('/api/meetingitemnotes/post', params);
- }
- function createSectionNote(params) {
- return post('/api/meetingsectionnotes/post', params);
- }
- function createPublicSpeaker(params) {
- return post('/api/publicspeaker/post', params);
- }
- function addMeetingTypeAttendee(params){
- return post('/api/meetingTypeUserRole/post', params);
- }
- function addAdHocAttendee(params) {
- return post('/api/MeetingAttendee/AddAdHocAttendee', params);
- }
- function updateMeeting(params){
- return post('/api/meeting/post', params);
- }
- function updateMeetingAttendees(params) {
- return post('/api/meetingAttendee/post', params)
- }
- function deleteMeeting(id){
- return post('/api/meeting/delete/'+id);
- }
- function deleteSection(id){
- return post('/api/meetingsectiontemplate/delete/'+id);
- }
- function deleteMeetingItem(params){
- return post('/api/meetingitem/remove',{}, {headers: {'Content-Type': 'application/x-www-form-urlencoded'}, params:params})
- }
- function deleteItemMinute(id) {
- return post('/api/meetingitemminutes/delete/' + id);
- }
- function deleteSectionMinute(id) {
- return post('/api/meetingsectionminutes/delete/' + id);
- }
- function deleteItemAction(id) {
- return post('/api/meetingitemactions/delete/' + id);
- }
- function deleteSectionAction(id) {
- return post('/api/meetingsectionactions/delete/' + id);
- }
- function deleteSectionNote(id) {
- return post('/api/meetingsectionnotes/delete/' + id)
- }
- function deleteItemNote(id) {
- return post('/api/meetingitemnotes/delete/' + id)
- }
- function deleteItemMotion(id) {
- return post('/api/meetingitemmotion/delete/' + id);
- }
- function deleteSectionMotion(id) {
- return post('/api/meetingsectionmotion/deletemotion/' + id);
- }
- function deletePublicSpeaker(id) {
- return post('/api/publicspeaker/delete?id=' + id);
- }
- function deleteMeetingTypeUserRole(id){
- return post('/api/meetingTypeUserRole/delete/'+id)
- }
- function activateSection(id) {
- return post('/api/meetingSection/activateSection/' + id);
- }
- function activateItem(id) {
- return post('/api/meetingItem/activate/' + id);
- }
- function sortItems(params) {
- return post('/api/meetingitem/sort', {}, { params: params });
- }
- function sortSections(params) {
- return post('/api/meetingsectiontemplate/sort', {}, { params: params });
- }
- function compileAgenda(params){
- return post('/api/meeting/compile',params);
- }
- function publishAgenda(id){
- return post('/api/compiledMeetingDocument/publish/'+id,{publish:1})
- }
- function meetingSearch(params){
- return get('/api/meeting/search',{params:params});
- }
- /**
- * ********* ATTACHMENTS API ***********************************************
- */
- function getAttachmentViewerTemplates() {
- return get('/api/accusoftviewer/gettemplates');
- }
- function getAttachmentViewerRedactionReasons() {
- return get('/api/accusoftviewer/getredactonreasons');
- }
- function getAttachmentViewerLanguageJson() {
- return get('/api/accusoftviewer/getlanguagejson');
- }
- function getAttachmentViewerSearchJson() {
- return get('/api/accusoftviewer/GetSearchJson');
- }
- function getAttachmentViewerSessionId(name) {
- return post('/api/AccusoftViewer/GetSessionId?documentName=' + name + '.pdf');
- }
- function getDownloadItemAttachment(attachmentId) {
- return get('/api/systemItemAttachment2/DownloadItemAttachment?id=' + attachmentId);
- }
- function getAttachmentDownloadUrl(id) {
- return get('/api/systemitemattachment/getdownloadurl/' + id);
- }
- function getAttachmentPDFDownloadUrl(id) {
- return get('/api/systemitemattachment/getdownloadurlforpdf/' + id);
- }
- function uploadAttachment(file, itemId) {
- var deffered = $q.defer();
- var flow = new Flow({ target: apiUrl + '/api/systemitemattachment/upload', query: { systemItemId: itemId }, testChunks: false, headers: { Authorization: token } });
- flow.on('complete', deffered.resolve);
- flow.addFile(file);
- flow.upload();
- return deffered.promise;
- }
- function loadAttachmentAnnotations(docId, userId, id, type) {
- return get('/api/accusoftviewer/loadannotations/q?SessionID=u' + docId + '&username=' + userId + '&id=' + id + '&type=' + type)
- }
- function saveAttachmentAnnotations(docId, userId, id, type, params) {
- return post('/api/accusoftviewer/saveannotations/q?SessionID=u' + docId + '&username=' + userId + '&id=' + id + '&type=' + type, params)
- }
- /**
- * ********* COMMITEES API ***********************************************
- */
- function getCommittees(){
- return post('/api/committee/list');
- }
- function getCommiteePositions(id, date) {
- return get('/api/committeeposition/listfordate?committeeId=' + id + '&date=' + date);
- }
- /**
- * ********* FORMS API ***********************************************
- */
- function getFormById(formId) {
- return get('/api/formInstance/get/' + formId)
- }
- function getFormsByType(typeId, archived){
- return get('/api/formInstance/listForDefinition/?id='+typeId+'&getArchived='+!!archived) ;
- }
- /**
- * ********* DOCUMENTS API ***********************************************
- */
- function getDocumentById(docId){
- return get('/api/systemdocument/get?id='+docId);
- }
- function getDocumentComments(docId){
- return get('/api/systemdocumentcomment/list?id='+docId)
- }
- function getDocumentAttachments(docId){
- return get('/api/systemdocumentattachment/list/'+docId);
- }
- function getDocumentAttachmentDownloadUrl(id){
- return get('/api/systemdocumentattachment/getdownloadurl/'+id);
- }
- function getDocumentsByType(id){
- return get('api/systemDocument/ListByDocumentType/'+id);
- }
- function searchDocuments(term){
- return get('/api/systemdocument/search/?searchTerm='+term);
- }
- function downloadDocumentById(docId){
- return get('/api/systemdocument/DownloadSystemDocument?id='+docId);
- }
- function addDocumentComment(docId, text, type){
- return post('/api/systemdocumentcomment/post', { Id: 0, CommentById: 0, SystemDocumentId: docId, Comment: text, Type: type || 0 })
- }
- function updateDocumentComment(commentId, userId, docId, text, type) {
- return post('/api/systemdocumentcomment/post', { Id: commentId, CommentById:userId || 0, SystemDocumentId: docId, Comment: text, Type: type || 0 })
- }
- function uploadDocumentAttachment(file, docId) {
- var deffered = $q.defer();
- var flow = new Flow({ target: apiUrl + '/api/systemdocumentattachment/upload', query: { systemDocumentId: docId }, testChunks: false, headers:{ Authorization : token} });
- flow.on('fileSuccess', function(file ,id){
- deffered.resolve({file:file, id:id});
- });
- flow.addFile(file);
- flow.upload();
- return deffered.promise;
- }
- function convertDocumnetAttachmentToPdf(id){
- return post('/api/systemdocumentattachment/converttopdf?Id='+id)
- }
- function deleteDocumentAttachment(id){
- return post('/api/systemdocumentattachment/delete?Id='+id);
- }
- /**
- * ********* WORKFLOW AND TASKS API ***********************************************
- */
- function getMyWorkflowTasks(completed) {
- return get('/api/workflow_Task/listActive?completed=' + !!completed + '&showAll=false');
- }
- function getAllWorkflowTasks(completed) {
- return get('/api/workflow_Task/listActive?completed='+!!completed+'&showAll=true');
- }
- function getWorkflowTaskById(id){
- return get('/api/workflow_Task/get/'+id);
- }
- function getWorkflowTaskChoices(id){
- return get('/api/workflow_Task/getTaskChoices/'+id);
- }
- function completeTask(params){
- // params: id, choice, comments
- return post('/api/workflow_Task/completeTask', params)
- }
- /**
- * ******** YOUTUBE API ***************************************************
- */
- function youtubeAuthList(){
- return get('/api/youtubeauth/list');
- }
- function youtubeAuthById(id){
- return get('/api/youtubeauth/get?id='+id);
- }
- /**
- * ******** PUBLIC API ***************************************************
- */
- function getMeetingTypesPublic() {
- return publicGet('/api/meetingtype/list');
- }
- function getCommitteesPublic() {
- return publicPost('/api/committee/list');
- }
- function meetingSearchPublic(params) {
- return publicGet('/api/meeting/search', { params: params });
- }
- function getUpcomingMeetingsPublic() {
- return publicGet('/api/meeting/search?from=' + helpers.formatDate(new Date()) + '&to=' + helpers.formatDate(new Date(),180) + '&_=' + new Date().getTime());
- }
- function getPreviousMeetingsPublic() {
- return publicGet('/api/meeting/search?from=' + helpers.formatDate(new Date()) + '&to=' + helpers.formatDate(new Date(), -180) + '&_=' + new Date().getTime());
- }
- function getMeetingsByDateRangePublic(from, to) {
- return publicGet('/api/meeting/search?from=' + helpers.formatDate(from) + '&to=' + helpers.formatDate(to) + '&_=' + new Date().getTime());
- }
- function getMeetingByDateAndTypePublic(date,typeId) {
- return publicGet('/api/meeting/search?from=' + helpers.formatDate(date) + '&to=' + helpers.formatDate(date, 1) + '&meetingTypeId='+ typeId +'&_=' + new Date().getTime());
- }
- function getPublishedDownloadUrl(id){
- return publicGet('/api/compiledMeetingDocument/getpublisheddownloadurl/'+id);
- }
- function getMeetingAgendaHtml(meetingId, templateId){
- return publicGet('/api/portal/getMeetingBodyHtml?meetingId='+ meetingId +'&templateId='+ templateId);
- }
- function getMeetingItemAttachmentsPublic(itemId){
- return publicGet('/api/meetingitemattachment/ListPublic?meetingItemId='+itemId);
- }
- function getMeetingItemDocumentAttachmentsPublic(itemId) {
- return publicGet('/api/meetingitemattachment/listDocumentAttachmentsPublic?meetingItemId=' + itemId);
- }
- function getPdfDownloadUrlPublic(id){
- return publicGet('/api/meetingitemattachment/GetPublicPdfDownloadUrl/' + id)
- }
- function getItemVideoLocationPublic(itemId){
- return publicGet('/api/meetingitem/getVideoLocation/' + itemId);
- }
- function createPublicSpeakerPublic(params) {
- return publicPost('/api/publicspeaker/post', params);
- }
- function getMeetingSectionItemsPublic(sectionId, meetingId) {
- return publicPost('/api/meetingitem/ListForPreMeetingBySection', {
- id: sectionId,
- meetingId: meetingId
- });
- }
- function submitFormPublic(form /* html element */){
- var formData = new FormData(form);
- return publicPost('/api/formInstance/postPublic', formData, { headers: { 'Content-Type': undefined } });
- }
- /** PRIVATE FUNCTIONS *********************************************************************/
- function get(url, params){
- return getAuthToken().then(function(token){
- if(token){
- setSessionActivity();
- return $http.get(apiUrl + url, params).then(function(result){
- return result.data;
- });
- }else{
- console.log('session has expired');
- return logout();
- }
- });
- }
- function post(url, params, options){
- return getAuthToken().then(function(token){
- if(token){
- setSessionActivity();
- return $http.post(apiUrl + url, params, options).then(function(result){
- return result.data;
- });
- }else{
- console.log('session has expired');
- return logout();
- }
- });
- }
- function publicGet(url, params) {
- return $http.get(apiUrl + url, params).then(function (result) {
- return result.data;
- });
- }
- function publicPost(url, params, options) {
- return $http.post(apiUrl + url, params, options).then(function (result) {
- return result.data;
- });
- }
- function getAuthToken(un, pw){
- if(isLoggedIn()) return $q.when(token);
- if(!un || !pw) return $q.when(false);
- return $http.post(apiUrl + '/token', $.param({userName: un, password: pw, grant_type: 'password'})).then(function(result){
- if(result.data && result.data.access_token && result.data.expires_in){
- token = 'Bearer '+ result.data.access_token;
- localStorage.setItem('PG_Token', token);
- localStorage.setItem('PG_TokenTimeout',result.data.expires_in + new Date().getTime());
- localStorage.setItem('PG_SessionTimeout', new Date().getTime());
- localStorage.setItem('PG_UserName',result.data.userName);
- $http.defaults.headers.common['Authorization'] = token;
- return token;
- }
- });
- }
- function setSessionActivity(){
- localStorage.setItem('PG_SessionTimeout', new Date().getTime());
- }
- }]);
- ;angular.module('pgCore').directive('collapsable', [function() {
- return {
- restrict: 'A',
- scope: {
- collapsable:"=?collapsable",
- lineCount: "=?",
- maxHeight: "=?",
- toggle: "=?",
- deepWatch: '=?',
- disabled: '=?'
- },
- link: function(scope, elem) {
- var collapsedHeight, height, lineHeight, style, expanded;
- var $wrapper;
- var $elipse = $('<div class="collapsable-elipse" />');
- var $elipseBar = $('<div class="collapsable-elipse-bar" />').append($elipse);
- init();
- function init(){
- $wrapper = $('<div class="collapsable-wrapper" />')
- .html(elem.children())
- .css({'height':0})
- .appendTo(elem);
- elem.on('click', _.debounce(toggleExpand,300,{'leading':true,'trailing':false}))
- .addClass('collapsable')
- .append($elipseBar);
- if(scope.deepWatch){
- scope.$watchCollection('collapsable',load);
- }else{
- scope.$watch('collapsable',load);
- }
- scope.$watch('toggle', toggleOveride);
- }
- function load(){
- _.defer(function(){
- var $trueform = $wrapper.clone()
- .css({height:''})
- .addClass('collapsable-trueform')
- .appendTo(elem.parent());
- style = window.getComputedStyle($trueform[0]);
- height = parseInt(style['height'].replace('px',''));
- lineHeight = parseInt(style['lineHeight'].replace('px', '')) || parseInt(style['fontSize'].replace('px', ''))*1.165;
- collapsedHeight = (scope.lineCount || 3) * lineHeight;
- $trueform.remove();
- $trueform = null;
- $elipseBar.css({
- height: lineHeight
- }).addClass('hide-me');
- $wrapper.css({
- height: Math.min(collapsedHeight, height)
- }).removeClass('expanded scrollable');
- if(height > collapsedHeight){
- toggleExpand(null,false);
- }
- });
- }
- function toggleOveride(){
- if(height <= collapsedHeight) return;
- if(scope.toggle){
- expandElement();
- }else{
- collapseElement();
- }
- $elipseBar.toggleClass('hide-me',expanded);
- }
- function toggleExpand(e,expand){
- if(height <= collapsedHeight || !_.isUndefined(scope.toggle)) return;
- expanded = _.isUndefined(expand) ? !expanded : expand;
- if(expanded){
- expandElement();
- }else{
- collapseElement();
- }
- $elipseBar.toggleClass('hide-me',expanded);
- }
- function expandElement(){
- $wrapper.css({
- height: height
- }).addClass('expanded');
- if(scope.maxHeight && scope.maxHeight < height){
- $wrapper.css({
- maxHeight: scope.maxHeight
- }).addClass('scrollable');
- }
- }
- function collapseElement(){
- if(scope.disabled) return;
- $wrapper.css({
- height: collapsedHeight
- }).removeClass('expanded scrollable');
- $wrapper[0].scrollTop = 0;
- }
- }
- }
- }]);
- ;angular.module('pgCore').directive('onEnterDown', ['$timeout',function ($timeout) {
- return {
- restrict: 'A',
- scope: {
- onEnter: "&onEnterDown"
- },
- link: function (scope, elem) {
- elem.on('keydown',function(e){
- if (scope.onEnter && e.which === 13){
- $timeout(function(){
- scope.onEnter({ $event: e });
- })
- }
- });
- }
- }
- }]);
- angular.module('pgCore').directive('onEnterPress', ['$timeout', function ($timeout) {
- return {
- restrict: 'A',
- scope: {
- onEnter: "&onEnterPress"
- },
- link: function (scope, elem) {
- elem.on('keypress', function (e) {
- if (scope.onEnter && e.which === 13) {
- $timeout(function () {
- scope.onEnter({ $event: e });
- })
- }
- });
- }
- }
- }]);
- angular.module('pgCore').directive('onEnterUp', ['$timeout', function ($timeout) {
- return {
- restrict: 'A',
- scope: {
- onEnter: "&onEnterUp"
- },
- link: function (scope, elem) {
- elem.on('keyup', function (e) {
- if (scope.onEnter && e.which === 13) {
- $timeout(function () {
- scope.onEnter({ $event: e });
- })
- }
- });
- }
- }
- }]);
- ;angular.module('pgCore').directive('stopPropagation', [function() {
- return {
- restrict: 'A',
- scope: {
- events:"@stopPropagation"
- },
- link: function(scope, elem) {
- if(scope.events){
- if(!scope.events.length) scope.events = 'click';
- scope.events.split(',').forEach(function(event){
- elem.on(event,function(e){
- e.stopPropagation();
- })
- });
- }
- }
- }
- }]);
- ;angular.module('pgCore').directive('checkboxInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- value: '=?',
- items: '=?',
- selected: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- model: '=?',
- onSelect: '&?',
- labelKey: '@',
- labelTemplate: '=?',
- optionsVisibleAlways: '=?',
- labelPosition: '@',
- boxPosition: '@',
- sort: '@'
- },
- template: '<div red="red\'s" class="form-field checkbox-input"><div class="form-field-container checkbox-wrapper" ng-class="labelPosition"><div class="form-label" ng-show="model.label.length || label.length">{{model.label || label}}</div><div class="form-label zero-state-label" ng-hide="model.label.length || label.length">Checkbox</div><div class="checkbox-container border-radius" ng-show="useSingleItem"><div class="checkbox-input-wrapper" ng-class="boxPosition"><label class="checkbox-mask" for="cb-single-{{:: label}}" ng-class="{checked: value}"><i class="icon-check"></i></label> <input ng-disabled="disabled" id="cb-single-{{:: label}}" type="checkbox" ng-model="value"></div></div><div class="checkbox-container border-radius" ng-showe="items"><div class="checkbox-input-wrapper" ng-class="boxPosition" ng-repeat="item in items | orderBy:(model.sort || sort || model.labelKey || labelKey) | filter:selectedLabel"><label class="checkbox-mask" ng-class="{checked: item.value}" for="cb-multi-{{$index}}"><i class="icon-check"></i></label> <input ng-disabled="disabled" id="cb-multi-{{$index}}" type="checkbox" ng-model="item.value"> <label class="checkbox-label inline" for="cb-multi-{{$index}}">{{item.label}}</label></div></div></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init() {
- if(!scope.labelKey) scope.labelKey = 'label';
- if(!_.isUndefined(scope.value)){
- scope.useSingleItem = true;
- }
- }
- }
- }
- }]);;angular.module('pgCore').directive('dropdownInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- items: '=?',
- selected: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- model: '=?',
- onSelect: '&?',
- labelKey: '@',
- labelTemplate: '=?',
- optionsVisibleAlways: '=?',
- labelPosition: '@'
- },
- template: '<div class="form-field dropdown-input"><div class="form-field-container dropdown-container" ng-class="labelPosition"><div class="label" ng-class="labelPosition" ng-show="model.label.length || label.length">{{model.label || label}}</div><div class="label zero-state-label" ng-hide="model.label.length || label.length">Dropdown</div><div class="dropdown-input-wrapper" ng-click="focusInput($event)" ng-class="{\'show\':optionsVisible, \'show-always\': optionsVisibleAlways}"><div class="dropdown-input-container"><div class="input-placeholder" ng-hide="optionsVisible" ng-class="{\'placeholder\': !model.selected[labelKey] && !selected[labelKey] }">{{model.selected[labelKey] || selected[labelKey] || model.placeholder || placeholder}}</div><input type="text hidden" ng-blur="onBlur($event)" ng-disabled="disabled" ng-class="{\'visible\':optionsVisible}" placeholder="{{model.selected[labelKey] || selected[labelKey] || model.placeholder || placeholder}}" ng-model="selectedLabel" ng-focus="onFocus($event)"> <span class="dropdown-arrow" ng-click="disabled || toggleOptions($event)"></span></div><div class="dropdown-options" ng-mousedown="onMouseDown($event)" ng-class="{\'show\':optionsVisible, \'show-always\': optionsVisibleAlways}" ng-click="disabled || stopPropagation($event)"><div class="dropdown-option" ng-repeat="item in items | orderBy:(model.labelKey || labelKey) | filter:selectedLabel track by $index" ng-click="disabled || selectItem((model.item || item), $event)">{{model.item[labelKey] || item[labelKey]}}</div></div></div></div></div>',
- link: function (scope, elem, attrs) {
- var $input, stopBlurEvent;
- init();
- function init(){
- scope.showOptions = showOptions;
- scope.hideOptions = hideOptions;
- scope.toggleOptions = toggleOptions;
- scope.selectItem = selectItem;
- scope.onBlur = onBlur;
- scope.onFocus = onFocus;
- scope.onMouseDown = onMouseDown;
- scope.focusInput = focusInput;
- scope.stopPropagation = stopPropagation;
- scope.optionsVisible = false;
- if(!scope.labelKey) scope.labelKey = 'label';
- }
- function selectItem(item,e){
- scope.selected = item;
- scope.selectedLabel = '';
- if(scope.onSelect) scope.onSelect({item:scope.selected});
- hideOptions();
- }
- function showOptions(){
- scope.optionsVisible = true;
- }
- function hideOptions(){
- scope.optionsVisible = false;
- stopBlurEvent = false;
- }
- function toggleOptions(e){
- stopPropagation(e);
- scope.optionsVisible ? hideOptions() : showOptions();
- }
- function onBlur() {
- _.defer(function () {
- if (!stopBlurEvent) {
- hideOptions();
- scope.$digest();
- }
- });
- }
- function onFocus(){
- showOptions();
- }
- function onMouseDown(){
- stopBlurEvent = true;
- }
- function stopPropagation(e){
- if(!scope.disabled){
- e.stopPropagation();
- e.preventDefault();
- return false;
- }
- }
- function focusInput(e){
- stopPropagation(e);
- if(!$input) $input = elem.find('input');
- $input.focus();
- }
- }
- }
- }]);;angular.module('pgCore').directive('emailInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- id: '=?',
- value: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- onChange: '=?',
- labelPosition: '@',
- hideLabel: '=?',
- tooltip: '=?'
- },
- template: '<div class="form-field email-input"><div class="form-field-container" ng-class="labelPosition"><div class="form-label" ng-show="!hideLabel && label.length">{{label}}</div><div class="form-label zero-state-label" ng-hide="hideLabel || label.length">Email</div><input ng-disabled="disabled" id="{{id}}" type="email" placeholder="{{placeholder}}" ng-model="value" ng-change="onChange()"></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){}
- }
- }
- }]);;angular.module('pgCore').directive('multilineInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- id: '=?',
- value: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- onChange: '=?',
- labelPosition: '@',
- hideLabel: '=?',
- tooltip: '=?'
- },
- template: '<div class="form-field multiline-input"><div class="form-field-container" ng-class="labelPosition"><div class="form-label" ng-show="!hideLabel && label.length">{{label}}</div><div class="form-label zero-state-label" ng-hide="hideLabel || label.length">Text</div><textarea ng-disabled="disabled" id="{{id}}" placeholder="{{placeholder}}" ng-model="value" ng-change="onChange()">{{value}}</textarea></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){}
- }
- }
- }]);;angular.module('pgCore').directive('numberInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- id: '=?',
- value: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- onChange: '=?',
- labelPosition: '@',
- hideLabel: '=?',
- tooltip: '=?'
- },
- template: '<div class="form-field number-input"><div class="form-field-container" ng-class="labelPosition"><div class="form-label" ng-show="!hideLabel && label.length">{{label}}</div><div class="form-label zero-state-label" ng-hide="hideLabel || label.length">Number</div><input ng-disabled="disabled" id="{{id}}" type="number" placeholder="{{placeholder}}" ng-model="value" ng-change="onChange()"></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){}
- }
- }
- }]);;angular.module('pgCore').directive('radioInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- items: '=?',
- selected: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- model: '=?',
- onSelect: '&?',
- labelKey: '@',
- labelTemplate: '=?',
- optionsVisibleAlways: '=?',
- labelPosition: '@',
- boxPosition: '@',
- sort: '@'
- },
- template: '<div class="form-field radio-input"><div class="form-field-container radio-wrapper" ng-class="labelPosition"><div class="form-label" ng-show="model.label.length || label.length">{{model.label || label}}</div><div class="form-label zero-state-label" ng-hide="model.label.length || label.length">Multiple Choice</div><div class="radio-container border-radius"><div class="radio-input-wrapper" ng-class="boxPosition" ng-repeat="item in items | orderBy:(model.sort || sort || model.labelKey || labelKey) | filter:selectedLabel"><label class="radio-mask" ng-class="{checked: $parent.value === item}" for="rd-multi-{{$index}}"></label> <input id="rd-multi-{{$index}}" type="radio" ng-model="$parent.value" ng-value="item"> <label class="radio-label inline" for="rd-multi-{{$index}}">{{item.label}}</label></div></div></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){
- if(!scope.labelKey) scope.labelKey = 'label';
- }
- }
- }
- }]);;angular.module('pgCore').directive('sectionHeader', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- field: '=?'
- },
- template: '<div class="form-field section-header"><h3 class="section-header-placeholder" ng-hide="field.text">Section Header</h3><h3 class="section-header-label" ng-show="field.text">{{field.text}}</h3><hr></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){}
- }
- }
- }]);;angular.module('pgCore').directive('textInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- id: '=?',
- value: '=?',
- label: '=?',
- placeholder: '=?',
- disabled: '=?',
- onChange: '=?',
- labelPosition: '@',
- hideLabel: '=?',
- tooltip: '=?'
- },
- template: '<div class="form-field text-input"><div class="form-field-container" ng-class="labelPosition"><div class="label" ng-show="!hideLabel && label.length">{{label}}</div><div class="label zero-state-label" ng-hide="hideLabel || label.length">Text</div><input ng-disabled="disabled" id="{{id}}" type="text" placeholder="{{placeholder}}" ng-model="value" ng-change="onChange()"></div></div>',
- link: function (scope, elem, attrs) {
- init();
- function init(){}
- }
- }
- }]);;angular.module('pgCore').directive('toggleInput', [function(){
- return {
- restrict: 'E',
- replace: true,
- scope: {
- model: '=?',
- key: '@?',
- onChange: '&?'
- },
- template: '<div class="form-field toggle-input"><label class="form-field-container toggle-wrapper" ng-class="{\'toggle-on\':model[key], \'disabled\':model.disabled}" for="toggle-{{:: uniqId}}"><div class="toggle-button"></div></label> <input class="input-hidden" type="checkbox" ng-model="model[key]" ng-disabled="model.disabled" id="toggle-{{:: uniqId}}" ng-change="onChange(model)"></div>',
- link: function (scope, elem, attrs) {
- init();
- function init() {
- if(!scope.key){
- scope.key = 'value';
- }
- scope.uniqId = _.uniqueId('toggle_')
- }
- }
- }
- }]);;angular.module('pgCore').directive('header', ['pgService', 'events', 'config', 'headerService', function(pgService, events, config, headerService) {
- return{
- restrict: 'E',
- replace: true,
- scope: {},
- template: '<div class="pg-header wrapper"> <div class="left"> <a href="/" class="logo"> <img src="http://primegov.com/wp-content/themes/primegov/images/inverse-logo.png"/></a> <a href="/" class="title" ng-click="goHome()"><span class="platform_title">Live Meeting - Meeting Viewer</span></a> </div><div class="right"> <div class="platform_selection"> <div class="dropdown"> <button class="platform_button btn btn-default dropdown-toggle language-selector" type="button" id="LanguageDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <img src="http://primegov.com/wp-content/themes/primegov/images/icon_Trans.png"> </button> <ul class="dropdown-menu" aria-labelledby="LanguageDropdown"> <li class="dropdown-header"> <span>PrimeGov Applications</span> </li><li class="first-item"> <a href="http://dev.primegov.com/" target="_blank" data-culture="en-US" class="language-selection"> <img class="pg_icon_black" src="http://primegov.com/wp-content/themes/primegov/images/icon_black_trans.png"> <span>Meetings & Committees</span> </a> </li><li> <a href="http://dev.primegov.com/portal/search" target="_blank" class="language-selection"> <i class="fa fa-search"></i> <span>Search Portal</span> </a> </li><li class="active_platform"> <a href="#" target="_blank" class="language-selection"> <i class="fa fa-group"></i> <span>Live Meeting</span> </a> </li></ul> </div></div><div class="user-profile"> <div class="name" ng-click="userDropdown=true"> <span ng-show="currentUser.id">{{(currentUser.firstName + \' \' + currentUser.lastName)}}</span> <i class="icon-caret-down"></i> </div><div class="user-dropdown" ng-show="userDropdown"> <div class="user-dropdown-overlay" ng-click="userDropdown=false"></div><div class="user-dropdown-items"> <div ng-repeat="item in menuItems | orderBy: \'sort\'" class="user-dropdown-item" ng-click="::onMenuItemClick(item.action)"> <i class="{{::item.icon}}"></i>{{::item.name || item.id}}</div></div></div></div></div></div>',
- link: function(scope, elem) {
- var cancellers = [
- events.loggedIn.on(function(){
- pgService.getCurrentUser();
- }),
- events.menuItemsAdded.on(addMenuItem),
- events.navItemsAdded.on(addNavItem)
- ];
- var defaultMenuItems = [{
- id: 'logout',
- name: 'Logout',
- icon: 'icon-power',
- action: logout,
- sort: 0
- }];
- var defaultNavItems = [{
- id: 'logout',
- name: 'Logout',
- icon: 'icon-power',
- action: logout,
- sort: 0
- }];
- scope.$on('$destroy',onDestroy);
- init();
- function init() {
- scope.logout = logout;
- scope.goHome = goHome;
- scope.onMenuItemClick = onMenuItemClick;
- scope.currentUser = pgService.currentUser;
- scope.userDropdown = false;
- scope.config = config;
- scope.menuItems = headerService.getMenuItems();
- scope.navItems = headerService.getNavItems();
- headerService.addMenuItems(defaultMenuItems);
- // headerService.addNavItems(defaultNavItems);
- }
- function onMenuItemClick(callback){
- scope.userDropdown = false;
- callback && callback();
- }
- function addMenuItem(menuItems){
- scope.menuItems = menuItems;
- }
- function addNavItem(items){
- scope.navItems = items;
- }
- function onDestroy(){
- cancellers.forEach(function(fn){fn();});
- }
- function goHome(){
- window.location = './#/';
- }
- function logout(){
- pgService.logout();
- }
- }
- }
- }]);
- ;'use strict';
- /**
- * addMenuItems(
- * {id, name, action, icon, sort}
- * )
- */
- angular.module('pgCore').factory('headerService', ['events',function (events) {
- var menuItems = [];
- var navItems = [];
- var menuItemsMap = {};
- var navItemsMap = {};
- return {
- addMenuItems: function(items){
- if (!Array.isArray(items)) items = [items]
- items.forEach(function(item){
- if (item && item.id && !menuItemsMap[item.id]) {
- menuItems.push(item);
- menuItemsMap[item.id] = item
- }
- });
- events.menuItemsAdded.trigger(menuItems);
- },
- getMenuItems: function(){
- return menuItems
- },
- addNavItems: function (items) {
- if (!Array.isArray(items)) items = [items]
- items.forEach(function (item) {
- if (item && item.id && !navItemsMap[item.id]) {
- navItems.push(item);
- navItemsMap[item.id] = item;
- }
- });
- events.navItemsAdded.trigger(navItems);
- },
- getNavItems: function (items) {
- return navItems;
- }
- }
- }]);
- ;angular.module('pgCore').directive('login', ['config', 'pgService', 'events', function(config, pgService, events) {
- return {
- restrict: 'E',
- replace: true,
- scope: {
- publicLogin: '=?'
- },
- template: '<div class="login-wrapper" ng-class="{\'hide-me\':loggedIn, \'fade-in\': fadeIn, \'public-login\': publicLogin}"><div class="login-container"><div class="login-header"><div class="prime-gov-logo" ng-hide="::config.clientLogoUrl"><i class="icon-prime-gov"></i></div><img class="client-logo" ng-src="{{::config.clientLogoUrl}}" ng-show="::config.clientLogoUrl"><div class="app-name">{{::config.name}}</div></div><form><div class="input-container" ng-class="{\'not-empty\': username.length}"><input type="text" name="username" id="username" ng-model="username" ng-keyup="checkKeyUp($event)"><div class="expanding-label" label="Email"></div></div><div class="input-container" ng-class="{\'not-empty\': password.length || passwordAutoFilled}"><input type="password" name="password" id="password" ng-model="password" ng-keyup="checkKeyUp($event)" ng-change="passwordAutoFilled = false"><div class="expanding-label" label="Password"></div></div><div class="link forgot-password-link" ng-click="openPasswordReset()">Forgot Password?</div><div class="button-container"><div class="button primary slide-on-hover" ng-click="login()"><i class="icon-check-2"></i>Sign in</div></div></form></div></div>',
- link: function(scope, elem) {
- var passwordResetWindow, signupWindow;
- var cancellers = [];
- init();
- function init() {
- scope.login = login;
- scope.checkKeyUp = checkKeyUp;
- scope.openPasswordReset = openPasswordReset;
- scope.openSignup = openSignup;
- scope.username = '';
- scope.password = '';
- scope.config = config;
- cancellers = [
- events.loggedIn.on(onLoggedIn),
- events.loggedOut.on(onLoggedOut)
- ];
- scope.$on('$destroy', onDestroy);
- if(pgService.isLoggedIn()){
- scope.loggedIn = true;
- _.defer(function(){
- events.loggedIn.trigger();
- })
- } else if (scope.publicLogin) {
- config.getConfig().then(function(){
- if (config.publicEmail && config.publicPassword){
- scope.username = config.publicEmail;
- scope.password = config.publicPassword;
- login();
- }
- })
- }
- // hack to fix chrome autofill bug on passwords https://bugs.chromium.org/p/chromium/issues/detail?id=636425
- _.delay(function(){
- var passwordInput = document.querySelector('input#password');
- scope.passwordAutoFilled = window.getComputedStyle(passwordInput).backgroundColor !== 'rgb(255, 255, 255)';
- scope.fadeIn = true;
- scope.$digest();
- },500);
- }
- function onDestroy(){
- cancellers.forEach(function(fn){fn();});
- }
- function checkKeyUp(e){
- if(e.which === 13){
- login();
- }
- }
- function openPasswordReset(){
- if(passwordResetWindow && !passwordResetWindow.closed){
- passwordResetWindow.focus();
- }else{
- passwordResetWindow = window.open('/account/forgotPassword', '', 'width=900, height=640');
- }
- }
- function openSignup(){
- if(signupWindow && !signupWindow.closed){
- signupWindow.focus();
- }else{
- signupWindow = window.open('/account/forgotPassword', '', 'width=900, height=640');
- }
- }
- function login(){
- if(!scope.username.length || !scope.password.length) return;
- pgService.login(scope.username, scope.password).then(function(data){
- if(data && data.success){
- events.loggedIn.trigger();
- }else{
- if(data && data.error && data.error.data && data.error.data.error_description){
- alert(data.error.data.error_description);
- }else{
- alert('something went wrong');
- console.log(data);
- }
- scope.password = '';
- }
- });
- }
- function onLoggedIn(){
- scope.loggedIn = pgService.isLoggedIn();
- }
- function onLoggedOut(){
- scope.loggedIn = pgService.isLoggedIn();
- window.location.reload();
- }
- }
- }
- }]);
- ;angular.module('pgCore').directive('pgI18n', ['$sanitize',function ($sanitize) {
- return {
- restrict: 'EA',
- compile: compile
- };
- function deepSanitize(data) {
- var keys;
- if (typeof data === 'undefined' || data === null) return data; // return undefined
- if (typeof data === 'string') {
- // Use $sanitize service to remove <script> tags
- // and then unescape &#XXXX; characters for multibyte and accents
- data = $sanitize(data).replace(/&#(\d*);/g, function (_, capture) {
- return String.fromCharCode(capture);
- });
- // remove any double curly braces to prevent sandbox escape
- data = data.replace(/\{\{/g, '').replace(/\}\}/g, '');
- } else if (Array.isArray(data)) {
- data = data.map(function (item) { // map sanitize on arrays
- return deepSanitize(item);
- });
- } else if (typeof data === 'object') { // recursively sanitize object properties
- keys = Object.keys(data);
- for (var i = 0; i < keys.length; i++) {
- data[keys[i]] = deepSanitize(data[keys[i]]);
- }
- }
- return data;
- }
- function compile(tElement, tAttrs) {
- //get the i18n key from the attributes
- var key = tAttrs.key || tAttrs.dmI18n;
- //detect if transclusion is being used
- var isTranscluding = tAttrs.hasOwnProperty("ngTransclude");
- //use the key and attributes to determine if the template is "static"
- var isStatic = !isTranscluding && !tAttrs.safeData && !tAttrs.data && key.indexOf("{") == -1;
- //if the template is static, fix up the template element now, before it's in the DOM (most likely)
- isStatic && tElement.html(dmI18n.get(key).replace(/\s\n\s/g, '<br>'));
- //if dynamic, the compilation will happen in the post link. if static, no need to postLink
- return isStatic ? angular.noop : postLink;
- }
- function postLink(scope, element, attrs) {
- function keyValueChange(key) {
- if (attrs.data || !key) {
- return;
- }
- getI18nResult(key, attrs.data, scope.$eval(attrs.safeData), attrs.dmI18nAttr);
- }
- /**
- * @param {String} key path to string (eg. "library/history")
- * @param {Object} data merge fields that should be escaped
- * @param {Object} data merge fields that should *not* be escaped
- * @param {String} [attr] attribute to update (default: html)
- * @return {void}
- */
- function getI18nResult(key, data, safeData, attr) {
- attr = attr || 'html';
- switch (attr) {
- case 'html':
- case 'innerHTML':
- element.html(dmI18n.get(key, data, safeData).replace(/\s\n\s/g, '<br>'));
- break;
- default:
- element.attr(attr, dmI18n.get(key, data, safeData).replace(/\s\n\s/g, '<br>'));
- break;
- }
- }
- attrs.$observe('key', keyValueChange, true);
- attrs.$observe('dmI18n', keyValueChange, true);
- attrs.$observe('data', dataAttrChange);
- attrs.$observe('safeData', dataAttrChange);
- function dataAttrChange(attr) {
- if (attr) {
- scope.$watch(attr, function () {
- getI18nResult(attrs.key || attrs.dmI18n, deepSanitize(scope.$eval(attrs.data)), scope.$eval(attrs.safeData), attrs.dmI18nAttr);
- }, true);
- }
- }
- }
- }]);
- ;angular.module('pgCore').directive('pgModal', [function() {
- return {
- restrict: 'E',
- replace: true,
- transclude: true,
- scope: {
- show: '=?',
- minimized: '=?',
- fullScreen: '=?',
- hideMinimize: '=?',
- onOpen: '&?',
- onClose: '&?',
- onMaximize: '&?',
- onMinimize: '&?',
- },
- template:'<div class="pg-modal-wrapper" ng-class="{\'show-me\': show && !fullScreen, \'minimized\': minimized && !hideMinimize && !fullScreen, \'full-screen\':fullScreen}"><div class="pg-modal-overlay"></div><div class="pg-modal"><div class="pg-minimized-overlay"></div><div class="pg-modal-buttons"><div class="close-modal" ng-click="close()"><i class="icon-x-2"></i></div><div class="minimize-modal" ng-click="minimize()" ng-if="!hideMinimize"><i class="icon-minimize"></i></div><div class="maximize-modal" ng-click="maximize()"><i class="icon-maximize"></i></div></div><div class="pg-modal-container" ng-transclude></div></div></div>',
- link: function(scope, elem) {
- var cancellers =[];
- init();
- function init() {
- scope.open = open;
- scope.close = close;
- scope.minimize = minimize;
- scope.maximize = maximize;
- scope.$watch('show',function(newVal, oldVal){
- if(!!oldVal && !newVal){
- if(scope.onClose) scope.onClose();
- }
- });
- scope.$on('$destroy',onDestroy);
- }
- function onDestroy(){
- cancellers.forEach(function(fn){fn();});
- }
- function close(){
- scope.show = false;
- }
- function open(id){
- scope.show = true;
- if(scope.onOpen) scope.onOpen();
- }
- function minimize(){
- scope.minimized = true;
- if(scope.onMinimize) scope.onMinimize();
- }
- function maximize(){
- scope.minimized = false;
- if(scope.onMaximize) scope.onMaximize();
- }
- }
- }
- }]);
- ;angular.module('pgCore').directive('tooltip', [function() {
- return {
- restrict: 'A',
- scope: {
- tooltip:"=tooltip",
- tooltipPosition: "@?",
- tooltipDelay: "=?"
- },
- link: function(scope, elem) {
- var $tooltip, client;
- var template = '<div class="tooltip"></div>';
- var top = 0;
- var left = 0;
- init();
- function init(){
- if(scope.tooltip && scope.tooltip.length) {
- elem.on('mouseenter', function () {
- client = elem[0].getBoundingClientRect();
- $tooltip = $(template)
- $tooltip.html(scope.tooltip);
- $tooltip.addClass(scope.tooltipPosition);
- $tooltip.css(getPositionCss(client, $tooltip));
- $('body').append($tooltip);
- _.delay(function(){
- if($tooltip) {
- $tooltip.addClass('pg-fade-in');
- }
- }, (scope.tooltipDelay || 10));
- });
- elem.on('mouseleave', function () {
- if($tooltip){
- $tooltip.remove();
- $tooltip = null;
- }
- });
- }
- scope.$on('$destroy', function () {
- elem.trigger('mouseleave');
- });
- }
- function getPositionCss(client, $tooltip){
- switch(scope.tooltipPosition){
- case 'left':
- return {top: client.top + (client.height/2) , left: client.left-6};
- case 'right':
- return {top: client.top + (client.height/2) , left: client.right+6};
- case 'bottom':
- return {top: client.bottom+6, left: client.left + (client.width/2)};
- default:
- return {top: client.top-6, left: client.left + (client.width/2)};
- }
- }
- }
- }
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement