/*!
* This file is part of Aloha Editor Project http://aloha-editor.org
* Copyright (c) 2010-2011 Gentics Software GmbH, aloha@gentics.com
* Contributors http://aloha-editor.org/contribution.php
* Licensed unter the terms of http://www.aloha-editor.org/license.html
*
* Aloha Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* Aloha Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see
// simple delicious implementation
Aloha.Repositories.myRepository.query = function (params, callback) {
// make local var of this to use in ajax function
var that = this;
// handle each word as tag
var tags = p.queryString.split(' ');
// if we have a query and no tag matching return
if ( p.queryString && tags.length == 0 ) {
callback.call( that, []);
return;
}
// no handling of objectTypeFilter, filter, inFolderId, etc...
// in real implementation you should handle all parameters
jQuery.ajax({ type: "GET",
dataType: "jsonp",
url: 'http://feeds.delicious.com/v2/json/' + tags.join('+'),
success: function(data) {
var items = [];
// convert data to Aloha objects
for (var i = 0; i < data.length; i++) {
if (typeof data[i] != 'function' ) {
items.push(new Aloha.Repository.Document ({
id: data[i].u,
name: data[i].d,
repositoryId: that.repositoryId,
type: 'website',
url: data[i].u
}));
}
}
callback.call( that, items);
}
});
};
*
* @param {object} params object with properties
* queryString
: String objectTypeFilter
: array (optional) filter
: array (optional) inFolderId
: boolean (optional) inTreeId
: boolean (optional) orderBy
: array (optional) maxItems
: Integer (optional) skipCount
: Integer (optional) renditionFilter
: array (optional) objectTypeFilter
: array (optional) filter
: array (optional) inFolderId
: boolean (optional) orderBy
: array (optional) maxItems
: Integer (optional) skipCount
: Integer (optional) renditionFilter
: array (optional)
Aloha.Repositories.myRepository.makeClean = function (obj) {
obj.removeAttr('data-myRepository-name');
};
* @param {jQuery} obj jQuery object to make clean
* @return void
*/
makeClean: function (obj) {},
/**
* This method will be called when a user chooses an item from a repository and wants
* to insert this item in his content.
* Mark or modify an object as needed by that repository for handling, processing or identification.
* Objects can be any DOM object as A, SPAN, ABBR, etc. or
* special objects such as aloha-aloha_block elements.
* (see http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data)
*
Aloha.Repositories.myRepository.markObject = function (obj, resourceItem) {
obj.attr('data-myRepository-name').text(resourceItem.name);
};
*
*
* @param obj jQuery target object to which the repositoryItem will be applied
* @param repositoryItem The selected item. A class constructed from Document or Folder.
* @return void
*/
markObject: function (obj, repositoryItem) {},
/**
* Set a template for rendering objects of this repository
* @param {String} template
* @return void
* @method
*/
setTemplate: function (template) {
if (template) {
this.template = template;
} else {
this.template = null;
}
},
/**
* Checks whether the repository has a template
* @return {boolean} true when the repository has a template, false if not
* @method
*/
hasTemplate: function () {
return this.template ? true : false;
},
/**
* Get the parsed template
* @return {Object} parsed template
* @method
*/
getTemplate: function () {
return this.template;
},
/**
* Get the repositoryItem with given id
* @param itemId {String} id of the repository item to fetch
* @param callback {function} callback function
* @return {Aloha.Repository.Object} item with given id
*/
getObjectById: function ( itemId, callback ) { return true; }
});
// expose the AbstractRepository
Aloha.AbstractRepository = AbstractRepository;
return AbstractRepository;
});