From 1ecde45f88fa9a7a54a9a6fd8a398f3f4a8481de Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Fri, 18 Sep 2015 15:34:57 -0400 Subject: pullup view in events to show event summaries across monitors --- www/lib/ionic-pullup/example/.bowerrc | 3 + www/lib/ionic-pullup/example/.gitignore | 7 + www/lib/ionic-pullup/example/bower.json | 7 + www/lib/ionic-pullup/example/config.xml | 42 ++++ www/lib/ionic-pullup/example/gulpfile.js | 52 +++++ www/lib/ionic-pullup/example/hooks/README.md | 83 ++++++++ .../hooks/after_prepare/010_add_platform_class.js | 94 +++++++++ www/lib/ionic-pullup/example/ionic.project | 11 + www/lib/ionic-pullup/example/package.json | 27 +++ .../resources/android/icon/drawable-hdpi-icon.png | Bin 0 -> 2875 bytes .../resources/android/icon/drawable-ldpi-icon.png | Bin 0 -> 1155 bytes .../resources/android/icon/drawable-mdpi-icon.png | Bin 0 -> 1802 bytes .../resources/android/icon/drawable-xhdpi-icon.png | Bin 0 -> 4317 bytes .../android/icon/drawable-xxhdpi-icon.png | Bin 0 -> 7793 bytes .../android/icon/drawable-xxxhdpi-icon.png | Bin 0 -> 11783 bytes .../android/splash/drawable-land-hdpi-screen.png | Bin 0 -> 13657 bytes .../android/splash/drawable-land-ldpi-screen.png | Bin 0 -> 3740 bytes .../android/splash/drawable-land-mdpi-screen.png | Bin 0 -> 7116 bytes .../android/splash/drawable-land-xhdpi-screen.png | Bin 0 -> 39781 bytes .../android/splash/drawable-land-xxhdpi-screen.png | Bin 0 -> 58987 bytes .../splash/drawable-land-xxxhdpi-screen.png | Bin 0 -> 89363 bytes .../android/splash/drawable-port-hdpi-screen.png | Bin 0 -> 13298 bytes .../android/splash/drawable-port-ldpi-screen.png | Bin 0 -> 3628 bytes .../android/splash/drawable-port-mdpi-screen.png | Bin 0 -> 7214 bytes .../android/splash/drawable-port-xhdpi-screen.png | Bin 0 -> 38625 bytes .../android/splash/drawable-port-xxhdpi-screen.png | Bin 0 -> 55504 bytes .../splash/drawable-port-xxxhdpi-screen.png | Bin 0 -> 81831 bytes www/lib/ionic-pullup/example/resources/icon.png | Bin 0 -> 60857 bytes .../example/resources/ios/icon/icon-40.png | Bin 0 -> 1248 bytes .../example/resources/ios/icon/icon-40@2x.png | Bin 0 -> 3564 bytes .../example/resources/ios/icon/icon-50.png | Bin 0 -> 1902 bytes .../example/resources/ios/icon/icon-50@2x.png | Bin 0 -> 4691 bytes .../example/resources/ios/icon/icon-60.png | Bin 0 -> 2452 bytes .../example/resources/ios/icon/icon-60@2x.png | Bin 0 -> 6042 bytes .../example/resources/ios/icon/icon-60@3x.png | Bin 0 -> 10875 bytes .../example/resources/ios/icon/icon-72.png | Bin 0 -> 2866 bytes .../example/resources/ios/icon/icon-72@2x.png | Bin 0 -> 7793 bytes .../example/resources/ios/icon/icon-76.png | Bin 0 -> 3319 bytes .../example/resources/ios/icon/icon-76@2x.png | Bin 0 -> 8305 bytes .../example/resources/ios/icon/icon-small.png | Bin 0 -> 818 bytes .../example/resources/ios/icon/icon-small@2x.png | Bin 0 -> 2287 bytes .../example/resources/ios/icon/icon-small@3x.png | Bin 0 -> 3856 bytes .../example/resources/ios/icon/icon.png | Bin 0 -> 2112 bytes .../example/resources/ios/icon/icon@2x.png | Bin 0 -> 5718 bytes .../ios/splash/Default-568h@2x~iphone.png | Bin 0 -> 31992 bytes .../example/resources/ios/splash/Default-667h.png | Bin 0 -> 40444 bytes .../example/resources/ios/splash/Default-736h.png | Bin 0 -> 45098 bytes .../ios/splash/Default-Landscape-736h.png | Bin 0 -> 44906 bytes .../ios/splash/Default-Landscape@2x~ipad.png | Bin 0 -> 102289 bytes .../ios/splash/Default-Landscape~ipad.png | Bin 0 -> 22655 bytes .../ios/splash/Default-Portrait@2x~ipad.png | Bin 0 -> 99461 bytes .../resources/ios/splash/Default-Portrait~ipad.png | Bin 0 -> 22692 bytes .../resources/ios/splash/Default@2x~iphone.png | Bin 0 -> 18852 bytes .../resources/ios/splash/Default~iphone.png | Bin 0 -> 7214 bytes www/lib/ionic-pullup/example/resources/splash.png | Bin 0 -> 62210 bytes www/lib/ionic-pullup/example/scss/ionic.app.scss | 23 +++ www/lib/ionic-pullup/example/www/css/style.css | 1 + www/lib/ionic-pullup/example/www/img/ionic.png | Bin 0 -> 4757 bytes www/lib/ionic-pullup/example/www/index.html | 42 ++++ www/lib/ionic-pullup/example/www/js/app.js | 85 ++++++++ www/lib/ionic-pullup/example/www/js/controllers.js | 35 ++++ www/lib/ionic-pullup/example/www/js/ion-pullup.js | 226 +++++++++++++++++++++ www/lib/ionic-pullup/example/www/js/services.js | 50 +++++ .../example/www/templates/chat-detail.html | 14 ++ .../example/www/templates/tab-account.html | 9 + .../example/www/templates/tab-chats.html | 33 +++ .../example/www/templates/tab-dash.html | 46 +++++ .../ionic-pullup/example/www/templates/tabs.html | 24 +++ 68 files changed, 914 insertions(+) create mode 100644 www/lib/ionic-pullup/example/.bowerrc create mode 100644 www/lib/ionic-pullup/example/.gitignore create mode 100644 www/lib/ionic-pullup/example/bower.json create mode 100644 www/lib/ionic-pullup/example/config.xml create mode 100644 www/lib/ionic-pullup/example/gulpfile.js create mode 100644 www/lib/ionic-pullup/example/hooks/README.md create mode 100644 www/lib/ionic-pullup/example/hooks/after_prepare/010_add_platform_class.js create mode 100644 www/lib/ionic-pullup/example/ionic.project create mode 100644 www/lib/ionic-pullup/example/package.json create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-hdpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-ldpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-mdpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-xhdpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-xxhdpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/icon/drawable-xxxhdpi-icon.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-hdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-ldpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-mdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-xhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-xxhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-land-xxxhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-hdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-ldpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-mdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-xhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-xxhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/android/splash/drawable-port-xxxhdpi-screen.png create mode 100644 www/lib/ionic-pullup/example/resources/icon.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-40.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-40@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-50.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-50@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-60.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-60@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-60@3x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-72.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-72@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-76.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-76@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-small.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-small@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon-small@3x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/icon/icon@2x.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-568h@2x~iphone.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-667h.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-736h.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-Landscape-736h.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-Landscape@2x~ipad.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-Landscape~ipad.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-Portrait@2x~ipad.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default-Portrait~ipad.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default@2x~iphone.png create mode 100644 www/lib/ionic-pullup/example/resources/ios/splash/Default~iphone.png create mode 100644 www/lib/ionic-pullup/example/resources/splash.png create mode 100644 www/lib/ionic-pullup/example/scss/ionic.app.scss create mode 100644 www/lib/ionic-pullup/example/www/css/style.css create mode 100644 www/lib/ionic-pullup/example/www/img/ionic.png create mode 100644 www/lib/ionic-pullup/example/www/index.html create mode 100644 www/lib/ionic-pullup/example/www/js/app.js create mode 100644 www/lib/ionic-pullup/example/www/js/controllers.js create mode 100644 www/lib/ionic-pullup/example/www/js/ion-pullup.js create mode 100644 www/lib/ionic-pullup/example/www/js/services.js create mode 100644 www/lib/ionic-pullup/example/www/templates/chat-detail.html create mode 100644 www/lib/ionic-pullup/example/www/templates/tab-account.html create mode 100644 www/lib/ionic-pullup/example/www/templates/tab-chats.html create mode 100644 www/lib/ionic-pullup/example/www/templates/tab-dash.html create mode 100644 www/lib/ionic-pullup/example/www/templates/tabs.html (limited to 'www/lib/ionic-pullup/example') diff --git a/www/lib/ionic-pullup/example/.bowerrc b/www/lib/ionic-pullup/example/.bowerrc new file mode 100644 index 00000000..e28246d4 --- /dev/null +++ b/www/lib/ionic-pullup/example/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "www/lib" +} diff --git a/www/lib/ionic-pullup/example/.gitignore b/www/lib/ionic-pullup/example/.gitignore new file mode 100644 index 00000000..88d92183 --- /dev/null +++ b/www/lib/ionic-pullup/example/.gitignore @@ -0,0 +1,7 @@ +# Specifies intentionally untracked files to ignore when using Git +# http://git-scm.com/docs/gitignore + +node_modules/ +platforms/ +plugins/ +www/lib/ \ No newline at end of file diff --git a/www/lib/ionic-pullup/example/bower.json b/www/lib/ionic-pullup/example/bower.json new file mode 100644 index 00000000..2995b60f --- /dev/null +++ b/www/lib/ionic-pullup/example/bower.json @@ -0,0 +1,7 @@ +{ + "name": "HelloIonic", + "private": "true", + "devDependencies": { + "ionic": "driftyco/ionic-bower#1.0.1" + } +} diff --git a/www/lib/ionic-pullup/example/config.xml b/www/lib/ionic-pullup/example/config.xml new file mode 100644 index 00000000..b897c8b6 --- /dev/null +++ b/www/lib/ionic-pullup/example/config.xml @@ -0,0 +1,42 @@ + + + example + + An Ionic Framework and Cordova project. + + + Ionic Framework Team + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/www/lib/ionic-pullup/example/gulpfile.js b/www/lib/ionic-pullup/example/gulpfile.js new file mode 100644 index 00000000..3efdfc0a --- /dev/null +++ b/www/lib/ionic-pullup/example/gulpfile.js @@ -0,0 +1,52 @@ +var gulp = require('gulp'); +var gutil = require('gulp-util'); +var bower = require('bower'); +var concat = require('gulp-concat'); +var sass = require('gulp-sass'); +var minifyCss = require('gulp-minify-css'); +var rename = require('gulp-rename'); +var sh = require('shelljs'); + +var paths = { + sass: ['./scss/**/*.scss'] +}; + +gulp.task('default', ['sass']); + +gulp.task('sass', function(done) { + gulp.src('./scss/ionic.app.scss') + .pipe(sass({ + errLogToConsole: true + })) + .pipe(gulp.dest('./www/css/')) + .pipe(minifyCss({ + keepSpecialComments: 0 + })) + .pipe(rename({ extname: '.min.css' })) + .pipe(gulp.dest('./www/css/')) + .on('end', done); +}); + +gulp.task('watch', function() { + gulp.watch(paths.sass, ['sass']); +}); + +gulp.task('install', ['git-check'], function() { + return bower.commands.install() + .on('log', function(data) { + gutil.log('bower', gutil.colors.cyan(data.id), data.message); + }); +}); + +gulp.task('git-check', function(done) { + if (!sh.which('git')) { + console.log( + ' ' + gutil.colors.red('Git is not installed.'), + '\n Git, the version control system, is required to download Ionic.', + '\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.', + '\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.' + ); + process.exit(1); + } + done(); +}); diff --git a/www/lib/ionic-pullup/example/hooks/README.md b/www/lib/ionic-pullup/example/hooks/README.md new file mode 100644 index 00000000..d2563eab --- /dev/null +++ b/www/lib/ionic-pullup/example/hooks/README.md @@ -0,0 +1,83 @@ + +# Cordova Hooks + +This directory may contain scripts used to customize cordova commands. This +directory used to exist at `.cordova/hooks`, but has now been moved to the +project root. Any scripts you add to these directories will be executed before +and after the commands corresponding to the directory name. Useful for +integrating your own build systems or integrating with version control systems. + +__Remember__: Make your scripts executable. + +## Hook Directories +The following subdirectories will be used for hooks: + + after_build/ + after_compile/ + after_docs/ + after_emulate/ + after_platform_add/ + after_platform_rm/ + after_platform_ls/ + after_plugin_add/ + after_plugin_ls/ + after_plugin_rm/ + after_plugin_search/ + after_prepare/ + after_run/ + after_serve/ + before_build/ + before_compile/ + before_docs/ + before_emulate/ + before_platform_add/ + before_platform_rm/ + before_platform_ls/ + before_plugin_add/ + before_plugin_ls/ + before_plugin_rm/ + before_plugin_search/ + before_prepare/ + before_run/ + before_serve/ + pre_package/ <-- Windows 8 and Windows Phone only. + +## Script Interface + +All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables: + +* CORDOVA_VERSION - The version of the Cordova-CLI. +* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios). +* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer) +* CORDOVA_HOOK - Path to the hook that is being executed. +* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate) + +If a script returns a non-zero exit code, then the parent cordova command will be aborted. + + +## Writing hooks + +We highly recommend writting your hooks using Node.js so that they are +cross-platform. Some good examples are shown here: + +[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) + diff --git a/www/lib/ionic-pullup/example/hooks/after_prepare/010_add_platform_class.js b/www/lib/ionic-pullup/example/hooks/after_prepare/010_add_platform_class.js new file mode 100644 index 00000000..bda3e415 --- /dev/null +++ b/www/lib/ionic-pullup/example/hooks/after_prepare/010_add_platform_class.js @@ -0,0 +1,94 @@ +#!/usr/bin/env node + +// Add Platform Class +// v1.0 +// Automatically adds the platform class to the body tag +// after the `prepare` command. By placing the platform CSS classes +// directly in the HTML built for the platform, it speeds up +// rendering the correct layout/style for the specific platform +// instead of waiting for the JS to figure out the correct classes. + +var fs = require('fs'); +var path = require('path'); + +var rootdir = process.argv[2]; + +function addPlatformBodyTag(indexPath, platform) { + // add the platform class to the body tag + try { + var platformClass = 'platform-' + platform; + var cordovaClass = 'platform-cordova platform-webview'; + + var html = fs.readFileSync(indexPath, 'utf8'); + + var bodyTag = findBodyTag(html); + if(!bodyTag) return; // no opening body tag, something's wrong + + if(bodyTag.indexOf(platformClass) > -1) return; // already added + + var newBodyTag = bodyTag; + + var classAttr = findClassAttr(bodyTag); + if(classAttr) { + // body tag has existing class attribute, add the classname + var endingQuote = classAttr.substring(classAttr.length-1); + var newClassAttr = classAttr.substring(0, classAttr.length-1); + newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote; + newBodyTag = bodyTag.replace(classAttr, newClassAttr); + + } else { + // add class attribute to the body tag + newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">'); + } + + html = html.replace(bodyTag, newBodyTag); + + fs.writeFileSync(indexPath, html, 'utf8'); + + process.stdout.write('add to body class: ' + platformClass + '\n'); + } catch(e) { + process.stdout.write(e); + } +} + +function findBodyTag(html) { + // get the body tag + try{ + return html.match(/])(.*?)>/gi)[0]; + }catch(e){} +} + +function findClassAttr(bodyTag) { + // get the body tag's class attribute + try{ + return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0]; + }catch(e){} +} + +if (rootdir) { + + // go through each of the platform directories that have been prepared + var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []); + + for(var x=0; x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/www/lib/ionic-pullup/example/www/js/app.js b/www/lib/ionic-pullup/example/www/js/app.js new file mode 100644 index 00000000..c7c7c5f2 --- /dev/null +++ b/www/lib/ionic-pullup/example/www/js/app.js @@ -0,0 +1,85 @@ +// Ionic Starter App + +// angular.module is a global place for creating, registering and retrieving Angular modules +// 'starter' is the name of this angular module example (also set in a attribute in index.html) +// the 2nd parameter is an array of 'requires' +// 'starter.services' is found in services.js +// 'starter.controllers' is found in controllers.js +angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ionic-pullup']) + +.run(function($ionicPlatform) { + $ionicPlatform.ready(function() { + // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard + // for form inputs) + if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); + cordova.plugins.Keyboard.disableScroll(true); + + } + if (window.StatusBar) { + // org.apache.cordova.statusbar required + StatusBar.styleLightContent(); + } + }); +}) + +.config(function($stateProvider, $urlRouterProvider) { + + // Ionic uses AngularUI Router which uses the concept of states + // Learn more here: https://github.com/angular-ui/ui-router + // Set up the various states which the app can be in. + // Each state's controller can be found in controllers.js + $stateProvider + + // setup an abstract state for the tabs directive + .state('tab', { + url: '/tab', + abstract: true, + templateUrl: 'templates/tabs.html' + }) + + // Each tab has its own nav history stack: + + .state('tab.dash', { + url: '/dash', + views: { + 'tab-dash': { + templateUrl: 'templates/tab-dash.html', + controller: 'DashCtrl' + } + } + }) + + .state('tab.chats', { + url: '/chats', + views: { + 'tab-chats': { + templateUrl: 'templates/tab-chats.html', + controller: 'ChatsCtrl' + } + } + }) + .state('tab.chat-detail', { + url: '/chats/:chatId', + views: { + 'tab-chats': { + templateUrl: 'templates/chat-detail.html', + controller: 'ChatDetailCtrl' + } + } + }) + + .state('tab.account', { + url: '/account', + views: { + 'tab-account': { + templateUrl: 'templates/tab-account.html', + controller: 'AccountCtrl' + } + } + }); + + // if none of the above states are matched, use this as the fallback + $urlRouterProvider.otherwise('/tab/dash'); + +}); diff --git a/www/lib/ionic-pullup/example/www/js/controllers.js b/www/lib/ionic-pullup/example/www/js/controllers.js new file mode 100644 index 00000000..9a418765 --- /dev/null +++ b/www/lib/ionic-pullup/example/www/js/controllers.js @@ -0,0 +1,35 @@ +angular.module('starter.controllers', []) + +.controller('DashCtrl', function($scope) { + $scope.footerExpand = function() { + console.log('Footer expanded'); + }; + $scope.footerCollapse = function() { + console.log('Footer collapsed'); + }; + }) + +.controller('ChatsCtrl', function($scope, Chats) { + // With the new view caching in Ionic, Controllers are only called + // when they are recreated or on app start, instead of every page change. + // To listen for when this page is active (for example, to refresh data), + // listen for the $ionicView.enter event: + // + //$scope.$on('$ionicView.enter', function(e) { + //}); + + $scope.chats = Chats.all(); + $scope.remove = function(chat) { + Chats.remove(chat); + }; +}) + +.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) { + $scope.chat = Chats.get($stateParams.chatId); +}) + +.controller('AccountCtrl', function($scope) { + $scope.settings = { + enableFriends: true + }; +}); diff --git a/www/lib/ionic-pullup/example/www/js/ion-pullup.js b/www/lib/ionic-pullup/example/www/js/ion-pullup.js new file mode 100644 index 00000000..c558cb93 --- /dev/null +++ b/www/lib/ionic-pullup/example/www/js/ion-pullup.js @@ -0,0 +1,226 @@ +angular.module('ionic-pullup', []) + .constant('ionPullUpFooterState', { + COLLAPSED: 'COLLAPSED', + MINIMIZED: 'MINIMIZED', + EXPANDED: 'EXPANDED' + }) + .constant('ionPullUpFooterBehavior', { + HIDE: 'HIDE', + EXPAND: 'EXPAND' + }) + .directive('ionPullUpFooter', ['$timeout', '$rootScope', '$window', function($timeout, $rootScope, $window) { + return { + restrict: 'AE', + scope: { + onExpand: '&', + onCollapse: '&', + onMinimize: '&' + }, + controller: ['$scope', '$element', '$attrs', 'ionPullUpFooterState', 'ionPullUpFooterBehavior', function($scope, $element, $attrs, FooterState, FooterBehavior) { + var + tabs = document.querySelector('.tabs'), + hasBottomTabs = document.querySelector('.tabs-bottom'), + header = document.querySelector('.bar-header'), + tabsHeight = tabs ? tabs.offsetHeight : 0, + headerHeight = header ? header.offsetHeight : 0, + handleHeight = 0, + footer = { + height: 0, + posY: 0, + lastPosY: 0, + state: FooterState.COLLAPSED, + defaultHeight : $element[0].offsetHeight, + maxHeight: parseInt($attrs.maxHeight, 10) || 0, + initialState: $attrs.initialState ? $attrs.initialState.toUpperCase() : FooterState.COLLAPSED, + defaultBehavior: $attrs.defaultBehavior ? $attrs.defaultBehavior.toUpperCase() : FooterBehavior.EXPAND + }; + + function init() { + $element.css({'-webkit-backface-visibility': 'hidden', 'backface-visibility': 'hidden', 'transition': '300ms ease-in-out', 'padding': 0}); + if (tabs && hasBottomTabs) { + $element.css('bottom', tabs.offsetHeight + 'px'); + } + } + + function computeHeights() { + footer.height = footer.maxHeight > 0 ? footer.maxHeight : $window.innerHeight - headerHeight - handleHeight - tabsHeight; + $element.css({'height': footer.height + 'px'}); + + if (footer.initialState == FooterState.MINIMIZED) { + minimize(); + } else { + collapse(); + } + } + + function expand() { + footer.lastPosY = 0; + $element.css({'-webkit-transform': 'translate3d(0, 0, 0)', 'transform': 'translate3d(0, 0, 0)'}); + $scope.onExpand(); + footer.state = FooterState.EXPANDED; + } + + function collapse() { + footer.lastPosY = (tabs && hasBottomTabs) ? footer.height - tabsHeight : footer.height - footer.defaultHeight; + $element.css({'-webkit-transform': 'translate3d(0, ' + footer.lastPosY + 'px, 0)', 'transform': 'translate3d(0, ' + footer.lastPosY + 'px, 0)'}); + $scope.onCollapse(); + footer.state = FooterState.COLLAPSED + } + + function minimize() { + footer.lastPosY = footer.height; + $element.css({'-webkit-transform': 'translate3d(0, ' + footer.lastPosY + 'px, 0)', 'transform': 'translate3d(0, ' + footer.lastPosY + 'px, 0)'}); + $scope.onMinimize(); + footer.state = FooterState.MINIMIZED; + } + + + this.setHandleHeight = function(height) { + handleHeight = height; + computeHeights(); + }; + + this.getHeight = function() { + return $element[0].offsetHeight; + }; + + this.getBackground = function() { + return $window.getComputedStyle($element[0]).background; + }; + + this.onTap = function(e) { + e.gesture.srcEvent.preventDefault(); + e.gesture.preventDefault(); + + if (footer.state == FooterState.COLLAPSED) { + if (footer.defaultBehavior == FooterBehavior.HIDE) { + minimize(); + } else { + expand(); + } + } else { + if (footer.state == FooterState.MINIMIZED) { + if (footer.defaultBehavior == FooterBehavior.HIDE) + collapse(); + else + expand(); + } else { + // footer is expanded + footer.initialState == FooterState.MINIMIZED ? minimize() : collapse(); + } + } + + $rootScope.$broadcast('ionPullUp:tap', footer.state); + }; + + this.onDrag = function(e) { + e.gesture.srcEvent.preventDefault(); + e.gesture.preventDefault(); + + switch (e.type) { + case 'dragstart': + $element.css('transition', 'none'); + break; + case 'drag': + footer.posY = Math.round(e.gesture.deltaY) + footer.lastPosY; + if (footer.posY < 0 || footer.posY > footer.height) return; + $element.css({'-webkit-transform': 'translate3d(0, ' + footer.posY + 'px, 0)', 'transform': 'translate3d(0, ' + footer.posY + 'px, 0)'}); + break; + case 'dragend': + $element.css({'transition': '300ms ease-in-out'}); + footer.lastPosY = footer.posY; + break; + } + }; + + $window.addEventListener('orientationchange', function() { + $timeout(function() { + computeHeights(); + }, 500); + }); + + init(); + }], + compile: function(element, attrs) { + attrs.defaultHeight && element.css('height', parseInt(attrs.defaultHeight, 10) + 'px'); + element.addClass('bar bar-footer'); + } + } + }]) + .directive('ionPullUpContent', [function() { + return { + restrict: 'AE', + require: '^ionPullUpFooter', + link: function (scope, element, attrs, controller) { + var + footerHeight = controller.getHeight(); + element.css({'display': 'block', 'margin-top': footerHeight + 'px', width: '100%'}); + // add scrolling if needed + if (attrs.scroll && attrs.scroll.toUpperCase() == 'TRUE') { + element.css({'overflow-y': 'scroll', 'overflow-x': 'hidden'}); + } + } + } + }]) + .directive('ionPullUpBar', [function() { + return { + restrict: 'AE', + require: '^ionPullUpFooter', + link: function (scope, element, attrs, controller) { + var + footerHeight = controller.getHeight(); + element.css({'display': 'flex', 'height': footerHeight + 'px', position: 'absolute', right: '0', left: '0'}); + + } + } + }]) + .directive('ionPullUpTrigger', ['$ionicGesture', function($ionicGesture) { + return { + restrict: 'AE', + require: '^ionPullUpFooter', + link: function (scope, element, attrs, controller) { + // add gesture + $ionicGesture.on('tap', controller.onTap, element); + $ionicGesture.on('drag dragstart dragend', controller.onDrag, element); + } + } + }]) + .directive('ionPullUpHandle', ['$ionicGesture', '$timeout', '$window', function($ionicGesture, $timeout, $window) { + return { + restrict: 'AE', + require: '^ionPullUpFooter', + link: function (scope, element, attrs, controller) { + var height = parseInt(attrs.height,10) || 25, width = parseInt(attrs.width, 10) || 100, + background = controller.getBackground(), + toggleClasses = attrs.toggle; + + controller.setHandleHeight(height); + + element.css({ + display: 'block', + background: background, + position: 'absolute', + top: 1-height + 'px', + left: (($window.innerWidth - width) / 2) + 'px', + height: height + 'px', + width: width + 'px', + //margin: '0 auto', + 'text-align': 'center' + }); + + // add gesture + $ionicGesture.on('tap', controller.onTap, element); + $ionicGesture.on('drag dragstart dragend', controller.onDrag, element); + + scope.$on('ionPullUp:tap', function() { + element.find('i').toggleClass(toggleClasses); + }); + + $window.addEventListener('orientationchange', function() { + $timeout(function() { + element.css('left', (($window.innerWidth - width) / 2) + 'px'); + }, 500); + }); + } + } + }]); \ No newline at end of file diff --git a/www/lib/ionic-pullup/example/www/js/services.js b/www/lib/ionic-pullup/example/www/js/services.js new file mode 100644 index 00000000..db975f21 --- /dev/null +++ b/www/lib/ionic-pullup/example/www/js/services.js @@ -0,0 +1,50 @@ +angular.module('starter.services', []) + +.factory('Chats', function() { + // Might use a resource here that returns a JSON array + + // Some fake testing data + var chats = [{ + id: 0, + name: 'Ben Sparrow', + lastText: 'You on your way?', + face: 'https://pbs.twimg.com/profile_images/514549811765211136/9SgAuHeY.png' + }, { + id: 1, + name: 'Max Lynx', + lastText: 'Hey, it\'s me', + face: 'https://avatars3.githubusercontent.com/u/11214?v=3&s=460' + }, { + id: 2, + name: 'Adam Bradleyson', + lastText: 'I should buy a boat', + face: 'https://pbs.twimg.com/profile_images/479090794058379264/84TKj_qa.jpeg' + }, { + id: 3, + name: 'Perry Governor', + lastText: 'Look at my mukluks!', + face: 'https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png' + }, { + id: 4, + name: 'Mike Harrington', + lastText: 'This is wicked good ice cream.', + face: 'https://pbs.twimg.com/profile_images/578237281384841216/R3ae1n61.png' + }]; + + return { + all: function() { + return chats; + }, + remove: function(chat) { + chats.splice(chats.indexOf(chat), 1); + }, + get: function(chatId) { + for (var i = 0; i < chats.length; i++) { + if (chats[i].id === parseInt(chatId)) { + return chats[i]; + } + } + return null; + } + }; +}); diff --git a/www/lib/ionic-pullup/example/www/templates/chat-detail.html b/www/lib/ionic-pullup/example/www/templates/chat-detail.html new file mode 100644 index 00000000..e776d022 --- /dev/null +++ b/www/lib/ionic-pullup/example/www/templates/chat-detail.html @@ -0,0 +1,14 @@ + + + + +

+ {{chat.lastText}} +

+
+
diff --git a/www/lib/ionic-pullup/example/www/templates/tab-account.html b/www/lib/ionic-pullup/example/www/templates/tab-account.html new file mode 100644 index 00000000..2e72f67a --- /dev/null +++ b/www/lib/ionic-pullup/example/www/templates/tab-account.html @@ -0,0 +1,9 @@ + + + + + Enable Friends + + + + diff --git a/www/lib/ionic-pullup/example/www/templates/tab-chats.html b/www/lib/ionic-pullup/example/www/templates/tab-chats.html new file mode 100644 index 00000000..0c6a88ad --- /dev/null +++ b/www/lib/ionic-pullup/example/www/templates/tab-chats.html @@ -0,0 +1,33 @@ + + + + + +

{{chat.name}}

+

{{chat.lastText}}

+ + + + Delete + +
+
+
+ +
More details
+ + + + + +
+
Recent Updates
+
+
+ There is a fire in sector 3 +
+
+
+
+
+
diff --git a/www/lib/ionic-pullup/example/www/templates/tab-dash.html b/www/lib/ionic-pullup/example/www/templates/tab-dash.html new file mode 100644 index 00000000..37b688fd --- /dev/null +++ b/www/lib/ionic-pullup/example/www/templates/tab-dash.html @@ -0,0 +1,46 @@ + + +
+
Recent Updates
+
+
+ There is a fire in sector 3 +
+
+
+
+
Upcoming
+ +
+
+
Upcoming
+
+
+ You have 29 meetings on your calendar tomorrow. +
+
+
+
+ + + + + +

Tap here

+ +
+ +
+
Recent Updates
+
+
+ There is a fire in sector 3 +
+
+
+
+
+
diff --git a/www/lib/ionic-pullup/example/www/templates/tabs.html b/www/lib/ionic-pullup/example/www/templates/tabs.html new file mode 100644 index 00000000..ed615d2c --- /dev/null +++ b/www/lib/ionic-pullup/example/www/templates/tabs.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3