123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- 'use strict';
- goog.provide('Blockly.FieldClickImage');
- goog.require('Blockly.FieldImage');
- Blockly.FieldClickImage = function(src, width, height, opt_alt, opt_Handler, yOffset) {
- Blockly.FieldClickImage.superClass_.constructor.call(this,
- src, width, height, '');
- this.handler_ = opt_Handler;
- this.yOffset_ = yOffset;
- };
- goog.inherits(Blockly.FieldClickImage, Blockly.FieldImage);
- Blockly.FieldClickImage.prototype.EDITABLE = true;
- Blockly.FieldClickImage.prototype.CURSOR = 'default';
- Blockly.FieldClickImage.prototype.updateEditable = function() {
- if (this.sourceBlock_.isInFlyout || !this.EDITABLE) {
- Blockly.addClass_( (this.fieldGroup_),
- 'blocklyIconGroupReadonly');
- } else {
- Blockly.removeClass_( (this.fieldGroup_),
- 'blocklyIconGroupReadonly');
- }
- };
- Blockly.FieldClickImage.prototype.init = function(block) {
- if (this.fieldGroup_) {
-
- return;
- }
- Blockly.FieldClickImage.superClass_.init.call(this, block);
-
- Blockly.addClass_( (this.fieldGroup_),
- 'blocklyIconGroup');
-
-
- this.updateEditable();
-
- this.mouseUpWrapper_ =
- Blockly.bindEvent_(this.fieldGroup_, 'mouseup', this, this.onMouseUp_);
-
- this.updateTextNode_();
-
- this.imageElement_.style.y = this.yOffset_;
- }
- Blockly.FieldClickImage.prototype.clone = function() {
- return new Blockly.FieldClickImage(this.handler_,
- this.rootBlock_, this.name_, this.pos_);
- };
- Blockly.FieldClickImage.prototype.showEditor_ = function(e) {
- if (this.handler_) {
- var saveDragMode = Blockly.dragMode_;
- Blockly.dragMode_ = 0;
- this.handler_(this, this.sourceBlock_, e);
- Blockly.dragMode_ = saveDragMode;
- }
- };
|