TCAD.ui = {}; /** @constructor */ TCAD.ui.Window = function(el) { this.root = el; var root = this.root; this.root.find('.tool-caption .rm').click(function() { root.hide(); }); }; TCAD.ui.bindOpening = function(btn, win) { btn.click(function(e) { TCAD.ui.openWin(win, e); }); }; TCAD.ui.createActionsWinBuilder = function(win) { var content = win.root.find('.content'); var template = content.html(); content.empty(); return function(name, action) { content.append(template.replace("$value$", name)); content.find('div:last input').click(action); }; }; TCAD.ui.closeWin = function(win) { win.root.hide(); }; TCAD.ui.openWin = function(win, mouseEvent) { var x = mouseEvent.pageX; var y = mouseEvent.pageY; var pageW = $(window).width(); var pageH = $(window).height(); var winW = win.root.width(); var winH = win.root.height(); var left = x < pageW / 2 ? x : x - winW; var top = y < pageH / 2 ? y : y - winH; win.root.show(); win.root.offset({top : top, left : left}); }; /** @constructor */ TCAD.ui.List = function(id, model) { this.ul = $('