我试图将包含大约 480 行的整个原型文件转换为 jQuery。我们不使用原型库。
我有一些东西可以在线转换 但它似乎只适用于少数人。但他给出了很多建议。
我的疑问是如何开始?当我在 stackoverflow 中浏览时,我得到了很多……如果我们完全从原型更改为 jquery,我们是否需要使用“原型”这个词。? 示例:原型到 jquery - stackoverflow
var buildAShop = Class.create();
buildAShop.prototype = {
initialize: function (parameters) {
var params = parameters.evalJSON(); // passing json object so we can add more variables from jsp if needed.
this.scheduleSearchAjax = null; // keep track of the latest scheduleSearch ajax call to ensure only the last one gets displayed.
this.intrastitialContent = null; // store the intrastial content from the page so all HTML is in the jsp page.
// create controller object for all shops and their info
this.shopObj = {currentShop: params.selectedShopNumber,
shopNumbers: params.shopNumbers,
shopNumbersForSelectedSlices: params.shopNumbersForSelectedSlices};
for (var i = 0; i < params.shopNumbers.length; i++) {
var thisShopDiv = $(params.shopNumbers[i].toString());
var thisShopHeader = thisShopDiv.getFirstElementByClassName('shopHeader');
// observe the shop header for changing shops and highlighting the 'tab'
Event.observe(thisShopHeader, 'click', this.switchShop.bindAsEventListener(this, params.shopNumbers[i]));
Event.observe(thisShopHeader, 'mouseover', this.hoverHeader.bindAsEventListener(this, thisShopHeader, 'on'));
Event.observe(thisShopHeader, 'mouseout', this.hoverHeader.bindAsEventListener(this, thisShopHeader, 'off'));
// initialize this shopSet
this.initShopSet(thisShopDiv, params.shopNumbers[i], params.shopNames[i]);
};
},
// initializes a shop set
initShopSet: function (thisShopDiv, shopId, shopName) {
this.shopObj[shopId] = {};
var flt = this.shopObj[shopId];
我没有在这里给出整个代码。