bjui-plugins.js 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. /*!
  2. * B-JUI v1.2 (http://b-jui.com)
  3. * Git@OSC (http://git.oschina.net/xknaan/B-JUI)
  4. * Copyright 2014 K'naan (xknaan@163.com).
  5. * Licensed under Apache (http://www.apache.org/licenses/LICENSE-2.0)
  6. */
  7. /* ========================================================================
  8. * B-JUI: bjui-plugins.js v1.2
  9. * @author K'naan (xknaan@163.com)
  10. * http://git.oschina.net/xknaan/B-JUI/blob/master/BJUI/js/bjui-plugins.js
  11. * ========================================================================
  12. * Copyright 2014 K'naan.
  13. * Licensed under Apache (http://www.apache.org/licenses/LICENSE-2.0)
  14. * ======================================================================== */
  15. +function ($) {
  16. 'use strict';
  17. $(document).on(BJUI.eventType.initUI, function(e) {
  18. var $box = $(e.target)
  19. // UI init begin...
  20. /* i-check */
  21. var $icheck = $box.find('[data-toggle="icheck"]')
  22. $icheck.each(function(i) {
  23. var $element = $(this),
  24. id = $element.attr('id'),
  25. name = $element.attr('name'),
  26. label = $element.data('label')
  27. if (label) $element.after('<label for="'+ id +'" class="ilabel">'+ label +'</label>')
  28. $element
  29. .on('ifCreated', function(e) {
  30. /* Fixed validate msgbox position */
  31. var $parent = $(this).closest('div'),
  32. $ilabel = $parent.next('[for="'+ id +'"]')
  33. $parent.attr('data-icheck', name)
  34. $ilabel.attr('data-icheck', name)
  35. })
  36. .iCheck({
  37. checkboxClass : 'icheckbox_minimal-purple',
  38. radioClass : 'iradio_minimal-purple',
  39. increaseArea : '20%' // optional
  40. })
  41. .on('ifChanged', function() {
  42. /* Trigger validation */
  43. $(this).trigger('validate')
  44. })
  45. if ($element.prop('disabled')) $element.iCheck('disable')
  46. })
  47. /* i-check check all */
  48. $icheck.filter('.checkboxCtrl').on('ifChanged', function(e) {
  49. var checked = e.target.checked == true ? 'check' : 'uncheck'
  50. var group = $(this).data('group')
  51. $box.find(':checkbox[name="'+ group +'"]').iCheck(checked)
  52. })
  53. /* fixed ui style */
  54. $box.find(':text, :password, textarea, :button, a.btn').each(function() {
  55. var $element = $(this), $tabledit = $element.closest('table.bjui-tabledit')
  56. if (($element.is(':text') || $element.is(':password') || $element.isTag('textarea')) && !$element.hasClass('form-control'))
  57. $element.addClass('form-control')
  58. if ($element.is(':button')) {
  59. var icon = $element.data('icon'), large = $element.data('large'), oldClass = $element.attr('class')
  60. if (!$element.hasClass('btn'))
  61. $element.removeClass().addClass('btn').addClass(oldClass)
  62. if (icon) {
  63. var _icon = 'fa-'+ icon.replace('fa-', '')
  64. if (!$element.data('bjui.icon')) {
  65. $element.html('<i class="fa '+ _icon +'"></i> '+ $element.html())
  66. .data('bjui.icon', true)
  67. }
  68. }
  69. }
  70. if ($element.isTag('a')) {
  71. var icon = $element.data('icon'), large = $element.data('large')
  72. if (icon) {
  73. var _icon = 'fa-'+ icon.replace('fa-', '')
  74. if (!$element.data('bjui.icon')) {
  75. $element.html('<i class="fa '+ _icon +'"></i> '+ $element.html())
  76. .data('bjui.icon', true)
  77. }
  78. }
  79. }
  80. if ($element.isTag('textarea')) {
  81. var toggle = $element.data('toggle')
  82. if (toggle && toggle == 'autoheight' && $.fn.autosize) $element.addClass('autosize').autosize()
  83. }
  84. if (!$tabledit.length) {
  85. var size = $element.attr('size') || $element.attr('cols'), width = size * 10
  86. if (!size) return
  87. if (width) $element.css('width', width)
  88. }
  89. })
  90. /* form validate */
  91. $box.find('form[data-toggle="validate"]').each(function() {
  92. var $element = $(this), alertmsg = (typeof $element.data('alertmsg') == 'undefined') ? true : $element.data('alertmsg')
  93. $(this)
  94. .validator({
  95. valid: function(form) {
  96. $(form).bjuiajax('ajaxForm', $(form).data())
  97. },
  98. validClass : 'ok',
  99. theme : 'red_right_effect'
  100. })
  101. .on('invalid.form', function(e, form, errors) {
  102. if (alertmsg) $(form).alertmsg('error', FRAG.validateErrorMsg.replace('#validatemsg#', BJUI.regional.validatemsg).replaceMsg(errors.length))
  103. })
  104. })
  105. /* moreSearch */
  106. $box.find('[data-toggle="moresearch"]').each(function() {
  107. var $element = $(this),
  108. $parent = $element.closest('.bjui-pageHeader'),
  109. $more = $parent && $parent.find('.bjui-moreSearch'),
  110. name = $element.data('name')
  111. if (!$element.attr('title')) $element.attr('title', '更多查询条件')
  112. $element.click(function(e) {
  113. if (!$more.length) {
  114. BJUI.debug('Not created \'moresearch\' box[class="bjui-moreSearch"]!')
  115. return
  116. }
  117. $more.css('top', $parent.outerHeight() - 1)
  118. if ($more.is(':visible')) {
  119. $element.html('<i class="fa fa-angle-double-down"></i>')
  120. if (name) $('body').data('moresearch.'+ name, false)
  121. } else {
  122. $element.html('<i class="fa fa-angle-double-up"></i>')
  123. if (name) $('body').data('moresearch.'+ name, true)
  124. }
  125. $more.fadeToggle('slow', 'linear')
  126. e.preventDefault()
  127. })
  128. if (name && $('body').data('moresearch.'+ name)) {
  129. $more.css('top', $parent.outerHeight() - 1).fadeIn()
  130. $element.html('<i class="fa fa-angle-double-up"></i>')
  131. }
  132. })
  133. /* bootstrap - select */
  134. var $selectpicker = $box.find('select[data-toggle="selectpicker"]')
  135. var bjui_select_linkage = function($obj, $next) {
  136. var refurl = $obj.data('refurl')
  137. var _setEmpty = function($select) {
  138. var $_nextselect = $($select.data('nextselect'))
  139. if ($_nextselect && $_nextselect.length) {
  140. var emptytxt = $_nextselect.data('emptytxt') || '&nbsp;'
  141. $_nextselect.html('<option>'+ emptytxt +'</option>').selectpicker('refresh')
  142. _setEmpty($_nextselect)
  143. }
  144. }
  145. if (($next && $next.length) && refurl) {
  146. var val = $obj.data('val'), nextVal = $next.data('val')
  147. if (typeof val == 'undefined') val = $obj.val()
  148. $.ajax({
  149. type : 'POST',
  150. dataType : 'json',
  151. url : refurl.replace('{value}', encodeURIComponent(val)),
  152. cache : false,
  153. data : {},
  154. success : function(json) {
  155. if (!json) return
  156. var html = '', selected = ''
  157. $.each(json, function(i) {
  158. var value, label
  159. if (json[i] && json[i].length) {
  160. value = json[i][0]
  161. label = json[i][1]
  162. } else {
  163. value = json[i].value
  164. label = json[i].label
  165. }
  166. if (typeof nextVal != 'undefined') selected = value == nextVal ? ' selected' : ''
  167. html += '<option value="'+ value +'"'+ selected +'>' + label + '</option>'
  168. })
  169. $obj.removeAttr('data-val').removeData('val')
  170. $next.removeAttr('data-val').removeData('val')
  171. if (!html) {
  172. html = $next.data('emptytxt') || '&nbsp;'
  173. html = '<option>'+ html +'</option>'
  174. }
  175. $next.html(html).selectpicker('refresh')
  176. _setEmpty($next)
  177. },
  178. error : BJUI.ajaxError
  179. })
  180. }
  181. }
  182. $selectpicker.each(function() {
  183. var $element = $(this)
  184. var options = $element.data()
  185. var $next = $(options.nextselect)
  186. $element.addClass('show-tick')
  187. if (!options.style) $element.data('style', 'btn-default')
  188. if (!options.width) $element.data('width', 'auto')
  189. if (!options.container) $element.data('container', 'body')
  190. else if (options.container == true) $element.attr('data-container', 'false').data('container', false)
  191. $element.selectpicker()
  192. if ($next && $next.length && (typeof $next.data('val') != 'undefined'))
  193. bjui_select_linkage($element, $next)
  194. })
  195. /* bootstrap - select - linkage && Trigger validation */
  196. $selectpicker.change(function() {
  197. var $element = $(this)
  198. var $nextselect = $($element.data('nextselect'))
  199. bjui_select_linkage($element, $nextselect)
  200. /* Trigger validation */
  201. if ($element.attr('aria-required')) {
  202. $element.trigger('validate')
  203. }
  204. })
  205. /* zTree - plugin */
  206. $box.find('[data-toggle="ztree"]').each(function() {
  207. var $this = $(this), op = $this.data(), options = op.options, _setting
  208. if (options && typeof options == 'string') options = options.toObj()
  209. if (options) $.extend(op, typeof options == 'object' && options)
  210. _setting = op.setting
  211. if (!op.nodes) {
  212. op.nodes = []
  213. $this.find('> li').each(function() {
  214. var $li = $(this)
  215. var node = $li.data()
  216. if (node.pid) node.pId = node.pid
  217. node.name = $li.html()
  218. op.nodes.push(node)
  219. })
  220. $this.empty()
  221. } else {
  222. if (typeof op.nodes == 'string') {
  223. if (op.nodes.trim().startsWith('[') || op.nodes.trim().startsWith('{')) {
  224. op.nodes = op.nodes.toObj()
  225. } else {
  226. op.nodes = op.nodes.toFunc()
  227. }
  228. }
  229. if (typeof op.nodes == 'function') {
  230. op.nodes = op.nodes.call(this)
  231. }
  232. $this.removeAttr('data-nodes')
  233. }
  234. if (!op.showRemoveBtn) op.showRemoveBtn = false
  235. if (!op.showRenameBtn) op.showRenameBtn = false
  236. if (op.addHoverDom && typeof op.addHoverDom != 'function') op.addHoverDom = (op.addHoverDom == 'edit') ? _addHoverDom : op.addHoverDom.toFunc()
  237. if (op.removeHoverDom && typeof op.removeHoverDom != 'function') op.removeHoverDom = (op.removeHoverDom == 'edit') ? _removeHoverDom : op.removeHoverDom.toFunc()
  238. if (!op.maxAddLevel) op.maxAddLevel = 2
  239. var setting = {
  240. view: {
  241. addHoverDom : op.addHoverDom || null,
  242. removeHoverDom : op.removeHoverDom || null,
  243. addDiyDom : op.addDiyDom ? op.addDiyDom.toFunc() : null
  244. },
  245. edit: {
  246. enable : op.editEnable,
  247. showRemoveBtn : op.showRemoveBtn,
  248. showRenameBtn : op.showRenameBtn
  249. },
  250. check: {
  251. enable : op.checkEnable,
  252. chkStyle : op.chkStyle,
  253. radioType : op.radioType
  254. },
  255. callback: {
  256. onClick : op.onClick ? op.onClick.toFunc() : null,
  257. beforeDrag : op.beforeDrag ? op.beforeDrag.toFunc() : _beforeDrag,
  258. beforeDrop : op.beforeDrop ? op.beforeDrop.toFunc() : _beforeDrop,
  259. onDrop : op.onDrop ? op.onDrop.toFunc() : null,
  260. onCheck : op.onCheck ? op.onCheck.toFunc() : null,
  261. beforeRemove : op.beforeRemove ? op.beforeRemove.toFunc() : null,
  262. onRemove : op.onRemove ? op.onRemove.toFunc() : null,
  263. onNodeCreated : _onNodeCreated,
  264. onCollapse : _onCollapse,
  265. onExpand : _onExpand
  266. },
  267. data: {
  268. simpleData: {
  269. enable: op.simpleData || true
  270. },
  271. key: {
  272. title: op.title || ''
  273. }
  274. }
  275. }
  276. if (_setting && typeof _setting == 'string') _setting = _setting.toObj()
  277. if (_setting) $.extend(true, setting, typeof _setting == 'object' && _setting)
  278. $.fn.zTree.init($this, setting, op.nodes)
  279. var IDMark_A = '_a'
  280. var zTree = $.fn.zTree.getZTreeObj($this.attr('id'))
  281. if (op.expandAll) zTree.expandAll(true)
  282. // onCreated
  283. function _onNodeCreated(event, treeId, treeNode) {
  284. if (treeNode.faicon) {
  285. var $a = $('#'+ treeNode.tId +'_a')
  286. if (!$a.data('faicon')) {
  287. $a.data('faicon', true)
  288. .addClass('faicon')
  289. .find('> span.button').append('<i class="fa fa-'+ treeNode.faicon +'"></i>')
  290. }
  291. }
  292. if (op.onNodeCreated) {
  293. op.onNodeCreated.toFunc().call(this, event, treeId, treeNode)
  294. }
  295. }
  296. // onCollapse
  297. function _onCollapse(event, treeId, treeNode) {
  298. if (treeNode.faiconClose) {
  299. $('#'+ treeNode.tId +'_ico').find('> i').attr('class', 'fa fa-'+ treeNode.faiconClose)
  300. }
  301. console.log('11')
  302. if (op.onCollapse) {
  303. op.onCollapse.toFunc().call(this, event, treeId, treeNode)
  304. }
  305. }
  306. // onExpand
  307. function _onExpand(event, treeId, treeNode) {
  308. if (treeNode.faicon && treeNode.faiconClose) {
  309. $('#'+ treeNode.tId +'_ico').find('> i').attr('class', 'fa fa-'+ treeNode.faicon)
  310. }
  311. if (op.onExpand) {
  312. op.onExpand.toFunc().call(this, event, treeId, treeNode)
  313. }
  314. }
  315. // add button, del button
  316. function _addHoverDom(treeId, treeNode) {
  317. var level = treeNode.level
  318. var $obj = $('#'+ treeNode.tId + IDMark_A)
  319. var $add = $('#diyBtn_add_'+ treeNode.id)
  320. var $del = $('#diyBtn_del_'+ treeNode.id)
  321. if (!$add.length) {
  322. if (level < op.maxAddLevel) {
  323. $add = $('<span class="tree_add" id="diyBtn_add_'+ treeNode.id +'" title="添加"></span>')
  324. $add.appendTo($obj);
  325. $add.on('click', function(){
  326. zTree.addNodes(treeNode, {name:'新增Item'})
  327. })
  328. }
  329. }
  330. if (!$del.length) {
  331. var $del = $('<span class="tree_del" id="diyBtn_del_'+ treeNode.id +'" title="删除"></span>')
  332. $del
  333. .appendTo($obj)
  334. .on('click', function(event) {
  335. var delFn = function() {
  336. $del.alertmsg('confirm', '确认要删除 '+ treeNode.name +' 吗?', {
  337. okCall: function() {
  338. zTree.removeNode(treeNode)
  339. if (op.onRemove) {
  340. var fn = op.onRemove.toFunc()
  341. if (fn) fn.call(this, event, treeId, treeNode)
  342. }
  343. },
  344. cancelCall: function () {
  345. return
  346. }
  347. })
  348. }
  349. if (op.beforeRemove) {
  350. var fn = op.beforeRemove.toFunc()
  351. if (fn) {
  352. var isdel = fn.call(fn, treeId, treeNode)
  353. if (isdel && isdel == true) delFn()
  354. }
  355. } else {
  356. delFn()
  357. }
  358. }
  359. )
  360. }
  361. }
  362. // remove add button && del button
  363. function _removeHoverDom(treeId, treeNode) {
  364. var $add = $('#diyBtn_add_'+ treeNode.id)
  365. var $del = $('#diyBtn_del_'+ treeNode.id)
  366. if ($add && $add.length) {
  367. $add.off('click').remove()
  368. }
  369. if ($del && $del.length) {
  370. $del.off('click').remove()
  371. }
  372. }
  373. // Drag
  374. function _beforeDrag(treeId, treeNodes) {
  375. for (var i = 0; i < treeNodes.length; i++) {
  376. if (treeNodes[i].drag === false) {
  377. return false
  378. }
  379. }
  380. return true
  381. }
  382. function _beforeDrop(treeId, treeNodes, targetNode, moveType) {
  383. return targetNode ? targetNode.drop !== false : true
  384. }
  385. })
  386. /* zTree - drop-down selector */
  387. var $selectzTree = $box.find('[data-toggle="selectztree"]')
  388. $selectzTree.each(function() {
  389. var $this = $(this)
  390. var options = $this.data(),
  391. $tree = $(options.tree),
  392. w = parseFloat($this.css('width')),
  393. h = $this.outerHeight()
  394. options.width = options.width || $this.outerWidth()
  395. options.height = options.height || 'auto'
  396. if (!$tree || !$tree.length) return
  397. var treeid = $tree.attr('id')
  398. var $box = $('#'+ treeid +'_select_box')
  399. var setPosition = function($box) {
  400. var top = $this.offset().top,
  401. left = $this.offset().left,
  402. $clone = $tree.clone().appendTo($('body')),
  403. treeHeight = $clone.outerHeight()
  404. $clone.remove()
  405. var offsetBot = $(window).height() - treeHeight - top - h,
  406. maxHeight = $(window).height() - top - h
  407. if (options.height == 'auto' && offsetBot < 0) maxHeight = maxHeight + offsetBot
  408. $box.css({top:(top + h), left:left, 'max-height':maxHeight})
  409. }
  410. $this.click(function() {
  411. if ($box && $box.length) {
  412. setPosition($box)
  413. $box.show()
  414. return
  415. }
  416. var zindex = 2
  417. var dialog = $.CurrentDialog
  418. if (dialog && dialog.length) {
  419. zindex = dialog.css('zIndex') + 1
  420. }
  421. $box = $('<div id="'+ treeid +'_select_box" class="tree-box"></div>')
  422. .css({position:'absolute', 'zIndex':zindex, 'min-width':options.width, height:options.height, overflow:'auto', background:'#FAFAFA', border:'1px #EEE solid'})
  423. .hide()
  424. .appendTo($('body'))
  425. $tree.appendTo($box).css('width','100%').data('fromObj', $this).removeClass('hide').show()
  426. setPosition($box)
  427. $box.show()
  428. })
  429. $('body').on('mousedown', function(e) {
  430. var $target = $(e.target)
  431. if (!($this[0] == e.target || ($box && $box.length > 0 && $target.closest('.tree-box').length > 0))) {
  432. $box.hide()
  433. }
  434. })
  435. var $scroll = $this.closest('.bjui-pageContent')
  436. if ($scroll && $scroll.length) {
  437. $scroll.scroll(function() {
  438. if ($box && $box.length) {
  439. setPosition($box)
  440. }
  441. })
  442. }
  443. //destroy selectzTree
  444. $this.on('destroy.bjui.selectztree', function() {
  445. $box.remove()
  446. })
  447. })
  448. /* accordion */
  449. $box.find('[data-toggle="accordion"]').each(function() {
  450. var $this = $(this), hBox = $this.data('heightbox'), height = $this.data('height')
  451. var initAccordion = function(hBox, height) {
  452. var offsety = $this.data('offsety') || 0,
  453. height = height || ($(hBox).outerHeight() - (offsety * 1)),
  454. $pheader = $this.find('.panel-heading'),
  455. h1 = $pheader.outerHeight()
  456. h1 = (h1 + 1) * $pheader.length
  457. $this.css('height', height)
  458. height = height - h1
  459. $this.find('.panel-collapse').find('.panel-body').css('height', height)
  460. }
  461. if ($this.find('> .panel').length) {
  462. if (hBox || height) {
  463. initAccordion(hBox, height)
  464. $(window).resize(function() {
  465. initAccordion(hBox, height)
  466. })
  467. $this.on('hidden.bs.collapse', function (e) {
  468. var $last = $(this).find('> .panel:last'), $a = $last.find('> .panel-heading > h4 > a')
  469. if ($a.hasClass('collapsed'))
  470. $last.css('border-bottom', '1px #ddd solid')
  471. })
  472. }
  473. }
  474. })
  475. /* Kindeditor */
  476. $box.find('[data-toggle="kindeditor"]').each(function() {
  477. var $editor = $(this), options = $editor.data()
  478. if (options.items && typeof options.items == 'string')
  479. options.items = options.items.replaceAll('\'', '').replaceAll(' ', '').split(',')
  480. if (options.afterUpload) options.afterUpload = options.afterUpload.toFunc()
  481. if (options.afterSelectFile) options.afterSelectFile = options.afterSelectFile.toFunc()
  482. if (options.confirmSelect) options.confirmSelect = options.confirmSelect.toFunc()
  483. var htmlTags = {
  484. font : [/*'color', 'size', 'face', '.background-color'*/],
  485. span : ['.color', '.background-color', '.font-size', '.font-family'
  486. /*'.color', '.background-color', '.font-size', '.font-family', '.background',
  487. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'*/
  488. ],
  489. div : ['.margin', '.padding', '.text-align'
  490. /*'align', '.border', '.margin', '.padding', '.text-align', '.color',
  491. '.background-color', '.font-size', '.font-family', '.font-weight', '.background',
  492. '.font-style', '.text-decoration', '.vertical-align', '.margin-left'*/
  493. ],
  494. table: ['align', 'width'
  495. /*'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
  496. '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
  497. '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
  498. '.width', '.height', '.border-collapse'*/
  499. ],
  500. 'td,th': ['align', 'valign', 'width', 'height', 'colspan', 'rowspan'
  501. /*'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
  502. '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
  503. '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'*/
  504. ],
  505. a : ['href', 'target', 'name'],
  506. embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
  507. img : ['src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
  508. 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
  509. 'class', 'align', '.text-align', '.color', /*'.background-color', '.font-size', '.font-family', '.background',*/
  510. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
  511. ],
  512. pre : ['class'],
  513. hr : ['class', '.page-break-after'],
  514. 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : []
  515. }
  516. KindEditor.create($editor, {
  517. pasteType : options.pasteType,
  518. minHeight : options.minHeight || 260,
  519. autoHeightMode : options.autoHeight || false,
  520. items : options.items || KindEditor.options.items,
  521. uploadJson : options.uploadJson,
  522. fileManagerJson : options.fileManagerJson,
  523. allowFileManager : options.allowFileManager || true,
  524. fillDescAfterUploadImage : options.fillDescAfterUploadImage || true, //上传图片成功后转到属性页,为false则直接插入图片[设为true方便自定义函数(X_afterSelect)]
  525. afterUpload : options.afterUpload,
  526. afterSelectFile : options.afterSelectFile,
  527. X_afterSelect : options.confirmSelect,
  528. htmlTags : htmlTags,
  529. cssPath : [
  530. BJUI.PLUGINPATH + 'kindeditor_4.1.10/editor-content.css',
  531. BJUI.PLUGINPATH + 'kindeditor_4.1.10/plugins/code/prettify.css'
  532. ],
  533. afterBlur : function() { this.sync() }
  534. })
  535. })
  536. $box.find('[data-toggle="wangEditor"]').each(function() {
  537. var $this = $(this)
  538. var editor = new wangEditor($this);
  539. var uploadUrl = $this.data('upload');
  540. editor.config.uploadImgUrl= uploadUrl;
  541. editor.config.hideLinkImg = true;
  542. editor.config.uploadImgFileName='file';
  543. editor.config.menus = [
  544. 'source',
  545. '|',
  546. 'bold',
  547. 'underline',
  548. 'italic',
  549. 'strikethrough',
  550. 'eraser',
  551. 'forecolor',
  552. 'bgcolor',
  553. '|',
  554. 'quote',
  555. 'fontfamily',
  556. 'fontsize',
  557. 'lineheight',
  558. 'indent',
  559. 'head',
  560. 'unorderlist',
  561. 'orderlist',
  562. 'alignleft',
  563. 'aligncenter',
  564. 'alignright',
  565. '|',
  566. 'link',
  567. 'unlink',
  568. 'table',
  569. 'emotion',
  570. '|',
  571. 'img',
  572. 'video',
  573. 'location',
  574. 'insertcode',
  575. '|',
  576. 'undo',
  577. 'redo',
  578. 'fullscreen'
  579. ];
  580. editor.config.fontsizes = {
  581. // 格式:'value': 'title'
  582. 1: '10px',
  583. 2: '13px',
  584. 3: '16px',
  585. 4: '19px',
  586. 5: '22px',
  587. 6: '25px',
  588. 7: '28px'
  589. };
  590. editor.create();
  591. })
  592. $box.find('[data-toggle="CKEditor"]').each(function() {
  593. var $this = $(this);
  594. var uploadUrl = $this.data('upload');
  595. var CKeditor = $this.ckeditor().editor;
  596. CKEDITOR.config.extraAllowedContent = 'video [*]{*}(*);source [*]{*}(*);';
  597. CKeditor.config.height=450;
  598. CKeditor.config.filebrowserImageUploadUrl = uploadUrl;
  599. })
  600. /* colorpicker */
  601. $box.find('[data-toggle="colorpicker"]').each(function() {
  602. var $this = $(this)
  603. var isbgcolor = $this.data('bgcolor')
  604. $this.colorpicker()
  605. if (isbgcolor) {
  606. $this.on('changeColor', function(ev) {
  607. $this.css('background-color', ev.color.toHex())
  608. })
  609. }
  610. })
  611. $box.find('[data-toggle="clearcolor"]').each(function() {
  612. var $this = $(this)
  613. var $target = $this.data('target') ? $($this.data('target')) : null
  614. if ($target && $target.length) {
  615. $this.click(function() {
  616. $target.val('')
  617. if ($target.data('bgcolor')) $target.css('background-color', '')
  618. })
  619. }
  620. })
  621. /* tooltip */
  622. $box.find('[data-toggle="tooltip"]').each(function() {
  623. $(this).tooltip()
  624. })
  625. /* fixed dropdown-menu width */
  626. $box.find('[data-toggle="dropdown"]').parent().on('show.bs.dropdown', function(e) {
  627. var $this = $(this), width = $this.outerWidth(), $menu = $this.find('> .dropdown-menu'), menuWidth = $menu.outerWidth()
  628. if (width > menuWidth) {
  629. $menu.css('min-width', width)
  630. }
  631. })
  632. /* WebUploader */
  633. if (WebUploader) {
  634. var initWebUploader = function($element, index) {
  635. var old = $element.data('webuploader'), options = $element.data('options')
  636. if (old) {
  637. old.destroy()
  638. $element.data('webuploader.wrap').remove()
  639. }
  640. if (options) {
  641. if (typeof options === 'string') {
  642. options = options.trim().toObj()
  643. }
  644. if (typeof options === 'object') {
  645. $element.hide()
  646. var $wrap = $('<div id="uploader" class="mutiUpload"><div class="queueList"><div id="dndArea" class="placeholder"><div id="filePicker"></div><p>或将文件拖到这里</p></div></div><div class="statusBar" style="display:none;"><div class="progress"><span class="text">0%</span><span class="percentage"></span></div><div class="info"></div><div class="btns"><div id="filePicker2"></div><div class="uploadBtn">开始上传</div></div></div>'),
  647. // 图片容器
  648. $queue = $('<ul class="filelist"></ul>').appendTo($wrap.find('.queueList')),
  649. // 状态栏,包括进度和控制按钮
  650. $statusBar = $wrap.find('.statusBar'),
  651. // 文件总体选择信息。
  652. $info = $statusBar.find('.info'),
  653. // 上传按钮
  654. $upload = $wrap.find('.uploadBtn'),
  655. // 没选择文件之前的内容。
  656. $placeHolder = $wrap.find('.placeholder'),
  657. // 总体进度条
  658. $progress = $statusBar.find('.progress').hide(),
  659. // 添加的文件数量
  660. fileCount = 0,
  661. // 添加的文件总大小
  662. fileSize = 0,
  663. // 优化retina, 在retina下这个值是2
  664. ratio = window.devicePixelRatio || 1,
  665. // 缩略图大小
  666. thumbnailWidth = 110 * ratio,
  667. thumbnailHeight = 110 * ratio,
  668. // 可能有pedding, ready, uploading, confirm, done.
  669. state = 'pedding',
  670. // 所有文件的进度信息,key为file id
  671. percentages = {},
  672. supportTransition = (function() {
  673. var s = document.createElement('p').style,
  674. r = 'transition' in s ||
  675. 'WebkitTransition' in s ||
  676. 'MozTransition' in s ||
  677. 'msTransition' in s ||
  678. 'OTransition' in s
  679. s = null
  680. return r
  681. })(),
  682. // 图片访问基地址
  683. basePath = options.basePath || '',
  684. // WebUploader实例
  685. uploader,
  686. // 上传文件的单位(单位 + 类型)
  687. upunit = options.upunit || '张图片'
  688. // 当有文件添加进来时执行,负责view的创建
  689. var addFile = function(file, isuploaded, _index) {
  690. if (!file && options.uploaded) {
  691. $.each(options.uploaded.split(','), function(i, n) {
  692. var uploadedFile = {id:'WU_FILE_UP_'+ i, name:n.trim(), src:basePath + n.trim()}
  693. addFile(uploadedFile, true, i)
  694. fileCount++
  695. })
  696. if (fileCount) {
  697. $placeHolder.addClass('element-invisible');
  698. $statusBar.show()
  699. setState('uploaded')
  700. }
  701. return
  702. }
  703. if (fileCount >= options.fileNumLimit) {
  704. $statusBar.find('#filePicker2').hide()
  705. }
  706. var uploadedAttr = isuploaded && upunit === '张图片' ? ' style="cursor:pointer;" data-toggle="dialog" data-options="{id:\'bjui-dialog-view-upload-image\', image:\''+ encodeURIComponent(file.src) +'\', width:800, height:500, mask:true, title:\'查看已上传图片\'}"' : '',
  707. $li = $('<li class="'+ (isuploaded ? 'uploaded' : '') +'" id="'+ file.id +'_'+ index +'">' +
  708. '<p class="title">' + file.name + '</p>' +
  709. '<p class="imgWrap" '+ uploadedAttr +'></p>'+
  710. '<p class="progress"><span></span></p>' +
  711. '</li>'),
  712. $btns = $('<div class="file-panel">' +
  713. '<span class="cancel">删除</span>' +
  714. '<span class="rotateRight">向右旋转</span>' +
  715. '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
  716. $prgress = $li.find('p.progress span'),
  717. $imgWrap = $li.find('p.imgWrap'),
  718. $info = $('<p class="error"></p>'),
  719. text = '',
  720. showError = function(code) {
  721. switch(code) {
  722. case 'exceed_size':
  723. text = '文件大小超出'
  724. break
  725. case 'interrupt':
  726. text = '上传暂停'
  727. break
  728. default:
  729. text = '上传失败,请重试'
  730. break
  731. }
  732. $info.text(text).appendTo($li)
  733. }
  734. if (!isuploaded) {
  735. if (file.getStatus() === 'invalid') {
  736. showError(file.statusText)
  737. } else {
  738. // @todo lazyload
  739. $imgWrap.text('预览中')
  740. uploader.makeThumb(file, function(error, src) {
  741. if (error) {
  742. $imgWrap.text('不能预览')
  743. return
  744. }
  745. var img = $('<img src="'+src+'">')
  746. $imgWrap.empty().append(img)
  747. }, thumbnailWidth, thumbnailHeight)
  748. percentages[file.id] = [file.size, 0]
  749. file.rotation = 0
  750. }
  751. file.on('statuschange', function(cur, prev) {
  752. if (prev === 'progress') {
  753. $prgress.hide().width(0)
  754. } else if (prev === 'queued') {
  755. }
  756. // 成功
  757. if (cur === 'error' || cur === 'invalid') {
  758. showError(file.statusText)
  759. percentages[file.id][1] = 1
  760. } else if (cur === 'interrupt') {
  761. showError('interrupt')
  762. } else if (cur === 'queued') {
  763. percentages[file.id][1] = 0
  764. } else if (cur === 'progress') {
  765. $info.remove()
  766. $prgress.css('display', 'block')
  767. } else if (cur === 'complete') {
  768. $li.append('<span class="success"></span>')
  769. }
  770. $li.removeClass('state-' + prev).addClass('state-' + cur)
  771. })
  772. } else {
  773. $imgWrap.empty().append('<img src="'+ file.src +'">')
  774. if (options.initUploaded) {
  775. var arr = options.initUploaded.split(',')
  776. $li.append('<input type="hidden" class="upload" name="'+ (options.upname || $element.data('name')) +'" value="'+ arr[_index] +'">')
  777. }
  778. }
  779. $li.on('mouseenter', function() {
  780. $btns.stop().animate({height: 30})
  781. })
  782. $li.on('mouseleave', function() {
  783. $btns.stop().animate({height: 0})
  784. })
  785. $btns.on('click', 'span', function() {
  786. var index = $(this).index(),
  787. deg
  788. switch (index) {
  789. case 0:
  790. if (isuploaded) {
  791. fileCount --
  792. removeFile(file)
  793. if (!fileCount) {
  794. setState('pedding');
  795. }
  796. uploader.refresh()
  797. updateTotalProgress()
  798. } else {
  799. uploader.removeFile(file)
  800. }
  801. return
  802. case 1:
  803. file.rotation += 90
  804. break
  805. case 2:
  806. file.rotation -= 90
  807. break
  808. }
  809. if (supportTransition) {
  810. deg = 'rotate(' + file.rotation + 'deg)'
  811. $imgWrap.css({
  812. '-webkit-transform': deg,
  813. '-mos-transform': deg,
  814. '-o-transform': deg,
  815. 'transform': deg
  816. })
  817. } else {
  818. $imgWrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ (~~((file.rotation/90)%4 + 4)%4) +')')
  819. }
  820. })
  821. $li.appendTo($queue)
  822. }
  823. // 负责view的销毁
  824. var removeFile = function(file) {
  825. var $li = $wrap.find('#'+ file.id +'_'+ index)
  826. delete percentages[file.id]
  827. updateTotalProgress()
  828. $li.off().find('.file-panel').off().end().remove()
  829. if (fileCount < options.fileNumLimit) {
  830. $statusBar.find('#filePicker2').show()
  831. }
  832. }
  833. var updateTotalProgress = function() {
  834. var loaded = 0,
  835. total = 0,
  836. spans = $progress.children(),
  837. percent
  838. $.each(percentages, function(k, v) {
  839. total += v[0]
  840. loaded += v[0] * v[1]
  841. })
  842. percent = total ? loaded / total : 0
  843. spans.eq(0).text(Math.round(percent * 100) + '%')
  844. spans.eq(1).css('width', Math.round(percent * 100) + '%')
  845. updateStatus()
  846. }
  847. var updateStatus = function() {
  848. var text = '', stats;
  849. if (state === 'ready') {
  850. text = '选中'+ fileCount + upunit + ',共'+ WebUploader.formatSize(fileSize) +'。'
  851. } else if (state === 'confirm') {
  852. stats = uploader.getStats()
  853. if (stats.uploadFailNum) {
  854. text = '已成功上传'+ stats.successNum + upunit +','+
  855. stats.uploadFailNum + upunit +'上传失败,<a class="retry" href="#">重新上传</a> 或 <a class="ignore" href="#">忽略</a>'
  856. }
  857. } else if (state === 'uploaded') {
  858. text = '已上传'+ fileCount + upunit
  859. } else {
  860. stats = uploader.getStats()
  861. text = '共'+ fileCount + upunit +'(' + WebUploader.formatSize(fileSize) +'),已上传' + stats.successNum
  862. if (stats.uploadFailNum) {
  863. text += ',失败' + stats.uploadFailNum
  864. }
  865. }
  866. $info.html(text)
  867. $element.data('fileCount', fileCount)
  868. }
  869. var setState = function(val) {
  870. var file, stats
  871. if (val === state) {
  872. return
  873. }
  874. $upload.removeClass('state-' + state)
  875. $upload.addClass('state-' + val)
  876. state = val
  877. switch (state) {
  878. case 'pedding':
  879. $placeHolder.removeClass('element-invisible')
  880. $queue.parent().removeClass('filled')
  881. $queue.hide();
  882. $statusBar.addClass('element-invisible')
  883. uploader.refresh()
  884. break
  885. case 'ready':
  886. $placeHolder.addClass('element-invisible')
  887. $wrap.find('#filePicker2').removeClass('element-invisible')
  888. $queue.parent().addClass('filled')
  889. $queue.show()
  890. $statusBar.removeClass('element-invisible')
  891. uploader.refresh()
  892. $upload.removeClass('disabled')
  893. break
  894. case 'uploading':
  895. $wrap.find('#filePicker2').addClass('element-invisible')
  896. $progress.show()
  897. $upload.text('暂停上传')
  898. break
  899. case 'paused':
  900. $progress.show()
  901. $upload.text('继续上传')
  902. break
  903. case 'confirm':
  904. $progress.hide()
  905. $upload.text('开始上传').addClass('disabled')
  906. stats = uploader.getStats()
  907. if (stats.successNum && !stats.uploadFailNum) {
  908. setState('finish')
  909. return
  910. }
  911. break
  912. case 'finish':
  913. stats = uploader.getStats()
  914. if (stats.successNum) {
  915. } else {
  916. // 没有成功的图片,重设
  917. state = 'done'
  918. BJUI.alertmsg('info', '上传失败!')
  919. }
  920. break
  921. case 'uploaded':
  922. $upload.text('开始上传').addClass('disabled')
  923. break
  924. }
  925. if (state !== 'uploaded')
  926. updateStatus()
  927. }
  928. $wrap.insertAfter($element)
  929. if (!WebUploader.Uploader.support()) {
  930. alert('Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器');
  931. throw new Error('WebUploader does not support the browser you are using.');
  932. }
  933. // 是否允许重新上传
  934. if (typeof options.reupload === 'undefined')
  935. options.reupload = true
  936. options = $.extend(true, {}, {
  937. pick: {
  938. id: $wrap.find('#filePicker'),
  939. label: '点击选择图片'
  940. },
  941. dnd: $wrap.find('.queueList'),
  942. paste: false,
  943. accept: {
  944. title: 'Images',
  945. extensions: 'gif,jpg,jpeg,bmp,png',
  946. mimeTypes: 'image/*'
  947. },
  948. swf: BJUI.PLUGINPATH + 'webuploader/Uploader.swf', // swf文件路径
  949. disableGlobalDnd: false,
  950. chunked: false,
  951. server: null,
  952. fileNumLimit: 300,
  953. fileSizeLimit: 200 * 1024 * 1024, // 200 M
  954. fileSingleSizeLimit: 50 * 1024 * 1024 // 50 M
  955. }, options)
  956. // 实例化
  957. uploader = WebUploader.create(options)
  958. // 如果有已上传的图片(编辑时)
  959. if (typeof $element.data('uploaded') !== 'undefined')
  960. options.uploaded = $element.data('uploaded')
  961. if (options.uploaded) {
  962. // 将已上传图片加到队列
  963. addFile()
  964. $queue.parent().addClass('filled')
  965. }
  966. // 上传成功
  967. uploader.on('uploadSuccess', function(file, response) {
  968. if (response[BJUI.keys.statusCode] != BJUI.statusCode.ok) {
  969. BJUI.alertmsg('error', response.message)
  970. } else {
  971. var $li = $wrap.find('#'+ file.id +'_'+ index)
  972. $li.find('input.upload').remove().end()
  973. .append('<input type="hidden" class="upload" name="'+ (options.upname || $element.data('name')) +'" value="'+ response.filename +'">')
  974. }
  975. })
  976. // 上传失败
  977. uploader.on('uploadError', function(file, response) {
  978. BJUI.alertmsg('error', response.message)
  979. })
  980. // 添加“添加文件”的按钮,
  981. if (options.fileNumLimit > 1) {
  982. uploader.addButton({
  983. id: $wrap.find('#filePicker2'),
  984. label: '继续添加'
  985. })
  986. if (fileCount >= options.fileNumLimit)
  987. $statusBar.find('#filePicker2').hide()
  988. }
  989. uploader.onUploadProgress = function(file, percentage) {
  990. var $li = $wrap.find('#'+ file.id +'_'+ index),
  991. $percent = $li.find('.progress span')
  992. $percent.css('width', percentage * 100 + '%')
  993. percentages[file.id][1] = percentage
  994. updateTotalProgress()
  995. }
  996. uploader.onFileQueued = function(file) {
  997. fileCount++
  998. fileSize += file.size
  999. if (fileCount === 1) {
  1000. $placeHolder.addClass('element-invisible');
  1001. $statusBar.show()
  1002. }
  1003. addFile(file)
  1004. setState('ready')
  1005. updateTotalProgress()
  1006. }
  1007. uploader.onFileDequeued = function(file) {
  1008. fileCount--
  1009. fileSize -= file.size
  1010. if (!fileCount) {
  1011. setState('pedding');
  1012. }
  1013. removeFile(file)
  1014. updateTotalProgress()
  1015. }
  1016. uploader.on('all', function(type) {
  1017. var stats
  1018. switch(type) {
  1019. case 'uploadFinished':
  1020. setState('confirm')
  1021. break
  1022. case 'startUpload':
  1023. setState('uploading')
  1024. break
  1025. case 'stopUpload':
  1026. setState('paused')
  1027. break
  1028. }
  1029. })
  1030. uploader.onError = function(code) {
  1031. if (code === 'Q_EXCEED_NUM_LIMIT') {
  1032. BJUI.alertmsg('info', '只允许上传'+ options.fileNumLimit + upunit +'!')
  1033. } else if (code === 'Q_TYPE_DENIED') {
  1034. BJUI.alertmsg('info', '不支持的文件类型!')
  1035. } else if (code === 'F_EXCEED_SIZE') {
  1036. BJUI.alertmsg('info', '文件太大了!')
  1037. } else if (code === 'F_DUPLICATE') {
  1038. BJUI.alertmsg('info', '已添加过该文件!')
  1039. } else {
  1040. BJUI.alertmsg('info', code)
  1041. }
  1042. }
  1043. $upload.on('click', function() {
  1044. if ($(this).hasClass('disabled')) {
  1045. return false
  1046. }
  1047. if (state === 'ready') {
  1048. uploader.upload()
  1049. } else if (state === 'paused') {
  1050. uploader.upload()
  1051. } else if (state === 'uploading') {
  1052. uploader.stop()
  1053. }
  1054. })
  1055. $info.on('click', '.retry', function() {
  1056. uploader.retry()
  1057. })
  1058. $info.on('click', '.ignore', function() {
  1059. alert('todo')
  1060. })
  1061. $upload.addClass('state-' + state)
  1062. updateTotalProgress()
  1063. $element.data('webuploader', uploader).data('webuploader.wrap', $wrap)
  1064. }
  1065. }
  1066. }
  1067. $box.find('input[data-toggle="webuploader"]').each(function(i) {
  1068. initWebUploader($(this), i)
  1069. $(this).on('reload.webuploader', function() {
  1070. initWebUploader($(this), i)
  1071. })
  1072. })
  1073. }
  1074. /* not validate */
  1075. $box.find('form[data-toggle="ajaxform"]').each(function() {
  1076. $(this).validator({ignore: ':input'})
  1077. $(this).validator('destroy')
  1078. })
  1079. /* ========================================================================
  1080. * @description highCharts
  1081. * @author 小策一喋 <xvpindex@qq.com>
  1082. * @Blog http://www.topjui.com
  1083. * ======================================================================== */
  1084. var $highcharts = $box.find('[data-toggle="highcharts"]')
  1085. $highcharts.each(function(){
  1086. var $element = $(this)
  1087. var options = $element.data()
  1088. $.get(options.url, function(chartData){
  1089. $element.highcharts(chartData)
  1090. }, 'json')
  1091. })
  1092. /* ========================================================================
  1093. * @description ECharts
  1094. * @author 小策一喋 <xvpindex@qq.com>
  1095. * @Blog http://www.topjui.com
  1096. * ======================================================================== */
  1097. var $echarts = $box.find('[data-toggle="echarts"]')
  1098. $echarts.each(function(){
  1099. var $element = $(this)
  1100. var options = $element.data()
  1101. var theme = options.theme ? options.theme : 'blue'
  1102. var typeArr = options.type.split(',')
  1103. require.config({
  1104. paths: {
  1105. echarts: BJUI.PLUGINPATH + 'echarts'
  1106. }
  1107. })
  1108. require(
  1109. [
  1110. 'echarts',
  1111. 'echarts/theme/' + theme,
  1112. 'echarts/chart/' + typeArr[0],
  1113. typeArr[1] ? 'echarts/chart/' + typeArr[1] : 'echarts'
  1114. ],
  1115. function (ec,theme) {
  1116. var myChart = ec.init($element[0],theme)
  1117. $.get(options.url, function(chartData){
  1118. myChart.setOption(chartData)
  1119. }, 'json')
  1120. }
  1121. )
  1122. })
  1123. })
  1124. }(jQuery);