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");
dojo.provide("fox.FeedStoreModel");
require(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) {
dojo.require("dijit.Tree");
dojo.require("dijit.Menu");
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
return declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
getItemsInCategory: function (id) {
if (!this.store._itemsByIdentity) return undefined;
@ -16,10 +12,10 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
return undefined;
},
getItemById: function(id) {
getItemById: function (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 (is_cat)
@ -30,17 +26,17 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
if (treeItem)
return this.store.getValue(treeItem, key);
},
getFeedName: function(feed, is_cat) {
getFeedName: function (feed, is_cat) {
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'));
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));
},
setFeedValue: function(feed, is_cat, key, value) {
setFeedValue: function (feed, is_cat, key, value) {
if (!value) value = '';
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++) {
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 id = this.store.getValue(items[j], 'id');
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');
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;
},
hasCats: function() {
hasCats: function () {
if (this.store && this.store._itemsByIdentity)
return this.store._itemsByIdentity['CAT:-1'] != undefined;
else
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) {
return; // Stop dijit.Tree from interpreting keystrokes
},
@ -586,4 +586,6 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
return false;
}
},
});
});

View File

@ -1,10 +1,6 @@
dojo.provide("fox.PrefFeedTree");
dojo.provide("fox.PrefFeedStore");
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
dojo.require("lib.CheckBoxTree");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
newFileContentString) {
@ -17,9 +13,13 @@ dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
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) {
var tnode = this.inherited(arguments);
@ -121,5 +121,6 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
(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");
dojo.require("dojo.data.ItemFileWriteStore");
return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
_saveEverything: function (saveCompleteCallback, saveFailedCallback,
newFileContentString) {
dojo.xhrPost({
url: "backend.php",
content: {op: "pref-filters", method: "savefilterorder",
payload: newFileContentString},
content: {
op: "pref-filters", method: "savefilterorder",
payload: newFileContentString
},
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) {
var tnode = this.inherited(arguments);
@ -63,7 +66,7 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
if (inverse)
label += " (" + __("Inverse") + ")";
/* if (item.param)
/* if (item.param)
label = "<span class=\"labelFixedLength\">" + label +
"</span>" + item.param[0]; */
@ -92,5 +95,8 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
this.inherited(arguments);
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");
dojo.require("dijit.form.DropDownButton");
dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
setNameById: function (id, name) {
var item = this.model.store._itemsByIdentity['LABEL:' + id];
@ -39,5 +36,8 @@ dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
getIconClass: function (item, opened) {
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
},
});
});

View File

@ -943,15 +943,12 @@ function init() {
"dijit/Toolbar",
"dijit/Tree",
"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() {
dojo.require("lib.CheckBoxTree");
dojo.require("fox.PrefFeedTree");
dojo.require("fox.PrefFilterTree");
dojo.require("fox.PrefLabelTree");
parser.parse();
loading_set_progress(50);

View File

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

View File

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