mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Merge pull request #72 from VincentRoth/master
Positioning dialog for iOS
This commit is contained in:
commit
b969aa748a
@ -24,10 +24,12 @@ cordova.plugins.fileOpener2.open(
|
|||||||
fileMIMEType,
|
fileMIMEType,
|
||||||
{
|
{
|
||||||
error : function(){ },
|
error : function(){ },
|
||||||
success : function(){ }
|
success : function(){ },
|
||||||
|
position : [x, y]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
`position` array of coordinates from top-left device screen, use for iOS dialog positioning.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
@ -39,6 +39,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
showPreview = [[command.arguments objectAtIndex:2] boolValue];
|
showPreview = [[command.arguments objectAtIndex:2] boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGRect rect;
|
||||||
|
if ([command.arguments count] >= 4) {
|
||||||
|
NSArray *positionValues = command.arguments[3];
|
||||||
|
rect = CGRectMake(0,0,[[positionValues objectAtIndex:0] floatValue],[[positionValues objectAtIndex:1] floatValue]);
|
||||||
|
} else {
|
||||||
|
rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
CDVViewController* cont = (CDVViewController*)[super viewController];
|
CDVViewController* cont = (CDVViewController*)[super viewController];
|
||||||
self.cdvViewController = cont;
|
self.cdvViewController = cont;
|
||||||
NSString *uti = nil;
|
NSString *uti = nil;
|
||||||
@ -80,7 +88,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
wasOpened = [docController presentPreviewAnimated: NO];
|
wasOpened = [docController presentPreviewAnimated: NO];
|
||||||
} else {
|
} else {
|
||||||
CDVViewController* cont = self.cdvViewController;
|
CDVViewController* cont = self.cdvViewController;
|
||||||
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
|
|
||||||
wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES];
|
wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ var exec = require('cordova/exec');
|
|||||||
|
|
||||||
function FileOpener2() {}
|
function FileOpener2() {}
|
||||||
|
|
||||||
FileOpener2.prototype.open = function (fileName, contentType, callbackContext) {
|
FileOpener2.prototype.open = function (fileName, contentType, options) {
|
||||||
contentType = contentType || '';
|
contentType = contentType || '';
|
||||||
callbackContext = callbackContext || {};
|
options = options || {};
|
||||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]);
|
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false, options.position]);
|
||||||
};
|
};
|
||||||
|
|
||||||
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
|
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user