'use strict'; const AppConstant = { DEFAULT_IMAGE: 'assets/app/images/default/avatar.default.png', AUTHENTICATED_USER_ID: 0 }; 'use strict'; const CastingTypeConstant = { AVAILABILITY_CHECK: 'Availability Check', // constant value is not in upper-case for backward compatibility PHYSICAL_LOCATION: 'Attend', // constant value is not in upper-case for backward compatibility ONLINE_SUBMISSION: 'Online', // constant value is not in upper-case for backward compatibility BOTH_PHYSICAL_LOCATION_AND_ONLINE_SUBMISSION: 'Both' // constant value is not in upper-case for backward compatibility - currently not supported when creating a new casting - this is for backward compatibility only }; 'use strict'; const HttpConstant = { GET: 'GET', POST: 'POST', PUT: 'PUT', DELETE: 'DELETE', HEADERS: {'Content-Type': 'application/x-www-form-urlencoded'}, DEFAULT_ERROR_MESSAGE: 'You are having trouble connecting to our server at the moment. Please check your internet connection.' }; 'use strict'; const ModalConstant = {}; /** * Main AngularJS Web Application */ "use strict"; /** * Initialize angular js application. * @type {angular.Module} */ angular .module("bookdWebApp", [ "ngRoute", "ngSanitize", "ngWebSocket", "ngFileUpload", "angular-loading-bar", "wu.masonry", "720kb.socialshare", "multipleDatePicker", "ngRateIt", "infinite-scroll", "ngYoutubeEmbed", "ng-mfb", "ngEmoticons", "ngImgCrop", "luegg.directives", "ngclipboard", "angucomplete-alt", "uiCropper", "autoCompleteModule" ]); "use strict"; /** * Kick start application. */ angular .module("bookdWebApp") .run(function ($rootScope, CONSTANTS) { $rootScope.CONSTANTS = CONSTANTS; $rootScope.NOTIFICATION = {}; $rootScope.finishedLoading = false; $rootScope.isLoggingOut = false; $rootScope.outGoingMessage = ""; $rootScope.currentYear = moment().year(); }); "use strict"; /** * Application constants. */ angular .module("bookdWebApp") .constant("CONSTANTS", { DEFAULT_IMAGE: "assets/app/images/default/avatar.default.png", JOIN: "JOIN", TALK: "TALK", PRIVATE_MESSAGE: "PRIVATE_MESSAGE", JOB_MESSAGE: "JOB_MESSAGE", JOB: "JOB", CASTING: "CASTING", GALLERY: "gallery", PORTFOLIO: "PORTFOLIO", POLAROID: "POLAROID", VIDEO_CASTING: "VIDEO CASTING", ADVERTISEMENT_VIDEO: "ADVERTISEMENT VIDEO", PROFILE_IMAGE_UPLOAD_MODAL: "profileImageUploadModal", IMAGE_UPLOAD_MODAL: "imageUploadModal", VIDEO_CASTING_MODAL: "videoCastingModal", ADVERTISEMENT_VIDEO_MODAL: "advertisementVideoModal", ALL: "ALL", SINGLE: "SINGLE", TALENT: "Talent", AGENCY: "Agency", CLIENT: "Client", SCOUT: "Scout", ACTIVATE: "Activate", DEACTIVATE: "Deactivate", DELETE: "Delete", FIELD_DELETE: "fieldDelete", ADD: "Add", SHOW: "show", HIDE: "hide", ACTIVE: "Active", PENDING: "Pending", DELETED: "Deleted", PENDING_VERIFICATION: "Pending Verification", JOB_MESSAGE_NOTIFICATION_DESCRIPTION: "You have a new job message.", RULE: /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/, MODEL: "Model", ACTOR: "Actor", SINGER: "Singer", DANCER: "Dancer", EMCEE: "Emcee", VOICEOVER: "Voiceover", DJ: "DJ", // Add the constants here from application/views/shared/scripts/constants AppConstant: AppConstant, HttpConstant: HttpConstant, ModalConstant: ModalConstant, CastingTypeConstant: CastingTypeConstant, }); /** * Javascript constants. * @type {string} */ const DEFAULT_IMAGE = "assets/app/images/default/avatar.default.png"; const GET = "GET"; const POST = "POST"; const HEADERS = {"Content-Type": "application/x-www-form-urlencoded"}; const ERROR_MESSAGE = "We're having trouble connecting to bookd!. Please try again later."; "use strict"; /*app.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'self', '*://www.youtube.com/!**' ]); }); app.config(function (blockUIConfig) { blockUIConfig.message = "Loading... "; });*/ /** * Initialize application global options. */ angular .module("bookdWebApp") .config(function () { toastr.options = { "positionClass": "toast-top-center", "timeOut": 10000 }; }); let AUTHENTICATED_ID = 0; (function () { "use strict"; angular .module("bookdWebApp") .controller("PublicProfileController", initialize); function initialize($route, $location, Upload, $sce, $rootScope, $window, UserAccountFactory, StatisticsFactory, JsonFactory, ProfessionFactory, LanguageFactory, AccentFactory, ExposureFactory, TalentListFactory, JobRateFactory, StyleFactory, BookingFactory, DateTimeService) { let vm = this; let CONSTANTS = $rootScope.CONSTANTS; vm.hasLoaded = { profile: false, statistics: false, portfolio: false, polaroid: false, videoCasting: false }; vm.isLoading = { image: false, video: false, portfolio: false, polaroid: false, videoCasting: false }; vm.cropping = false; vm.busyLoadingData = false; vm.profile = {}; vm.polaroid = {}; vm.portfolio = {}; vm.statistics = {}; vm.styles = {}; vm.formData = {}; vm.currentDate = new Date(); vm.currentSection = ""; vm.source = ""; vm.caption = ""; vm.portfolioSourceContainer = []; vm.polaroidSourceContainer = []; vm.visitedSection = []; vm.collectedFiles = []; vm.files = []; vm.uploadType = CONSTANTS.PORTFOLIO; vm.newVideoUrl = ""; vm.currentModalId = ""; vm.video = null; vm.profileImage = null; vm.croppedImage = []; vm.imageUploadProgress = 0; vm.videoUploadProgress = 0; vm.profileImageUploadProgress = 0; vm.activitiesList = []; vm.images = []; vm.uploadedImageLength = 0; vm.deleteType = ""; vm.referenceVideoFields = 1; vm.referenceVideo = []; vm.croppedImage = []; vm.wasProfileImageCropped = false; vm.jobUsageList = []; vm.professions = []; vm.group = {}; vm.recentExposures = []; vm.selectedProfession = {}; vm.language = {}; vm.accent = {}; vm.exposures = []; vm.renameTalentListDirectoryStatus = []; vm.talentListDirectories = []; vm.duplicate = false; vm.opentTalentListDirectoryName = ""; vm.next = encodeURIComponent(location.href); vm.selectedTalentLists = []; vm.bookingRequest = {}; vm.isSubmittingBookingRequest = false; vm.selectList = selectList; vm.isSelectedTalentList = isSelectedTalentList; vm.addTalentToTalentListDirectory = addTalentToTalentListDirectory; vm.submitBookingRequest = submitBookingRequest; vm.showModal = function (modal) { $("#".concat(modal)).modal(CONSTANTS.SHOW); }; vm.hideModal = function (modal) { $("#".concat(modal)).modal(CONSTANTS.HIDE); }; vm.isModelOrActor = function (type) { return type === CONSTANTS.MODEL || type === CONSTANTS.ACTOR; }; vm.isEmceeOrSinger = function (type) { return type === CONSTANTS.EMCEE || type === CONSTANTS.SINGER; }; vm.isVoiceover = function (type) { return type === CONSTANTS.VOICEOVER; }; vm.isDj = function (type) { return type === CONSTANTS.DJ; }; vm.initRenameTalentListDirectory = function () { for (let i = 0; i < vm.talentListDirectories.length; i++) { vm.renameTalentListDirectoryStatus[i] = false; } }; vm.showAddToListModal = function () { if (IS_LOGGED_IN) { vm.getTalentListDirectories(); } vm.showModal("add-to-list-modal"); }; vm.getTalentListDirectories = function () { let payload = { id: vm.currentUserId }; TalentListFactory.getTalentListDirectories(payload).then(function () { vm.talentListDirectories = TalentListFactory.talentListDirectories; }); }; function selectList(talentListId) { if (isSelectedTalentList(talentListId)) { vm.selectedTalentLists.splice(vm.selectedTalentLists.indexOf(talentListId), 1) } else { vm.selectedTalentLists.push(talentListId); } } function isSelectedTalentList(talentListId) { return vm.selectedTalentLists.indexOf(talentListId) > -1; } function addTalentToTalentListDirectory() { if (!vm.profile.id || !vm.selectedTalentLists) { return; } let payload = { talentId: vm.profile.id, talentListId: vm.selectedTalentLists.toString() }; TalentListFactory.addTalentToList(payload).then(function () { vm.hideModal("add-to-list-modal"); vm.selectedTalentLists = []; }); } vm.deleteTalentListDirectory = function (talentDirectoryId) { let payload = { talentListId: talentDirectoryId }; TalentListFactory.deleteTalentListDirectories(payload).then(function () { vm.getTalentListDirectories(); }); }; vm.renameTalentListDirectory = function ($index) { vm.opentTalentListDirectoryName = vm.talentListDirectories[$index].name; vm.initRenameTalentListDirectory(); vm.renameTalentListDirectoryStatus[$index] = true; }; vm.listen = function () { vm.duplicate = false; }; vm.saveRenamedTalentListDirectory = function (list, $index) { for (let i = 0; i < vm.talentListDirectories.length; i++) { if (i === $index) { continue; } if (vm.talentListDirectories[i].name === list.name) { vm.duplicate = true; break; } } if (vm.duplicate) { return; } vm.duplicate = false; let payload = { talentListId: list.id, name: list.name }; TalentListFactory.saveTalentListDirectories(payload).then(function () { vm.renameTalentListDirectoryStatus[$index] = false; }); }; vm.cancelRenameTalentListDirectory = function ($index) { vm.talentListDirectories[$index].name = vm.opentTalentListDirectoryName; vm.renameTalentListDirectoryStatus[$index] = false; }; vm.checkTalentListName = function (talentListDirectoryName) { vm.duplicate = false; for (let i = 0; i < vm.talentListDirectories.length; i++) { if (vm.talentListDirectories[i].name === talentListDirectoryName) { vm.duplicate = true; break; } } }; vm.createTalentListDirectory = function (talentListDirectoryName) { for (let i = 0; i < vm.talentListDirectories.length; i++) { if (vm.talentListDirectories[i].name === talentListDirectoryName) { vm.duplicate = true; break; } } if (vm.duplicate) { return; } vm.duplicate = false; let payload = { name: talentListDirectoryName }; TalentListFactory.saveTalentListDirectories(payload).then(function () { vm.getTalentListDirectories(); vm.newTalentListDirectoryName = ""; }); }; vm.getReferenceVideoOffset = function (index, referenceVideoLength) { let offset = ""; if (referenceVideoLength % 2 === 1 && index === referenceVideoLength - 1) { offset = "col-md-offset-3"; } return offset; }; vm.trustSource = function (source) { return $sce.trustAsResourceUrl(source); }; vm.isValidYoutubeUrl = function (url) { if(url.match(CONSTANTS.RULE)){ return url.match(CONSTANTS.RULE)[1]; } //return url.match(CONSTANTS.RULE); }; vm.calculateAge = function (birthday) { birthday = new Date(birthday); let ageDifference = Date.now() - birthday.getTime(); let ageDate = new Date(ageDifference); let age = Math.abs(ageDate.getUTCFullYear() - 1970); return age ? age : ""; }; vm.getRandomValue = function () { return Math.floor(Math.random() * (40 - 20 + 1) + 20); }; vm.viewJobRates = function () { vm.getJobRates(); vm.showModal("view-job-rates-modal"); }; vm.getJobRates = function () { let payload = { professionId: vm.selectedProfession.id }; JobRateFactory.getJobRates(payload).then(function () { vm.jobRates = JobRateFactory.jobRates; }); }; vm.getExposures = function () { let payload = { professionId: vm.selectedProfession.id }; ExposureFactory.getExposures(payload).then(function () { vm.exposures = ExposureFactory.exposures; }); }; vm.getAccent = function () { let payload = { profileId: vm.profile.id }; AccentFactory.getAccent(payload).then(function () { vm.accent = AccentFactory.accent; }); }; vm.getLanguage = function () { let payload = { profileId: vm.profile.id }; LanguageFactory.getLanguage(payload).then(function () { vm.language = LanguageFactory.language; vm.getAccent(); }); }; vm.viewProfileByProfession = function (profession) { vm.selectedProfession = angular.copy(profession); vm.selectedProfession.styledActivities = []; vm.selectedProfession.styledJobTypes = []; let isModelOrActor = vm.isModelOrActor(vm.selectedProfession.type); let list = isModelOrActor ? vm.statistics.activities : vm.selectedProfession.jobTypes; if (list && list.length) { list.forEach(item => { let data = { item: item, //value: vm.getRandomValue() value: 20 }; if (isModelOrActor) { vm.selectedProfession.styledActivities.push(data); } else { vm.selectedProfession.styledJobTypes.push(data); } }); } if (vm.selectedProfession.type === CONSTANTS.VOICEOVER) { vm.getLanguage(); vm.getStyles(); } if (!vm.isModelOrActor(vm.selectedProfession.type)) { vm.getJobRates(); } vm.getExposures(); }; vm.findProfessionByType = function (type) { let profession = {}; if (!type) { return vm.professions[0]; } try { vm.professions.forEach(professionData => { if (professionData.type.toLowerCase() === type.toLowerCase()) { profession = professionData; throw new Exception(); } }); } catch (Exception) { // TODO: Implement exception handling. } if (!profession.type) { profession = vm.professions[0]; } return profession; }; vm.getProfessions = function () { let payload = { profileId: USER_ACCOUNT_ID }; ProfessionFactory.getProfessions(payload).then(function () { vm.professions = ProfessionFactory.professions; if (vm.professions.length) { let profession = vm.findProfessionByType(PROFILE_TYPE); vm.viewProfileByProfession(profession); } }); }; vm.getStatistics = function () { StatisticsFactory.getStatistics(USER_ACCOUNT_ID).then(function () { vm.statistics = StatisticsFactory.statistics; vm.hasLoaded.statistics = true; vm.getProfessions(); }); }; vm.getStyles = function () { StyleFactory.getStyles(USER_ACCOUNT_ID).then(function () { vm.styles = StyleFactory.styles; }); }; vm.getProfile = function () { let payload = { profileId: USER_ACCOUNT_ID }; UserAccountFactory.getProfile(payload).then(function () { vm.profile = UserAccountFactory.profile; vm.profile.birthday = DateTimeService.convertTimestampToStandardDate(vm.profile.birthday); console.log(DateTimeService.convertTimestampToStandardDate(vm.profile.birthday),'wew'); let isValidDate = vm.profile.birthday !== "0000-00-00"; vm.profile.age = isValidDate ? vm.calculateAge(vm.profile.birthday) : ""; vm.profile.jobAgeRanges.sort(function (a, b) { return parseInt(a) - parseInt(b); }); vm.hasLoaded.profile = true; vm.getStatistics(); vm.bookingRequest.talentId = vm.profile.userName; }); }; vm.init = function () { $("body").tooltip({selector: '[data-toggle=tooltip]'}); $('.panel-collapse:not(".in")').collapse(CONSTANTS.SHOW); vm.getProfile(); }; function submitBookingRequest() { vm.isSubmittingBookingRequest = true; BookingFactory.submitBookingRequest(vm.bookingRequest).then((response) => { vm.bookingRequest = {}; vm.isSubmittingBookingRequest = false; }); } vm.init(); window.name = "Public Profile | Bookd"; } })(); "use strict"; angular .module("bookdWebApp") .factory("AccentFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let AccentFactory = {}; AccentFactory.accent = {}; AccentFactory.getAccent = function (payload) { let request = { url: "app/web/public-profile/accent/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { AccentFactory.accent = response.data.accent; }, function () { NotificationFactory.showCallbackNotification(); }); }; return AccentFactory; } ]); (function () { "use strict"; angular .module("bookdWebApp") .factory("BookingFactory", initialize); function initialize(RequestFactory) { return { submitBookingRequest: submitBookingRequest }; function submitBookingRequest(payload) { let url = "app/web/public-profile/booking-request/submit"; return RequestFactory.post(url, payload); } } })(); "use strict"; angular .module("bookdWebApp") .factory("ExposureFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let ExposureFactory = {}; ExposureFactory.exposures = []; ExposureFactory.getExposures = function (payload) { let request = { url: "app/web/public-profile/exposures/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { ExposureFactory.exposures = response.data.exposures.list; }, function () { NotificationFactory.showCallbackNotification(); }); }; return ExposureFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("JobRateFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let JobRateFactory = {}; JobRateFactory.jobRates = []; JobRateFactory.getJobRates = function (payload) { let request = { url: "app/web/public-profile/job-rates/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { JobRateFactory.jobRates = response.data.jobRates.list; }, function () { NotificationFactory.showCallbackNotification(); }); }; return JobRateFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("JsonFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let JsonFactory = {}; JsonFactory.countries = {}; JsonFactory.countryCodes = []; JsonFactory.ethnicities = []; JsonFactory.jobUsageList = []; JsonFactory.getCountries = function () { let request = { url: "app/web/json/countries", method: GET, headers: HEADERS }; return $http(request).then(function (response) { JsonFactory.countries = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; JsonFactory.getCountryCodes = function () { let request = { url: "app/web/json/country-codes", method: GET, headers: HEADERS }; return $http(request).then(function (response) { JsonFactory.countryCodes = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; JsonFactory.getJobUsageList = function () { let request = { url: "app/web/json/job-usage-list", method: GET, headers: HEADERS }; return $http(request).then(function (response) { JsonFactory.jobUsageList = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; JsonFactory.getEthnicities = function () { let request = { url: "app/web/json/ethnicities", method: GET, headers: HEADERS }; return $http(request).then(function (response) { JsonFactory.ethnicities = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; return JsonFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("LanguageFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let LanguageFactory = {}; LanguageFactory.language = {}; LanguageFactory.getLanguage = function (payload) { let request = { url: "app/web/public-profile/language/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { LanguageFactory.language = response.data.language; }, function () { NotificationFactory.showCallbackNotification(); }); }; return LanguageFactory; } ]); (function () { "use strict"; angular .module("bookdWebApp") .factory("NotificationFactory", initialize); function initialize() { return { showSuccessNotification: showSuccessNotification, showErrorNotification: showErrorNotification, showDefaultNotification: showDefaultNotification, showNotification: showNotification, showCallbackNotification: showCallbackNotification }; function showSuccessNotification(message) { toastr.success(message); } function showErrorNotification(message) { toastr.error(message); } function showDefaultNotification() { // toastr.warning(ERROR_MESSAGE); } function showNotification(response) { if (response.data.success) { toastr.success(response.data.success); } else { toastr.error(response.data.error); } } function showCallbackNotification() { // toastr.warning(ERROR_MESSAGE); } } })(); "use strict"; angular .module("bookdWebApp") .factory("ProfessionFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let ProfessionFactory = {}; ProfessionFactory.professions = []; ProfessionFactory.getProfessions = function (payload) { let request = { url: "app/web/public-profile/professions/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { ProfessionFactory.professions = response.data.professions.list; }, function () { NotificationFactory.showCallbackNotification(); }); }; return ProfessionFactory; } ]); (function () { "use strict"; angular .module("bookdWebApp") .factory("RequestFactory", initialize); function initialize($http, NotificationFactory) { let DEFAULT_HEADERS = {"Content-Type": "application/x-www-form-urlencoded"}; return { get: get, post: post }; function get(url, params, headers) { params = (typeof params === "undefined") ? {} : params; headers = (typeof headers === "undefined") ? DEFAULT_HEADERS : headers; let request = { url: url, method: "GET", headers: headers, params: params }; return $http(request) .then((response) => { if (response.data.success) { NotificationFactory.showSuccessNotification(response.data.success); } return response.data; }) .catch((error) => { if (error.status === 500) { NotificationFactory.showDefaultNotification(); } else if (error.data && error.data.error) { NotificationFactory.showErrorNotification(error.data.error); } return error.data; }); } function post(url, payload, headers) { payload = (typeof payload === "undefined") ? {} : payload; headers = (typeof headers === "undefined") ? DEFAULT_HEADERS : headers; let request = { url: url, method: "POST", headers: headers, data: $.param(payload) }; return $http(request) .then((response) => { if (response.data.success) { NotificationFactory.showSuccessNotification(response.data.success); } return response.data; }) .catch((error) => { if (error.status === 500) { NotificationFactory.showDefaultNotification(); } else if (error.data && error.data.error) { NotificationFactory.showErrorNotification(error.data.error); } return error.data; }); } } })(); "use strict"; angular .module("bookdWebApp") .factory("StatisticsFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let StatisticsFactory = {}; StatisticsFactory.statistics = {}; StatisticsFactory.getStatistics = function (profileId) { let request = { url: "app/web/public-profile/statistics/get", method: POST, headers: HEADERS, data: $.param({ profileId: profileId }) }; return $http(request).then(function (response) { StatisticsFactory.statistics = response.data.statistics; }, function () { NotificationFactory.showCallbackNotification(); }); }; return StatisticsFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("StyleFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let StyleFactory = {}; StyleFactory.styles = {}; StyleFactory.getStyles = function (profileId) { let request = { url: "app/web/public-profile/styles/get", method: POST, headers: HEADERS, data: $.param({ profileId: profileId }) }; return $http(request).then(function (response) { StyleFactory.styles = response.data.styles; }, function () { NotificationFactory.showCallbackNotification(); }); }; return StyleFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("TalentListFactory", ["$http", "NotificationFactory", function ($http, NotificationFactory) { let TalentListFactory = {}; TalentListFactory.talentListDirectories = []; TalentListFactory.getTalentListDirectories = function () { let request = { url: "app/web/talent-list/get", method: GET, headers: HEADERS }; return $http(request).then(function (response) { try { TalentListFactory.talentListDirectories = response.data.talentList.list; } catch (Exception) { location.reload(); } }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.saveTalentListDirectories = function (payload) { let request = { url: "app/web/talent-list/save", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { NotificationFactory.showNotification(response); }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.deleteTalentListDirectories = function (payload) { let request = { url: "app/web/talent-list/delete", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { NotificationFactory.showNotification(response); }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.deleteTalent = function (payload) { let request = { url: "app/web/talents/remove-from-list", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { NotificationFactory.showNotification(response); }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.addTalentToList = function (payload) { let request = { url: "app/web/talent/add-to-list", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { TalentListFactory.talentList = response.data; NotificationFactory.showNotification(response); }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.getTalentLists = function () { let request = { url: "app/web/talent-list/get", method: GET, headers: HEADERS }; return $http(request).then(function (response) { TalentListFactory.talentList = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.getTalentListsDetails = function (payload) { let request = { url: "app/web/talents-from-list/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { TalentListFactory.talentListDetails = response.data; }, function () { NotificationFactory.showCallbackNotification(); }); }; TalentListFactory.saveCasting = function (payload) { let request = { url: "app/web/casting/save", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { NotificationFactory.showNotification(response); }, function () { NotificationFactory.showCallbackNotification(); }); }; return TalentListFactory; } ]); "use strict"; angular .module("bookdWebApp") .factory("UserAccountFactory", ["$rootScope", "$http", "Upload", "NotificationFactory", function ($rootScope, $http, Upload, NotificationFactory) { let UserAccountFactory = {}; UserAccountFactory.profile = {}; UserAccountFactory.getProfile = function (payload) { let request = { url: "app/web/public-profile/get", method: POST, headers: HEADERS, data: $.param(payload) }; return $http(request).then(function (response) { UserAccountFactory.profile = response.data.profile; UserAccountFactory.profile.email = response.data.email; UserAccountFactory.profile.verified = response.data.verified; UserAccountFactory.profile.rating = response.data.rating; }, function () { NotificationFactory.showCallbackNotification(); }); }; return UserAccountFactory; } ]); (function () { "use strict"; angular .module("bookdWebApp") .service("ContactNumberService", initialize); function initialize($http) { return { getNumber: getNumber, getCountryCode: getCountryCode, getContactNumber: getContactNumber, getCurrentLocation: getCurrentLocation, setCurrentCountry: setCurrentCountry }; function getNumber(contactNumberIntlTelInput) { if (!contactNumberIntlTelInput) { return ""; } return contactNumberIntlTelInput.getNumber(); } function getCountryCode(contactNumberIntlTelInput) { if (!contactNumberIntlTelInput) { return ""; } let countryData = contactNumberIntlTelInput.getSelectedCountryData(); if (!countryData) { return ""; } return ("+" + countryData.dialCode); } function getContactNumber(contactNumberIntlTelInput) { let countryCode = getCountryCode(contactNumberIntlTelInput); let contactNumber = getNumber(contactNumberIntlTelInput); return contactNumber.replace(countryCode, ""); } function getCurrentLocation() { return new Promise((resolve, reject) => { $http.get('http://ip-api.com/json').then((response) => { resolve(response.data); }); }); } function setCurrentCountry(contactNumberIntlTelInput) { if (!contactNumberIntlTelInput) { return; } getCurrentLocation().then((currentLocation) => { if (!currentLocation) { return; } contactNumberIntlTelInput.setCountry(currentLocation.countryCode); }); } } })(); (function () { "use strict"; angular .module("bookdWebApp") .service("CountryService", initialize); function initialize(DataTypeService, JsonFactory) { let countryData = {}; let countryCodeData = {}; initCountryData(); initCountryCodeData(); return { initCountryData: initCountryData, initCountryCodeData: initCountryCodeData, getCountries: getCountries, getCities: getCities, getCountryCodes: getCountryCodes }; /** * Initialize country data. * Assign country data to countryData variable. */ function initCountryData() { JsonFactory.getCountries().then(function () { countryData = JsonFactory.countries; }); } /** * Initialize country code data. * Assign country code data to countryCodeData variable. */ function initCountryCodeData() { JsonFactory.getCountryCodes().then(function () { countryCodeData = JsonFactory.countryCodes; }) } /** * Get all countries. * @return {[]} */ function getCountries() { return Object.keys(countryData).sort(); } /** * Get cities by country. * @param country * @return {[]} */ function getCities(country) { if (!country) { return []; } return countryData[country].sort(); } /** * Get country codes. * @return {[]} */ function getCountryCodes() { return countryCodeData.map(code => { return code.dial_code; }); } } })(); (function () { "use strict"; angular .module("bookdWebApp") .service("DataService", initialize); function initialize() { return { getActivities: getActivities, getMusicGenre: getMusicGenre, getEthnicities: getEthnicities, getRaces: getRaces, getEyeColors: getEyeColors, getHairColors: getHairColors, getJobTypes: getJobTypes, getProfessions: getProfessions, getJobAgeRanges: getJobAgeRanges, getProfessionsWithJobTypes: getProfessionsWithJobTypes, getLanguages: getLanguages, getAccents: getAccents, getStyles: getStyles, getAffiliations: getAffiliations, getMonths: getMonths, getHeightMeasurements: getHeightMeasurements, getWeightMeasurements: getWeightMeasurements, getChestMeasurements: getChestMeasurements, getHipMeasurements: getHipMeasurements, getWaistMeasurements: getWaistMeasurements, getLegMeasurements: getLegMeasurements, getShoulderMeasurements: getShoulderMeasurements, getNeckMeasurements: getNeckMeasurements, getShoeMeasurements: getShoeMeasurements, getVerificationStatusConstants: getVerificationStatusConstants, getMessagesToPotentialTalents: getMessagesToPotentialTalents, getSectionInfoList: getSectionInfoList }; function getActivities() { return [ "Football", "Basketball", "Baseball", "Rugby", "NFL", "Volleyball", "Netball", "Ice Skating", "Tennis", "Squash", "Badminton", "Martial Arts", "Boxing", "Yoga", "Parkour", "Ballet", "Dancing", "Fitness Training", "Golf", "Motorbike", "Ski", "Snowboard", "Mountain Biking", "Horse Riding", "Rock Climbing", "Running", "Scuba Diving", "Singing", "Surfing", "Swimming", "Vehicle License", "Water Ski" ]; } function getMusicGenre() { return [ 'RnB Electronic Dance', 'House', 'Hip Hop', 'Electronic', 'Dance', 'Techno', 'Disco', 'Electro House', 'Funk', 'Electronica', 'Afro beats', 'Trance', 'Psychedelic Trance', 'Tech House', 'Progressive House', 'Deep House', 'Chill-out', 'Pop', 'Dance-pop', 'Electro', ]; } function getEthnicities() { return [ "African", "African-American", "Asian (Mixed)", "Caucasian", "Chinese", "Eastern European", "Eurasian", "European", "Hispanic", "Indian", "Japanese", "Korean", "Malay", "Middle Eastern", "Native American", "Pacific Islander", "Persian" ]; } function getRaces() { return [ "Malay", "Chinese", "Indigenous", "Indian" ]; } function getEyeColors() { return [ "Black", "Grey", "Dark Brown", "Light Brown", "Dark Blue", "Light Blue", "Bluish Green", "Teal", "Purple", "Brown Green", "Gold Green", "Blue Grey", "Blue" ]; } function getHairColors() { return [ "Black", "Brown", "Light Brown", "Dark Brown", "Bleach Blond", "Copper Blond", "Natural Blond", "Strawberry Blond", "Red", "Grey" ]; } function getJobTypes() { return [ "Accessories", "Body Parts", "Cat Walk", "Commercial Video", "Corporate Video", "Corporate Wear", "Cultural Wear", "Event Ambassador", "Event Talent", "Fitness Wear", "Glamour", "Hair Exhibition", "Lingerie", "Men's Wear", "Nude", "Swim Wear", "Video Extra", "Women's Wear", "Baby Wear", "Teen Wear", "Child Extra" ]; } function getProfessions() { return [ "Actor", "Dancer", "Emcee", "Model", "Singer", "Voiceover", "Group Manager", "DJ" ]; } function getJobAgeRanges() { return [ "3-5", "6-10", "11-15", "16-20", "21-25", "26-30", "31-35", "36-40", "41-45", "46-50", "51-55", "56-59", "60-100" ]; } function getProfessionsWithJobTypes() { return { Model: [ "Ladies Fashion", "Men\'s Fashion", "Corporate Fashion", "Cultural Fashion", "Fitness Fashion", "Teen Fashion", "Baby Fashion", "Lingerie & Underwear Fashion", "Swimwear", "Nude", "Glamour", "Hand Model", "Foot Model", "Leg Model", "Accessory / Jewelry", "Hair / Beauty Exhibition", "Event Ambassador", "Magazine Editorial", "Skin Beauty", "Commercial Video", "Corporate Video", "Commercial/Video Extra" ], Actor: [ "Brand Commercial Video", "Corporate Video", "Online Film & Video", "Extra Role", "Feature Role", "Main Role", "Stage / Theatre Performer", "Voice Over" ], Dancer: [ "House", "Jazz / Funk", "Pop / Jazz", "Lyrical Dance", "Ballroom", "Latin Ballroom", "Tap", "Swing", "Flamengco", "Caporiera", "Ballet", "Contemporary", "Hiphop", "Jazz", "Street / Break", "Zumba (Dance)", "Zumba (Instructor)" ], Singer: [ "Opera Singer", "Contemporary Singer", "Jazz Singer", "Crooner Singer", "Modern Pop", "Cover Singer", "Country Singer", "Voiceover" ], Emcee: [ "Corporate Event", "Gala Dinner", "Store Opening", "Launch Event", "Road Show", "Voiceover" ], Voiceover: [ "Automated Dialogue Replacement (ADR)", "Anime", "Announcer", "Audiobooks", "Cartoon/Animation", "Character", "Commercials", "E-Learning", "Online Commercials", "Radio", "Telephone & Interactive Voice Response (IVR)", "Video Gaming", "Voice Prompt" ], DJ: [ 'Corporate Events', 'Product Launches', 'Birthdays & Anniversary Parties', 'Weddings', 'Private Party', 'Club & Bars' ] }; } function getLanguages() { return [ "English", "Chinese (Mandarin)", "Chinese (Cantonese)", "Spanish", "Hindi", "Arabic", "Portuguese", "Bengali", "Russian", "Japanese", "Punjabi", "French", "Italian", "German", "Malay", "Korean" ]; } function getAccents() { return [ "African", "Australian", "British", "American", "Chinese", "East European", "French", "German", "Italian", "Indian", "Irish", "Jamaican", "Korean", "Japanese", "Malay", "Mexican", "Middle Eastern", "Russian", "Scot", "Spanish" ]; } function getStyles() { return [ "Energetic", "Young", "Corporate", "Fatherly/Motherly", "High-pitched", "Low", "Gravelly", "Smooth", "Sexy", "Conversational" ]; } function getAffiliations() { return [ "I am a freelancer", "I have a mother agency", "I am scouted by..." ]; } function getMonths() { return [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; } function getHeightMeasurements() { let heightMeasurements = []; for (let measurement = 1; measurement <= 220; measurement++) { heightMeasurements.push({value: measurement, text: measurement}); } return heightMeasurements; } function getWeightMeasurements() { let weightMeasurements = []; for (let measurement = 1; measurement <= 150; measurement++) { weightMeasurements.push({value: measurement, text: measurement}); } return weightMeasurements; } function getChestMeasurements() { let chestMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { chestMeasurements.push({value: measurement, text: measurement}); } return chestMeasurements; } function getHipMeasurements() { let hipMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { hipMeasurements.push({value: measurement, text: measurement}); } return hipMeasurements; } function getWaistMeasurements() { let waistMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { waistMeasurements.push({value: measurement, text: measurement}); } return waistMeasurements; } function getLegMeasurements() { let legMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { legMeasurements.push({value: measurement, text: measurement}); } return legMeasurements; } function getShoulderMeasurements() { let shoulderMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { shoulderMeasurements.push({value: measurement, text: measurement}); } return shoulderMeasurements; } function getNeckMeasurements() { let neckMeasurements = []; for (let measurement = 1; measurement <= 200; measurement++) { neckMeasurements.push({value: measurement, text: measurement}); } return neckMeasurements; } function getShoeMeasurements() { let shoeMeasurements = []; for (let measurement = 10; measurement <= 50; measurement++) { shoeMeasurements.push({value: measurement, text: measurement}); } return shoeMeasurements; } function getVerificationStatusConstants() { return { NON_VERIFIED: "Non Verified", PENDING_VERIFICATION: "Pending Verification", VERIFIED: "Verified" } } function getMessagesToPotentialTalents() { let emailMessageToPotentialTalents = `Hi (name), I have just come across a new platform called bookd! It is a booking platform for professional talent such as models, dancers, singers, actors and emcees to get jobs all around the world. You are a great talent and I believe this is an amazing opportunity for you to showcase your professional profile. It's super easy to register and it's completely FREE to have a profile. The booking and online casting features are great and allow clients to book and cast you immediately if they like you. You can accept, decline and even negotiate the job budgets and with their 15 working day payment guarantee and only taking 10% commissions on jobs. I feel it is a secure and efficient way of working with International Clients. They also provide you with full training on how to get your professional profile live and ready for clients to view within 1 hour! Or if you are close to one of their studios you can book in for a one on one guided shoot with their team, I checked out the training and studio shoot myself and it was of the highest quality. Click this link to sign up, follow the instructions and get seen by clients. \${affiliateLink}\ Message me if you need any help at all. You can also check out and book in for your shoot here: https://bookd.timetap.com`; let whatsappMessageToPotentialTalents = `Hi (name), I have just come across a new platform called bookd! It is a booking platform for professional talent like yourself to get jobs all around the world. You are a great talent and I believe this is an amazing opportunity for you to showcase your professional profile. Here is what I found out: - It’s completely FREE to have a profile. - Booking and casting features that allow you to accept, decline or even negotiate the job budgets. - They give a 15 working day payment guarantee. - Only taking 10% commissions on jobs you book. - They provide a safer and more secure way of working with International Clients. You’re even provided with full training on how to get your professional profile live and ready for clients to view within 1 hour! Or if you are close to one of their studios you can book in for a one on one guided shoot with their team, I checked out the training and studio shoot myself and it was of the highest quality. Click this link to sign up, follow the instructions and get seen by clients. \${affiliateLink}\ Message me if you need any help at all. You can also check out and book in for your shoot here: https://bookd.timetap.com Thanks!`; return { EMAIL_MESSAGE_TO_POTENTIAL_TALENTS: emailMessageToPotentialTalents, WHATSAPP_MESSAGE_TO_POTENTIAL_TALENTS: whatsappMessageToPotentialTalents } } function getSectionInfoList() { return { personalInfo: 'This section is for your personal info. Please keep this updated.', statistics: 'This section is for your statistics. Please keep this updated.', jobTypes: 'This section is for your job types. Please keep this updated.', jobAgeRange: 'The Potential Age Range You Could Be Booked For.', styles: 'This section is for your styles. Please keep this updated.', language: 'This section is for your language. Please keep this updated.', accents: 'This section is for your accents. Please keep this updated.', activities: 'This section is for your activities. Please keep this updated.', musicGenre: 'This section is for your music genre. Please keep this updated.', recentExposure: 'This section is for your recent exposure. Please keep this updated.', jobRates: 'This section is for your job rates. Please keep this updated.', portfolio: 'Minimum 5 images, maximum 20 images. Images from work credited test shoots.', portfolioVoiceover: 'MP3 files minimum of 5.', polaroid: '20 images required. They are Natural Snapshots, with a clean background and minimal make up. Variety of expression and movement.', videoCasting: 'A 90-second introduction video, once verified you may add up to 4 more commercial videos.', videoReferences: 'Add more videos to showcase yourself to clients. Copy and paste the url from your youtube channel of up to 4 additional reference videos.' }; } } })(); (function () { "use strict"; angular .module("bookdWebApp") .service("DataTypeService", initialize); function initialize() { return { toString: toString, toInt: toInt, toFloat: toFloat, toArray: toArray, isArray: isArray }; /** * Convert data to string. * @param data * @return {string} */ function toString(data) { return data ? data.toString() : ""; } /** * Convert data to number. * @param data * @return {number} */ function toInt(data) { return data ? +data : 0; } /** * Convert data to float. * @param data * @return {number} */ function toFloat(data) { return data ? parseFloat(data.replace(",", ".")) : 0.0; } /** * Convert data to array. * @param data * @return {[]} */ function toArray(data) { return data ? Array.from(data) : []; } /** * Convert data to boolean. * @param data * @return {boolean} */ function isArray(data) { return data ? Array.isArray(data) : false; } } })(); (function () { 'use strict'; function DateTimeService() { const FORMAT_SLASH_MDY = 'MM/DD/YYYY'; const FORMAT_DAY = 'D'; const FORMAT_MONTH_NAME = 'MMMM'; const FORMAT_YEAR = 'YYYY'; const FORMAT_DATE = 'YYYY-MM-DD'; const FORMAT_DATETIME = 'YYYY-MM-DD hh:mm'; const momentInstance = moment; const toMoment = (date = null) => { return date ? moment(date) : moment(); }; /** * Converts month, day and year to millis. * @param month * @param day * @param year * @returns {number} */ const toMillis = (month, day, year) => { return +new Date(month + ' ' + day + ' ' + year); }; /** * Get month from millis. * @param millis * @returns {*|string} */ const getMonthFromMillis = (millis) => { return toMoment(new Date(parseInt(millis))).format(FORMAT_MONTH_NAME); }; /** * Get day from millis. * @param millis * @returns {*|string} */ const getDayFromMillis = (millis) => { return parseInt(toMoment(new Date(parseInt(millis))).format(FORMAT_DAY)); }; /** * Get year from millis. * @param millis * @returns {*|string} */ const getYearFromMillis = (millis) => { return parseInt(toMoment(new Date(parseInt(millis))).format(FORMAT_YEAR)); }; /** * Add number of days to the provided date. * @param date - moment date object * @param numberOfDays - integer number of days * @returns {*} */ const addDaysToDate = (date, numberOfDays) => { if (!date || (date && !date.isValid())) { date = toMoment(); } return date.add(numberOfDays, 'day'); }; /** * Subtract number of days to the provided date. * @param date - moment date object * @param numberOfDays - integer number of days * @returns {*} */ const subtractDaysToDate = (date, numberOfDays) => { if (!date || (date && !date.isValid())) { date = toMoment(); } return date.subtract(numberOfDays, 'day'); }; /** * Find earliest date in list of dates. * @param dates - array of moment dates * @returns {*} */ const findEarliestDate = (dates) => { if (!dates || (dates && dates.constructor !== Array) || !dates.length) { return; } let earliestDate = dates[0]; dates.forEach(date => earliestDate = date.isValid() && date.isBefore(earliestDate) ? date : earliestDate); return earliestDate; }; /** * Find earliest date in list of dates. * @param dates - array of moment dates * @returns {*} */ const findLatestDate = (dates) => { if (!dates || (dates && dates.constructor !== Array) || !dates.length) { return; } let latestDate = dates[0]; dates.forEach(date => latestDate = date.isValid() && date.isAfter(latestDate) ? date : latestDate); return latestDate; }; /** * Convert unix timestamp to standard date - YYYY-MM-DD. * @param timestamp - unix timestamp * @returns {*} */ const convertTimestampToStandardDate = (timestamp) => { return toMoment(new Date(parseInt(timestamp) * 1000)).format(FORMAT_DATE); }; /** * Convert standard date to unix timestamp. * @param date - human readable date format * @returns {number} */ const convertStandardDateToTimestamp = (date) => { return toMoment(new Date(date)).unix(); }; /** * Convert millis to moment dates. * @param dateInMillis * @returns {*} */ const convertMillisDateToMoment = (dateInMillis) => { if (!dateInMillis) { return; } return toMoment(new Date(parseInt(dateInMillis))); }; /** * Convert millis to moment dates. * @param datesInMillis * @returns {*} */ const convertMillisDatesToMoment = (datesInMillis) => { if (!datesInMillis || (datesInMillis && datesInMillis.constructor !== Array) || !datesInMillis.length) { return; } let dates = []; datesInMillis.forEach(date => dates.push(convertMillisDateToMoment(date))); return dates; }; /** * Format timestamp. * @param timestamp * @param format * @returns {*} */ const formatTimestamp = (timestamp, format = FORMAT_DATE) => { return momentInstance.unix(Number(timestamp)).format(format); }; /** * Convert timestamp to slash mdy format. * @param timestamp * @returns {*} */ const timestampToMDY = (timestamp) => { return formatTimestamp(timestamp, FORMAT_SLASH_MDY); }; /** * Get start of month. * @returns {*} */ const getStartOfMonthDate = () => { return toMoment().startOf('month').format(FORMAT_DATETIME); }; /** * Get end of month. * @returns {*} */ const getEndOfMonthDate = () => { return toMoment().endOf('month').format(FORMAT_DATETIME); }; return { toMoment, toMillis, getMonthFromMillis, getDayFromMillis, getYearFromMillis, addDaysToDate, subtractDaysToDate, findEarliestDate, findLatestDate, convertTimestampToStandardDate, convertStandardDateToTimestamp, convertMillisDateToMoment, convertMillisDatesToMoment, formatTimestamp, timestampToMDY, getStartOfMonthDate, getEndOfMonthDate }; } angular .module('bookdWebApp') .service('DateTimeService', DateTimeService); })(); (function () { "use strict"; angular .module("bookdWebApp") .service("ImageService", initialize); function initialize(Upload) { const IMAGE_MAX_WIDTH = 2000; const IMAGE_MAX_HEIGHT = 2000; const IMAGE_MAX_SIZE = 5000000; const ROTATE_LEFT = "left"; const ROTATE_RIGHT = "right"; let degrees = 0; return { blobToDataUrl: blobToDataUrl, imageUrlToDataUrl: imageUrlToDataUrl, dataUrlToBlob: dataUrlToBlob, dataUrlToFile: dataUrlToFile, rotate: rotate }; /** * Convert blob to data url (base 64 image). * @param image (File) - image to be converted to base 64 image * @return {Promise} - base 64 image */ function blobToDataUrl(image) { return new Promise((resolve, reject) => { let base64Image = ""; let fileReader = new FileReader(); fileReader.readAsDataURL(image); fileReader.onload = function () { let imageElement = document.createElement("img"); imageElement.src = fileReader.result; base64Image = fileReader.result; setTimeout(function () { if (imageElement.width > IMAGE_MAX_WIDTH || imageElement.height > IMAGE_MAX_HEIGHT || image.size > IMAGE_MAX_SIZE) { toastr.warning("This image is too large. The image should be " + IMAGE_MAX_WIDTH + " x " + IMAGE_MAX_HEIGHT + " pixels and less than 5MB."); base64Image = ""; } else { resolve(base64Image); } }, 1000); }; }); } /** * Convert image url to data url (base 64 image). * @param imageUrl - url of the image to be converted to base 64 image * @return {Promise} - base 64 image */ function imageUrlToDataUrl(imageUrl) { return new Promise((resolve, reject) => { let image = new Image(); image.crossOrigin = "anonymous"; image.onload = function () { let canvas = document.createElement("canvas"); let context2D = canvas.getContext("2d"); canvas.width = image.width; canvas.height = image.height; context2D.drawImage(image, 0, 0); resolve(canvas.toDataURL("image/png")); }; image.src = imageUrl; }); } /** * Convert data url (base 64 image) to Blob. * @param croppedImage (File) - source image to be cropped * @return {Blob} */ function dataUrlToBlob(croppedImage) { let fileName = "image.png"; return Upload.dataUrltoBlob(croppedImage, fileName); } /** * Convert data url (base 64 image) to File. * @param dataUrl (string) - source image to be cropped * @return {File} */ function dataUrlToFile(dataUrl) { let fileName = "image.png"; let blob = dataUrlToBlob(dataUrl); blob.lastModifiedDate = new Date(); blob.name = fileName; return new File([blob], fileName); } /** * Rotate image. * @param base64Image - base 64 image to be rotated * @param direction - direction (left, right) * @return {Promise} - base 64 image */ function rotate(base64Image, direction) { return new Promise((resolve, reject) => { let image = new Image(); image.onload = function () { let canvas = document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; let context2D = canvas.getContext("2d"); if (direction === ROTATE_RIGHT) { degrees += 90; } else if (direction === ROTATE_LEFT) { degrees -= 90; } let angle = degrees * Math.PI / 180; // translate to center-canvas // the origin [0,0] is now center-canvas context2D.translate(canvas.width / 2, canvas.height / 2); // roate the canvas by +90% (==Math.PI/2) context2D.rotate(angle); // draw the signature // since images draw from top-left offset the draw by 1/2 width & height context2D.drawImage(image, -image.width / 2, -image.height / 2); // un-rotate the canvas by -90% (== -Math.PI/2) context2D.rotate(-degrees); // un-translate the canvas back to origin==top-left canvas context2D.translate(-canvas.width / 2, -canvas.height / 2); resolve(canvas.toDataURL()); }; image.src = base64Image; }); } } })(); (function () { 'use strict'; angular .module('bookdWebApp') .service('NotificationService', initialize); function initialize() { return { showSuccessNotification: showSuccessNotification, showErrorNotification: showErrorNotification, showDefaultNotification: showDefaultNotification }; function showSuccessNotification(message) { toastr.success(message); } function showErrorNotification(message) { toastr.error(message); } function showDefaultNotification() { toastr.warning(ERROR_MESSAGE); } } })(); (function () { "use strict"; angular .module("bookdWebApp") .service("PageService", PageService); function PageService() { return { showModal: showModal, hideModal: hideModal, hideActiveModal: hideActiveModal }; function showModal(modal) { hideActiveModal(); $("#" + modal).modal("show"); setTimeout(() => { let body = $("body"); if (!body.hasClass("modal-open")) { body.addClass("modal-open"); } }, 2000); } function hideModal(modal) { $("#" + modal).modal("hide"); } function hideActiveModal() { $(".modal").modal("hide"); } } })(); (function () { "use strict"; angular .module("bookdWebApp") .service("StringService", initialize); function initialize() { return { capitalize: capitalize, convertParameterToValue: convertParameterToValue, format: format }; function capitalize(words) { return words ? words[0].toUpperCase() + words.substr(1).toLowerCase() : ""; } function convertParameterToValue(parameter) { return parameter ? capitalize(parameter).replace("-", " ") : ""; } function format(text, items) { for (let key in items) { if (items.hasOwnProperty(key)) { text = text.replace("${" + key + "}", items[key]); } } return text; } } })(); (function () { 'use strict'; angular .module('bookdWebApp') .filter('unixTimestampToLocalDate', function () { return function (unixTimestamp) { return moment(new Date(parseInt(unixTimestamp) * 1000)).format('ll'); }; }); angular .module('bookdWebApp') .filter('dateToISO', function () { return function (input) { return new Date(input).toISOString(); }; }); angular .module('bookdWebApp') .filter('toLocalDateTime', function () { return function (dateTime) { let date = new Date(moment.utc(dateTime)); return moment(date).format('MMM DD, Y h:mm A'); }; }); angular .module('bookdWebApp') .filter('toLocalDate', function () { return function (date) { //return moment(date).format('MMM DD, Y'); return moment(new Date(parseInt(date))).format('ll'); }; }); angular .module('bookdWebApp') .filter('timestampToLocalDate', function () { return function (date) { return moment(new Date(parseInt(date) * 1000)).format('ll'); }; }); angular .module('bookdWebApp') .filter('toLocalMonthYearDate', function () { return function (date) { return moment(new Date(parseInt(date))).format('MMM Y'); }; }); angular .module('bookdWebApp') .filter('toLocalTime', function () { return function (date) { return moment(new Date(parseInt(date))).format('LT'); }; }); angular .module('bookdWebApp') .filter('toMediumDate', function () { return function (date) { let currentDate = new Date(date); return moment(currentDate).format('MMM DD, Y'); }; }); angular .module('bookdWebApp') .filter('plusFiveDays', function () { return function (date) { let initialDate = new Date(parseInt(date)); return moment(initialDate).add(5, 'day').format('ll'); }; }); angular .module('bookdWebApp') .filter('plusFifteenDays', function () { return function (date) { let initialDate = new Date(parseInt(date)); return moment(initialDate).add(15, 'day').format('ll'); }; }); angular .module('bookdWebApp') .filter('leadingZeros', function () { return function (input) { let size = 2; if (input) { while (input.length < (size || 2)) { input = '0' + input; } return input; } }; }); angular .module('bookdWebApp') .filter('minusOneDay', function () { return function (date) { let initialDate = new Date(parseInt(date)); return moment(initialDate).subtract(1, 'day').format('ll'); }; }); angular .module('bookdWebApp') .filter('shootLocationsObjectToString', function () { return function (locations) { let shootLocations = ''; let locationItem; if (typeof locations === 'string') { locations = JSON.parse(locations); } for (locationItem in locations) { shootLocations += locations[locationItem].city + ', ' + locations[locationItem].country + '/'; } return shootLocations; }; }); angular .module('bookdWebApp') .filter('toLocalDateString', function () { return function (dateString) { if (typeof dateString === 'undefined') { return; } let dateList = []; let dates = []; if (typeof dateString === 'string') { if (dateString.includes(',')) { dateList = dateString.split(','); } else { dateList = [dateString]; } } else if (Array.isArray(dateString)) { dateList = dateString; } dateList.forEach(date => { if (date.includes('-')) { const dateParts = date.split('-'); const dateStart = moment(new Date(parseInt(dateParts[0]))).format('MMM DD Y hh:mm A'); const dateEnd = moment(new Date(parseInt(dateParts[1]))).format('hh:mm A'); dates.push(dateStart + '-' + dateEnd); } else { dates.push(moment(new Date(parseInt(date))).format('MMM DD Y')); } }); return (dates.toString()).replace(',', ', '); }; }); angular .module('bookdWebApp') .filter('toLocalDateTimeString', function () { return function (dateString) { if (typeof dateString === 'undefined') { return; } let dateList = []; let dates = []; if (typeof dateString === 'string') { if (dateString.includes(',')) { dateList = dateString.split(','); } else { dateList = [dateString]; } } else if (Array.isArray(dateString)) { dateList = dateString; } dateList.forEach(date => { if (date.includes('-')) { const dateParts = date.split('-'); const dateStart = moment(new Date(parseInt(dateParts[0]))).format('MMM DD Y hh:mm A'); const dateEnd = moment(new Date(parseInt(dateParts[1]))).format('hh:mm A'); dates.push(dateStart + '-' + dateEnd); } else { dates.push(moment(new Date(parseInt(date))).format('MMM DD Y hh:mm A')); } }); return (dates.toString()).replace(',', ', '); }; }); angular .module('bookdWebApp') .filter('toLocalDateTimeStringVertical', function () { return function (dateString) { if (typeof dateString === 'undefined') { return; } let dateList = dateString; let dates = []; let dateTimes = []; if (typeof dateString === 'string') { dateList = dateString.split(','); } dateList.forEach(date => { if (date.indexOf('-') > -1) { dateTimes = date.split('-'); dates.push(moment(new Date(parseInt(dateTimes[0]))).format('MMM DD. Y hh:mm A') + ' - ' + moment(new Date(parseInt(dateTimes[1]))).format('hh:mm A')); } else { dates.push(moment(new Date(parseInt(date))).format('MMM DD Y')); } }); let formattedDateTimeString = (dates.toString()).replace(/,/g, '\n'); return formattedDateTimeString.replace('.', ','); }; }); angular .module('bookdWebApp') .filter('toArray', function () { return function (text) { return text.split(','); }; }); angular .module('bookdWebApp') .filter('yearRange', function () { return function (input, startYear) { let currentYear = new Date().getFullYear(); for (let i = startYear; i <= currentYear; i++) { input.push(i); } return input; }; }); angular .module('bookdWebApp') .filter('range', function () { return function (input, total) { total = !total ? 0 : total; total = Math.round(parseFloat(total)); for (let i = 0; i < total; i++) { input.push(i); } return input; }; }); angular .module('bookdWebApp') .filter('ratingRange', function () { return function (input, total) { total = !total ? 0 : total; total = 5 - Math.round(parseFloat(total)); for (let i = 0; i < total; i++) { input.push(i); } return input; }; }); angular .module('bookdWebApp') .filter('linebreaks', function () { return function (text) { return text.replace(/\n/g, '
'); }; }); angular .module('bookdWebApp') .filter('trustUrl', function ($sce) { return function (url) { return $sce.trustAsResourceUrl(url); }; }); angular .module('bookdWebApp') .filter('toString', function () { return function (data) { if (typeof data === 'undefined') { return; } if (typeof data !== 'string') { data = data.toString(); } return data.split(',').join(', '); }; }); angular .module('bookdWebApp') .filter('toTitle', function () { return function (data) { if (typeof data === 'undefined') { return; } if (typeof data !== 'string') { data = data.toString(); } data = data.split(',').join(' '); return data.split(',').join(' ').toUpperCase(); }; }); angular .module('bookdWebApp') .filter('currencyCode', function () { return function (currencyFullName) { if (typeof currencyFullName === 'undefined') { return; } return currencyFullName.substring(0, currencyFullName.indexOf('' - '')); }; }); angular .module('bookdWebApp') .filter('toLocationDisplay', function () { return function (locationData) { let location = ''; try { let items = JSON.parse(locationData); if (items.constructor === Array) { items.forEach(item => { location += item.city + ' ' + item.country; if (items.indexOf(item) + 1 < items.length) { location += '|'; } }); } } catch (e) { location = locationData; } return location; }; }); angular .module('bookdWebApp') .filter('convertTimestampToStandardDate', function () { return function (timestamp) { if (typeof timestamp === 'undefined') { return; } return moment(new Date(parseInt(timestamp) * 1000)).format('YYYY-MM-DD'); }; }); angular .module('bookdWebApp') .filter('toNearestTenth', function () { return function (number) { if (typeof number === 'undefined' || !number) { return 'N/A'; } return Math.round(parseFloat(number) * 10) / 10; }; }); angular .module('bookdWebApp') .filter('unixTimestampToAge', function () { return function (unixTimestamp) { if (typeof unixTimestamp === 'undefined') { return; } const birthday = new Date(Number(unixTimestamp) * 1000); let ageDifference = Date.now() - birthday.getTime(); let ageDate = new Date(ageDifference); let age = Math.abs(ageDate.getUTCFullYear() - 1970); return age || ''; }; }); angular .module('bookdWebApp') .filter('toEthnicities', function () { return function (data) { if (typeof data === 'undefined') { return; } if (typeof data !== 'string') { data = data.toString(); } return data.split(',').join(', ', ''); }; }); angular .module('bookdWebApp') .filter('toLocalDateArray', function () { return function (dateString) { if (typeof dateString === 'undefined') { return; } let dateList = dateString; let dates = []; let dateTimes = []; if (typeof dateString === 'string') { dateList = dateString.split(','); } dateList.forEach(date => { if (date.indexOf('-') > -1) { dateTimes = date.split('-'); dates.push(moment(new Date(parseInt(dateTimes[0]))).format('MMM DD Y hh:mm A') + ' - ' + moment(new Date(parseInt(dateTimes[1]))).format('hh:mm A')); } else { dates.push(moment(new Date(parseInt(date))).format('MMM DD Y')); } }); return dates; return (dates.toString()).replace(',', ', '); }; }); })(); (function () { /** * Directs all other Pages */ "use strict"; angular .module("bookdWebApp") .directive("myOnKeyDownCall", function () { return function (scope, element, attrs) { let numKeysPress = 0; element.bind("keydown keypress", function (event) { numKeysPress++; if (numKeysPress >= 5) { scope.$apply(function () { scope.$eval(attrs.myOnKeyDownCall); }); event.preventDefault(); } }); }; }); angular .module("bookdWebApp") .directive("onFinishRender", ["$timeout", function ($timeout) { return { restrict: "A", link: function (scope, element, attr) { if (scope.$last === true) { $timeout(function () { scope.$emit("ngRepeatFinished"); }); } } } }]); angular .module("bookdWebApp") .directive("fileModel", ["$parse", function ($parse) { return { restrict: "A", link: function (scope, element, attrs) { let model = $parse(attrs.fileModel); let modelSetter = model.assign; element.bind("change", function () { scope.$apply(function () { modelSetter(scope, element[0].files[0]); }); }); } }; }]); angular .module("bookdWebApp") .directive("collapsible", function () { return function (scope, element, attrs) { if (scope.$last) { $(".collapsible").collapsible({ accordion: false }); } }; }); angular .module("bookdWebApp") .directive("lightgallery", function () { return { restrict: "A", link: function (scope, element, attrs) { if (scope.$last) { element.parent().lightGallery(); } } }; }); angular .module("bookdWebApp") .animation(".slide", function () { let NG_HIDE_CLASS = "ng-hide"; return { beforeAddClass: function (element, className, done) { if (className === NG_HIDE_CLASS) { element.slideUp(done); } }, removeClass: function (element, className, done) { if (className === NG_HIDE_CLASS) { element.hide().slideDown(done); } } } }); angular .module("bookdWebApp") .directive("enter", function () { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { if (event.which === 13 && !event.shiftKey) { scope.$apply(function () { scope.$eval(attrs.enter); }); event.preventDefault(); } }); }; }); angular .module("bookdWebApp") .directive("ngFileModel", ["$parse", function ($parse) { return { restrict: "A", link: function (scope, element, attrs) { let model = $parse(attrs.ngFileModel); let isMultiple = attrs.multiple; let modelSetter = model.assign; element.bind("change", function () { let values = []; angular.forEach(element[0].files, function (item) { let value = { // File Name name: item.name, //File Size size: item.size + " kb", //File URL to view url: URL.createObjectURL(item), // File Input Value _file: item }; values.push(value); }); scope.$apply(function () { if (isMultiple) { modelSetter(scope, values); } else { modelSetter(scope, values[0]); } }); }); } }; }]); angular .module("bookdWebApp") .directive("numericbinding", function () { return { restrict: "A", require: "ngModel", scope: { model: "=ngModel", }, link: function (scope, element, attrs, ngModelCtrl) { if (scope.model && typeof scope.model === "string") { scope.model = parseInt(scope.model); } } }; }); angular .module("bookdWebApp") .directive("number", function () { return { restrict: "A", link: function (scope, elem, attrs) { angular.element(elem).on("keypress", function (event) { let isNumber = /[0-9]|-/.test(String.fromCharCode(event.which)); if (!isNumber) { event.preventDefault(); } }); } } }); angular .module("bookdWebApp") .directive("limit", function () { return { restrict: "A", link: function (scope, elem, attrs) { let limit = parseInt(attrs.limit); angular.element(elem).on("keypress", function (event) { if (this.value.length === limit) { event.preventDefault(); } }); } } }); angular .module("bookdWebApp") .directive("preventCheckOrUncheck", function () { return { restrict: "A", link: function (scope, elem, attrs) { angular.element(elem).on("click", function (event) { event.preventDefault(); }); } } }); angular .module("bookdWebApp") .directive("compile", ["$compile", function ($compile) { return function (scope, element, attrs) { scope.$watch( function (scope) { return scope.$eval(attrs.compile); }, function (value) { element.html(value); $compile(element.contents())(scope); } ); }; }]); })();