This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 251075
Collapse All | Expand All

(-)a/api.knockout/apichanges.xml (+14 lines)
Lines 57-62 Link Here
57
    <!-- ACTUAL CHANGES BEGIN HERE: -->
57
    <!-- ACTUAL CHANGES BEGIN HERE: -->
58
58
59
<changes>
59
<changes>
60
    <change id="bindings-function">
61
        <api name="ko"/>
62
        <summary>Introducing Bindings.function(String name)</summary>
63
        <version major="1" minor="1" />
64
        <date day="11" month="3" year="2015"/>
65
        <author login="rsvitanic"/>
66
        <compatibility addition="yes" modification="no" semantic="compatible" source="compatible" binary="compatible"/>
67
        <description>
68
            <p>
69
                Added method Bindings.function(String name) which generates an empty function property.
70
            </p>
71
        </description>
72
        <issue number="251075"/>
73
    </change>
60
    <change id="branding.token">
74
    <change id="branding.token">
61
        <api name="ko"/>
75
        <api name="ko"/>
62
        <summary>Introduced</summary>
76
        <summary>Introduced</summary>
(-)a/api.knockout/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.api.knockout
2
OpenIDE-Module: org.netbeans.api.knockout
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/knockout/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/knockout/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.0
4
OpenIDE-Module-Specification-Version: 1.1
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
(-)a/api.knockout/src/org/netbeans/spi/knockout/Bindings.java (+13 lines)
Lines 148-153 Link Here
148
        return this;
148
        return this;
149
    }
149
    }
150
150
151
    /**
152
     * Generates a function (empty) into the JSON class.
153
     *
154
     * @param name name of variable (must be valid JavaScript identifier)
155
     * @return this object
156
     *
157
     * @since 1.1
158
     */
159
    public final Bindings function(String name) {
160
        addProp(name, false, "function() {}");
161
        return this;
162
    }
163
151
    final String generate() {
164
    final String generate() {
152
        StringBuilder sb = new StringBuilder();
165
        StringBuilder sb = new StringBuilder();
153
        //sb.append("(function() {\n");
166
        //sb.append("(function() {\n");
(-)a/api.knockout/test/unit/src/org/netbeans/spi/knockout/BindingsNGTest.java (+14 lines)
Lines 91-96 Link Here
91
        assertEquals(eng.eval("ko.value.currentTweets[0].from_user_id"), 0d, "Boolean values are set to true");
91
        assertEquals(eng.eval("ko.value.currentTweets[0].from_user_id"), 0d, "Boolean values are set to true");
92
    }
92
    }
93
93
94
    @Test
95
    public void generateModelWithFunctions() throws Exception {
96
        Bindings myModel = Bindings.create("MyModel").
97
                function("myFunc1").
98
                function("func2");
99
100
        String txt = myModel.generate();
101
        assertValidJS(txt);
102
        assertNotNull(eng.eval("ko"));
103
        assertNotNull(eng.eval("ko.value"));
104
        assertNotNull(eng.eval("ko.value.myFunc1"));
105
        assertNotNull(eng.eval("ko.value.func2"));
106
    }
107
94
    private void assertValidJS(String txt) {
108
    private void assertValidJS(String txt) {
95
        assertNotNull(txt, "We have some script");
109
        assertNotNull(txt, "We have some script");
96
        try {
110
        try {

Return to bug 251075