switch modules to new dojo definition format

This commit is contained in:
Andrew Dolgov 2016-08-10 13:40:24 +03:00
parent 546b419f52
commit d39a2f8005
7 changed files with 1151 additions and 1134 deletions

View File

@ -1,10 +1,6 @@
dojo.provide("fox.FeedTree"); require(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) {
dojo.provide("fox.FeedStoreModel");
dojo.require("dijit.Tree"); return declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
dojo.require("dijit.Menu");
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
getItemsInCategory: function (id) { getItemsInCategory: function (id) {
if (!this.store._itemsByIdentity) return undefined; if (!this.store._itemsByIdentity) return undefined;
@ -16,10 +12,10 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
return undefined; return undefined;
}, },
getItemById: function(id) { getItemById: function (id) {
return this.store._itemsByIdentity[id]; return this.store._itemsByIdentity[id];
}, },
getFeedValue: function(feed, is_cat, key) { getFeedValue: function (feed, is_cat, key) {
if (!this.store._itemsByIdentity) return undefined; if (!this.store._itemsByIdentity) return undefined;
if (is_cat) if (is_cat)
@ -30,17 +26,17 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
if (treeItem) if (treeItem)
return this.store.getValue(treeItem, key); return this.store.getValue(treeItem, key);
}, },
getFeedName: function(feed, is_cat) { getFeedName: function (feed, is_cat) {
return this.getFeedValue(feed, is_cat, 'name'); return this.getFeedValue(feed, is_cat, 'name');
}, },
getFeedUnread: function(feed, is_cat) { getFeedUnread: function (feed, is_cat) {
var unread = parseInt(this.getFeedValue(feed, is_cat, 'unread')); var unread = parseInt(this.getFeedValue(feed, is_cat, 'unread'));
return (isNaN(unread)) ? 0 : unread; return (isNaN(unread)) ? 0 : unread;
}, },
setFeedUnread: function(feed, is_cat, unread) { setFeedUnread: function (feed, is_cat, unread) {
return this.setFeedValue(feed, is_cat, 'unread', parseInt(unread)); return this.setFeedValue(feed, is_cat, 'unread', parseInt(unread));
}, },
setFeedValue: function(feed, is_cat, key, value) { setFeedValue: function (feed, is_cat, key, value) {
if (!value) value = ''; if (!value) value = '';
if (!this.store._itemsByIdentity) return undefined; if (!this.store._itemsByIdentity) return undefined;
@ -67,12 +63,12 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
if (items[i] == treeItem) { if (items[i] == treeItem) {
for (var j = i+1; j < items.length; j++) { for (var j = i + 1; j < items.length; j++) {
var unread = this.store.getValue(items[j], 'unread'); var unread = this.store.getValue(items[j], 'unread');
var id = this.store.getValue(items[j], 'id'); var id = this.store.getValue(items[j], 'id');
if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j]; if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j];
} }
} }
@ -81,7 +77,7 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
var id = this.store.getValue(items[j], 'id'); var id = this.store.getValue(items[j], 'id');
if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j]; if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j];
} }
} }
} }
@ -89,15 +85,19 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
return null; return null;
}, },
hasCats: function() { hasCats: function () {
if (this.store && this.store._itemsByIdentity) if (this.store && this.store._itemsByIdentity)
return this.store._itemsByIdentity['CAT:-1'] != undefined; return this.store._itemsByIdentity['CAT:-1'] != undefined;
else else
return false; return false;
}, },
});
}); });
dojo.declare("fox.FeedTree", dijit.Tree, { require(["dojo/_base/declare", "dijit/Tree", "dijit/Menu"], function (declare) {
return declare("fox.FeedTree", dijit.Tree, {
_onKeyPress: function(/* Event */ e) { _onKeyPress: function(/* Event */ e) {
return; // Stop dijit.Tree from interpreting keystrokes return; // Stop dijit.Tree from interpreting keystrokes
}, },
@ -586,4 +586,6 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
return false; return false;
} }
}, },
});
}); });

View File

@ -1,10 +1,6 @@
dojo.provide("fox.PrefFeedTree"); require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
dojo.provide("fox.PrefFeedStore");
dojo.require("lib.CheckBoxTree"); return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
dojo.require("dojo.data.ItemFileWriteStore");
dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function(saveCompleteCallback, saveFailedCallback, _saveEverything: function(saveCompleteCallback, saveFailedCallback,
newFileContentString) { newFileContentString) {
@ -17,9 +13,13 @@ dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
load: saveCompleteCallback}); load: saveCompleteCallback});
}, },
});
}); });
dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = this.inherited(arguments); var tnode = this.inherited(arguments);
@ -121,5 +121,6 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
(id.match("root") && position == "over")); (id.match("root") && position == "over"));
} }
}, },
});
}); });

View File

@ -1,24 +1,27 @@
dojo.provide("fox.PrefFilterTree"); require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
dojo.require("lib.CheckBoxTree"); return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
dojo.require("dojo.data.ItemFileWriteStore");
dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, { _saveEverything: function (saveCompleteCallback, saveFailedCallback,
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
newFileContentString) { newFileContentString) {
dojo.xhrPost({ dojo.xhrPost({
url: "backend.php", url: "backend.php",
content: {op: "pref-filters", method: "savefilterorder", content: {
payload: newFileContentString}, op: "pref-filters", method: "savefilterorder",
payload: newFileContentString
},
error: saveFailedCallback, error: saveFailedCallback,
load: saveCompleteCallback}); load: saveCompleteCallback
});
}, },
});
}); });
dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
return declare("fox.PrefFilterTree", lib.CheckBoxTree, {
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = this.inherited(arguments); var tnode = this.inherited(arguments);
@ -63,7 +66,7 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
if (inverse) if (inverse)
label += " (" + __("Inverse") + ")"; label += " (" + __("Inverse") + ")";
/* if (item.param) /* if (item.param)
label = "<span class=\"labelFixedLength\">" + label + label = "<span class=\"labelFixedLength\">" + label +
"</span>" + item.param[0]; */ "</span>" + item.param[0]; */
@ -92,5 +95,8 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
this.inherited(arguments); this.inherited(arguments);
this.tree.model.store.save(); this.tree.model.store.save();
}, },
});
}); });

View File

@ -1,9 +1,6 @@
dojo.provide("fox.PrefLabelTree"); require(["dojo/_base/declare", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare) {
dojo.require("lib.CheckBoxTree"); return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
dojo.require("dijit.form.DropDownButton");
dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
setNameById: function (id, name) { setNameById: function (id, name) {
var item = this.model.store._itemsByIdentity['LABEL:' + id]; var item = this.model.store._itemsByIdentity['LABEL:' + id];
@ -39,5 +36,8 @@ dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
getIconClass: function (item, opened) { getIconClass: function (item, opened) {
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
}, },
});
}); });

View File

@ -943,15 +943,12 @@ function init() {
"dijit/Toolbar", "dijit/Toolbar",
"dijit/Tree", "dijit/Tree",
"dijit/tree/dndSource", "dijit/tree/dndSource",
"dojo/data/ItemFileWriteStore"], function (dojo, ready, parser) { "dojo/data/ItemFileWriteStore",
"fox/PrefFeedTree",
"fox/PrefFilterTree",
"fox/PrefLabelTree" ], function (dojo, ready, parser) {
ready(function() { ready(function() {
dojo.require("lib.CheckBoxTree");
dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree");
parser.parse(); parser.parse();
loading_set_progress(50); loading_set_progress(50);

View File

@ -248,12 +248,11 @@ function init() {
"dijit/Tree", "dijit/Tree",
"dijit/tree/dndSource", "dijit/tree/dndSource",
"dijit/tree/ForestStoreModel", "dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore" ], function (dojo, ready, parser) { "dojo/data/ItemFileWriteStore",
"fox/FeedTree" ], function (dojo, ready, parser) {
ready(function() { ready(function() {
dojo.require("fox.FeedTree");
parser.parse(); parser.parse();
if (!genericSanityCheck()) if (!genericSanityCheck())

View File

@ -1,16 +1,18 @@
dojo.provide("lib.CheckBoxTree"); //dojo.provide("lib.CheckBoxTree");
dojo.provide("lib.CheckBoxStoreModel"); //dojo.provide("lib.CheckBoxStoreModel");
// THIS WIDGET IS BASED ON DOJO/DIJIT 1.4.0 AND WILL NOT WORK WITH PREVIOUS VERSIONS // THIS WIDGET IS BASED ON DOJO/DIJIT 1.4.0 AND WILL NOT WORK WITH PREVIOUS VERSIONS
// //
// Release date: 02/05/2010 // Release date: 02/05/2010
// //
dojo.require("dijit.Tree"); //dojo.require("dijit.Tree");
dojo.require("dijit.form.CheckBox"); //dojo.require("dijit.form.CheckBox");
dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel, require(["dojo/_base/declare", "dijit/tree/TreeStoreModel"], function (declare) {
{
return declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
{
// checkboxAll: Boolean // checkboxAll: Boolean
// If true, every node in the tree will receive a checkbox regardless if the 'checkbox' attribute // If true, every node in the tree will receive a checkbox regardless if the 'checkbox' attribute
// is specified in the dojo.data. // is specified in the dojo.data.
@ -108,7 +110,7 @@ dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
// Special handling required for the 'fake' root entry (the root is NOT a dojo.data.item). // Special handling required for the 'fake' root entry (the root is NOT a dojo.data.item).
// this stuff is only relevant for Forest store -fox // this stuff is only relevant for Forest store -fox
/* if ( storeItem == this.root ) { /* if ( storeItem == this.root ) {
if( typeof(storeItem.checkbox) == "undefined" ) { if( typeof(storeItem.checkbox) == "undefined" ) {
this.root.checkbox = undefined; // create a new checbox reference as undefined. this.root.checkbox = undefined; // create a new checbox reference as undefined.
if( this.checkboxRoot ) { if( this.checkboxRoot ) {
@ -332,15 +334,19 @@ dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
// callback // callback
} }
});
}); });
dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode, require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
{
return declare("lib._CheckBoxTreeNode", dijit._TreeNode,
{
// _checkbox: [protected] dojo.doc.element // _checkbox: [protected] dojo.doc.element
// Local reference to the dojo.doc.element of type 'checkbox' // Local reference to the dojo.doc.element of type 'checkbox'
_checkbox: null, _checkbox: null,
_createCheckbox: function() { _createCheckbox: function () {
// summary: // summary:
// Create a checkbox on the CheckBoxTreeNode // Create a checkbox on the CheckBoxTreeNode
// description: // description:
@ -351,8 +357,8 @@ dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode,
// Note: the attribute 'checkboxAll' is validated by the getCheckboxState function // Note: the attribute 'checkboxAll' is validated by the getCheckboxState function
// therefore no need to do that here. (see getCheckboxState for details). // therefore no need to do that here. (see getCheckboxState for details).
// //
var currState = this.tree.model.getCheckboxState( this.item ); var currState = this.tree.model.getCheckboxState(this.item);
if( currState !== undefined ) { if (currState !== undefined) {
this._checkbox = new dijit.form.CheckBox(); this._checkbox = new dijit.form.CheckBox();
//this._checkbox = dojo.doc.createElement('input'); //this._checkbox = dojo.doc.createElement('input');
this._checkbox.type = 'checkbox'; this._checkbox.type = 'checkbox';
@ -361,19 +367,22 @@ dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode,
} }
}, },
postCreate: function() { postCreate: function () {
// summary: // summary:
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated. // Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
// description: // description:
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated. // Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
this._createCheckbox(); this._createCheckbox();
this.inherited( arguments ); this.inherited(arguments);
} }
});
}); });
dojo.declare( "lib.CheckBoxTree", dijit.Tree, require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
{
return declare( "lib.CheckBoxTree", dijit.Tree,
{
onNodeChecked: function(/*dojo.data.Item*/ storeItem, /*treeNode*/ treeNode) { onNodeChecked: function(/*dojo.data.Item*/ storeItem, /*treeNode*/ treeNode) {
// summary: // summary:
@ -471,4 +480,7 @@ dojo.declare( "lib.CheckBoxTree", dijit.Tree,
return new lib._CheckBoxTreeNode(args); return new lib._CheckBoxTreeNode(args);
} }
});
}); });