diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..e9824f1 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "www/components" +} diff --git a/.cordova/README.md b/.cordova/README.md new file mode 100644 index 0000000..f9a6643 --- /dev/null +++ b/.cordova/README.md @@ -0,0 +1,13 @@ +#Steroids compatibility with Cordova CLI + +The `.cordova` folder is included in new Steroids projects for initial [Cordova CLI](https://github.com/apache/cordova-cli) compatibility. + +Cordova CLI commands can thus be run inside a Steroids project. The support is not complete; the current main use case is to facilitate plugin development in Xcode/Eclipse without having to create a separate Cordova project. You shouldn't use the native iOS/Android projects for actual development, since Steroids.js features are unavailable there. + +Note that you have to load `cordova.js` from the `www/` root in Cordova projects, instead of via `localhost` as it is in Steroids: + +``` + +``` + +The hooks in the `hooks/` folder only affect Cordova CLI commands. For Steroids pre- and post-make hooks, see `config/application.coffee`. \ No newline at end of file diff --git a/.cordova/config.json b/.cordova/config.json index a1104f0..fafc7fe 100644 --- a/.cordova/config.json +++ b/.cordova/config.json @@ -1 +1 @@ -{"id":"com.ionicframework.starter","name":"StarterApp"} \ No newline at end of file +{"id":"com.ionicframework.appgyverstarter","name":"IonicAngularAppGyverSeed"} \ No newline at end of file diff --git a/.gitignore b/.gitignore index f6c8104..b8279af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -*.keystore -*.sw* -platforms/^.* +.DS_Store +/dist +node_modules diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..1752eaf --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,16 @@ +/* + * Default Gruntfile for AppGyver Steroids + * http://www.appgyver.com + * + * Licensed under the MIT license. + */ + +'use strict'; + +module.exports = function(grunt) { + + grunt.loadNpmTasks("grunt-steroids"); + + grunt.registerTask("default", ["steroids-make", "steroids-compile-sass"]); + +}; diff --git a/README.md b/README.md index f9028d5..47e752a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -ionic-angular-cordova-seed +ionic-angular-appgyver-seed ========================== -The perfect starting point for an Ionic project. +The perfect starting point for an Ionic + AppGyver project. -- [Ionic Tutorials](http://ionicframework.com/tutorials/) \ No newline at end of file +- [Ionic Tutorials](http://ionicframework.com/tutorials/) +- [AppGyver Tutorials](http://academy.appgyver.com/courses/steroids) \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..8a9214d --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "ionic-angular-appgyver-seed", + "version": "0.0.1", + "authors": [ + ], + "ignore": [ + "**/.*", + "node_modules", + "www/components", + "www/spec", + "test", + "tests" + ], + "dependencies": { + "steroids-js": "3.1.x" + } +} diff --git a/config/application.coffee b/config/application.coffee new file mode 100644 index 0000000..e3097b8 --- /dev/null +++ b/config/application.coffee @@ -0,0 +1,58 @@ +# For an explanation of the steroids.config properties, see the guide at +# http://guides.appgyver.com/steroids/guides/project_configuration/config-application-coffee/ + +steroids.config.name = "ionic-angular-appgyver-seed" + +# -- Initial Location -- +steroids.config.location = "http://localhost/index.html" + +# -- Tab Bar -- +# steroids.config.tabBar.enabled = true +# steroids.config.tabBar.tabs = [ +# { +# title: "Index" +# icon: "icons/pill@2x.png" +# location: "http://localhost/index.html" +# }, +# { +# title: "Internet" +# icon: "icons/telescope@2x.png" +# location: "http://www.google.com" +# } +# ] + +# steroids.config.tabBar.tintColor = "#000000" +# steroids.config.tabBar.tabTitleColor = "#00aeef" +# steroids.config.tabBar.selectedTabTintColor = "#ffffff" +# steroids.config.tabBar.selectedTabBackgroundImage = "icons/pill@2x.png" + +# steroids.config.tabBar.backgroundImage = "" + +# -- Navigation Bar -- +steroids.config.navigationBar.tintColor = "#00aeef" +steroids.config.navigationBar.titleColor = "#ffffff" +steroids.config.navigationBar.buttonTintColor = "#ffffff" +steroids.config.navigationBar.buttonTitleColor = "#ffffff" + +# steroids.config.navigationBar.landscape.backgroundImage = "" +# steroids.config.navigationBar.portrait.backgroundImage = "" + +# -- Android Loading Screen +steroids.config.loadingScreen.tintColor = "#262626" + +# -- iOS Status Bar -- +steroids.config.statusBar.enabled = true +steroids.config.statusBar.style = "default" + +# -- File Watcher -- +# steroids.config.watch.exclude = ["www/my_excluded_file.js", "www/my_excluded_dir"] + +# -- Pre- and Post-Make hooks -- +# steroids.config.hooks.preMake.cmd = "echo" +# steroids.config.hooks.preMake.args = ["running yeoman"] +# steroids.config.hooks.postMake.cmd = "echo" +# steroids.config.hooks.postMake.args = ["cleaning up files"] + +# -- Default Editor -- +# steroids.config.editor.cmd = "subl" +# steroids.config.editor.args = ["."] diff --git a/merges/README.md b/merges/README.md new file mode 100644 index 0000000..b048913 --- /dev/null +++ b/merges/README.md @@ -0,0 +1,12 @@ +Use the `merges` directory just like you would in a vanilla Cordova project. + +Example structure: +`/merges/android/index.html` +`/merges/ios/index.html` + +This will generate `dist/index.android.html` (android) and `dist/index.html` (ios) files during Steroids `make`. +Read more about the `.android.` extension here: http://guides.appgyver.com/steroids/guides/android/android-extension/ + +Merge files will overwrite existing files when building to the `dist` directory. + +For example: `www/index.html` would be overwritten by `merges/ios/index.html` and `www/index.android.html` would be overwritten by `merges/android/index.html`. \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..4e490c1 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "mySteroidsProject", + "version": "0.0.1", + "description": "My awesome AppGyver Steroids project.", + "repository": "N/A", + "readme":"N/A", + "private": true, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "devDependencies": { + "grunt-steroids": "0.x" + }, + "license": "none", + "engines": { + "steroids": "3.1.9" + } +} diff --git a/platforms/.gitignore b/platforms/.gitignore index 5e7d273..3c8f938 100644 --- a/platforms/.gitignore +++ b/platforms/.gitignore @@ -2,3 +2,5 @@ * # Except this file !.gitignore +# and README.md +!README.md \ No newline at end of file diff --git a/platforms/README.md b/platforms/README.md new file mode 100644 index 0000000..daf2473 --- /dev/null +++ b/platforms/README.md @@ -0,0 +1,8 @@ +The `platforms/` folder houses native Android and iOS Cordova projects, added with the + +``` +$ cordova platform add + +``` + +command. See `.cordova/readme.md` for more information about Cordova CLI compatibility with Steroids. \ No newline at end of file diff --git a/plugins/.gitignore b/plugins/.gitignore index 5e7d273..3c8f938 100644 --- a/plugins/.gitignore +++ b/plugins/.gitignore @@ -2,3 +2,5 @@ * # Except this file !.gitignore +# and README.md +!README.md \ No newline at end of file diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 0000000..2202539 --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,3 @@ +Unlike in vanilla Cordova projects, custom plugins are configured in the cloud: http://guides.appgyver.com/steroids/guides/cloud_services/plugin-config/ + +For a list of plugins included with AppGyver Scanner, see the GitHub repo at https://github.com/AppGyver/steroids-plugins \ No newline at end of file diff --git a/www/config.android.xml b/www/config.android.xml new file mode 100644 index 0000000..0d35055 --- /dev/null +++ b/www/config.android.xml @@ -0,0 +1,16 @@ + + + IonicAngularAppGyverSeed + + A sample Ionic Framework app using AppGyver and AngularJS + + + Apache Cordova Team + + + + + + + + \ No newline at end of file diff --git a/www/config.ios.xml b/www/config.ios.xml new file mode 100644 index 0000000..1ab6b1b --- /dev/null +++ b/www/config.ios.xml @@ -0,0 +1,29 @@ + + + IonicAngularAppGyverSeed + + A sample Ionic Framework app using AppGyver and AngularJS + + + Apache Cordova Team + + + + + + + + + + + + + + + + + + + + + diff --git a/www/config.tizen.xml b/www/config.tizen.xml new file mode 100644 index 0000000..d4cccbe --- /dev/null +++ b/www/config.tizen.xml @@ -0,0 +1,43 @@ + + + + + + + + + My Steroids App + + + + + + + + + + + + + + + + + + + + * + default-src *; script-src 'unsafe-inline' *; + + + diff --git a/www/config.xml b/www/config.xml index 894a8c5..a789223 100644 --- a/www/config.xml +++ b/www/config.xml @@ -1,16 +1,6 @@ + + - - StarterApp - - A sample Ionic Framework app using Cordova and AngularJS - - - Apache Cordova Team - - - - - - - + + HelloCordova diff --git a/www/index.html b/www/index.html index 2253b49..ce0cb0b 100644 --- a/www/index.html +++ b/www/index.html @@ -3,13 +3,15 @@ - Ionic Seed App + Ionic Angular AppGyver Seed App + + @@ -19,8 +21,9 @@ - - + + + diff --git a/www/js/console.log.android.js b/www/js/console.log.android.js new file mode 100644 index 0000000..3d93504 --- /dev/null +++ b/www/js/console.log.android.js @@ -0,0 +1 @@ +// no need to override in android diff --git a/www/js/console.log.js b/www/js/console.log.js new file mode 100644 index 0000000..6df73ea --- /dev/null +++ b/www/js/console.log.js @@ -0,0 +1,37 @@ +// When using iOS simulator, the first console.log messages might not appear before Cordova has overridden the console.log +// Here we buffer the messages and output when override is done. + +(function(window) { + + var logMessages = []; + + var defaultConsoleLog = window.console.log; + + window.console.log = function(args) { + logMessages.push(args); + } + + var bufferConsoleLogUntilReadyAndFlush = function() { + var cordovaOverride = "logWithArgs"; + var isNative = "[native code]"; + + if ( (defaultConsoleLog.toString().indexOf(cordovaOverride) > -1) || + (defaultConsoleLog.toString().indexOf(isNative) > -1) ) { + window.console.log = defaultConsoleLog; + for (var i=0; i= 0) { + return true; + } else { + return false; + } + }; + return (_ref = callbacks.onSuccess) != null ? _ref.call() : void 0; + }; + + WebView.prototype.setBackgroundColor = function(options, callbacks) { + var newColor; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + newColor = options.constructor.name === "String" ? options : options.color; + return steroids.nativeBridge.nativeCall({ + method: "setWebViewBackgroundColor", + parameters: { + color: newColor + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return WebView; + +})(); +;var PreviewFileView; + +PreviewFileView = (function() { + function PreviewFileView(options) { + var _ref; + if (options == null) { + options = {}; + } + this.filePath = options.constructor.name === "String" ? options : options.filePath; + this.relativeTo = (_ref = options.relativeTo) != null ? _ref : steroids.app.path; + } + + PreviewFileView.prototype.getNativeFilePath = function() { + return "" + this.relativeTo + "/" + this.filePath; + }; + + return PreviewFileView; + +})(); +;var Audio; + +Audio = (function() { + function Audio() {} + + Audio.prototype.play = function(options, callbacks) { + var readyCapableDevice, + _this = this; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + readyCapableDevice = false; + setTimeout(function() { + if (readyCapableDevice) { + return; + } + return navigator.notification.alert("Audio playback requires a newer version of Scanner, please update from the App Store.", null, "Update Required"); + }, 500); + return steroids.on("ready", function() { + var mediaPath, relativeTo, _ref; + readyCapableDevice = true; + relativeTo = (_ref = options.relativeTo) != null ? _ref : steroids.app.path; + mediaPath = options.constructor.name === "String" ? "" + relativeTo + "/" + options : "" + relativeTo + "/" + options.path; + return steroids.nativeBridge.nativeCall({ + method: "play", + parameters: { + filenameWithPath: mediaPath + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }); + }; + + Audio.prototype.prime = function(options, callbacks) { + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return steroids.nativeBridge.nativeCall({ + method: "primeAudioPlayer", + parameters: options, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return Audio; + +})(); +;var OAuth2Flow; + +OAuth2Flow = (function() { + function OAuth2Flow(options) { + this.options = options != null ? options : {}; + this.options.callbackUrl = "http://localhost:13101/" + this.options.callbackPath; + } + + OAuth2Flow.prototype.authenticate = function() { + throw "ERROR: " + this.name + " has not overridden authenticate method"; + }; + + OAuth2Flow.prototype.concatenateUrlParams = function(params) { + var first, key, result, value; + first = true; + result = ""; + for (key in params) { + value = params[key]; + if (first) { + result = result.concat("?"); + first = false; + } else { + result = result.concat("&"); + } + result = result.concat("" + key + "=" + (encodeURIComponent(value))); + } + return result; + }; + + OAuth2Flow.prototype.urlEncode = function(string) { + var c, hex, i, reserved_chars, str_len, string_arr; + hex = function(code) { + var result; + result = code.toString(16).toUpperCase(); + if (result.length < 2) { + result = 0 + result; + } + return "%" + result; + }; + if (!string) { + return ""; + } + string = string + ""; + reserved_chars = /[ \r\n!*"'();:@&=+$,\/?%#\[\]<>{}|`^\\\u0080-\uffff]/; + str_len = string.length; + i = void 0; + string_arr = string.split(""); + c = void 0; + i = 0; + while (i < str_len) { + if (c = string_arr[i].match(reserved_chars)) { + c = c[0].charCodeAt(0); + if (c < 128) { + string_arr[i] = hex(c); + } else if (c < 2048) { + string_arr[i] = hex(192 + (c >> 6)) + hex(128 + (c & 63)); + } else if (c < 65536) { + string_arr[i] = hex(224 + (c >> 12)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63)); + } else { + if (c < 2097152) { + string_arr[i] = hex(240 + (c >> 18)) + hex(128 + ((c >> 12) & 63)) + hex(128 + ((c >> 6) & 63)) + hex(128 + (c & 63)); + } + } + } + i++; + } + return string_arr.join(""); + }; + + return OAuth2Flow; + +})(); +;var AuthorizationCodeFlow, _ref, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + +AuthorizationCodeFlow = (function(_super) { + __extends(AuthorizationCodeFlow, _super); + + function AuthorizationCodeFlow() { + this.finish = __bind(this.finish, this); + this.authenticate = __bind(this.authenticate, this); + _ref = AuthorizationCodeFlow.__super__.constructor.apply(this, arguments); + return _ref; + } + + AuthorizationCodeFlow.prototype.authenticate = function() { + var authenticationLayer, authorizationUrl; + this.xhrAuthorizationParams = { + response_type: "code", + client_id: this.options.clientID, + redirect_uri: this.options.callbackUrl, + scope: this.options.scope || "" + }; + authorizationUrl = this.options.authorizationUrl.concat(this.concatenateUrlParams(this.xhrAuthorizationParams)); + authenticationLayer = new steroids.views.WebView({ + location: authorizationUrl + }); + return steroids.modal.show({ + layer: authenticationLayer + }); + }; + + AuthorizationCodeFlow.prototype.finish = function(callback) { + var body, key, request, value, _ref1, + _this = this; + this.xhrAccessTokenParams = { + client_id: this.options.clientID, + client_secret: this.options.clientSecret, + redirect_uri: this.callbackUrl, + grant_type: "authorization_code" + }; + request = new XMLHttpRequest(); + request.open("POST", this.options.accessTokenUrl); + body = []; + _ref1 = this.xhrAccessTokenParams; + for (key in _ref1) { + value = _ref1[key]; + body.push("" + key + "=" + (this.urlEncode(value))); + } + body.push("code=" + steroids.view.params['code']); + body = body.sort().join('&'); + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.onreadystatechange = function() { + var responseJSON; + if (request.readyState === 4) { + responseJSON = JSON.parse(request.responseText); + callback(responseJSON.access_token); + return steroids.modal.hide(); + } + }; + return request.send(body); + }; + + return AuthorizationCodeFlow; + +})(OAuth2Flow); +;var ClientCredentialsFlow, _ref, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + +ClientCredentialsFlow = (function(_super) { + __extends(ClientCredentialsFlow, _super); + + function ClientCredentialsFlow() { + _ref = ClientCredentialsFlow.__super__.constructor.apply(this, arguments); + return _ref; + } + + ClientCredentialsFlow.prototype.authenticate = function(callback) { + var body, key, request, value, _ref1, + _this = this; + this.xhrAccessTokenParams = { + client_id: this.options.clientID, + client_secret: this.options.clientSecret, + scope: this.options.scope || "", + grant_type: "client_credentials" + }; + request = new XMLHttpRequest(); + request.open("POST", this.options.accessTokenUrl); + body = []; + _ref1 = this.xhrAccessTokenParams; + for (key in _ref1) { + value = _ref1[key]; + body.push("" + key + "=" + (this.urlEncode(value))); + } + body = body.sort().join('&'); + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.onreadystatechange = function() { + var responseJSON; + if (request.readyState === 4) { + responseJSON = JSON.parse(request.responseText); + return callback(responseJSON.access_token); + } + }; + return request.send(body); + }; + + return ClientCredentialsFlow; + +})(OAuth2Flow); +;var OAuth2; + +OAuth2 = (function() { + function OAuth2() {} + + OAuth2.AuthorizationCodeFlow = AuthorizationCodeFlow; + + OAuth2.ClientCredentialFlow = ClientCredentialsFlow; + + return OAuth2; + +})(); +;var RSS; + +RSS = (function() { + function RSS(options) { + this.options = options != null ? options : {}; + this.url = options.constructor.name === "String" ? options : options.url; + if (!this.url) { + throw "URL required"; + } + } + + return RSS; + +})(); +;var TouchDB, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +TouchDB = (function() { + TouchDB.baseURL = "http://.touchdb."; + + function TouchDB(options) { + var _this = this; + this.options = options != null ? options : {}; + this.replicateFrom = __bind(this.replicateFrom, this); + this.fireCallbacks = __bind(this.fireCallbacks, this); + if (!this.options.name) { + throw "Database name required"; + } + this.replicas = {}; + this.baseURL = "" + TouchDB.baseURL + "/" + this.options.name; + this.eventCallbacks = {}; + this.createDB({}, { + onSuccess: function() { + return _this.fireCallbacks('ready'); + }, + onFailure: function(error) { + if (error.status === 412) { + return _this.fireCallbacks('ready'); + } else { + return console.log("unable to initialize database: " + error.error); + } + } + }); + this.startMonitoringChanges({}, { + onChange: function() { + return _this.fireCallbacks('change'); + } + }); + } + + TouchDB.prototype.fireCallbacks = function(name) { + var callback, _i, _len, _ref, _results; + if (!this.eventCallbacks[name]) { + return; + } + _ref = this.eventCallbacks[name]; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + callback = _ref[_i]; + _results.push(callback.call()); + } + return _results; + }; + + TouchDB.prototype.on = function(eventName, callback) { + var _base; + (_base = this.eventCallbacks)[eventName] || (_base[eventName] = []); + return this.eventCallbacks[eventName].push(callback); + }; + + TouchDB.prototype.startMonitoringChanges = function(options, callbacks) { + var request, + _this = this; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + request = new XMLHttpRequest(); + request.open("GET", "" + this.baseURL + "/_changes?feed=continuous"); + request.onreadystatechange = function() { + if (request.readyState !== 3) { + return; + } + return callbacks.onChange(); + }; + return request.send(); + }; + + TouchDB.prototype.createDB = function(options, callbacks) { + var request, + _this = this; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + request = new XMLHttpRequest(); + request.open("PUT", "" + this.baseURL + "/"); + request.onreadystatechange = function() { + var errorObj, responseObj; + if (request.readyState !== 4) { + return; + } + if (request.status === 412) { + errorObj = JSON.parse(request.responseText); + if (callbacks.onFailure) { + callbacks.onFailure(errorObj); + } + } + if (request.status === 201) { + responseObj = JSON.parse(request.responseText); + if (callbacks.onSuccess) { + return callbacks.onSuccess(responseObj); + } + } + }; + return request.send(); + }; + + TouchDB.prototype.addTwoWayReplica = function(options, callbacks) { + var fromCloudAdded, fromCloudFailed, toCloudAdded, toCloudFailed, + _this = this; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + toCloudAdded = function() { + return _this.startReplication({ + source: options.url, + target: _this.options.name + }, { + onSuccess: fromCloudAdded, + onFailure: fromCloudFailed + }); + }; + toCloudFailed = function() { + if (callbacks.onFailure) { + return callbacks.onFailure(); + } + }; + fromCloudAdded = function() { + _this.replicas[options.url] = {}; + if (callbacks.onSuccess) { + return callbacks.onSuccess(); + } + }; + fromCloudFailed = function() { + if (callbacks.onFailure) { + return callbacks.onFailure(); + } + }; + return this.startReplication({ + source: this.options.name, + target: options.url + }, { + onSuccess: toCloudAdded, + onFailure: toCloudFailed + }); + }; + + TouchDB.prototype.replicateFrom = function(options, callbacks) { + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return this.startReplication({ + source: options.url, + target: this.options.name + }, { + onSuccess: callbacks.onSuccess, + onFailure: callbacks.onFailure + }); + }; + + TouchDB.prototype.startReplication = function(options, callbacks) { + var request, + _this = this; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + request = new XMLHttpRequest(); + request.open("POST", "" + TouchDB.baseURL + "/_replicate"); + request.onreadystatechange = function() { + var errorObj, responseObj; + if (request.readyState !== 4) { + return; + } + if (request.status === 412) { + errorObj = JSON.parse(request.responseText); + callbacks.onFailure(errorObj); + } + if (request.status === 200) { + responseObj = JSON.parse(request.responseText); + return callbacks.onSuccess.call(responseObj); + } + }; + return request.send(JSON.stringify({ + source: options.source, + target: options.target, + continuous: true + })); + }; + + return TouchDB; + +})(); +;var SQLiteDB, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +SQLiteDB = (function() { + function SQLiteDB(options) { + this.options = options != null ? options : {}; + this.execute = __bind(this.execute, this); + this.createTable = __bind(this.createTable, this); + this.dropTable = __bind(this.dropTable, this); + this.databaseName = options.constructor.name === "String" ? options : options.name; + if (!window.sqlitePlugin) { + throw "window.sqlitePlugin is undefined, please load plugin"; + } + if (!this.databaseName) { + throw "database name required"; + } + } + + SQLiteDB.prototype.dropTable = function(opts, callbacks) { + var tableName; + if (opts == null) { + opts = {}; + } + if (callbacks == null) { + callbacks = {}; + } + tableName = opts.constructor.name === "String" ? opts : opts.name; + steroids.debug("dropping table " + tableName); + return this.execute({ + statement: "DROP TABLE " + tableName + }, callbacks); + }; + + SQLiteDB.prototype.createTable = function(opts, callbacks) { + var columnDefinitionString, columnsString, key, statement, tableName, type; + if (opts == null) { + opts = {}; + } + if (callbacks == null) { + callbacks = {}; + } + tableName = opts.constructor.name === "String" ? opts : opts.name; + statement = "CREATE TABLE " + tableName; + if (opts.columns != null) { + columnsString = (function() { + var _ref, _results; + _ref = opts.columns; + _results = []; + for (key in _ref) { + type = _ref[key]; + _results.push("" + key + " " + (type.toUpperCase())); + } + return _results; + })(); + columnDefinitionString = columnsString.join(", "); + } + steroids.debug("creating table " + tableName + " with " + columnDefinitionString); + if (columnDefinitionString != null) { + statement += " (" + columnDefinitionString + ")"; + } + return this.execute({ + statement: statement + }, callbacks); + }; + + SQLiteDB.prototype.execute = function(opts, callbacks) { + var statement, + _this = this; + if (opts == null) { + opts = {}; + } + if (callbacks == null) { + callbacks = {}; + } + statement = opts.constructor.name === "String" ? opts : opts.statement; + steroids.debug("stament to execute: " + statement); + return document.addEventListener('deviceready', function() { + if (!_this.db) { + _this.db = window.sqlitePlugin.openDatabase(_this.databaseName); + } + return _this.db.transaction(function(tx) { + var failure, success; + steroids.debug("execute transaction started"); + success = function(stx, res) { + var i, rows, _i, _ref; + rows = []; + for (i = _i = 0, _ref = res.rows.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) { + rows.push(res.rows.item(i)); + } + steroids.debug("execute success, returned " + rows.length + " rows"); + if (callbacks.onSuccess) { + return callbacks.onSuccess(rows, res, stx); + } + }; + failure = function(tx, err) { + steroids.debug("execute failure -- err.message: " + err.message); + if (callbacks.onFailure) { + return callbacks.onFailure(err, tx); + } + }; + return tx.executeSql(statement, [], success, failure); + }); + }); + }; + + return SQLiteDB; + +})(); +;var XHR, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +XHR = (function() { + XHR.prototype.headers = []; + + function XHR() { + this.setRequestHeader = __bind(this.setRequestHeader, this); + this.send = __bind(this.send, this); + this.method = void 0; + this.url = void 0; + this.async = void 0; + this.status = 0; + this.readyState = 0; + this.headers = {}; + } + + XHR.prototype.open = function(methodString, urlString, isAsync) { + if (isAsync == null) { + isAsync = true; + } + this.method = methodString; + this.url = urlString; + return this.async = isAsync; + }; + + XHR.prototype.send = function(data) { + if (!(this.method && this.url)) { + throw "Error: INVALID_STATE_ERR: DOM Exception 11"; + } + if (this.method !== "GET") { + throw "Method not implemented"; + } + return this.fetch({ + url: this.url, + filenameWithPath: "temp", + headers: this.headers + }); + }; + + XHR.prototype.setRequestHeader = function(name, value) { + return this.headers[name] = value; + }; + + XHR.prototype.fetch = function(options, callbacks) { + var destinationPath; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + destinationPath = options.constructor.name === "String" ? options : options.absoluteDestinationPath; + return steroids.nativeBridge.nativeCall({ + method: "downloadFile", + parameters: { + url: options.url || this.url, + headers: options.headers || this.headers, + filenameWithPath: destinationPath + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return XHR; + +})(); +;var Analytics; + +Analytics = (function() { + function Analytics() {} + + Analytics.prototype.track = function(event, callbacks) { + if (event == null) { + event = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return steroids.nativeBridge.nativeCall({ + method: "recordEvent", + parameters: { + type: "custom", + attributes: event + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return Analytics; + +})(); +;var Screen; + +Screen = (function() { + function Screen() {} + + Screen.prototype.edges = { + LEFT: "left", + RIGHT: "right", + TOP: "top", + BOTTOM: "bottom" + }; + + Screen.prototype.freeze = function(options, callbacks) { + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return steroids.nativeBridge.nativeCall({ + method: "freeze", + parameters: options, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + Screen.prototype.unfreeze = function(options, callbacks) { + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return steroids.nativeBridge.nativeCall({ + method: "unfreeze", + parameters: options, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + Screen.prototype.capture = function(options, callbacks) { + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + return steroids.nativeBridge.nativeCall({ + method: "takeScreenshot", + parameters: options, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return Screen; + +})(); +;var File; + +File = (function() { + function File(options) { + var _ref; + if (options == null) { + options = {}; + } + this.path = options.constructor.name === "String" ? options : options.path; + this.relativeTo = (_ref = options.relativeTo) != null ? _ref : steroids.app.path; + } + + File.prototype.resizeImage = function(options, callbacks) { + var nativeCompression, parameters, userCompression, _ref, _ref1, _ref2, _ref3; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + if (this.relativeTo !== steroids.app.userFilesPath) { + throw "Cannot resize images outside `steroids.app.userFilesPath`. Files must first be copied under application document root and then resized."; + } + userCompression = (_ref = (_ref1 = options.format) != null ? _ref1.compression : void 0) != null ? _ref : 100; + nativeCompression = 1 - (userCompression / 100); + parameters = { + filenameWithPath: "" + this.relativeTo + "/" + this.path, + format: (_ref2 = (_ref3 = options.format) != null ? _ref3.type : void 0) != null ? _ref2 : "jpg", + compression: nativeCompression + }; + if (options.constraint != null) { + switch (options.constraint.dimension) { + case "width": + parameters.size = { + width: options.constraint.length + }; + break; + case "height": + parameters.size = { + height: options.constraint.length + }; + break; + default: + throw "unknown constraint name"; + } + } else { + throw "constraint not specified"; + } + return steroids.nativeBridge.nativeCall({ + method: "resizeImage", + parameters: parameters, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + File.prototype.unzip = function(options, callbacks) { + var destinationPath, parameters, sourcePath; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + sourcePath = "" + this.relativeTo + "/" + this.path; + destinationPath = options.constructor.name === "String" ? options : options.destinationPath; + parameters = { + filenameWithPath: sourcePath, + path: destinationPath + }; + return steroids.nativeBridge.nativeCall({ + method: "unzip", + parameters: parameters, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return File; + +})(); +;var OpenURL; + +OpenURL = (function() { + function OpenURL() {} + + OpenURL.open = function(options, callbacks) { + var url; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + url = options.constructor.name === "String" ? options : options.url; + return steroids.nativeBridge.nativeCall({ + method: "openURL", + parameters: { + url: url + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return OpenURL; + +})(); +;var Notifications; + +Notifications = (function() { + function Notifications() {} + + Notifications.prototype.post = function(options, callbacks) { + var message; + if (options == null) { + options = {}; + } + if (callbacks == null) { + callbacks = {}; + } + message = options.constructor.name === "String" ? options : options.message; + return steroids.nativeBridge.nativeCall({ + method: "postNotification", + parameters: { + body: message + }, + successCallbacks: [callbacks.onSuccess], + failureCallbacks: [callbacks.onFailure] + }); + }; + + return Notifications; + +})(); +;var PostMessage; + +PostMessage = (function() { + function PostMessage() {} + + PostMessage.postMessage = function(message, targetOrigin) { + var escapedJSONMessage; + escapedJSONMessage = escape(JSON.stringify(message)); + return steroids.nativeBridge.nativeCall({ + method: "broadcastJavascript", + parameters: { + javascript: "steroids.PostMessage.dispatchMessageEvent('" + escapedJSONMessage + "', '*');" + }, + successCallbacks: [], + recurringCallbacks: [] + }); + }; + + PostMessage.dispatchMessageEvent = function(escapedJSONMessage, targetOrigin) { + var e, message; + message = JSON.parse(unescape(escapedJSONMessage)); + e = document.createEvent("MessageEvent"); + e.initMessageEvent("message", false, false, message, "", "", window, null); + return window.dispatchEvent(e); + }; + + return PostMessage; + +}).call(this); +;window.steroids = { + version: "3.1.2", + Animation: Animation, + XHR: XHR, + File: File, + views: { + WebView: WebView, + PreviewFileView: PreviewFileView + }, + buttons: { + NavigationBarButton: NavigationBarButton + }, + data: { + SQLiteDB: SQLiteDB, + TouchDB: TouchDB, + RSS: RSS, + OAuth2: OAuth2 + }, + openURL: OpenURL.open, + eventCallbacks: {}, + waitingForComponents: [], + debugMessages: [], + debugEnabled: false, + debug: function(msg) { + var blue, debugMessage, msgJSON, red, reset; + if (!steroids.debugEnabled) { + return; + } + msgJSON = JSON.stringify(msg); + red = '\u001b[31m'; + blue = '\u001b[34m'; + reset = '\u001b[0m'; + debugMessage = "[" + red + "DEBUG" + reset + "] - " + msgJSON + " - " + blue + " " + window.location.href + reset; + window.steroids.debugMessages.push(debugMessage); + return console.log(debugMessage); + }, + on: function(event, callback) { + var _base; + this.debug("on event " + event); + if (this["" + event + "_has_fired"] != null) { + this.debug("on event " + event + ", alrueady fierd"); + return callback(); + } else { + this.debug("on event " + event + ", waiting"); + (_base = this.eventCallbacks)[event] || (_base[event] = []); + return this.eventCallbacks[event].push(callback); + } + }, + fireSteroidsEvent: function(event) { + var callback, callbacks, _i, _len, _results; + this.debug("firign event " + event); + this["" + event + "_has_fired"] = new Date().getTime(); + if (this.eventCallbacks[event] != null) { + this.debug("firign event " + event + " callbacks"); + callbacks = this.eventCallbacks[event].splice(0); + _results = []; + for (_i = 0, _len = callbacks.length; _i < _len; _i++) { + callback = callbacks[_i]; + this.debug("firing event " + event + " callback"); + _results.push(callback()); + } + return _results; + } + }, + resetSteroidsEvent: function(event) { + this.debug("resettign event " + event); + return this["" + event + "_has_fired"] = void 0; + }, + markComponentReady: function(model) { + this.debug("" + model + " is ready"); + this.waitingForComponents.splice(this.waitingForComponents.indexOf(model), 1); + if (this.waitingForComponents.length === 0) { + this.debug("steroids is ready"); + return this.fireSteroidsEvent("ready"); + } + } +}; + +window.steroids.nativeBridge = Bridge.getBestNativeBridge(); + +window.steroids.waitingForComponents.push("App"); + +window.steroids.waitingForComponents.push("Events.focuslisteners"); + +window.steroids.waitingForComponents.push("Events.initialVisibility"); + +window.steroids.app = new App; + +Events.extend(); + +window.steroids.drawers = new DrawerCollection; + +window.steroids.layers = new LayerCollection; + +window.steroids.view = new steroids.views.WebView({ + location: window.location.href +}); + +window.steroids.modal = new Modal; + +window.steroids.audio = new Audio; + +window.steroids.navigationBar = new NavigationBar; + +window.steroids.statusBar = new StatusBar; + +window.steroids.tabBar = new TabBar; + +window.steroids.device = new Device; + +window.steroids.analytics = new Analytics; + +window.steroids.screen = new Screen; + +window.steroids.notifications = new Notifications; + +window.steroids.PostMessage = PostMessage; + +window.postMessage = PostMessage.postMessage; + +})(window); diff --git a/www/loading.html b/www/loading.html new file mode 100644 index 0000000..a044b85 --- /dev/null +++ b/www/loading.html @@ -0,0 +1,57 @@ + + + + + + Loading... + + + + + + + + +
+

Loading...

+ +
+ + diff --git a/www/loading.png b/www/loading.png new file mode 100644 index 0000000..d79375f Binary files /dev/null and b/www/loading.png differ