Skip to content

Commit 439fd25

Browse files
committed
Merge branch 'dev'
2 parents c8b0f95 + 3c47ff4 commit 439fd25

File tree

11 files changed

+371
-2
lines changed

11 files changed

+371
-2
lines changed

RELEASENOTES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@
2828
* Rename CHANGELOG.md -> RELEASENOTES.md
2929
* [CB-4592] [Blackberry10] Added beep support
3030
* [CB-4752] Incremented plugin version on dev branch.
31+
32+
### 0.2.3 (Oct 28, 2013)
33+
* CB-5128: added repo + issue tag to plugin.xml for dialogs plugin
34+
* new plugin execute arguments supported
35+
* new plugin style
36+
* smaller fonts styling input
37+
* img files copied inside plugin
38+
* style added
39+
* prompt added
40+
* styling from James
41+
* fixed "exec" calls addedd css, but not working yet
42+
* first (blind) try
43+
* [CB-4915] Incremented plugin version on dev branch.

plugin.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,39 @@
22

33
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
44
id="org.apache.cordova.dialogs"
5-
version="0.2.2">
5+
version="0.2.3">
66

77
<name>Notification</name>
88
<description>Cordova Notification Plugin</description>
99
<license>Apache 2.0</license>
1010
<keywords>cordova,notification</keywords>
11+
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git</repo>
12+
<issue>https://issues.apache.org/jira/browse/CB/component/12320642</issue>
1113

1214
<js-module src="www/notification.js" name="notification">
1315
<merges target="navigator.notification" />
1416
</js-module>
1517

18+
<!-- firefoxos -->
19+
<platform name="firefoxos">
20+
<config-file target="config.xml" parent="/*">
21+
<feature name="Notification">
22+
<param name="firefoxos-package" value="Notification" />
23+
</feature>
24+
</config-file>
25+
26+
<asset src="www/firefoxos/notification.css" target="css/notification.css" />
27+
<asset src="www/firefoxos/danger-press.png" target="css/danger-press.png" />
28+
<asset src="www/firefoxos/danger.png" target="css/danger.png" />
29+
<asset src="www/firefoxos/default.png" target="css/default.png" />
30+
<asset src="www/firefoxos/gradient.png" target="css/gradient.png" />
31+
<asset src="www/firefoxos/pattern.png" target="css/pattern.png" />
32+
<asset src="www/firefoxos/recommend.png" target="css/recommend.png" />
33+
<js-module src="src/firefoxos/notification.js" name="dialogs-impl">
34+
<runs />
35+
</js-module>
36+
</platform>
37+
1638
<!-- android -->
1739
<platform name="android">
1840
<config-file target="res/xml/config.xml" parent="/*">

src/firefoxos/notification.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
function _empty() {}
2+
3+
function modal(message, callback, title, buttonLabels, domObjects) {
4+
/*
5+
<form role="dialog">
6+
<section>
7+
<h1>Some Title</h1>
8+
<p>Can't find a proper question for that ...</p>
9+
</section>
10+
<menu>
11+
<button>Cancel</button>
12+
<button class="danger">Delete</button>
13+
<button class="recommend">Recommend</button>
14+
<button>Standard</button>
15+
</menu>
16+
</form>
17+
*/
18+
// create a modal window
19+
var box = document.createElement('form');
20+
box.setAttribute('role', 'dialog');
21+
// prepare and append empty section
22+
var section = document.createElement('section');
23+
box.appendChild(section);
24+
// add title
25+
var boxtitle = document.createElement('h1');
26+
boxtitle.appendChild(document.createTextNode(title));
27+
section.appendChild(boxtitle);
28+
// add message
29+
var boxMessage = document.createElement('p');
30+
boxMessage.appendChild(document.createTextNode(message));
31+
section.appendChild(boxMessage);
32+
// inject what's needed
33+
if (domObjects) {
34+
section.appendChild(domObjects);
35+
}
36+
// add buttons and assign callbackButton on click
37+
var menu = document.createElement('menu');
38+
box.appendChild(menu);
39+
for (var index = 0; index < buttonLabels.length; index++) {
40+
// TODO: last button listens to the cancel key
41+
addButton(buttonLabels[index], index, (index === 0));
42+
}
43+
document.body.appendChild(box);
44+
45+
function addButton(label, index, recommended) {
46+
var button = document.createElement('button');
47+
button.appendChild(document.createTextNode(label));
48+
button.labelIndex = index;
49+
button.addEventListener('click', callbackButton, false);
50+
if (recommended) {
51+
// TODO: default one listens to Enter key
52+
button.classList.add('recommend');
53+
}
54+
menu.appendChild(button);
55+
}
56+
57+
// call callback and destroy modal
58+
function callbackButton() {
59+
callback(this.labelIndex);
60+
box.parentNode.removeChild(box);
61+
}
62+
}
63+
64+
var Notification = {
65+
vibrate: function(milliseconds) {
66+
navigator.vibrate(milliseconds);
67+
},
68+
alert: function(successCallback, errorCallback, args) {
69+
var message = args[0];
70+
var title = args[1];
71+
var _buttonLabels = [args[2]];
72+
var _callback = (successCallback || _empty);
73+
modal(message, _callback, title, _buttonLabels);
74+
},
75+
confirm: function(successCallback, errorCallback, args) {
76+
var message = args[0];
77+
var title = args[1];
78+
var buttonLabels = args[2];
79+
var _callback = (successCallback || _empty);
80+
modal(message, _callback, title, buttonLabels);
81+
},
82+
prompt: function(successCallback, errorCallback, args) {
83+
console.log(args);
84+
var message = args[0];
85+
var title = args[1];
86+
var buttonLabels = args[2];
87+
var defaultText = args[3];
88+
var _tempcallback = (successCallback || _empty);
89+
function _callback(labelIndex) {
90+
var content = document.getElementById('prompt-input').value;
91+
successCallback(labelIndex, content);
92+
}
93+
var inputParagraph = document.createElement('p');
94+
inputParagraph.classList.add('input');
95+
var inputElement = document.createElement('input');
96+
inputElement.setAttribute('type', 'text');
97+
inputElement.id = 'prompt-input';
98+
if (defaultText) {
99+
inputElement.setAttribute('placeholder', defaultText);
100+
}
101+
inputParagraph.appendChild(inputElement);
102+
modal(message, _callback, title, buttonLabels, inputParagraph);
103+
}
104+
};
105+
106+
module.exports = Notification;
107+
require('cordova/firefoxos/commandProxy').add('Notification', Notification);

www/firefoxos/danger-press.png

1015 Bytes
Loading

www/firefoxos/danger.png

1.01 KB
Loading

www/firefoxos/default.png

1014 Bytes
Loading

www/firefoxos/gradient.png

3.63 KB
Loading

www/firefoxos/notification.css

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/* Main dialog setup */
2+
form[role="dialog"] {
3+
background:
4+
url(../img/pattern.png) repeat left top,
5+
url(../img/gradient.png) no-repeat left top / 100% 100%;
6+
overflow: hidden;
7+
position: absolute;
8+
z-index: 100;
9+
top: 0;
10+
left: 0;
11+
right: 0;
12+
bottom: 0;
13+
padding: 1.5rem 0 7rem;
14+
font-family: "MozTT", Sans-serif;
15+
font-size: 0;
16+
/* Using font-size: 0; we avoid the unwanted visual space (about 3px)
17+
created by white-spaces and break lines in the code betewen inline-block elements */
18+
color: #fff;
19+
text-align: left;
20+
}
21+
22+
form[role="dialog"]:before {
23+
content: "";
24+
display: inline-block;
25+
vertical-align: middle;
26+
width: 0.1rem;
27+
height: 100%;
28+
margin-left: -0.1rem;
29+
}
30+
31+
form[role="dialog"] > section {
32+
font-weight: lighter;
33+
font-size: 1.8rem;
34+
color: #FAFAFA;
35+
padding: 0 1.5rem;
36+
-moz-box-sizing: padding-box;
37+
width: 100%;
38+
display: inline-block;
39+
overflow-y: scroll;
40+
max-height: 100%;
41+
vertical-align: middle;
42+
white-space: normal;
43+
}
44+
45+
form[role="dialog"] h1 {
46+
font-weight: normal;
47+
font-size: 1.6rem;
48+
line-height: 1.5em;
49+
color: #fff;
50+
margin: 0;
51+
padding: 0 1.5rem 1rem;
52+
border-bottom: 0.1rem solid #686868;
53+
}
54+
55+
/* Menu & buttons setup */
56+
form[role="dialog"] menu {
57+
margin: 0;
58+
padding: 1.5rem;
59+
padding-bottom: 0.5rem;
60+
border-top: solid 0.1rem rgba(255, 255, 255, 0.1);
61+
background: #2d2d2d url(../img/pattern.png) repeat left top;
62+
display: block;
63+
overflow: hidden;
64+
position: absolute;
65+
left: 0;
66+
right: 0;
67+
bottom: 0;
68+
text-align: center;
69+
}
70+
71+
form[role="dialog"] menu button::-moz-focus-inner {
72+
border: none;
73+
outline: none;
74+
}
75+
form[role="dialog"] menu button {
76+
width: 100%;
77+
height: 2.4rem;
78+
margin: 0 0 1rem;
79+
padding: 0 1.5rem;
80+
-moz-box-sizing: border-box;
81+
display: inline-block;
82+
vertical-align: middle;
83+
text-overflow: ellipsis;
84+
white-space: nowrap;
85+
overflow: hidden;
86+
background: #fafafa url(../img/default.png) repeat-x left bottom/ auto 100%;
87+
border: 0.1rem solid #a6a6a6;
88+
border-radius: 0.3rem;
89+
font: 500 1.2rem/2.4rem 'MozTT', Sans-serif;
90+
color: #333;
91+
text-align: center;
92+
text-shadow: 0.1rem 0.1rem 0 rgba(255,255,255,0.3);
93+
text-decoration: none;
94+
outline: none;
95+
}
96+
97+
/* Press (default & recommend) */
98+
form[role="dialog"] menu button:active,
99+
form[role="dialog"] menu button.recommend:active,
100+
a.recommend[role="button"]:active {
101+
border-color: #008aaa;
102+
color: #333;
103+
}
104+
105+
/* Recommend */
106+
form[role="dialog"] menu button.recommend {
107+
background-image: url(../img/recommend.png);
108+
background-color: #00caf2;
109+
border-color: #008eab;
110+
}
111+
112+
/* Danger */
113+
form[role="dialog"] menu button.danger,
114+
a.danger[role="button"] {
115+
background-image: url(../img/danger.png);
116+
background-color: #b70404;
117+
color: #fff;
118+
text-shadow: none;
119+
border-color: #820000;
120+
}
121+
122+
/* Danger Press */
123+
form[role="dialog"] menu button.danger:active {
124+
background-image: url(../img/danger-press.png);
125+
background-color: #890707;
126+
}
127+
128+
/* Disabled */
129+
form[role="dialog"] > menu > button[disabled] {
130+
background: #5f5f5f;
131+
color: #4d4d4d;
132+
text-shadow: none;
133+
border-color: #4d4d4d;
134+
pointer-events: none;
135+
}
136+
137+
138+
form[role="dialog"] menu button:nth-child(even) {
139+
margin-left: 1rem;
140+
}
141+
142+
form[role="dialog"] menu button,
143+
form[role="dialog"] menu button:nth-child(odd) {
144+
margin: 0 0 1rem 0;
145+
}
146+
147+
form[role="dialog"] menu button {
148+
width: calc((100% - 1rem) / 2);
149+
}
150+
151+
form[role="dialog"] menu button.full {
152+
width: 100%;
153+
}
154+
155+
/* Specific component code */
156+
form[role="dialog"] p {
157+
word-wrap: break-word;
158+
margin: 1rem 0 0;
159+
padding: 0 1.5rem 1rem;
160+
line-height: 3rem;
161+
}
162+
163+
form[role="dialog"] p img {
164+
float: left;
165+
margin-right: 2rem;
166+
}
167+
168+
form[role="dialog"] p strong {
169+
font-weight: lighter;
170+
}
171+
172+
form[role="dialog"] p small {
173+
font-size: 1.4rem;
174+
font-weight: normal;
175+
color: #cbcbcb;
176+
display: block;
177+
}
178+
179+
form[role="dialog"] dl {
180+
border-top: 0.1rem solid #686868;
181+
margin: 1rem 0 0;
182+
overflow: hidden;
183+
padding-top: 1rem;
184+
font-size: 1.6rem;
185+
line-height: 2.2rem;
186+
}
187+
188+
form[role="dialog"] dl > dt {
189+
clear: both;
190+
float: left;
191+
width: 7rem;
192+
padding-left: 1.5rem;
193+
font-weight: 500;
194+
text-align: left;
195+
}
196+
197+
form[role="dialog"] dl > dd {
198+
padding-right: 1.5rem;
199+
font-weight: 300;
200+
text-overflow: ellipsis;
201+
vertical-align: top;
202+
overflow: hidden;
203+
}
204+
205+
/* input areas */
206+
input[type="text"],
207+
input[type="password"],
208+
input[type="email"],
209+
input[type="tel"],
210+
input[type="search"],
211+
input[type="url"],
212+
input[type="number"],
213+
textarea {
214+
-moz-box-sizing: border-box;
215+
display: block;
216+
overflow: hidden;
217+
width: 100%;
218+
height: 3rem;
219+
resize: none;
220+
padding: 0 1rem;
221+
font-size: 1.6rem;
222+
line-height: 3rem;
223+
border: 0.1rem solid #ccc;
224+
border-radius: 0.3rem;
225+
box-shadow: none; /* override the box-shadow from the system (performance issue) */
226+
background: #fff url(input_areas/images/ui/shadow.png) repeat-x;
227+
}

www/firefoxos/pattern.png

6.69 KB
Loading

www/firefoxos/recommend.png

1020 Bytes
Loading

0 commit comments

Comments
 (0)