/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. (function() {
  17. function WarpControl(delegate, name, config) {
  18. WarpControl.$super.call(this, delegate, name, config);
  19. this.init();
  20. }
  21. Global.Utils.extend(WarpControl).from(Global.BaseControl);
  22. WarpControl.prototype.init = function() {
  23. var desc = this.config,
  24. self = this;
  25. this.ctrl = $("<div/>")
  26. .attr("id", "param-" + this.name);
  27. this.canvas = Global.WarpHelpers.buildWarpCanvas(this.ctrl, 180, 180, function() {
  28. self._onChange();
  29. });
  30. }
  31. WarpControl.prototype._onChange = function() {
  32. this.onValueChange();
  33. }
  34. WarpControl.prototype._updateControls = function() {
  35. var value = this.getValue();
  36. if (!(value instanceof Array) && !(value instanceof Global.ActiveCollection))
  37. return;
  38. this.canvas.setPoints(value);
  39. this.canvas.redraw();
  40. }
  41. WarpControl.prototype.pushControls = function(parent) {
  42. this.pushTableColumns(parent, this.ctrl);
  43. }
  44. Global.Controls.register("warp", WarpControl);
  45. })();