Added Windows8 support

This commit is contained in:
Sebastián Katzer 2014-04-06 11:10:49 +02:00
parent 7a095b6095
commit 02e39320d5
3 changed files with 62 additions and 1 deletions

View File

@ -46,6 +46,10 @@ More informations can be found [here](https://build.phonegap.com/plugins/360).
## Release Notes ## Release Notes
#### Version 0.6.0 (not yet released)
- [feature]: Added Windows8 support<br>
*Thanks to* ***pirvudoru***
#### Version 0.5.2 (22.03.2014) #### Version 0.5.2 (22.03.2014)
- [bugfix:] `isServiceAvailable` on Android did not return a list of available printing apps. - [bugfix:] `isServiceAvailable` on Android did not return a list of available printing apps.

View File

@ -9,7 +9,7 @@
<description>A bunch of printig plugins for Cordova 3.x.x</description> <description>A bunch of printig plugins for Cordova 3.x.x</description>
<repo>https://github.com/katzer/cordova-plugin-printer.git</repo> <repo>https://github.com/katzer/cordova-plugin-printer.git</repo>
<keywords>print, printer, ios, android</keywords> <keywords>print, printer, ios, android, windows 8</keywords>
<license>Apache 2.0</license> <license>Apache 2.0</license>
<author>Sebastián Katzer</author> <author>Sebastián Katzer</author>
@ -45,4 +45,11 @@
<source-file src="src/android/Printer.java" target-dir="src/de/appplant/cordova/plugin/printer" /> <source-file src="src/android/Printer.java" target-dir="src/de/appplant/cordova/plugin/printer" />
</platform> </platform>
<!-- windows8 -->
<platform name="windows8">
<js-module src="src/windows8/PrinterProxy.js" name="PrinterProxy">
<clobbers target="" />
</js-module>
</platform>
</plugin> </plugin>

View File

@ -0,0 +1,50 @@
/*
Copyright 2013-2014 appPlant UG
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
PrinterProxy = {
isServiceAvailable: function (successCallback, failCallback, args) {
args[0](true);
},
print: function (successCallback, failCallback, args) {
window.printContent = args[0];
Windows.Graphics.Printing.PrintManager.showPrintUIAsync();
},
printTaskRequested: function (printEvent) {
printEvent.request.createPrintTask("Print", function (args) {
var documentFragment = document.createDocumentFragment();
var content = document.createElement("html");
content.innerHTML = window.printContent;
documentFragment.appendChild(content);
args.setSource(MSApp.getHtmlPrintDocumentSource(documentFragment));
});
}
};
var printManager = Windows.Graphics.Printing.PrintManager.getForCurrentView();
printManager.onprinttaskrequested = PrinterProxy.printTaskRequested;
require("cordova/windows8/commandProxy").add("Printer", PrinterProxy);