cubeletInit
method$.fn.cubeletInit()
Creates a Cubelet widget. The elements that this method is called upon are treated as containers — it is recommended that these containers are empty when this method is called.
$.fn.cubeletInit = function () {
if (!hasPerformedFirstTimeInit) {
firstTimeInit();
hasPerformedFirstTimeInit = true;
}
this._cubeletCoordinates = { x: 0, y: 0, z: 0, scale: 1 };
this._lastOffsetX = null;
this._lastOffsetY = null;
this._$cubeletHtmlFragment = $cubeletBaseHtmlFragment.clone();
this.append(this._$cubeletHtmlFragment);
this._$cubeletContainer = this.find('.cubelet-container');
this._$cubeletCube = this.find('.cubelet-cube');
this._$cubeletZRotationArm = this.find('.cubelet-rotation-arm');
this._$cubeletZRotationHandle = this.find('.cubelet-rotation-handle');
this.css({
height: CUBELET_SIZE + 'px'
,width: CUBELET_SIZE + 'px'
});
this.addClass('cubelet');
this.cubeletSetCoords(this._cubeletCoordinates);
this._$cubeletContainer.on(
'mousedown', $.proxy(onCubeletMousedown, this, this));
this._$cubeletContainer.on(
'mousemove', $.proxy(onCubeletMousemove, this, this));
return this;
};