PageRenderTime 19ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/controls/warp_control.js

https://github.com/ajanthanm/cssfilterlab
JavaScript | 56 lines | 30 code | 11 blank | 15 comment | 2 complexity | 5817eef5168933508a6a5689e9e1af43 MD5 | raw file
 1/*
 2 * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
 3 * 
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 * 
 8 *     http://www.apache.org/licenses/LICENSE-2.0
 9 * 
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17(function() {
18
19    function WarpControl(delegate, name, config) {
20        WarpControl.$super.call(this, delegate, name, config);
21        this.init();
22    }
23
24    Global.Utils.extend(WarpControl).from(Global.BaseControl);
25
26    WarpControl.prototype.init = function() {
27        var desc = this.config,
28            self = this;
29
30        this.ctrl = $("<div/>")
31                    .attr("id", "param-" + this.name);
32
33        this.canvas = Global.WarpHelpers.buildWarpCanvas(this.ctrl, 180, 180, function() {
34            self._onChange();
35        });
36    }
37
38    WarpControl.prototype._onChange = function() {
39        this.onValueChange();
40    }
41
42    WarpControl.prototype._updateControls = function() {
43        var value = this.getValue();
44        if (!(value instanceof Array) && !(value instanceof Global.ActiveCollection))
45            return;
46        this.canvas.setPoints(value);
47        this.canvas.redraw();
48    }
49
50    WarpControl.prototype.pushControls = function(parent) {
51        this.pushTableColumns(parent, this.ctrl);
52    }
53    
54    Global.Controls.register("warp", WarpControl);
55
56})();