WazeWrap Beta

A base library for WME script writers

当前为 2016-11-22 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/24870/159283/WazeWrap%20Beta.js

  1. // ==UserScript==
  2. // @name WazeWrap Beta
  3. // @namespace https://gf.qytechs.cn/users/30701-justins83-waze
  4. // @version 0.1.8c
  5. // @description A base library for WME script writers
  6. // @author JustinS83/MapOMatic
  7. // @include https://beta.waze.com/*editor/*
  8. // @include https://www.waze.com/*editor/*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /* global W */
  14. /* global WazeWrap */
  15. var WazeWrap = {};
  16.  
  17. (function() {
  18.  
  19. function bootstrap(tries) {
  20. tries = tries || 1;
  21. if (W &&
  22. W.map &&
  23. W.model &&
  24. W.loginManager &&
  25. $) {
  26. init();
  27. } else if (tries < 1000) {
  28. setTimeout(function () { bootstrap(tries++); }, 200);
  29. } else {
  30. console.log('WazeWrap failed to load');
  31. }
  32. }
  33.  
  34. bootstrap();
  35.  
  36. function init(){
  37. var oldLib = window.WazeWrap;
  38.  
  39. var root = this;
  40.  
  41. WazeWrap.Version = "0.1.8c";
  42. WazeWrap.isBetaEditor = /beta/.test(location.href);
  43.  
  44. SetUpRequire();
  45.  
  46. WazeWrap.test = "test";
  47. WazeWrap.Geometry = new Geometry;
  48. WazeWrap.Model = new Model;
  49. WazeWrap.Interface = new Interface;
  50. WazeWrap.User = new User;
  51. WazeWrap.Util = new Util;
  52. root.WazeWrap = WazeWrap;
  53.  
  54. console.log('WazeWrap Loaded');
  55. };
  56.  
  57.  
  58. function SetUpRequire(){
  59. if(this.isBetaEditor || typeof window.require !== "undefined")
  60. return;
  61.  
  62. console.log("Setting d2's require fix...");
  63. // setup one global var and put all in
  64. var WMEAPI = {};
  65.  
  66. // detect URL of WME source code
  67. WMEAPI.scripts = document.getElementsByTagName('script');
  68. WMEAPI.url=null;
  69. for (i=0;i<WMEAPI.scripts.length;i++){
  70. if (WMEAPI.scripts[i].src.indexOf('/assets-editor/js/app')!=-1)
  71. {
  72. WMEAPI.url=WMEAPI.scripts[i].src;
  73. break;
  74. }
  75. }
  76. if (WMEAPI.url==null)
  77. throw new Error("WME Hack: can't detect WME main JS");
  78.  
  79.  
  80. // setup a fake require and require.define
  81. WMEAPI.require=function (e) {
  82. if (WMEAPI.require.define.modules.hasOwnProperty(e))
  83. return WMEAPI.require.define.modules[e];
  84. else
  85. console.error('Require failed on ' + e, WMEAPI.require.define.modules);
  86. return null;
  87. };
  88.  
  89. WMEAPI.require.define=function (m) {
  90. if (WMEAPI.require.define.hasOwnProperty('modules')==false)
  91. WMEAPI.require.define.modules={};
  92. for (var p in m){
  93. WMEAPI.require.define.modules[p]=m[p];
  94. }
  95. };
  96.  
  97. // save the original webpackJsonp function
  98. WMEAPI.tmp = window.webpackJsonp;
  99.  
  100. // taken from WME code: this function is a wrapper that setup the API and may call recursively other functions
  101. WMEAPI.t = function (n) {
  102. if (WMEAPI.s[n]) return WMEAPI.s[n].exports;
  103. var r = WMEAPI.s[n] = {
  104. exports: {},
  105. id: n,
  106. loaded: !1
  107. };
  108. return WMEAPI.e[n].call(r.exports, r, r.exports, WMEAPI.t), r.loaded = !0, r.exports;
  109. };
  110.  
  111. // e is a copy of all WME funcs because function t need to access to this list
  112. WMEAPI.e=[];
  113.  
  114. // the patch
  115. window.webpackJsonp = function(a, i) {
  116. // our API but we will use it only to build the require stuffs
  117. var api={};
  118. // taken from WME code. a is [1], so...
  119. for (var o, d, u = 0, l = []; u < a.length; u++) d = a[u], WMEAPI.r[d] && l.push.apply(l, WMEAPI.r[d]), WMEAPI.r[d] = 0;
  120. var unknownCount=0;
  121. var classname, funcStr;
  122. // copy i in e and keep a link from classname to index in e
  123. for (o in i){
  124. WMEAPI.e[o] = i[o];
  125. funcStr = i[o].toString();
  126. classname = funcStr.match(/CLASS_NAME:\"([^\"]*)\"/);
  127. if (classname){
  128. // keep the link.
  129. api[classname[1].replace(/\./g,'/').replace(/^W\//, 'Waze/')]={index: o, func: WMEAPI.e[o]};
  130. }
  131. else{
  132. api['Waze/Unknown/' + unknownCount]={index: o, func: WMEAPI.e[o]};
  133. unknownCount++;
  134. }
  135. }
  136. // taken from WME code: it calls the original webpackJsonp and do something else, but I don't really know what.
  137. // removed the call to the original webpackJsonp: still works...
  138. //for (tmp && tmp(a, i); l.length;) l.shift().call(null, t);
  139. for (; l.length;) l.shift().call(null, WMEAPI.t);
  140. WMEAPI.s[0] = 0;
  141. // run the first func of WME. This first func will call recusrsively all funcs needed to setup the API.
  142. // After this call, s will contain all instanciables classes.
  143. //var ret = WMEAPI.t(0);
  144. // now, build the requires thanks to the link we've built in var api.
  145. var module={};
  146. var apiFuncName;
  147. unknownCount=0;
  148. for (o in i){
  149. funcStr = i[o].toString();
  150. classname = funcStr.match(/CLASS_NAME:\"([^\"]*)\"/);
  151. if (classname){
  152. module={};
  153. apiFuncName = classname[1].replace(/\./g,'/').replace(/^W\//, 'Waze/');
  154. module[apiFuncName]=WMEAPI.t(api[apiFuncName].index);
  155. WMEAPI.require.define(module);
  156. }
  157. else{
  158. var matches = funcStr.match(/SEGMENT:"segment",/);
  159. if (matches){
  160. module={};
  161. apiFuncName='Waze/Model/ObjectType';
  162. module[apiFuncName]=WMEAPI.t(api['Waze/Unknown/' + unknownCount].index);
  163. WMEAPI.require.define(module);
  164. }
  165. unknownCount++;
  166. }
  167. }
  168.  
  169. // restore the original func
  170. window.webpackJsonp=WMEAPI.tmp;
  171.  
  172. // set the require public if needed
  173. // if so: others scripts must wait for the window.require to be available before using it.
  174. window.require = WMEAPI.require;
  175. // all available functions are in WMEAPI.require.define.modules
  176. // console.debug this variable to read it:
  177. // console.debug('Modules: ', WMEAPI.require.define.modules);
  178. // run your script here:
  179. // setTimeout(yourscript);
  180. // again taken from WME code. Not sure about what it does.
  181. //if (i[0]) return ret;
  182. };
  183.  
  184. // some kind of global vars and init
  185. WMEAPI.s = {};
  186. WMEAPI.r = {
  187. 0: 0
  188. };
  189.  
  190. // hacking finished
  191.  
  192. // load again WME through our patched func
  193. WMEAPI.WMEHACK_Injected_script = document.createElement("script");
  194. WMEAPI.WMEHACK_Injected_script.setAttribute("type", "application/javascript");
  195. WMEAPI.WMEHACK_Injected_script.src = WMEAPI.url;
  196. document.body.appendChild(WMEAPI.WMEHACK_Injected_script);
  197. console.log("d2 fix complete");
  198. }
  199.  
  200. function Geometry(){
  201. //var geometry = WazeWrap.Geometry;
  202.  
  203. //Converts to "normal" GPS coordinates
  204. this.ConvertTo4326 = function (long, lat){
  205. var projI=new OpenLayers.Projection("EPSG:900913");
  206. var projE=new OpenLayers.Projection("EPSG:4326");
  207. return (new OpenLayers.LonLat(long, lat)).transform(projI,projE);
  208. };
  209. this.ConvertTo900913 = function (long, lat){
  210. var projI=new OpenLayers.Projection("EPSG:900913");
  211. var projE=new OpenLayers.Projection("EPSG:4326");
  212. return (new OpenLayers.LonLat(long, lat)).transform(projE,projI);
  213. };
  214.  
  215. //Converts the Longitudinal offset to an offset in 4326 gps coordinates
  216. this.CalculateLongOffsetGPS = function(longMetersOffset, long, lat)
  217. {
  218. var R= 6378137; //Earth's radius
  219. var dLon = longMetersOffset / (R * Math.cos(Math.PI * lat / 180)); //offset in radians
  220. var lon0 = dLon * (180 / Math.PI); //offset degrees
  221.  
  222. return lon0;
  223. };
  224.  
  225. //Converts the Latitudinal offset to an offset in 4326 gps coordinates
  226. this.CalculateLatOffsetGPS = function(latMetersOffset, lat)
  227. {
  228. var R= 6378137; //Earth's radius
  229. var dLat = latMetersOffset/R;
  230. var lat0 = dLat * (180 /Math.PI); //offset degrees
  231.  
  232. return lat0;
  233. };
  234. this.isLonLatInMapExtent = function (lonLat) {
  235. 'use strict';
  236. return lonLat && W.map.getExtent().containsLonLat(lonLat);
  237. };
  238. this.isGeometryInMapExtent = function (geometry) {
  239. 'use strict';
  240. return geometry && geometry.getBounds &&
  241. W.map.getExtent().intersectsBounds(geometry.getBounds());
  242. };
  243. };
  244.  
  245. function Model(){
  246. //var model = WazeWrap.Model;
  247.  
  248. this.getPrimaryStreetID = function(segmentID){
  249. return W.model.segments.get(segmentID).attributes.primaryStreetID;
  250. };
  251.  
  252. this.getStreetName = function(primaryStreetID){
  253. return W.model.streets.get(PrimaryStreetID).name;
  254. };
  255.  
  256. this.getCityID = function(primaryStreetID){
  257. return W.model.streets.get(primaryStreetID).cityID;
  258. };
  259.  
  260. this.getCityName = function(primaryStreetID){
  261. return W.model.cities.get(this.getCityID(primaryStreetID)).attributes.Name;
  262. };
  263.  
  264. this.getStateName = function(primaryStreetID){
  265. return W.model.states.get(getStateID(primaryStreetID)).Name;
  266. };
  267.  
  268. this.getStateID = function(primaryStreetID){
  269. return W.model.cities.get(primaryStreetID).attributes.stateID;
  270. };
  271.  
  272. this.getCountryID = function(primaryStreetID){
  273. return W.model.cities.get(this.getCityID(primaryStreetID)).attributes.CountryID;
  274. };
  275.  
  276. this.getCountryName = function(primaryStreetID){
  277. return W.model.countries.get(getCountryID(primaryStreetID)).name;
  278. };
  279.  
  280. this.getCityNameFromSegmentObj = function(segObj){
  281. return this.getCityName(segObj.attributes.primaryStreetID);
  282. };
  283.  
  284. this.getStateNameFromSegmentObj = function(segObj){
  285. return this.getStateName(segObj.attributes.primaryStreetID);
  286. };
  287.  
  288. //returns an array of segmentIDs for all segments that are part of the same roundabout as the passed segment
  289. this.getAllRoundaboutSegmentsFromObj = function(segObj){
  290. if(segObj.model.attributes.junctionID === null)
  291. return null;
  292.  
  293. return W.model.junctions.objects[segObj.model.attributes.junctionID].segIDs;
  294. };
  295.  
  296. this.getAllRoundaboutJunctionNodesFromObj = function(segObj){
  297. var RASegs = this.getAllRoundaboutSegmentsFromObj(segObj);
  298. var RAJunctionNodes = [];
  299. for(i=0; i< RASegs.length; i++){
  300. RAJunctionNodes.push(W.model.nodes.objects[W.model.segments.get(RASegs[i]).attributes.toNodeID]);
  301.  
  302. }
  303. return RAJunctionNodes;
  304. };
  305.  
  306. this.isRoundaboutSegmentID = function(segmentID){
  307. if(W.model.segments.get(segmentID).attributes.junctionID === null)
  308. return false;
  309. else
  310. return true;
  311. };
  312.  
  313. this.isRoundaboutSegmentObj = function(segObj){
  314. if(segObj.model.attributes.junctionID === null)
  315. return false;
  316. else
  317. return true;
  318. };
  319.  
  320. /**
  321. * Defers execution of a callback function until the WME map and data
  322. * model are ready. Call this function before calling a function that
  323. * causes a map and model reload, such as W.map.moveTo(). After the
  324. * move is completed the callback function will be executed.
  325. * @function WazeWrap.Model.onModelReady
  326. * @param {Function} callback The callback function to be executed.
  327. * @param {Boolean} now Whether or not to call the callback now if the
  328. * model is currently ready.
  329. * @param {Object} context The context in which to call the callback.
  330. */
  331. this.onModelReady = function (callback, now, context) {
  332. var deferModelReady = function () {
  333. return $.Deferred(function (dfd) {
  334. var resolve = function () {
  335. dfd.resolve();
  336. W.model.events.unregister('mergeend', null, resolve);
  337. };
  338. W.model.events.register('mergeend', null, resolve);
  339. }).promise();
  340. };
  341. var deferMapReady = function () {
  342. return $.Deferred(function (dfd) {
  343. var resolve = function () {
  344. dfd.resolve();
  345. W.vent.off('operationDone', resolve);
  346. };
  347. W.vent.on('operationDone', resolve);
  348. }).promise();
  349. };
  350.  
  351. if (typeof callback === 'function') {
  352. context = context || callback;
  353. if (now && WazeWrap.Util.mapReady() && WazeWrap.Util.modelReady()) {
  354. callback.call(context);
  355. } else {
  356. $.when(deferMapReady() && deferModelReady()).
  357. then(function () {
  358. callback.call(context);
  359. });
  360. }
  361. }
  362. };
  363. };
  364. function User(){
  365. this.Rank = function(){
  366. return W.loginManager.user.normalizedLevel;
  367. };
  368.  
  369. this.Username = function(){
  370. return W.loginManager.user.userName;
  371. };
  372.  
  373. this.isCM = function(){
  374. if(W.loginManager.user.editableCountryIDs.length > 0)
  375. return true;
  376. else
  377. return false;
  378. };
  379. this.isAM = function(){
  380. return W.loginManager.user.isAreaManager;
  381. };
  382. };
  383. function Util(){
  384. /**
  385. * Function to defer function execution until an element is present on
  386. * the page.
  387. * @function WazeWrap.Util.waitForElement
  388. * @param {String} selector The CSS selector string or a jQuery object
  389. * to find before executing the callback.
  390. * @param {Function} callback The function to call when the page
  391. * element is detected.
  392. * @param {Object} [context] The context in which to call the callback.
  393. */
  394. this.waitForElement = function (selector, callback, context) {
  395. var jqObj;
  396.  
  397. if (!selector || typeof callback !== 'function') {
  398. return;
  399. }
  400.  
  401. jqObj = typeof selector === 'string' ?
  402. $(selector) : selector instanceof $ ? selector : null;
  403.  
  404. if (!jqObj.size()) {
  405. window.requestAnimationFrame(function () {
  406. WazeWrap.Util.waitForElement(selector, callback, context);
  407. });
  408. } else {
  409. callback.call(context || callback);
  410. }
  411. };
  412.  
  413. /**
  414. * Function to track the ready state of the map.
  415. * @function WazeWrap.Util.mapReady
  416. * @return {Boolean} Whether or not a map operation is pending or
  417. * undefined if the function has not yet seen a map ready event fired.
  418. */
  419. this.mapReady = function () {
  420. var mapReady = true;
  421. W.vent.on('operationPending', function () {
  422. mapReady = false;
  423. });
  424. W.vent.on('operationDone', function () {
  425. mapReady = true;
  426. });
  427. return function () {
  428. return mapReady;
  429. };
  430. } ();
  431.  
  432. /**
  433. * Function to track the ready state of the model.
  434. * @function WazeWrap.Util.modelReady
  435. * @return {Boolean} Whether or not the model has loaded objects or
  436. * undefined if the function has not yet seen a model ready event fired.
  437. */
  438. this.modelReady = function () {
  439. var modelReady = true;
  440. W.model.events.register('mergestart', null, function () {
  441. modelReady = false;
  442. });
  443. W.model.events.register('mergeend', null, function () {
  444. modelReady = true;
  445. });
  446. return function () {
  447. return modelReady;
  448. };
  449. } ();
  450. };
  451.  
  452. function Interface() {
  453. /**
  454. * Generates id for message bars.
  455. * @private
  456. */
  457. var getNextID = function () {
  458. var id = 1;
  459. return function () {
  460. return id++;
  461. };
  462. } ();
  463. this.Shortcut = OL.Class(this, /** @lends WazeWrap.Interface.Shortcut.prototype */ {
  464. name: null,
  465. group: null,
  466. shortcut: {},
  467. callback: null,
  468. scope: null,
  469. groupExists: false,
  470. actionExists: false,
  471. eventExists: false,
  472. defaults: {
  473. group: 'default'
  474. },
  475. /**
  476. * Creates a new {WazeWrap.Interface.Shortcut}.
  477. * @class
  478. * @name WazeWrap.Interface.Shortcut
  479. * @param name {String} The name of the shortcut.
  480. * @param group {String} The name of the shortcut group.
  481. * @param shortcut {String} The shortcut key(s). The shortcut
  482. * should be of the form 'i' where i is the keyboard shortuct or
  483. * include modifier keys such as 'CSA+i', where C = the control
  484. * key, S = the shift key, A = the alt key, and i = the desired
  485. * keyboard shortcut. The modifier keys are optional.
  486. * @param callback {Function} The function to be called by the
  487. * shortcut.
  488. * @param scope {Object} The object to be used as this by the
  489. * callback.
  490. * @return {WazeWrap.Interface.Shortcut} The new shortcut object.
  491. * @example //Creates new shortcut and adds it to the map.
  492. * shortcut = new WazeWrap.Interface.Shortcut('myName', 'myGroup', 'C+p', callbackFunc, null).add();
  493. */
  494. initialize: function (name, group, shortcut, callback, scope) {
  495. if ('string' === typeof name && name.length > 0 &&
  496. 'string' === typeof shortcut && shortcut.length > 0 &&
  497. 'function' === typeof callback) {
  498. this.name = name;
  499. this.group = group || this.defaults.group;
  500. this.callback = callback;
  501. this.shortcut[shortcut] = name;
  502. if ('object' !== typeof scope) {
  503. this.scope = null;
  504. } else {
  505. this.scope = scope;
  506. }
  507. return this;
  508. }
  509. },
  510. /**
  511. * Determines if the shortcut's group already exists.
  512. * @private
  513. */
  514. doesGroupExist: function () {
  515. this.groupExists = 'undefined' !== typeof W.accelerators.Groups[this.group] &&
  516. undefined !== typeof W.accelerators.Groups[this.group].members &&
  517. W.accelerators.Groups[this.group].length > 0;
  518. return this.groupExists;
  519. },
  520. /**
  521. * Determines if the shortcut's action already exists.
  522. * @private
  523. */
  524. doesActionExist: function () {
  525. this.actionExists = 'undefined' !== typeof W.accelerators.Actions[this.name];
  526. return this.actionExists;
  527. },
  528. /**
  529. * Determines if the shortcut's event already exists.
  530. * @private
  531. */
  532. doesEventExist: function () {
  533. this.eventExists = 'undefined' !== typeof W.accelerators.events.listeners[this.name] &&
  534. W.accelerators.events.listeners[this.name].length > 0 &&
  535. this.callback === W.accelerators.events.listeners[this.name][0].func &&
  536. this.scope === W.accelerators.events.listeners[this.name][0].obj;
  537. return this.eventExists;
  538. },
  539. /**
  540. * Creates the shortcut's group.
  541. * @private
  542. */
  543. createGroup: function () {
  544. W.accelerators.Groups[this.group] = [];
  545. W.accelerators.Groups[this.group].members = [];
  546. },
  547. /**
  548. * Registers the shortcut's action.
  549. * @private
  550. */
  551. addAction: function () {
  552. W.accelerators.addAction(this.name, { group: this.group });
  553. },
  554. /**
  555. * Registers the shortcut's event.
  556. * @private
  557. */
  558. addEvent: function () {
  559. W.accelerators.events.register(this.name, this.scope, this.callback);
  560. },
  561. /**
  562. * Registers the shortcut's keyboard shortcut.
  563. * @private
  564. */
  565. registerShortcut: function () {
  566. W.accelerators._registerShortcuts(this.shortcut);
  567. },
  568. /**
  569. * Adds the keyboard shortcut to the map.
  570. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  571. */
  572. add: function () {
  573. /* If the group is not already defined, initialize the group. */
  574. if (!this.doesGroupExist()) {
  575. this.createGroup();
  576. }
  577.  
  578. /* Clear existing actions with same name */
  579. if (this.doesActionExist()) {
  580. W.accelerators.Actions[this.name] = null;
  581. }
  582. this.addAction();
  583.  
  584. /* Register event only if it's not already registered */
  585. if (!this.doesEventExist()) {
  586. this.addEvent();
  587. }
  588.  
  589. /* Finally, register the shortcut. */
  590. this.registerShortcut();
  591. return this;
  592. },
  593. /**
  594. * Removes the keyboard shortcut from the map.
  595. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  596. */
  597. remove: function () {
  598. if (this.doesEventExist()) {
  599. W.accelerators.events.unregister(this.name, this.scope, this.callback);
  600. }
  601. if (this.doesActionExist()) {
  602. delete W.accelerators.Actions[this.name];
  603. }
  604. //remove shortcut?
  605. return this;
  606. },
  607. /**
  608. * Changes the keyboard shortcut and applies changes to the map.
  609. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  610. */
  611. change: function (shortcut) {
  612. if (shortcut) {
  613. this.shortcut = {};
  614. this.shortcut[shortcut] = this.name;
  615. this.registerShortcut();
  616. }
  617. return this;
  618. }
  619. }),
  620.  
  621. this.Tab = OL.Class(this, {
  622. /** @lends WazeWrap.Interface.Tab */
  623. TAB_SELECTOR: '#user-tabs ul.nav-tabs',
  624. CONTENT_SELECTOR: '#user-info div.tab-content',
  625. callback: null,
  626. $content: null,
  627. context: null,
  628. $tab: null,
  629. /**
  630. * Creates a new WazeWrap.Interface.Tab. The tab is appended to the WME
  631. * editor sidebar and contains the passed HTML content.
  632. * @class
  633. * @name WazeWrap.Interface.Tab
  634. * @param {String} name The name of the tab. Should not contain any
  635. * special characters.
  636. * @param {String} content The HTML content of the tab.
  637. * @param {Function} [callback] A function to call upon successfully
  638. * appending the tab.
  639. * @param {Object} [context] The context in which to call the callback
  640. * function.
  641. * @return {WazeWrap.Interface.Tab} The new tab object.
  642. * @example //Creates new tab and adds it to the page.
  643. * new WazeWrap.Interface.Tab('thebestscriptever', '<div>Hello World!</div>');
  644. */
  645. initialize: function (name, content, callback, context) {
  646. var idName, i = 0;
  647. if (name && 'string' === typeof name &&
  648. content && 'string' === typeof content) {
  649. if (callback && 'function' === typeof callback) {
  650. this.callback = callback;
  651. this.context = context || callback;
  652. }
  653. /* Sanitize name for html id attribute */
  654. idName = name.toLowerCase().replace(/[^a-z-_]/g, '');
  655. /* Make sure id will be unique on page */
  656. while (
  657. $('#sidepanel-' + (i ? idName + i : idName)).length > 0) {
  658. i++;
  659. }
  660. if (i) {
  661. idName = idName + i;
  662. }
  663. /* Create tab and content */
  664. this.$tab = $('<li/>')
  665. .append($('<a/>')
  666. .attr({
  667. 'href': '#sidepanel-' + idName,
  668. 'data-toggle': 'tab',
  669. })
  670. .text(name));
  671. this.$content = $('<div/>')
  672. .addClass('tab-pane')
  673. .attr('id', 'sidepanel-' + idName)
  674. .html(content);
  675.  
  676. this.appendTab();
  677. }
  678. },
  679.  
  680. append: function (content) {
  681. this.$content.append(content);
  682. },
  683.  
  684. appendTab: function () {
  685. WazeWrap.Util.waitForElement(
  686. this.TAB_SELECTOR + ',' + this.CONTENT_SELECTOR,
  687. function () {
  688. $(this.TAB_SELECTOR).append(this.$tab);
  689. $(this.CONTENT_SELECTOR).first().append(this.$content);
  690. if (this.callback) {
  691. this.callback.call(this.context);
  692. }
  693. }, this);
  694. },
  695.  
  696. clearContent: function () {
  697. this.$content.empty();
  698. },
  699.  
  700. destroy: function () {
  701. this.$tab.remove();
  702. this.$content.remove();
  703. }
  704. });
  705. };
  706.  
  707. }.call(this));

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址