الإضافات

من ATbar Wiki
مراجعة ٠١:٢٦، ٢٤ نوفمبر ٢٠١٢ بواسطة MaraimMasoud (نقاش | مساهمات)

(فرق) → مراجعة أقدم | المراجعة الحالية (فرق) | مراجعة أحدث ← (فرق)
اذهب إلى: تصفح, بحث


محتويات

عن الإضافات

الإضافات هي الوسيلة الأكثر فاعلية و قابلية لإعادة الاستخدام لحزم الوظائف لغرض الاستخدام في AtKit. الإضافات يمكن تستعمل أي وظيفة من AtKit (إلق نظرة علي وثائق الإستخدام), و غالبا ما تحتوي على زر أو أكثر من ازرار شريط الأدوات, بالإضافة للترجمة و غيرها من الوظائف.

مثال عن الملحق الإضافي

فيما يلي مثال على استخدام ملحق إضافي لAtKit لتشغيل الإضافة الخاصة بالمقروئية.

(function(){

	var pluginName = "readability";
	var plugin = function(){

		// Plugin code goes here

		AtKit.addButton(
			"readability", 
			"Start Readability",
			"readability.png",
			function(dialogs, functions){
				window.readabilityToken="";
				AtKit.addScript(document.location.protocol + "//www.readability.com/bookmarklet/read.js");
			}
		);

	}

 	if(typeof window['AtKit'] == "undefined"){
 
 		window.AtKitLoaded = function(){
 			var eventAction = null;
 		
			this.subscribe = function(fn) {
				eventAction = fn;
			};
		
			this.fire = function(sender, eventArgs) {
				if (eventAction != null) {
					eventAction(sender, eventArgs);
				}
			};
		}

		window['AtKitLoaded'] = new AtKitLoaded();
		window['AtKitLoaded'].subscribe(function(){ AtKit.registerPlugin(pluginName, plugin); });
	} else {
		AtKit.registerPlugin(pluginName, plugin);
	}

})();

المكونات الأساسية للملحق المساعد

يمكن الإطلاع على النموذج المستخدم في الملحق المساعد في أسفل هذه الصفحة.القيمة المخزنة في المتغير pluginName هو اسم البرنامج المساعد في AtKit.و هذه القيمة يجب أن تكون فريدة من نوعها.

كافة التعليمات البرمجية موجودة ضمن الداله المخصصة للملحقات.

var plugin = function(){

}

The rest of the code in boilerplate to load the plugin into AtKit - it's best not to touch this.


Loading a plugin

If you wish to use plugins in your toolbar, you must put your toolbar code into an anonymous function and pass into AtKit.importPlugins(). An example has been given below:

	(function (window, AtKit) { 

		$ = AtKit.lib();
		
		var settings = {
			'baseURL': 'http://c.atbar.org/ATBar/',
			'version': '2.0.070d'
		};
		
		var onLoad = function(){
		
			// Set our logo
			AtKit.setLogo(settings.baseURL + "images/atbar.png");
			AtKit.setName("ATBar");
			// Set language to Arabic
			AtKit.setLanguage("ar");
			
			AtKit.setAbout("Version " + settings.version);
			
			// Add all the plugins to the toolbar
			AtKit.addPlugin("ftw");	
			AtKit.addPlugin("resize");
			AtKit.addPlugin("fonts");	
			AtKit.addPlugin("spell");
			AtKit.addPlugin("dictionary");
			AtKit.addPlugin("gtts");
			AtKit.addPlugin("css");

			AtKit.addResetFn('reset-saved', function(){
				AtKit.clearStorage();
			});
		
			// Run
			AtKit.render();
		};
		
		
		AtKit.importPlugins(["ftw", "resize", "fonts", "spell", "dictionary", "gtts", "css"], onLoad);
		
		
	}(window, AtKit));

In this example we have put our toolbar loading code into the anonymous function allocated to onLoad. This is passed into importPlugins as the second argument as a callback to run once the plugins (specified as an array as argument 1) have been loaded. Once the plugins have been loaded they can be added in order to the toolbar by using the addPlugin function.

Note that this example toolbar does not have the bootstrap code included. For a full example see Toolbars.

Blank plugin

(function(){

	var pluginName = "readability";
	var plugin = function(){

		// Plugin code goes here

	}

 	if(typeof window['AtKit'] == "undefined"){
 
 		window.AtKitLoaded = function(){
 			var eventAction = null;
 		
			this.subscribe = function(fn) {
				eventAction = fn;
			};
		
			this.fire = function(sender, eventArgs) {
				if (eventAction != null) {
					eventAction(sender, eventArgs);
				}
			};
		}

		window['AtKitLoaded'] = new AtKitLoaded();
		window['AtKitLoaded'].subscribe(function(){ AtKit.registerPlugin(pluginName, plugin); });
	} else {
		AtKit.registerPlugin(pluginName, plugin);
	}

})();
أدوات شخصية

المتغيرات
النطاقات
أفعال
إبحار
Languages
صندوق الأدوات