mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
Android can now call Angular!
This commit is contained in:
parent
799091b6e4
commit
e20e42b7bd
31204
app/src/main/assets/dist/book-bundle.js
vendored
31204
app/src/main/assets/dist/book-bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -22,7 +22,7 @@ gulp.task('watch', function() {
|
||||
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
|
||||
.pipe(source('book-bundle.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(uglify())
|
||||
//.pipe(uglify()) // Since Android needs to call in, can't minify
|
||||
.pipe(gulp.dest('./dist'));
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'jquery' # For using selectors to access scope
|
||||
$ = require 'jquery' # For using selectors to access scope
|
||||
require 'angular'
|
||||
|
||||
app = angular.module('bookApp', [])
|
||||
@ -8,10 +8,21 @@ app.controller 'BookCtrl', ['$scope', ($scope) ->
|
||||
{'text': 'hello.'}
|
||||
];
|
||||
|
||||
$scope.alert = ->
|
||||
alert "Hello!"
|
||||
$scope.appendVerse = (text) ->
|
||||
$scope.verses.push {'text': text}
|
||||
]
|
||||
|
||||
# Due to page initialization, we can only store the controller string.
|
||||
# The actual element changes, so there's nothing we can do with JQuery
|
||||
# etc. to grab the scope ahead of time and re-use it.
|
||||
controller = "#bookController"
|
||||
|
||||
window.appendVerse = (text) ->
|
||||
scope = angular.element($("#bookController")).scope()
|
||||
scope.appendVerse text
|
||||
# Since we're calling outside of angular, we need to manually apply
|
||||
scope.$apply()
|
||||
|
||||
###
|
||||
Future reference: Get the controller scope like so:
|
||||
angular.element($("<controller-element>")).scope().<function>
|
||||
|
@ -113,7 +113,8 @@ public class BookFragment extends BaseFragment {
|
||||
Verse initial = new Verse(vUtil.getVersification(mBook.get()),
|
||||
BibleBook.GEN, 1, 1);
|
||||
super.onPageFinished(view, url);
|
||||
// invokeJavascript("set_content", lookupService.getHTMLVerse(initial));
|
||||
// invokeJavascript("appendVerse", lookupService.getHTMLVerse(initial));
|
||||
invokeJavascript("appendVerse", "Testing string...");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,7 +125,7 @@ public class BookFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Remove remote debugging when ready
|
||||
// TODO: Remove remote debugging when ready - or should this be removed?
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user