You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openNG/public/elements/window.js

284 lines
7.9 KiB
JavaScript

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(4);
/***/ },
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ function(module, exports, __webpack_require__) {
var RateLimitedCall, polymerDefer;
RateLimitedCall = __webpack_require__(5);
polymerDefer = __webpack_require__(6);
Polymer("openng-window", {
publish: {
windowTitle: "",
url: "",
x: 200,
y: 200,
z: 0,
width: 400,
height: 300,
resizable: true,
visible: true,
focused: false,
dragged: false,
focus: function() {
return polymerDefer((function(_this) {
return function() {
return _this._manager.focus(_this);
};
})(this));
}
},
_externalHandler: function(url, method, options) {
var blankWindow;
blankWindow = new ngWindow();
blankWindow.url = url;
return $(blankWindow).insertAfter($(this));
},
_findWindowManager: function() {
var result;
result = $(this).closest("openng-window-manager");
if (result.length > 0) {
return result[0];
} else {
return void 0;
}
},
_register: function() {
this._manager = this._findWindowManager();
if (this._manager != null) {
return polymerDefer((function(_this) {
return function() {
return _this._manager.add(_this);
};
})(this));
}
},
_unregister: function() {
if (this._manager != null) {
return this._manager.remove(this);
}
},
_hookMoveEvents: function() {
var moveCall, self;
self = this;
moveCall = new RateLimitedCall(60, function() {
self.x = this.x - self.dragOffsetX;
return self.y = this.y - self.dragOffsetY;
});
return this._shadowDOM.find(".title").on("mousedown", (function(_this) {
return function(event) {
var moveHandler;
$("body").attr("unselectable", "on").css("user-select", "none").on("selectstart.disableSelect", false);
_this.dragOffsetX = event.pageX - _this.x;
_this.dragOffsetY = event.pageY - _this.y;
moveHandler = function(event) {
return moveCall.call(function() {
this.x = event.pageX;
return this.y = event.pageY;
});
};
_this.dragged = true;
$(document).on("mousemove", moveHandler);
return $(document).one("mouseup", function(event) {
_this.dragged = false;
$(document).off("mousemove", moveHandler);
return $("body").attr("unselectable", "off").css("user-select", "text").off("selectstart.disableSelect");
});
};
})(this));
},
_hookResizeEvents: function() {
var resizeCall, self;
self = this;
resizeCall = new RateLimitedCall(60, function() {
self.width = this.x - self.resizeOffsetX - self.x;
return self.height = this.y - self.resizeOffsetY - self.y;
});
return this._shadowDOM.find(".resizer").on("mousedown", (function(_this) {
return function(event) {
var resizeHandler;
$("body").attr("unselectable", "on").css("user-select", "none").on("selectstart.disableSelect", false);
_this.resizeOffsetX = (event.pageX - _this.x) - _this.width;
_this.resizeOffsetY = (event.pageY - _this.y) - _this.height;
resizeHandler = function(event) {
return resizeCall.call(function() {
this.x = event.pageX;
return this.y = event.pageY;
});
};
_this.dragged = true;
$(document).on("mousemove", resizeHandler);
return $(document).one("mouseup", function(event) {
_this.dragged = false;
$(document).off("mousemove", resizeHandler);
return $("body").attr("unselectable", "off").css("user-select", "text").off("selectstart.disableSelect");
});
};
})(this));
},
_hookCloseButton: function() {
return this._shadowDOM.find(".close a").on("mousedown", function(event) {
return event.stopPropagation();
}).on("click", (function(_this) {
return function(event) {
return $(_this).remove();
};
})(this));
},
_hookFocus: function() {
return this._shadowDOM.find(".wrapper").on("mousedown", (function(_this) {
return function(event) {
return _this.focus();
};
})(this));
},
ready: function() {
this._externalHandler = this._externalHandler.bind(this);
return this._shadowDOM = $(this.$.polymerWrapper);
},
domReady: function() {
this._hookMoveEvents();
this._hookResizeEvents();
this._hookCloseButton();
this._hookFocus();
this._register();
return this.focus();
},
detached: function() {
return this._unregister();
},
urlChanged: function(oldValue, newValue) {
if (newValue !== "") {
return this._shadowDOM.find("openng-router")[0].navigate(newValue);
}
}
});
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
var RateLimitedCall;
module.exports = RateLimitedCall = (function() {
RateLimitedCall.prototype.loopRunning = false;
RateLimitedCall.prototype._lastFrame = Date.now();
function RateLimitedCall(fps, frameHandler) {
this.fps = fps;
this.frameHandler = frameHandler;
this._interval = 1000 / this.fps;
}
RateLimitedCall.prototype._loop = function() {
this.loopRunning = true;
return this._frame();
};
RateLimitedCall.prototype._frame = function() {
var delta, now;
now = Date.now();
delta = now - this._lastFrame;
if (delta > this._interval) {
if (this.callActivated) {
this.frameHandler.apply(this);
this.callActivated = false;
this._lastFrame = now - (delta % this._interval);
} else {
this.loopRunning = false;
}
}
if (this.loopRunning) {
return requestAnimationFrame(this._frame.bind(this));
}
};
RateLimitedCall.prototype._activateRateLimitedCall = function() {
this.callActivated = true;
if (!this.loopRunning) {
return this._loop();
}
};
RateLimitedCall.prototype.call = function(func) {
func.apply(this);
return this._activateRateLimitedCall();
};
return RateLimitedCall;
})();
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
module.exports = function(func) {
if (window.polymerReady) {
return func();
} else {
return $(window).on("polymer-ready", function(event) {
return func();
});
}
};
/***/ }
/******/ ])