comm.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. (function ($) {
  2. $.fn.khjPageLink = function () {
  3. var _this = $(this);
  4. _this.bind("mousedown", function () {
  5. $(this).addClass("pageLink_push");
  6. });
  7. _this.bind("mouseup", function () {
  8. $(this).removeClass("pageLink_push");
  9. });
  10. _this.bind("mouseleave", function () {
  11. $(this).removeClass("pageLink_push");
  12. });
  13. };
  14. $.fn.khjAccordion = function () {
  15. var _this = $(this);
  16. _this.bind("click", function () {
  17. $(this).parent().parent().find(".body").toggle();
  18. });
  19. _this.khjToggleBtn();
  20. };
  21. $.fn.khjToggleBtn = function () {
  22. var _this = $(this),
  23. src = null,
  24. value = null;
  25. _this.each(function () {
  26. value = {};
  27. src = "";
  28. value.obj = $(this);
  29. value.mode = 0;
  30. src = value.obj.attr("src");
  31. value.nSrc = [src, src.replace("_N", "_SN")];
  32. value.oSrc = [src.replace("_N", "_O"), src.replace("_N", "_SO")];
  33. value.pSrc = [src.replace("_N", "_P"), src.replace("_N", "_SP")];
  34. value.dSrc = [src.replace("_N", "_D"), src.replace("_N", "_SD")];
  35. value.obj.data("value", value);
  36. });
  37. _this.bind("mouseover", function () {
  38. var value = $(this).data("value");
  39. value.obj.attr("src", value.oSrc[value.mode]);
  40. });
  41. _this.bind("mousedown", function () {
  42. var value = $(this).data("value");
  43. value.obj.attr("src", value.pSrc[value.mode]);
  44. });
  45. _this.bind("mouseup", function () {
  46. var value = $(this).data("value");
  47. value.obj.attr("src", value.oSrc[value.mode]);
  48. });
  49. _this.bind("mouseleave", function () {
  50. var value = $(this).data("value");
  51. value.obj.attr("src", value.nSrc[value.mode]);
  52. });
  53. _this.bind("click", function () {
  54. var value = $(this).data("value");
  55. value.mode = value.mode?0:1;
  56. value.obj.attr("src", value.oSrc[value.mode]);
  57. });
  58. };
  59. $.fn.khjImgButton = function () {
  60. var _this = $(this),
  61. src = null,
  62. value = null;
  63. _this.each(function () {
  64. value = {};
  65. src = "";
  66. value.obj = $(this);
  67. src = value.obj.attr("src");
  68. value.nSrc = src;
  69. value.oSrc = src.replace("_N", "_O");
  70. value.pSrc = src.replace("_N", "_P");
  71. value.dSrc = src.replace("_N", "_D");
  72. value.obj.data("value", value);
  73. });
  74. _this.bind("mouseover", function () {
  75. var value = $(this).data("value");
  76. value.obj.attr("src", value.oSrc);
  77. });
  78. _this.bind("mousedown", function () {
  79. var value = $(this).data("value");
  80. value.obj.attr("src", value.pSrc);
  81. });
  82. _this.bind("mouseup", function () {
  83. var value = $(this).data("value");
  84. value.obj.attr("src", value.oSrc);
  85. });
  86. _this.bind("mouseleave", function () {
  87. var value = $(this).data("value");
  88. value.obj.attr("src", value.nSrc);
  89. });
  90. };
  91. $.fn.khjSelectBox = function () {
  92. var _this = $(this),
  93. value = null;
  94. _this.each(function () {
  95. value = {};
  96. value.obj = $(this);
  97. value.text = value.obj.find(".selectTxt");
  98. value.btn = value.obj.find(".selectBtn");
  99. value.wrap = value.obj.find(".optionWrap");
  100. value.items = value.wrap.find("li");
  101. value.obj.data("value", value);
  102. if (value.items.size() > 5) value.wrap.css("height", "150px");
  103. value.btn.bind("click", function () {
  104. var value = $(this).parent().data("value");
  105. value.wrap.toggle();
  106. });
  107. value.obj.bind("mouseleave", function () {
  108. var value = $(this).data("value");
  109. value.wrap.hide();
  110. });
  111. value.items.bind("click", function () {
  112. var _this = $(this),
  113. value = _this.parent().parent().parent().data("value");
  114. value.text.html(_this.html());
  115. value.wrap.hide();
  116. });
  117. value.items.bind("mouseover", function () {
  118. $(this).addClass("on");
  119. });
  120. value.items.bind("mouseleave", function () {
  121. $(this).removeClass("on");
  122. });
  123. value.btn.khjImgButton();
  124. });
  125. };
  126. $.fn.khjSlider = function (value) {
  127. var _this = $(this),
  128. flag = false,
  129. txt = _this.find(".txt"),
  130. wrap = _this.find(".slider"),
  131. bg = _this.find(".sliderFull"),
  132. ball = _this.find(".ball"),
  133. width = wrap.width() - 20,
  134. old = 0,
  135. margin = 0,
  136. left = 0,
  137. per = width/100;
  138. if (value == undefined) value = txt.html();
  139. ball.khjImgButton();
  140. left = Math.ceil(per*value);
  141. ball.css("left", left);
  142. bg.css("width", left);
  143. txt.html(value);
  144. ball.get(0).ondragstart = function() { return false; };
  145. ball.bind("mousedown", function (e) {
  146. flag = true;
  147. old = e.pageX;
  148. e.stopPropagation();
  149. });
  150. $(document).bind("mousemove", function (e) {
  151. if (flag) {
  152. margin = e.pageX - old;
  153. left += margin;
  154. if (left >= width) left = width;
  155. if (left <= 0) left = 0;
  156. ball.css("left", left);
  157. bg.css("width", left);
  158. txt.html(Math.ceil(left/per));
  159. if(txt.prop("id") == "viewSizeSlider"){
  160. setviewsize(txt.html());
  161. }
  162. else if(txt.prop("id") == "bufferingSlider"){
  163. display_buff_change(txt.html());
  164. }
  165. old = e.pageX;
  166. }
  167. });
  168. $(document).bind("mouseup", function (e) {
  169. flag = false;
  170. });
  171. $(document).bind("mouseleave", function (e) {
  172. flag = false;
  173. });
  174. };
  175. $.fn.khjMenu = function () {
  176. var _this = $(this),
  177. src = null,
  178. value = null,
  179. on = _this.parent().filter(".on");
  180. _this.khjTxtToggleBtn();
  181. _this.bind("click", function () {
  182. $(this).parent().toggleClass("on");
  183. });
  184. on.removeClass("on");
  185. on.find(".menu img").trigger("click");
  186. };
  187. $.fn.khjTxtButton = function () {
  188. var _this = $(this),
  189. src = null,
  190. value = null;
  191. _this.each(function () {
  192. value = {};
  193. src = "";
  194. value.obj = $(this);
  195. value.img = value.obj.find("img");
  196. value.span = value.obj.find("span");
  197. src = value.img.attr("src");
  198. value.nSrc = src;
  199. value.oSrc = src.replace("_N", "_O");
  200. value.pSrc = src.replace("_N", "_P");
  201. value.dSrc = src.replace("_N", "_D");
  202. value.obj.data("value", value);
  203. });
  204. _this.bind("mouseover", function () {
  205. var value = $(this).data("value");
  206. value.img.attr("src", value.oSrc);
  207. });
  208. _this.bind("mousedown", function () {
  209. var value = $(this).data("value");
  210. value.span.addClass("p");
  211. value.img.attr("src", value.pSrc);
  212. });
  213. _this.bind("mouseup", function () {
  214. var value = $(this).data("value");
  215. value.span.removeClass("p");
  216. value.img.attr("src", value.oSrc);
  217. });
  218. _this.bind("mouseleave", function () {
  219. var value = $(this).data("value");
  220. value.span.removeClass("p");
  221. value.img.attr("src", value.nSrc);
  222. });
  223. };
  224. $.fn.khjSubMenuButton = function () {
  225. var _this = $(this),
  226. src = null,
  227. value = null;
  228. _this.each(function () {
  229. value = {};
  230. src = "";
  231. value.obj = $(this);
  232. value.img = value.obj.find("img");
  233. value.span = value.obj.find("span");
  234. src = value.img.attr("src");
  235. value.nSrc = src;
  236. value.oSrc = src.replace("_N", "_O");
  237. value.pSrc = src.replace("_N", "_P");
  238. value.dSrc = src.replace("_N", "_D");
  239. value.obj.data("value", value);
  240. });
  241. _this.bind("mouseover", function () {
  242. var value = $(this).data("value");
  243. value.img.attr("src", value.oSrc);
  244. });
  245. _this.bind("mousedown", function () {
  246. var value = $(this).data("value");
  247. value.span.addClass("p");
  248. value.img.attr("src", value.pSrc);
  249. });
  250. _this.bind("mouseup", function () {
  251. var value = $(this).data("value");
  252. value.span.removeClass("p");
  253. value.img.attr("src", value.oSrc);
  254. });
  255. _this.bind("mouseleave", function () {
  256. var value = $(this).data("value");
  257. value.span.removeClass("p");
  258. value.img.attr("src", value.nSrc);
  259. });
  260. _this.bind("click", function () {
  261. var id = $(this).attr("id").slice(1);
  262. T_SelectMenu(id);
  263. });
  264. };
  265. $.fn.khjTxtToggleBtn = function () {
  266. var _this = $(this),
  267. src = null,
  268. value = null;
  269. _this.each(function () {
  270. value = {};
  271. src = "";
  272. value.obj = $(this);
  273. value.img = value.obj.find("img");
  274. value.span = value.obj.find("span");
  275. value.mode = 0;
  276. src = value.img.attr("src");
  277. value.nSrc = [src, src.replace("_N", "_SN")];
  278. value.oSrc = [src.replace("_N", "_O"), src.replace("_N", "_SO")];
  279. value.pSrc = [src.replace("_N", "_P"), src.replace("_N", "_SP")];
  280. value.dSrc = [src.replace("_N", "_D"), src.replace("_N", "_SD")];
  281. value.obj.data("value", value);
  282. });
  283. _this.bind("mouseover", function () {
  284. var value = $(this).data("value");
  285. value.img.attr("src", value.oSrc[value.mode]);
  286. });
  287. _this.bind("mousedown", function () {
  288. var value = $(this).data("value");
  289. value.span.addClass("p");
  290. value.img.attr("src", value.pSrc[value.mode]);
  291. });
  292. _this.bind("mouseup", function () {
  293. var value = $(this).data("value");
  294. value.span.removeClass("p");
  295. value.img.attr("src", value.oSrc[value.mode]);
  296. });
  297. _this.bind("mouseleave", function () {
  298. var value = $(this).data("value");
  299. value.span.removeClass("p");
  300. value.img.attr("src", value.nSrc[value.mode]);
  301. });
  302. _this.bind("click", function () {
  303. var value = $(this).data("value");
  304. value.mode = value.mode?0:1;
  305. value.img.attr("src", value.oSrc[value.mode]);
  306. });
  307. };
  308. $.extend({
  309. changeWidth : function (margin) {
  310. // $(".wrapWidth").css("width", "+=" + margin);
  311. // $(".viewWidth").css("width", "+=" + margin);
  312. $(".wrapWidth").css("width", margin+201);
  313. $(".viewWidth").css("width", margin);
  314. },
  315. changeSetupWidth : function (margin) {
  316. // $(".wrapWidth").css("width", "+=" + margin);
  317. // $(".viewWidth").css("width", "+=" + margin);
  318. $(".wrapWidth").css("width", margin+301);
  319. $(".viewWidth").css("width", margin+61);
  320. },
  321. khjDisable : function (id, num) {
  322. var _this = $("#" + id),
  323. value = _this.data("value"),
  324. dSrc = null,
  325. btn = null;
  326. if (!value) {
  327. value = _this.find(".ball").data("value");
  328. }
  329. dSrc = value.dSrc;
  330. if (num != undefined) dSrc = value.dSrc[num];
  331. if (dSrc) {
  332. if (value.img != undefined) {
  333. value.img.attr("src", dSrc);
  334. value.span.addClass("d");
  335. } else {
  336. value.obj.attr("src", dSrc);
  337. }
  338. } else {
  339. btn = value.btn.data("value");
  340. dSrc = btn.dSrc;
  341. value.btn.attr("src", dSrc);
  342. value.btn.unbind("mouseover mouseleave mouseup mousedown click");
  343. }
  344. value.obj.unbind("mouseover mouseleave mouseup mousedown click");
  345. }
  346. });
  347. })(jQuery);