diff --git a/README.md b/README.md index 2690dcd..d66f830 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# ExtendedWebView Module 0.5 +# ExtendedWebView Module 0.6 ## Description This module extends the original Ti.UI.WebView by adding several new features. ###Note: -Version 0.5 of this module is not backwards compatible. +Version 0.5+ of this module is not backwards compatible. Please see the **usage** paragraph for more information. ## Installation @@ -19,6 +19,8 @@ Copy the module to your Titanium module folder, typically ## Adding the module to your project In Titanium Studio, add the module to your project. Open tiapp.xml and click the + button in the module section. Select de.mwfire.extwebview and add it. +NOTE: Unlike most other Ti modules, you do not need to `require` this module like you might normally, since it's a 'drop-in' extension to Ti.UI.webView. Just add it to your project as shown above and use the new methods on a normal Ti.UI.webView. + ## Reference @@ -40,6 +42,10 @@ Scrolls to the top of a WebView.
Scrolls to the bottom of a WebView.
*animated* optional, defaults to TRUE +`disableScrolling(BOOL)` (since 0.6)
+Disable scrolling (but not interactivity) on a webview.
+ + ## Usage ###Classic @@ -143,6 +149,9 @@ Minimum Titanium SDK is 3.5.0.GA
Supports iOS 7.1 and later ##Changelog +####V0.6 +- Disable scrolling. + ####V0.5 - Extend Ti.UI.WebView instead of a standalone module - Fixed build error on device @@ -157,6 +166,8 @@ Supports iOS 7.1 and later mwfire web development
[www.mwfire.de](http://www.mwfire.de) +Additional features: @kosso + ## License Licensed under the Apache License, Version 2.0 (the "License") \ No newline at end of file diff --git a/assets/README b/assets/README new file mode 100644 index 0000000..8121816 --- /dev/null +++ b/assets/README @@ -0,0 +1,9 @@ +Place your assets like PNG files in this directory and they will be packaged +with your module. + +All JavaScript files in the assets directory are IGNORED except if you create a +file named "de.mwfire.extwebview.js" in this directory in which case it will be +wrapped by native code, compiled, and used as your module. This allows you to +run pure JavaScript modules that are pre-compiled. + +Note: Mobile Web does not support this assets directory. diff --git a/assets/de.mwfire.extwebview.js b/assets/de.mwfire.extwebview.js new file mode 100644 index 0000000..0dacb8b --- /dev/null +++ b/assets/de.mwfire.extwebview.js @@ -0,0 +1 @@ +Ti.UI.createWebView(); \ No newline at end of file diff --git a/iphone/Classes/DeMwfireExtwebviewModuleAssets.m b/iphone/Classes/DeMwfireExtwebviewModuleAssets.m index 3403851..92217a5 100644 --- a/iphone/Classes/DeMwfireExtwebviewModuleAssets.m +++ b/iphone/Classes/DeMwfireExtwebviewModuleAssets.m @@ -12,10 +12,10 @@ - (NSData*) moduleAsset //##TI_AUTOGEN_BEGIN asset static UInt8 data[] = { - 0xc9,0x2e,0xb8,0x2e,0x62,0xe2,0x0a,0xcf,0x2d,0xec,0x45,0xa9,0x56,0xc6,0x45,0x5b,0x4c,0x61,0x48,0xb0 - ,0x6c,0x22,0x8a,0x30,0x07,0xca,0x71,0x9d,0x11,0xa9,0x4d,0xab,0xe4,0xd3,0x0c,0x57,0x95,0x31,0x96,0x74 - ,0x58,0x9e,0x9a,0x9c,0xe0,0x3b,0xf2,0x2b,0xd4,0x73,0x7b,0x9d,0xc6,0x9a,0xe2,0x57,0x09,0xb6,0x4c,0x2d - ,0x72,0x81,0x1c,0x0d }; + 0xf2,0xc4,0x61,0x37,0x9d,0xf7,0x95,0x0c,0xe7,0xad,0x39,0x73,0x89,0x5f,0x14,0xef,0x92,0x28,0x3d,0x62 + ,0xfb,0xe1,0xed,0xe6,0x42,0xd4,0xa7,0x7a,0x89,0xa8,0xd7,0x70,0x87,0xba,0x49,0xd8,0x51,0x72,0xd4,0x30 + ,0x94,0x80,0xa7,0x83,0x76,0x3d,0x6f,0xef,0xd6,0x6e,0x8a,0x52,0x35,0xb4,0x7d,0x38,0x31,0x15,0x28,0x33 + ,0x25,0xa7,0x35,0x9d }; static NSRange ranges[] = { {0,32} }; @@ -36,10 +36,10 @@ - (NSData*) resolveModuleAsset:(NSString*)path //##TI_AUTOGEN_BEGIN resolve_asset static UInt8 data[] = { - 0x77,0x64,0x6f,0x46,0xb6,0xa8,0x96,0x29,0x4e,0xa8,0xe2,0x5e,0xdb,0x57,0x69,0xaf,0x77,0x0b,0x0c,0xe7 - ,0xad,0xb1,0xc4,0x8d,0x08,0x74,0x93,0xf8,0xd2,0xb8,0xb6,0x7f,0x47,0x9d,0x34,0xf8,0x91,0xe6,0x02,0x43 - ,0x1d,0x29,0xa8,0x9e,0x5d,0x7b,0xa4,0x04,0x30,0x4f,0xbe,0xc6,0x63,0xf4,0x5f,0x57,0x93,0x9f,0x9b,0xa3 - ,0xb4,0x71,0xe1,0x28 }; + 0x0f,0xab,0x94,0x33,0xba,0xe2,0x62,0x26,0x56,0x76,0xec,0xff,0x9c,0x3e,0x45,0xc0,0xf6,0x96,0xbb,0xd5 + ,0x59,0x81,0xfa,0x47,0x33,0x73,0xd8,0x34,0x79,0x30,0xf7,0x53,0x29,0x11,0xc9,0x5a,0xfe,0x48,0xe0,0x23 + ,0xef,0x1f,0x8b,0xdb,0x39,0x74,0x40,0xc1,0x27,0x39,0x1b,0x0e,0xf9,0x28,0xe1,0x70,0xe9,0x1d,0x5f,0x4e + ,0x09,0x7f,0x11,0x98 }; static NSRange ranges[] = { {0,32} }; diff --git a/iphone/Classes/TiUIWebView+Extend.h b/iphone/Classes/TiUIWebView+Extend.h index 8abeaca..f438370 100644 --- a/iphone/Classes/TiUIWebView+Extend.h +++ b/iphone/Classes/TiUIWebView+Extend.h @@ -10,6 +10,7 @@ #import "TiUIWebView.h" @interface TiUIWebView (Extend) +- (void)disableScrolling:(id)args; - (void)scrollTo:(id)args; - (void)scrollToTop:(id)args; - (void)scrollToBottom:(id)args; diff --git a/iphone/Classes/TiUIWebView+Extend.m b/iphone/Classes/TiUIWebView+Extend.m index 93fb7f0..198bce9 100644 --- a/iphone/Classes/TiUIWebView+Extend.m +++ b/iphone/Classes/TiUIWebView+Extend.m @@ -29,10 +29,9 @@ -(void)scrollTo:(id)args CGFloat offsetX = [TiUtils floatValue:@"x" properties:[args objectAtIndex:0] def:0]; CGFloat offsetY = [TiUtils floatValue:@"y" properties:[args objectAtIndex:0] def:0]; BOOL animated = [TiUtils boolValue:@"animated" properties:[args objectAtIndex:0] def:YES]; - - UIScrollView *currScrollView = [self scrollview]; CGPoint newOffset = CGPointMake(offsetX, offsetY); - [currScrollView setContentOffset:newOffset animated:animated]; + [[self scrollview] setContentOffset:newOffset animated:animated]; + } -(void)scrollToBottom:(id)args @@ -40,7 +39,7 @@ -(void)scrollToBottom:(id)args BOOL animated = [TiUtils boolValue:@"animated" properties:[args objectAtIndex:0] def:YES]; UIScrollView *currScrollView = [self scrollview]; - + CGSize svContentSize = currScrollView.contentSize; CGSize svBoundSize = currScrollView.bounds.size; CGFloat svBottomInsets = currScrollView.contentInset.bottom; @@ -53,4 +52,26 @@ -(void)scrollToBottom:(id)args [currScrollView setContentOffset:newOffset animated:animated]; } +- (void)disableScrolling:(id)value +{ + BOOL allowed = ![TiUtils boolValue:value def:YES]; + [[self scrollview] setScrollEnabled:allowed]; +} + +-(void)enableCookieAcceptPolicyAlways:(id)args +{ + // via outdated fork : https://github.com/cmartyniuk/titanium-module-extended-webview + // http://stackoverflow.com/questions/14448373/3rd-party-cookies-in-an-ios6-uiwebview/14465407#14465407 + NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + storage.cookieAcceptPolicy = NSHTTPCookieAcceptPolicyAlways; +} + +-(void)setUserAgent:(id)userAgent +{ + // via outdated fork : https://github.com/cmartyniuk/titanium-module-extended-webview + // http://stackoverflow.com/questions/8487581/uiwebview-ios5-changing-user-agent + NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:[TiUtils stringValue:userAgent], @"UserAgent", nil]; + [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; +} + @end diff --git a/iphone/Classes/TiUIWebViewProxy+Extend.m b/iphone/Classes/TiUIWebViewProxy+Extend.m index 40413f0..09bf221 100644 --- a/iphone/Classes/TiUIWebViewProxy+Extend.m +++ b/iphone/Classes/TiUIWebViewProxy+Extend.m @@ -32,4 +32,13 @@ -(void)scrollToBottom:(id)args [(TiUIWebView *)[self view] scrollToBottom:args]; } +-(void)disableScrolling:(id)args +{ + ENSURE_UI_THREAD(disableScrolling, args); + [(TiUIWebView *)[self view] disableScrolling:args]; +} + + + + @end diff --git a/iphone/de.mwfire.extwebview-iphone-0.6.0.zip b/iphone/de.mwfire.extwebview-iphone-0.6.0.zip new file mode 100644 index 0000000..8f526ab Binary files /dev/null and b/iphone/de.mwfire.extwebview-iphone-0.6.0.zip differ diff --git a/iphone/manifest b/iphone/manifest index 21c3a67..6e1db6e 100644 --- a/iphone/manifest +++ b/iphone/manifest @@ -2,11 +2,11 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 0.5.0 +version: 0.6.0 apiversion: 2 architectures: armv7 arm64 i386 x86_64 description: Extends Ti.UI.WebView with several methods -author: Martin Wildfeuer +author: Martin Wildfeuer. Forked and added to by @kosso license: www.gnu.org/copyleft/gpl.html copyright: Copyright (c) 2015 by mwfire development @@ -15,4 +15,4 @@ name: ExtWebView moduleid: de.mwfire.extwebview guid: 1c0e017c-a06e-4842-9c53-fc75c8019a5f platform: iphone -minsdk: 3.5.0.GA +minsdk: 4.0.0.GA diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/LICENSE b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/LICENSE deleted file mode 100644 index 6ae867d..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: place your license here and we'll include it in the module distribution diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/documentation/index.html b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/documentation/index.html deleted file mode 100644 index b9c0388..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/documentation/index.html +++ /dev/null @@ -1,22 +0,0 @@ -

ExtWebView Module

-

Description

-

TODO: Enter your module description here

-

Accessing the ExtWebView Module

-

To access this module from JavaScript, you would do the following:

-
var extwebview = require("de.mwfire.extwebview");
-
-

The extwebview variable is a reference to the Module object.

-

Reference

-

TODO: If your module has an API, you should document -the reference here.

-

extwebview.function

-

TODO: This is an example of a module function.

-

extwebview.property

-

TODO: This is an example of a module property.

-

Usage

-

TODO: Enter your usage example here

-

Author

-

TODO: Enter your author name, email and other contact -details you want to share here.

-

License

-

TODO: Enter your license/legal information here.

\ No newline at end of file diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/example/app.js b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/example/app.js deleted file mode 100644 index 323fcb1..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/example/app.js +++ /dev/null @@ -1,112 +0,0 @@ -// Open a single window -var win = Ti.UI.createWindow({ - backgroundColor : 'white', - orientationModes : [ - Ti.UI.LANDSCAPE_LEFT, - Ti.UI.LANDSCAPE_RIGHT, - Ti.UI.PORTRAIT, - Ti.UI.UPSIDE_PORTRAIT - ] -}); -win.open(); - - -//// ------ VIEWS ---- //// - -// Create an extended webview -var webView = Ti.UI.createWebView({ - left: 0, right: 0, top: 0, bottom : 0, - url: "http://www.mwfire.de", - scalesPageToFit : true -}); -win.add(webView); - -// Add a reset zoom button -var reset = Ti.UI.createButton({ - bottom: "110dp", height: "40dp", left: "2%", right:"51%", - backgroundColor: "#FFFFFF", - title: 'Reset' -}); -win.add(reset); - -// Add a zoom in button -var zoomIn = Ti.UI.createButton({ - bottom: "110dp", height: "40dp", left: "51%", right:"2%", - backgroundColor: "#FFFFFF", - title: 'Zoom in' -}); -win.add(zoomIn); - -// Add a zoom out -var zoomOut = Ti.UI.createButton({ - bottom: "60dp", height: "40dp", left: "2%", right:"51%", - backgroundColor: "#FFFFFF", - title: 'Zoom out' -}); -win.add(zoomOut); - -// Add a scrollTo button -var scrollTo = Ti.UI.createButton({ - bottom: "60dp", height: "40dp", left: "51%", right:"2%", - backgroundColor: "#FFFFFF", - title: 'Scroll to' -}); -win.add(scrollTo); - -// Add a scroll to top button -var scrollTop = Ti.UI.createButton({ - bottom: "10dp", height: "40dp", left: "2%", right:"51%", - backgroundColor: "#FFFFFF", - title: 'Scroll to top' -}); -win.add(scrollTop); - -// Add a scroll to top button -var scrollBottom = Ti.UI.createButton({ - bottom: "10dp", height: "40dp", left: "51%", right:"2%", - backgroundColor: "#FFFFFF", - title: 'Scroll to bottom' -}); -win.add(scrollBottom); - - -//// ------ EVENT LISTENERS ---- //// - -reset.addEventListener('click', function() { - webView.scrollToTop(); - webView.setZoomScale(0.0); -}); - -zoomIn.addEventListener('click', function() { - // Set zoom level of the webview - // optional first parameter takes zoom level as float - // optional second parameter takes object with animation setting - // webView.setZoomScale(1.2); - webView.setZoomScale(2.0); -}); - -zoomOut.addEventListener('click', function() { - // 0.0 is standard zoom - webView.setZoomScale(0.0); -}); - -scrollTo.addEventListener('click', function() { - // Scrolls to a given offset - // optional parameter takes object are x, y, and animation settings - // webView.scrollTo( { x:10, y:150, animated: false } ); - webView.scrollTo( { y:150 } ); -}); - -scrollTop.addEventListener('click', function() { - // Scrolls webview to top - // optional parameter takes object with animation setting - // webView.scrollToTop({ animated: false }); - webView.scrollToTop(); -}); - -scrollBottom.addEventListener('click', function() { - // Scrolls webview to bottom - // optional parameter takes object with animation setting - // webView.scrollToBottom({ animated: false }); - webView.scrollToBottom(); -}); \ No newline at end of file diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/libde.mwfire.extwebview.a b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/libde.mwfire.extwebview.a deleted file mode 100644 index 838b38e..0000000 Binary files a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/libde.mwfire.extwebview.a and /dev/null differ diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/manifest b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/manifest deleted file mode 100644 index 21c3a67..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/manifest +++ /dev/null @@ -1,18 +0,0 @@ -# -# this is your module manifest and used by Titanium -# during compilation, packaging, distribution, etc. -# -version: 0.5.0 -apiversion: 2 -architectures: armv7 arm64 i386 x86_64 -description: Extends Ti.UI.WebView with several methods -author: Martin Wildfeuer -license: www.gnu.org/copyleft/gpl.html -copyright: Copyright (c) 2015 by mwfire development - -# these should not be edited -name: ExtWebView -moduleid: de.mwfire.extwebview -guid: 1c0e017c-a06e-4842-9c53-fc75c8019a5f -platform: iphone -minsdk: 3.5.0.GA diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/metadata.json b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/metadata.json deleted file mode 100644 index 7f30a3d..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"exports": ["UI.createWebView", "UI.createWebView"]} \ No newline at end of file diff --git a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/module.xcconfig b/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/module.xcconfig deleted file mode 100644 index 80ca884..0000000 --- a/iphone/modules/iphone/de.mwfire.extwebview/0.5.0/module.xcconfig +++ /dev/null @@ -1,27 +0,0 @@ -// -// PLACE ANY BUILD DEFINITIONS IN THIS FILE AND THEY WILL BE -// PICKED UP DURING THE APP BUILD FOR YOUR MODULE -// -// see the following webpage for instructions on the settings -// for this file: -// http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html -// - -// -// How to add a Framework (example) -// -// OTHER_LDFLAGS=$(inherited) -framework Foo -// -// Adding a framework for a specific version(s) of iPhone: -// -// OTHER_LDFLAGS[sdk=iphoneos4*]=$(inherited) -framework Foo -// OTHER_LDFLAGS[sdk=iphonesimulator4*]=$(inherited) -framework Foo -// -// -// How to add a compiler define: -// -// OTHER_CFLAGS=$(inherited) -DFOO=1 -// -// -// IMPORTANT NOTE: always use $(inherited) in your overrides -// diff --git a/iphone/titanium.xcconfig b/iphone/titanium.xcconfig index 54164b0..bb83683 100644 --- a/iphone/titanium.xcconfig +++ b/iphone/titanium.xcconfig @@ -4,17 +4,14 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 3.5.0.GA +TITANIUM_SDK_VERSION = 4.0.0.GA // // THESE SHOULD BE OK GENERALLY AS-IS // -TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) +TITANIUM_SDK = /Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" TITANIUM_BASE_SDK3 = "$(TITANIUM_SDK)/iphone/include/JavaScriptCore" -HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) $(TITANIUM_BASE_SDK3) - - - +HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) $(TITANIUM_BASE_SDK3) \ No newline at end of file