|
| 1 | +var DEMO; |
| 2 | + |
| 3 | + DEMO = { |
| 4 | + "files": { |
| 5 | + "html": [ |
| 6 | + { |
| 7 | + "name": "takeAction", |
| 8 | + "component": "$ionicActionSheet", |
| 9 | + "id": "$ionicActionSheet-takeAction", |
| 10 | + "fileType": ".html", |
| 11 | + "fileName": "index.html", |
| 12 | + "contents": "\n<ion-header-bar class=\"bar-positive\">\n <h1 class=\"title\">Action</h1>\n</ion-header-bar>\n<ion-content ng-controller=\"ActionSheetCtrl\" class=\"padding\">\n <div class=\"button button-assertive button-block\" ng-click=\"takeAction()\">\n Take Action!\n </div>\n <div class=\"card\" ng-show=\"messages.length\">\n <div class=\"item item-divider\">\n User Log\n </div>\n <div class=\"item item-text-wrap\">\n <div ng-repeat=\"message in messages\">\n {{message.text}}\n </div>\n </div>\n </div>\n</ion-content>", |
| 13 | + "extension": "html", |
| 14 | + "template": "asset.contents.template", |
| 15 | + "outputPath": "$ionicActionSheet/takeAction/index.html", |
| 16 | + "renderedContent": "\n<ion-header-bar class=\"bar-positive\">\n <h1 class=\"title\">Action</h1>\n</ion-header-bar>\n<ion-content ng-controller=\"ActionSheetCtrl\" class=\"padding\">\n <div class=\"button button-assertive button-block\" ng-click=\"takeAction()\">\n Take Action!\n </div>\n <div class=\"card\" ng-show=\"messages.length\">\n <div class=\"item item-divider\">\n User Log\n </div>\n <div class=\"item item-text-wrap\">\n <div ng-repeat=\"message in messages\">\n {{message.text}}\n </div>\n </div>\n </div>\n</ion-content>\n" |
| 17 | + } |
| 18 | + ], |
| 19 | + "js": [ |
| 20 | + { |
| 21 | + "name": "takeAction", |
| 22 | + "component": "$ionicActionSheet", |
| 23 | + "id": "$ionicActionSheet-takeAction", |
| 24 | + "fileType": ".js", |
| 25 | + "fileName": "index.js", |
| 26 | + "contents": "\nangular.module('takeAction', ['ionic'])\n.controller('ActionSheetCtrl', function($scope, $ionicActionSheet) {\n $scope.messages = [];\n $scope.takeAction = function() {\n $ionicActionSheet.show({\n buttons: [\n { text: 'Share <i class=\"icon ion-share\">' },\n { text: 'Edit <i class=\"icon ion-edit\">' }\n ],\n destructiveText: 'Delete <i class=\"icon ion-trash-b\">',\n titleText: 'Modify your album',\n cancelText: 'Cancel',\n cancel: function() {\n $scope.message('Cancel');\n return true;\n },\n buttonClicked: function(index) {\n $scope.message(index === 0 ? 'Share' : 'Edit');\n return true;\n },\n destructiveButtonClicked: function() {\n $scope.message('Delete');\n return true;\n }\n });\n };\n $scope.message = function(msg) {\n $scope.messages.unshift({\n text: 'User pressed ' + msg\n });\n };\n});", |
| 27 | + "extension": "js", |
| 28 | + "template": "asset.contents.template", |
| 29 | + "outputPath": "$ionicActionSheet/takeAction/index.js", |
| 30 | + "renderedContent": "\nangular.module('takeAction', ['ionic'])\n.controller('ActionSheetCtrl', function($scope, $ionicActionSheet) {\n $scope.messages = [];\n $scope.takeAction = function() {\n $ionicActionSheet.show({\n buttons: [\n { text: 'Share <i class=\"icon ion-share\">' },\n { text: 'Edit <i class=\"icon ion-edit\">' }\n ],\n destructiveText: 'Delete <i class=\"icon ion-trash-b\">',\n titleText: 'Modify your album',\n cancelText: 'Cancel',\n cancel: function() {\n $scope.message('Cancel');\n return true;\n },\n buttonClicked: function(index) {\n $scope.message(index === 0 ? 'Share' : 'Edit');\n return true;\n },\n destructiveButtonClicked: function() {\n $scope.message('Delete');\n return true;\n }\n });\n };\n $scope.message = function(msg) {\n $scope.messages.unshift({\n text: 'User pressed ' + msg\n });\n };\n});\n" |
| 31 | + } |
| 32 | + ], |
| 33 | + "scenario.js": [ |
| 34 | + { |
| 35 | + "name": "takeAction", |
| 36 | + "component": "$ionicActionSheet", |
| 37 | + "id": "$ionicActionSheet-takeAction", |
| 38 | + "fileType": ".scenario.js", |
| 39 | + "fileName": "test.scenario.js", |
| 40 | + "contents": "\n\nit('should open up actionsheet', function(){\n var ele = element(by.css('.button'));\n ele.click();\n});\n\nit('should close when clicking backdrop', function(){\n var ele = element(by.css('.action-sheet-backdrop'));\n ele.click();\n});\n\nit('should open up actionsheet again', function(){\n var ele = element(by.css('.button'));\n ele.click();\n});\n\nit('should click the share button', function(){\n var ele = element.all(by.css('.action-sheet-group .button'));\n ele.get(0).click();\n});", |
| 41 | + "extension": "scenario.js", |
| 42 | + "template": "scenario.template.js", |
| 43 | + "outputPath": "$ionicActionSheet/takeAction/test.scenario.js", |
| 44 | + "url": "http://localhost:8876/$ionicActionSheet/takeAction/", |
| 45 | + "renderedContent": "describe('$ionicActionSheet-takeAction', function() {\n\nit('should init', function() {\n browser.get('http://localhost:8876/$ionicActionSheet/takeAction/');\n});\n\n\n\nit('should open up actionsheet', function(){\n var ele = element(by.css('.button'));\n ele.click();\n});\n\nit('should close when clicking backdrop', function(){\n var ele = element(by.css('.action-sheet-backdrop'));\n ele.click();\n});\n\nit('should open up actionsheet again', function(){\n var ele = element(by.css('.button'));\n ele.click();\n});\n\nit('should click the share button', function(){\n var ele = element.all(by.css('.action-sheet-group .button'));\n ele.get(0).click();\n});\n\n});\n" |
| 46 | + } |
| 47 | + ] |
| 48 | + }, |
| 49 | + "id": "$ionicActionSheet-takeAction", |
| 50 | + "name": "takeAction", |
| 51 | + "component": "$ionicActionSheet", |
| 52 | + "href": "/$ionicActionSheet/takeAction/" |
| 53 | +}; |
| 54 | + |
| 55 | + |
| 56 | +angular.module('takeAction' |
| 57 | + ) |
| 58 | +.controller('IonicDemoCtrl', function($scope, $ionicModal, $ionicLoading) { |
| 59 | + $scope.$demos = DEMOS; |
| 60 | + |
| 61 | + |
| 62 | + $scope.$demo = DEMO; |
| 63 | + $ionicModal.fromTemplateUrl('ionic-demo-modal.html', { |
| 64 | + scope: $scope, |
| 65 | + focusFirstInput: false |
| 66 | + }).then(function(modal) { |
| 67 | + $scope.$demoModal = modal; |
| 68 | + }); |
| 69 | + |
| 70 | + //don't try this at home |
| 71 | + ionic.onGesture('dragup', function(e) { |
| 72 | + if (e.gesture.distance > 35 && !$scope.$demoModal.isShown()) { |
| 73 | + $scope.$apply(function(e) { |
| 74 | + $scope.$demoModal.show(); |
| 75 | + }); |
| 76 | + } |
| 77 | + }, document.querySelector('.demo-footer')); |
| 78 | + |
| 79 | + $scope.demoScratch = function(demo) { |
| 80 | + var form = angular.element('<form method="POST" action="http://scratch.ionicsdk.com/embed" target="_blank">'); |
| 81 | + |
| 82 | + var htmlInput = angular.element('<textarea type="text" name="html">') |
| 83 | + .val(['<html ng-app="takeAction">', |
| 84 | + '<head>', |
| 85 | + ' <meta charset="utf-8">', |
| 86 | + ' <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">', |
| 87 | + ' <link rel="stylesheet" href="http://code.ionicframework.com/1.0.0-beta.8/css/ionic.css">', |
| 88 | + ' <script src="http://code.ionicframework.com/1.0.0-beta.8/js/ionic.bundle.js"></script>', |
| 89 | + '</head>', |
| 90 | + '<body>', |
| 91 | + (demo.files.html || []).map(function(file) { |
| 92 | + return file.contents; |
| 93 | + }).join('\n'), |
| 94 | + '</body>', |
| 95 | + '</html>'].join('\n')); |
| 96 | + |
| 97 | + var cssInput = angular.element('<textarea type="text" name="css">') |
| 98 | + .val((demo.files.css || []).map(function(file) { |
| 99 | + return file.contents; |
| 100 | + }).join('\n')); |
| 101 | + |
| 102 | + var jsInput = angular.element('<textarea type="text" name="js">') |
| 103 | + .val((demo.files.js || []).map(function(file) { |
| 104 | + return file.contents; |
| 105 | + }).join('\n')); |
| 106 | + |
| 107 | + form |
| 108 | + .css('display','none') |
| 109 | + .append(htmlInput) |
| 110 | + .append(cssInput) |
| 111 | + .append(jsInput); |
| 112 | + |
| 113 | + document.body.appendChild(form[0]); |
| 114 | + form[0].submit(); |
| 115 | + }; |
| 116 | + |
| 117 | +}) |
| 118 | +.filter('humanize', function() { |
| 119 | + return function(input) { |
| 120 | + return input.charAt(0).toUpperCase() + |
| 121 | + input.substring(1).replace(/[A-Z]/g, function(match, i) { |
| 122 | + return ' ' + match.toUpperCase(); |
| 123 | + }); |
| 124 | + }; |
| 125 | +}); |
| 126 | + |
0 commit comments