-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This sample shows how textarea elements can be used in hashspace. | ||
|
||
[#output] | ||
|
||
Like for input elements, hashspace uses the `model` attribute to bind the textarea content with the template's model. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# template sample(data) | ||
<div class="info2">The following textarea elements are synchronized:</div> | ||
<div class="section"> | ||
<div>Text #1:</div> | ||
<textarea rows="4" cols="40" model="{data.text}"/> | ||
</div> | ||
<div class="section"> | ||
<div>Text #2:</div> | ||
<textarea rows="4" cols="40" model="{data.text}"/> | ||
</div> | ||
<a onclick="{changeText(data)}">Change text</a> | ||
# /template | ||
|
||
var d={ | ||
// Frog by Donna Shepherd | ||
text:" @..@\n (----)\n ( >__< )\n ^^ ~~ ^^" | ||
} | ||
|
||
var count=1; | ||
function changeText(d) { | ||
count++, msg=[]; | ||
for (var i=0;count>i;i++) { | ||
msg.push("This text contains "+count+" lines") | ||
} | ||
d.text=msg.join("\n"); | ||
} | ||
|
||
sample(d).render("output"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
/* | ||
* Copyright 2014 Amadeus s.a.s. | ||
* Licensed 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. | ||
*/ | ||
|
||
var hsp=require("hsp/rt"), | ||
ht=require("hsp/utils/hashtester"); | ||
|
||
# template test1(data) | ||
<textarea rows="4" cols="40" model="{data.text}"/> | ||
# /template | ||
|
||
describe("Textarea Elements", function () { | ||
it("validates model synchronization", function () { | ||
var h=ht.newTestContext(); | ||
var model={text:"line 1\nline2"}; | ||
|
||
test1(model).render(h.container); | ||
expect(h("textarea").value()).to.equal("line 1\nline2"); | ||
|
||
// change value from the DOM | ||
h("textarea").type("AAA\nBBB\nCCC"); | ||
expect(model.text).to.equal("AAA\nBBB\nCCC"); | ||
|
||
// change value from the model | ||
h.$set(model,"text","Hello\nWorld!"); | ||
expect(h("textarea").value()).to.equal("Hello\nWorld!"); | ||
|
||
h.$dispose(); | ||
}); | ||
}); |